hexsha
stringlengths
40
40
repo
stringlengths
5
105
path
stringlengths
3
173
license
sequence
language
stringclasses
1 value
identifier
stringlengths
1
438
return_type
stringlengths
1
106
original_string
stringlengths
21
40.7k
original_docstring
stringlengths
18
13.4k
docstring
stringlengths
11
3.24k
docstring_tokens
sequence
code
stringlengths
14
20.4k
code_tokens
sequence
short_docstring
stringlengths
0
4.36k
short_docstring_tokens
sequence
comment
sequence
parameters
list
docstring_params
dict
be587a9b6cf6aa4d94f23c1296577803c18dfaa7
libretro-mirrors/clove
src/3rdparty/Chipmunk2D/Demo/Simple.c
[ "MIT" ]
C
destroy
void
static void destroy(void) { ChipmunkDemoFreeSpaceChildren(space); cpSpaceFree(space); }
// destroy is called by the demo code to free all the memory we've allocated
destroy is called by the demo code to free all the memory we've allocated
[ "destroy", "is", "called", "by", "the", "demo", "code", "to", "free", "all", "the", "memory", "we", "'", "ve", "allocated" ]
static void destroy(void) { ChipmunkDemoFreeSpaceChildren(space); cpSpaceFree(space); }
[ "static", "void", "destroy", "(", "void", ")", "{", "ChipmunkDemoFreeSpaceChildren", "(", "space", ")", ";", "cpSpaceFree", "(", "space", ")", ";", "}" ]
destroy is called by the demo code to free all the memory we've allocated
[ "destroy", "is", "called", "by", "the", "demo", "code", "to", "free", "all", "the", "memory", "we", "'", "ve", "allocated" ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
90a10a9314cb5b6fb735b739e5da416b10870d85
kkan2020/evacc
firmware/main/stm32f10x_it.c
[ "MIT" ]
C
TIM4_IRQHandler
void
void TIM4_IRQHandler(void) { if(TIM_GetITStatus(TIM4, TIM_IT_Update) == SET) { EepromTimeoutHandler(&I2C2Port); TIM_ClearITPendingBit(TIM4, TIM_IT_Update); } }
/** * @brief This function handles TIM4 global interrupt request. * @param None * @retval None */
@brief This function handles TIM4 global interrupt request. @param None @retval None
[ "@brief", "This", "function", "handles", "TIM4", "global", "interrupt", "request", ".", "@param", "None", "@retval", "None" ]
void TIM4_IRQHandler(void) { if(TIM_GetITStatus(TIM4, TIM_IT_Update) == SET) { EepromTimeoutHandler(&I2C2Port); TIM_ClearITPendingBit(TIM4, TIM_IT_Update); } }
[ "void", "TIM4_IRQHandler", "(", "void", ")", "{", "if", "(", "TIM_GetITStatus", "(", "TIM4", ",", "TIM_IT_Update", ")", "==", "SET", ")", "{", "EepromTimeoutHandler", "(", "&", "I2C2Port", ")", ";", "TIM_ClearITPendingBit", "(", "TIM4", ",", "TIM_IT_Update", ")", ";", "}", "}" ]
@brief This function handles TIM4 global interrupt request.
[ "@brief", "This", "function", "handles", "TIM4", "global", "interrupt", "request", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
90a10a9314cb5b6fb735b739e5da416b10870d85
kkan2020/evacc
firmware/main/stm32f10x_it.c
[ "MIT" ]
C
DMA1_Channel1_IRQHandler
void
void DMA1_Channel1_IRQHandler(void) { extern osThreadId_t CTThread_id; if (DMA1->ISR & DMA1_IT_HT1) //half transfer osThreadFlagsSet(CTThread_id, CT_HALF_TRANS); else if (DMA1->ISR & DMA1_IT_TC1) //transfer complete osThreadFlagsSet(CTThread_id, CT_TRANS_COMP); /* Clear Global interrupt pending bits */ DMA1->IFCR = DMA1_IT_GL1; }
/** * @brief This function handles DMA1_Channel1 global interrupt request. * @param None * @retval None */
@brief This function handles DMA1_Channel1 global interrupt request. @param None @retval None
[ "@brief", "This", "function", "handles", "DMA1_Channel1", "global", "interrupt", "request", ".", "@param", "None", "@retval", "None" ]
void DMA1_Channel1_IRQHandler(void) { extern osThreadId_t CTThread_id; if (DMA1->ISR & DMA1_IT_HT1) osThreadFlagsSet(CTThread_id, CT_HALF_TRANS); else if (DMA1->ISR & DMA1_IT_TC1) osThreadFlagsSet(CTThread_id, CT_TRANS_COMP); DMA1->IFCR = DMA1_IT_GL1; }
[ "void", "DMA1_Channel1_IRQHandler", "(", "void", ")", "{", "extern", "osThreadId_t", "CTThread_id", ";", "if", "(", "DMA1", "->", "ISR", "&", "DMA1_IT_HT1", ")", "osThreadFlagsSet", "(", "CTThread_id", ",", "CT_HALF_TRANS", ")", ";", "else", "if", "(", "DMA1", "->", "ISR", "&", "DMA1_IT_TC1", ")", "osThreadFlagsSet", "(", "CTThread_id", ",", "CT_TRANS_COMP", ")", ";", "DMA1", "->", "IFCR", "=", "DMA1_IT_GL1", ";", "}" ]
@brief This function handles DMA1_Channel1 global interrupt request.
[ "@brief", "This", "function", "handles", "DMA1_Channel1", "global", "interrupt", "request", "." ]
[ "//half transfer\r", "//transfer complete \r", "/* Clear Global interrupt pending bits */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
90a10a9314cb5b6fb735b739e5da416b10870d85
kkan2020/evacc
firmware/main/stm32f10x_it.c
[ "MIT" ]
C
UART4_IRQHandler
void
void UART4_IRQHandler(void) { if(USART_GetITStatus(UART4, USART_IT_RXNE) != RESET) { if (!IS_TIMER_ENABLED(WIFI_UART_RX_TIM)) WiFiPort.RxPos = 0; if (WiFiPort.RxPos>=sizeof(WiFiPort.RxBuffer)) WiFiPort.RxPos = 0; WiFiPort.RxBuffer[WiFiPort.RxPos++] = USART_ReceiveData(UART4) & 0xFF; SetTimeout_us(WIFI_UART_RX_TIM, 5000); } if (USART_GetITStatus(UART4, USART_IT_TXE) != RESET) { if (WiFiPort.TxPos < WiFiPort.TxSize) USART_SendData(UART4, WiFiPort.TxBuffer[WiFiPort.TxPos++]); if (WiFiPort.TxPos >= WiFiPort.TxSize) { WiFiPort.TxSize = 0; USART_ITConfig(UART4, USART_IT_TXE, DISABLE); USART_ClearITPendingBit(UART4, USART_IT_TC); } } }
/* Handler of SOCKET 1 port (WIFI) */
Handler of SOCKET 1 port (WIFI)
[ "Handler", "of", "SOCKET", "1", "port", "(", "WIFI", ")" ]
void UART4_IRQHandler(void) { if(USART_GetITStatus(UART4, USART_IT_RXNE) != RESET) { if (!IS_TIMER_ENABLED(WIFI_UART_RX_TIM)) WiFiPort.RxPos = 0; if (WiFiPort.RxPos>=sizeof(WiFiPort.RxBuffer)) WiFiPort.RxPos = 0; WiFiPort.RxBuffer[WiFiPort.RxPos++] = USART_ReceiveData(UART4) & 0xFF; SetTimeout_us(WIFI_UART_RX_TIM, 5000); } if (USART_GetITStatus(UART4, USART_IT_TXE) != RESET) { if (WiFiPort.TxPos < WiFiPort.TxSize) USART_SendData(UART4, WiFiPort.TxBuffer[WiFiPort.TxPos++]); if (WiFiPort.TxPos >= WiFiPort.TxSize) { WiFiPort.TxSize = 0; USART_ITConfig(UART4, USART_IT_TXE, DISABLE); USART_ClearITPendingBit(UART4, USART_IT_TC); } } }
[ "void", "UART4_IRQHandler", "(", "void", ")", "{", "if", "(", "USART_GetITStatus", "(", "UART4", ",", "USART_IT_RXNE", ")", "!=", "RESET", ")", "{", "if", "(", "!", "IS_TIMER_ENABLED", "(", "WIFI_UART_RX_TIM", ")", ")", "WiFiPort", ".", "RxPos", "=", "0", ";", "if", "(", "WiFiPort", ".", "RxPos", ">=", "sizeof", "(", "WiFiPort", ".", "RxBuffer", ")", ")", "WiFiPort", ".", "RxPos", "=", "0", ";", "WiFiPort", ".", "RxBuffer", "[", "WiFiPort", ".", "RxPos", "++", "]", "=", "USART_ReceiveData", "(", "UART4", ")", "&", "0xFF", ";", "SetTimeout_us", "(", "WIFI_UART_RX_TIM", ",", "5000", ")", ";", "}", "if", "(", "USART_GetITStatus", "(", "UART4", ",", "USART_IT_TXE", ")", "!=", "RESET", ")", "{", "if", "(", "WiFiPort", ".", "TxPos", "<", "WiFiPort", ".", "TxSize", ")", "USART_SendData", "(", "UART4", ",", "WiFiPort", ".", "TxBuffer", "[", "WiFiPort", ".", "TxPos", "++", "]", ")", ";", "if", "(", "WiFiPort", ".", "TxPos", ">=", "WiFiPort", ".", "TxSize", ")", "{", "WiFiPort", ".", "TxSize", "=", "0", ";", "USART_ITConfig", "(", "UART4", ",", "USART_IT_TXE", ",", "DISABLE", ")", ";", "USART_ClearITPendingBit", "(", "UART4", ",", "USART_IT_TC", ")", ";", "}", "}", "}" ]
Handler of SOCKET 1 port (WIFI)
[ "Handler", "of", "SOCKET", "1", "port", "(", "WIFI", ")" ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
90a10a9314cb5b6fb735b739e5da416b10870d85
kkan2020/evacc
firmware/main/stm32f10x_it.c
[ "MIT" ]
C
RTC_IRQHandler
void
void RTC_IRQHandler(void) { static int ii=0; //read system tick counter values using as seed of private key if (ii > sizeof(RandomBytes)) ii = 0; if (ii!=0) { RandomBytes[ii-1] = SysTick->VAL; if (ii==sizeof(RandomBytes)) IsRandomBytesReady = 1; /* uint16_t t; srand(SysTick->VAL); do { t = rand() & 0xff; } while (!(isalpha(t) || isdigit(t) || (t=='-'))); RandomBytes[ii-1] = t; if (ii==sizeof(RandomBytes)) IsRandomBytesReady = 1; */ } ii++; if (!CountUpTimerFlag) CountUpTimerCounter++; if (CountDownTimerCounter) CountDownTimerCounter--; NVIC_ClearPendingIRQ(RTC_IRQn); RTC_ClearITPendingBit(RTC_IT_SEC); }
/******************************************************************************* * Function Name : RTC_IRQHandler * Description : This function handles RTC interrupt request which is triggered every second. * Input : None * Output : None * Return : None *******************************************************************************/
Function Name : RTC_IRQHandler Description : This function handles RTC interrupt request which is triggered every second.
[ "Function", "Name", ":", "RTC_IRQHandler", "Description", ":", "This", "function", "handles", "RTC", "interrupt", "request", "which", "is", "triggered", "every", "second", "." ]
void RTC_IRQHandler(void) { static int ii=0; if (ii > sizeof(RandomBytes)) ii = 0; if (ii!=0) { RandomBytes[ii-1] = SysTick->VAL; if (ii==sizeof(RandomBytes)) IsRandomBytesReady = 1; } ii++; if (!CountUpTimerFlag) CountUpTimerCounter++; if (CountDownTimerCounter) CountDownTimerCounter--; NVIC_ClearPendingIRQ(RTC_IRQn); RTC_ClearITPendingBit(RTC_IT_SEC); }
[ "void", "RTC_IRQHandler", "(", "void", ")", "{", "static", "int", "ii", "=", "0", ";", "if", "(", "ii", ">", "sizeof", "(", "RandomBytes", ")", ")", "ii", "=", "0", ";", "if", "(", "ii", "!=", "0", ")", "{", "RandomBytes", "[", "ii", "-", "1", "]", "=", "SysTick", "->", "VAL", ";", "if", "(", "ii", "==", "sizeof", "(", "RandomBytes", ")", ")", "IsRandomBytesReady", "=", "1", ";", "}", "ii", "++", ";", "if", "(", "!", "CountUpTimerFlag", ")", "CountUpTimerCounter", "++", ";", "if", "(", "CountDownTimerCounter", ")", "CountDownTimerCounter", "--", ";", "NVIC_ClearPendingIRQ", "(", "RTC_IRQn", ")", ";", "RTC_ClearITPendingBit", "(", "RTC_IT_SEC", ")", ";", "}" ]
Function Name : RTC_IRQHandler Description : This function handles RTC interrupt request which is triggered every second.
[ "Function", "Name", ":", "RTC_IRQHandler", "Description", ":", "This", "function", "handles", "RTC", "interrupt", "request", "which", "is", "triggered", "every", "second", "." ]
[ "//read system tick counter values using as seed of private key\r", "/* \r\n uint16_t t;\r\n srand(SysTick->VAL);\r\n do\r\n {\r\n t = rand() & 0xff;\r\n } while (!(isalpha(t) || isdigit(t) || (t=='-')));\r\n RandomBytes[ii-1] = t;\r\n if (ii==sizeof(RandomBytes))\r\n IsRandomBytesReady = 1; \r\n*/" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
6ada1dd513f05091d0333281529f0d30552d4378
kkan2020/evacc
firmware/tester/stm32f10x_it.c
[ "MIT" ]
C
TIM2_IRQHandler
void
void TIM2_IRQHandler(void) { /* Clear Capture compare interrupt pending bit */ TIO_TIMER->CNT = 0; //reset timeout timer TIM2->SR = (uint16_t)~TIM_IT_CC2; /* Disable timeout timer */ TIO_TIMER->CCR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); /* Get the Input Capture value */ IC2Value = TIM_GetCapture2(TIM2); if (IC2Value != 0) { /* Duty cycle computation */ PWM_DutyCycle = ((float)TIM_GetCapture1(TIM2) * 100) / IC2Value; /* Frequency computation */ PWM_Freq = ICP_TIMER_FREQ / IC2Value; } else { PWM_DutyCycle = 0; PWM_Freq = 0; } //disable timer // TIM2->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); }
/** * @brief This function handles TIM2 global interrupt request. * @param None * @retval None */
@brief This function handles TIM2 global interrupt request. @param None @retval None
[ "@brief", "This", "function", "handles", "TIM2", "global", "interrupt", "request", ".", "@param", "None", "@retval", "None" ]
void TIM2_IRQHandler(void) { TIO_TIMER->CNT = 0; TIM2->SR = (uint16_t)~TIM_IT_CC2; TIO_TIMER->CCR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); IC2Value = TIM_GetCapture2(TIM2); if (IC2Value != 0) { PWM_DutyCycle = ((float)TIM_GetCapture1(TIM2) * 100) / IC2Value; PWM_Freq = ICP_TIMER_FREQ / IC2Value; } else { PWM_DutyCycle = 0; PWM_Freq = 0; } }
[ "void", "TIM2_IRQHandler", "(", "void", ")", "{", "TIO_TIMER", "->", "CNT", "=", "0", ";", "TIM2", "->", "SR", "=", "(", "uint16_t", ")", "~", "TIM_IT_CC2", ";", "TIO_TIMER", "->", "CCR1", "&=", "(", "uint16_t", ")", "(", "~", "(", "(", "uint16_t", ")", "TIM_CR1_CEN", ")", ")", ";", "IC2Value", "=", "TIM_GetCapture2", "(", "TIM2", ")", ";", "if", "(", "IC2Value", "!=", "0", ")", "{", "PWM_DutyCycle", "=", "(", "(", "float", ")", "TIM_GetCapture1", "(", "TIM2", ")", "*", "100", ")", "/", "IC2Value", ";", "PWM_Freq", "=", "ICP_TIMER_FREQ", "/", "IC2Value", ";", "}", "else", "{", "PWM_DutyCycle", "=", "0", ";", "PWM_Freq", "=", "0", ";", "}", "}" ]
@brief This function handles TIM2 global interrupt request.
[ "@brief", "This", "function", "handles", "TIM2", "global", "interrupt", "request", "." ]
[ "/* Clear Capture compare interrupt pending bit */", "//reset timeout timer\r", "/* Disable timeout timer */", "/* Get the Input Capture value */", "/* Duty cycle computation */", "/* Frequency computation */", "//disable timer\r", "// TIM2->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN));\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
6ada1dd513f05091d0333281529f0d30552d4378
kkan2020/evacc
firmware/tester/stm32f10x_it.c
[ "MIT" ]
C
TIM4_IRQHandler
void
void TIM4_IRQHandler(void) { if(TIM_GetITStatus(TIM4, TIM_IT_Update) == SET) { /* Disable pilot signal measurement timer*/ // ICP_TIMER->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); PWM_DutyCycle = 0; PWM_Freq = 0; /* Reset DMA channel */ // DMA1_Channel1->CCR &= (uint16_t)(~DMA_CCR1_EN); /* Clear interrupt pending bit*/ TIM4->SR = (uint16_t)~TIM_IT_Update; //disable timer // TIM4->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); } }
/** * @brief This function handles TIM4 global interrupt request. * @param None * @retval None * @desc Called when PWM input capture timeout */
@brief This function handles TIM4 global interrupt request. @param None @retval None @desc Called when PWM input capture timeout
[ "@brief", "This", "function", "handles", "TIM4", "global", "interrupt", "request", ".", "@param", "None", "@retval", "None", "@desc", "Called", "when", "PWM", "input", "capture", "timeout" ]
void TIM4_IRQHandler(void) { if(TIM_GetITStatus(TIM4, TIM_IT_Update) == SET) { PWM_DutyCycle = 0; PWM_Freq = 0; TIM4->SR = (uint16_t)~TIM_IT_Update; } }
[ "void", "TIM4_IRQHandler", "(", "void", ")", "{", "if", "(", "TIM_GetITStatus", "(", "TIM4", ",", "TIM_IT_Update", ")", "==", "SET", ")", "{", "PWM_DutyCycle", "=", "0", ";", "PWM_Freq", "=", "0", ";", "TIM4", "->", "SR", "=", "(", "uint16_t", ")", "~", "TIM_IT_Update", ";", "}", "}" ]
@brief This function handles TIM4 global interrupt request.
[ "@brief", "This", "function", "handles", "TIM4", "global", "interrupt", "request", "." ]
[ "/* Disable pilot signal measurement timer*/", "// ICP_TIMER->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN));\r", "/* Reset DMA channel */", "// DMA1_Channel1->CCR &= (uint16_t)(~DMA_CCR1_EN);\r", "/* Clear interrupt pending bit*/", "//disable timer\r", "// TIM4->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN));\r" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
6ada1dd513f05091d0333281529f0d30552d4378
kkan2020/evacc
firmware/tester/stm32f10x_it.c
[ "MIT" ]
C
DMA1_Channel1_IRQHandler
void
void DMA1_Channel1_IRQHandler(void) { uint16_t i, s, valid = 0; float u; if (DMA1->ISR & DMA1_IT_HT1) //half transfer { valid = 1; for (i=s=0; i<CountOf(ADCConvertedValues)/2; i++) s += ADCConvertedValues[i]; } else if (DMA1->ISR & DMA1_IT_TC1) //transfer complete { valid = 1; for (s=0, i=CountOf(ADCConvertedValues)/2; i<CountOf(ADCConvertedValues); i++) s += ADCConvertedValues[i]; } if (valid) { s /= (CountOf(ADCConvertedValues)>>1); //average u = s*3.3/4095; if (u < VREF) CCResistance = u*RCC_PULLUP/(VREF-u) + 0.5; else CCResistance = 0xffff; //infinity } /* Clear Global interrupt pending bits */ DMA1->IFCR = DMA1_IT_GL1; }
/** * @brief This function handles DMA1_Channel1 global interrupt request. * @param None * @retval None */
@brief This function handles DMA1_Channel1 global interrupt request. @param None @retval None
[ "@brief", "This", "function", "handles", "DMA1_Channel1", "global", "interrupt", "request", ".", "@param", "None", "@retval", "None" ]
void DMA1_Channel1_IRQHandler(void) { uint16_t i, s, valid = 0; float u; if (DMA1->ISR & DMA1_IT_HT1) { valid = 1; for (i=s=0; i<CountOf(ADCConvertedValues)/2; i++) s += ADCConvertedValues[i]; } else if (DMA1->ISR & DMA1_IT_TC1) { valid = 1; for (s=0, i=CountOf(ADCConvertedValues)/2; i<CountOf(ADCConvertedValues); i++) s += ADCConvertedValues[i]; } if (valid) { s /= (CountOf(ADCConvertedValues)>>1); u = s*3.3/4095; if (u < VREF) CCResistance = u*RCC_PULLUP/(VREF-u) + 0.5; else CCResistance = 0xffff; } DMA1->IFCR = DMA1_IT_GL1; }
[ "void", "DMA1_Channel1_IRQHandler", "(", "void", ")", "{", "uint16_t", "i", ",", "s", ",", "valid", "=", "0", ";", "float", "u", ";", "if", "(", "DMA1", "->", "ISR", "&", "DMA1_IT_HT1", ")", "{", "valid", "=", "1", ";", "for", "(", "i", "=", "s", "=", "0", ";", "i", "<", "CountOf", "(", "ADCConvertedValues", ")", "/", "2", ";", "i", "++", ")", "s", "+=", "ADCConvertedValues", "[", "i", "]", ";", "}", "else", "if", "(", "DMA1", "->", "ISR", "&", "DMA1_IT_TC1", ")", "{", "valid", "=", "1", ";", "for", "(", "s", "=", "0", ",", "i", "=", "CountOf", "(", "ADCConvertedValues", ")", "/", "2", ";", "i", "<", "CountOf", "(", "ADCConvertedValues", ")", ";", "i", "++", ")", "s", "+=", "ADCConvertedValues", "[", "i", "]", ";", "}", "if", "(", "valid", ")", "{", "s", "/=", "(", "CountOf", "(", "ADCConvertedValues", ")", ">>", "1", ")", ";", "u", "=", "s", "*", "3.3", "/", "4095", ";", "if", "(", "u", "<", "VREF", ")", "CCResistance", "=", "u", "*", "RCC_PULLUP", "/", "(", "VREF", "-", "u", ")", "+", "0.5", ";", "else", "CCResistance", "=", "0xffff", ";", "}", "DMA1", "->", "IFCR", "=", "DMA1_IT_GL1", ";", "}" ]
@brief This function handles DMA1_Channel1 global interrupt request.
[ "@brief", "This", "function", "handles", "DMA1_Channel1", "global", "interrupt", "request", "." ]
[ "//half transfer\r", "//transfer complete \r", "//average\r", "//infinity \r", "/* Clear Global interrupt pending bits */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
72f94870e915acc85294a1c8c6b28f23590f8589
kkan2020/evacc
firmware/main/hal.c
[ "MIT" ]
C
SetTimeout_us
void
void SetTimeout_us(TIM_TypeDef* TIMx, uint16_t us) { DISABLE_TIMER(TIMx); TIMx->CNT = 0; //reset counter TIMx->ARR = us-1; //set auto-reload register TIMx->SR = (uint16_t)~TIM_FLAG_Update; //clear update flag ENABLE_TIMER(TIMx); }
/* * Only apply to timers with counter clock frequency 1000000Hz */
Only apply to timers with counter clock frequency 1000000Hz
[ "Only", "apply", "to", "timers", "with", "counter", "clock", "frequency", "1000000Hz" ]
void SetTimeout_us(TIM_TypeDef* TIMx, uint16_t us) { DISABLE_TIMER(TIMx); TIMx->CNT = 0; TIMx->ARR = us-1; TIMx->SR = (uint16_t)~TIM_FLAG_Update; ENABLE_TIMER(TIMx); }
[ "void", "SetTimeout_us", "(", "TIM_TypeDef", "*", "TIMx", ",", "uint16_t", "us", ")", "{", "DISABLE_TIMER", "(", "TIMx", ")", ";", "TIMx", "->", "CNT", "=", "0", ";", "TIMx", "->", "ARR", "=", "us", "-", "1", ";", "TIMx", "->", "SR", "=", "(", "uint16_t", ")", "~", "TIM_FLAG_Update", ";", "ENABLE_TIMER", "(", "TIMx", ")", ";", "}" ]
Only apply to timers with counter clock frequency 1000000Hz
[ "Only", "apply", "to", "timers", "with", "counter", "clock", "frequency", "1000000Hz" ]
[ "//reset counter\r", "//set auto-reload register\r", "//clear update flag\r" ]
[ { "param": "TIMx", "type": "TIM_TypeDef" }, { "param": "us", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "TIMx", "type": "TIM_TypeDef", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "us", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
762d3e8a4381902033d7a71728062a6cff01feec
kkan2020/evacc
firmware/main/RFID_Card.c
[ "MIT" ]
C
FindCard
uint8_t
uint8_t FindCard(TCardSn Serial) { uint8_t *response; int n, found=0; LastSector = -1; n = ANTI_COLLISION_COUNT; while (n-- && !found) { response = RFID_Send(RFID_RequestMsg()); if (!response || response[8]!=0) //negative return 0; response = RFID_Send(RFID_AntiCollisionMsg()); if (!response || response[8]!=0) //negative return 0; if (!Serial) //new card found = 1; else if ((memcmp(Serial, &response[9], sizeof(TCardSn))==0)) //card is found found = 1; } if (!found) return 0; memcpy(Card.Serial, &response[9], sizeof(Card.Serial)); response = RFID_Send(RFID_SelectMsg(Card.Serial)); if (!response || response[8]!=0) //negative return 0; return 1; }
//find the specified card with *pSerial if pSerial!=null or find a new card //card serial with be written into Card.Serial if found
find the specified card with *pSerial if pSerial!=null or find a new card card serial with be written into Card.Serial if found
[ "find", "the", "specified", "card", "with", "*", "pSerial", "if", "pSerial!", "=", "null", "or", "find", "a", "new", "card", "card", "serial", "with", "be", "written", "into", "Card", ".", "Serial", "if", "found" ]
uint8_t FindCard(TCardSn Serial) { uint8_t *response; int n, found=0; LastSector = -1; n = ANTI_COLLISION_COUNT; while (n-- && !found) { response = RFID_Send(RFID_RequestMsg()); if (!response || response[8]!=0) return 0; response = RFID_Send(RFID_AntiCollisionMsg()); if (!response || response[8]!=0) return 0; if (!Serial) found = 1; else if ((memcmp(Serial, &response[9], sizeof(TCardSn))==0)) found = 1; } if (!found) return 0; memcpy(Card.Serial, &response[9], sizeof(Card.Serial)); response = RFID_Send(RFID_SelectMsg(Card.Serial)); if (!response || response[8]!=0) return 0; return 1; }
[ "uint8_t", "FindCard", "(", "TCardSn", "Serial", ")", "{", "uint8_t", "*", "response", ";", "int", "n", ",", "found", "=", "0", ";", "LastSector", "=", "-1", ";", "n", "=", "ANTI_COLLISION_COUNT", ";", "while", "(", "n", "--", "&&", "!", "found", ")", "{", "response", "=", "RFID_Send", "(", "RFID_RequestMsg", "(", ")", ")", ";", "if", "(", "!", "response", "||", "response", "[", "8", "]", "!=", "0", ")", "return", "0", ";", "response", "=", "RFID_Send", "(", "RFID_AntiCollisionMsg", "(", ")", ")", ";", "if", "(", "!", "response", "||", "response", "[", "8", "]", "!=", "0", ")", "return", "0", ";", "if", "(", "!", "Serial", ")", "found", "=", "1", ";", "else", "if", "(", "(", "memcmp", "(", "Serial", ",", "&", "response", "[", "9", "]", ",", "sizeof", "(", "TCardSn", ")", ")", "==", "0", ")", ")", "found", "=", "1", ";", "}", "if", "(", "!", "found", ")", "return", "0", ";", "memcpy", "(", "Card", ".", "Serial", ",", "&", "response", "[", "9", "]", ",", "sizeof", "(", "Card", ".", "Serial", ")", ")", ";", "response", "=", "RFID_Send", "(", "RFID_SelectMsg", "(", "Card", ".", "Serial", ")", ")", ";", "if", "(", "!", "response", "||", "response", "[", "8", "]", "!=", "0", ")", "return", "0", ";", "return", "1", ";", "}" ]
find the specified card with *pSerial if pSerial!=null or find a new card card serial with be written into Card.Serial if found
[ "find", "the", "specified", "card", "with", "*", "pSerial", "if", "pSerial!", "=", "null", "or", "find", "a", "new", "card", "card", "serial", "with", "be", "written", "into", "Card", ".", "Serial", "if", "found" ]
[ "//negative\r", "//negative\r", "//new card\r", "//card is found\r", "//negative\r" ]
[ { "param": "Serial", "type": "TCardSn" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Serial", "type": "TCardSn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
762d3e8a4381902033d7a71728062a6cff01feec
kkan2020/evacc
firmware/main/RFID_Card.c
[ "MIT" ]
C
RFID_ReadFieldAndSkip
int
int RFID_ReadFieldAndSkip(TKey48 Key) { uint8_t *blk, unreadLen, readLen; int desPos; blk = ReadBlk(Key); if (!blk) return 0; SkipBlk(); unreadLen = 2+blk[1]; //2+field_length if (unreadLen > sizeof(Tlv)) //field too long return 0; // readLen = 0; desPos = 0; while (unreadLen) { readLen = MIN(RFID_BLK_SIZE, unreadLen); memcpy(&Tlv[desPos], blk, readLen); unreadLen -= readLen; desPos += readLen; if (unreadLen) { blk = ReadBlk(Key); if (!blk) return 0; SkipBlk(); } } if (ValidateCrcBlk(Tlv, 2+Tlv[1])) return 1; return 0; }
//read TLV field of RFID card to Tlv global variabl and validate CRC
read TLV field of RFID card to Tlv global variabl and validate CRC
[ "read", "TLV", "field", "of", "RFID", "card", "to", "Tlv", "global", "variabl", "and", "validate", "CRC" ]
int RFID_ReadFieldAndSkip(TKey48 Key) { uint8_t *blk, unreadLen, readLen; int desPos; blk = ReadBlk(Key); if (!blk) return 0; SkipBlk(); unreadLen = 2+blk[1]; if (unreadLen > sizeof(Tlv)) return 0; desPos = 0; while (unreadLen) { readLen = MIN(RFID_BLK_SIZE, unreadLen); memcpy(&Tlv[desPos], blk, readLen); unreadLen -= readLen; desPos += readLen; if (unreadLen) { blk = ReadBlk(Key); if (!blk) return 0; SkipBlk(); } } if (ValidateCrcBlk(Tlv, 2+Tlv[1])) return 1; return 0; }
[ "int", "RFID_ReadFieldAndSkip", "(", "TKey48", "Key", ")", "{", "uint8_t", "*", "blk", ",", "unreadLen", ",", "readLen", ";", "int", "desPos", ";", "blk", "=", "ReadBlk", "(", "Key", ")", ";", "if", "(", "!", "blk", ")", "return", "0", ";", "SkipBlk", "(", ")", ";", "unreadLen", "=", "2", "+", "blk", "[", "1", "]", ";", "if", "(", "unreadLen", ">", "sizeof", "(", "Tlv", ")", ")", "return", "0", ";", "desPos", "=", "0", ";", "while", "(", "unreadLen", ")", "{", "readLen", "=", "MIN", "(", "RFID_BLK_SIZE", ",", "unreadLen", ")", ";", "memcpy", "(", "&", "Tlv", "[", "desPos", "]", ",", "blk", ",", "readLen", ")", ";", "unreadLen", "-=", "readLen", ";", "desPos", "+=", "readLen", ";", "if", "(", "unreadLen", ")", "{", "blk", "=", "ReadBlk", "(", "Key", ")", ";", "if", "(", "!", "blk", ")", "return", "0", ";", "SkipBlk", "(", ")", ";", "}", "}", "if", "(", "ValidateCrcBlk", "(", "Tlv", ",", "2", "+", "Tlv", "[", "1", "]", ")", ")", "return", "1", ";", "return", "0", ";", "}" ]
read TLV field of RFID card to Tlv global variabl and validate CRC
[ "read", "TLV", "field", "of", "RFID", "card", "to", "Tlv", "global", "variabl", "and", "validate", "CRC" ]
[ "//2+field_length\r", "//field too long\r", "// readLen = 0;\r" ]
[ { "param": "Key", "type": "TKey48" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Key", "type": "TKey48", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
762d3e8a4381902033d7a71728062a6cff01feec
kkan2020/evacc
firmware/main/RFID_Card.c
[ "MIT" ]
C
RFID_WriteFieldAndSkip
int
int RFID_WriteFieldAndSkip(TKey48 Key) { int srcPos, unwriteLen, writeLen; if (Tlv[1] > sizeof(Tlv)-2) //Tlv buffer overflow return 0; CalcCrcBlk(Tlv, 2+Tlv[1]); srcPos = writeLen = 0; unwriteLen = 2 + Tlv[1]; while (unwriteLen>0) { writeLen = MIN(RFID_BLK_SIZE, unwriteLen); if (!WriteBlk(Key, &Tlv[srcPos])) return 0; SkipBlk(); srcPos += writeLen; unwriteLen -= writeLen; } return 1; }
//write TLV field of RFID card from Tlv global variable
write TLV field of RFID card from Tlv global variable
[ "write", "TLV", "field", "of", "RFID", "card", "from", "Tlv", "global", "variable" ]
int RFID_WriteFieldAndSkip(TKey48 Key) { int srcPos, unwriteLen, writeLen; if (Tlv[1] > sizeof(Tlv)-2) return 0; CalcCrcBlk(Tlv, 2+Tlv[1]); srcPos = writeLen = 0; unwriteLen = 2 + Tlv[1]; while (unwriteLen>0) { writeLen = MIN(RFID_BLK_SIZE, unwriteLen); if (!WriteBlk(Key, &Tlv[srcPos])) return 0; SkipBlk(); srcPos += writeLen; unwriteLen -= writeLen; } return 1; }
[ "int", "RFID_WriteFieldAndSkip", "(", "TKey48", "Key", ")", "{", "int", "srcPos", ",", "unwriteLen", ",", "writeLen", ";", "if", "(", "Tlv", "[", "1", "]", ">", "sizeof", "(", "Tlv", ")", "-", "2", ")", "return", "0", ";", "CalcCrcBlk", "(", "Tlv", ",", "2", "+", "Tlv", "[", "1", "]", ")", ";", "srcPos", "=", "writeLen", "=", "0", ";", "unwriteLen", "=", "2", "+", "Tlv", "[", "1", "]", ";", "while", "(", "unwriteLen", ">", "0", ")", "{", "writeLen", "=", "MIN", "(", "RFID_BLK_SIZE", ",", "unwriteLen", ")", ";", "if", "(", "!", "WriteBlk", "(", "Key", ",", "&", "Tlv", "[", "srcPos", "]", ")", ")", "return", "0", ";", "SkipBlk", "(", ")", ";", "srcPos", "+=", "writeLen", ";", "unwriteLen", "-=", "writeLen", ";", "}", "return", "1", ";", "}" ]
write TLV field of RFID card from Tlv global variable
[ "write", "TLV", "field", "of", "RFID", "card", "from", "Tlv", "global", "variable" ]
[ "//Tlv buffer overflow\r" ]
[ { "param": "Key", "type": "TKey48" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Key", "type": "TKey48", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2b7c200331877b0f0dc3c4d63fbef6d215be20d6
V1Soft/ttywm
dwm.c
[ "MIT" ]
C
focusin
void
void focusin(XEvent *e) { XFocusChangeEvent *ev = &e->xfocus; if (selmon->sel && ev->window != selmon->sel->win) setfocus(selmon->sel); }
/* there are some broken focus acquiring clients */
there are some broken focus acquiring clients
[ "there", "are", "some", "broken", "focus", "acquiring", "clients" ]
void focusin(XEvent *e) { XFocusChangeEvent *ev = &e->xfocus; if (selmon->sel && ev->window != selmon->sel->win) setfocus(selmon->sel); }
[ "void", "focusin", "(", "XEvent", "*", "e", ")", "{", "XFocusChangeEvent", "*", "ev", "=", "&", "e", "->", "xfocus", ";", "if", "(", "selmon", "->", "sel", "&&", "ev", "->", "window", "!=", "selmon", "->", "sel", "->", "win", ")", "setfocus", "(", "selmon", "->", "sel", ")", ";", "}" ]
there are some broken focus acquiring clients
[ "there", "are", "some", "broken", "focus", "acquiring", "clients" ]
[]
[ { "param": "e", "type": "XEvent" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "e", "type": "XEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2b7c200331877b0f0dc3c4d63fbef6d215be20d6
V1Soft/ttywm
dwm.c
[ "MIT" ]
C
xerror
int
int xerror(Display *dpy, XErrorEvent *ee) { if (ee->error_code == BadWindow || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable) || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) || (ee->request_code == X_GrabButton && ee->error_code == BadAccess) || (ee->request_code == X_GrabKey && ee->error_code == BadAccess) || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)) return 0; fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", ee->request_code, ee->error_code); return xerrorxlib(dpy, ee); /* may call exit */ }
/* There's no way to check accesses to destroyed windows, thus those cases are * ignored (especially on UnmapNotify's). Other types of errors call Xlibs * default error handler, which may call exit. */
There's no way to check accesses to destroyed windows, thus those cases are ignored (especially on UnmapNotify's). Other types of errors call Xlibs default error handler, which may call exit.
[ "There", "'", "s", "no", "way", "to", "check", "accesses", "to", "destroyed", "windows", "thus", "those", "cases", "are", "ignored", "(", "especially", "on", "UnmapNotify", "'", "s", ")", ".", "Other", "types", "of", "errors", "call", "Xlibs", "default", "error", "handler", "which", "may", "call", "exit", "." ]
int xerror(Display *dpy, XErrorEvent *ee) { if (ee->error_code == BadWindow || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable) || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) || (ee->request_code == X_GrabButton && ee->error_code == BadAccess) || (ee->request_code == X_GrabKey && ee->error_code == BadAccess) || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)) return 0; fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", ee->request_code, ee->error_code); return xerrorxlib(dpy, ee); }
[ "int", "xerror", "(", "Display", "*", "dpy", ",", "XErrorEvent", "*", "ee", ")", "{", "if", "(", "ee", "->", "error_code", "==", "BadWindow", "||", "(", "ee", "->", "request_code", "==", "X_SetInputFocus", "&&", "ee", "->", "error_code", "==", "BadMatch", ")", "||", "(", "ee", "->", "request_code", "==", "X_PolyText8", "&&", "ee", "->", "error_code", "==", "BadDrawable", ")", "||", "(", "ee", "->", "request_code", "==", "X_PolyFillRectangle", "&&", "ee", "->", "error_code", "==", "BadDrawable", ")", "||", "(", "ee", "->", "request_code", "==", "X_PolySegment", "&&", "ee", "->", "error_code", "==", "BadDrawable", ")", "||", "(", "ee", "->", "request_code", "==", "X_ConfigureWindow", "&&", "ee", "->", "error_code", "==", "BadMatch", ")", "||", "(", "ee", "->", "request_code", "==", "X_GrabButton", "&&", "ee", "->", "error_code", "==", "BadAccess", ")", "||", "(", "ee", "->", "request_code", "==", "X_GrabKey", "&&", "ee", "->", "error_code", "==", "BadAccess", ")", "||", "(", "ee", "->", "request_code", "==", "X_CopyArea", "&&", "ee", "->", "error_code", "==", "BadDrawable", ")", ")", "return", "0", ";", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "ee", "->", "request_code", ",", "ee", "->", "error_code", ")", ";", "return", "xerrorxlib", "(", "dpy", ",", "ee", ")", ";", "}" ]
There's no way to check accesses to destroyed windows, thus those cases are ignored (especially on UnmapNotify's).
[ "There", "'", "s", "no", "way", "to", "check", "accesses", "to", "destroyed", "windows", "thus", "those", "cases", "are", "ignored", "(", "especially", "on", "UnmapNotify", "'", "s", ")", "." ]
[ "/* may call exit */" ]
[ { "param": "dpy", "type": "Display" }, { "param": "ee", "type": "XErrorEvent" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dpy", "type": "Display", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ee", "type": "XErrorEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ee03790e8094f3302c77c64550620d9bec078c71
aniket1418/DSA-2
C/quicksort.c
[ "MIT" ]
C
partition
int
int partition(int array[], int low, int high) { // Select the pivot element int pivot = array[high]; int i = (low - 1); // Put the elements smaller than pivot on the left // and greater than pivot on the right of pivot for (int j = low; j < high; j++) { if (array[j] <= pivot) { i++; swap(&array[i], &array[j]); } } swap(&array[i + 1], &array[high]); return (i + 1); }
// Function to partition the array on the basis of pivot element
Function to partition the array on the basis of pivot element
[ "Function", "to", "partition", "the", "array", "on", "the", "basis", "of", "pivot", "element" ]
int partition(int array[], int low, int high) { int pivot = array[high]; int i = (low - 1); for (int j = low; j < high; j++) { if (array[j] <= pivot) { i++; swap(&array[i], &array[j]); } } swap(&array[i + 1], &array[high]); return (i + 1); }
[ "int", "partition", "(", "int", "array", "[", "]", ",", "int", "low", ",", "int", "high", ")", "{", "int", "pivot", "=", "array", "[", "high", "]", ";", "int", "i", "=", "(", "low", "-", "1", ")", ";", "for", "(", "int", "j", "=", "low", ";", "j", "<", "high", ";", "j", "++", ")", "{", "if", "(", "array", "[", "j", "]", "<=", "pivot", ")", "{", "i", "++", ";", "swap", "(", "&", "array", "[", "i", "]", ",", "&", "array", "[", "j", "]", ")", ";", "}", "}", "swap", "(", "&", "array", "[", "i", "+", "1", "]", ",", "&", "array", "[", "high", "]", ")", ";", "return", "(", "i", "+", "1", ")", ";", "}" ]
Function to partition the array on the basis of pivot element
[ "Function", "to", "partition", "the", "array", "on", "the", "basis", "of", "pivot", "element" ]
[ "// Select the pivot element", "// Put the elements smaller than pivot on the left ", "// and greater than pivot on the right of pivot" ]
[ { "param": "array", "type": "int" }, { "param": "low", "type": "int" }, { "param": "high", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "array", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "low", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "high", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ee03790e8094f3302c77c64550620d9bec078c71
aniket1418/DSA-2
C/quicksort.c
[ "MIT" ]
C
printArray
void
void printArray(int array[], int size) { for (int i = 0; i < size; ++i) { printf("%d ", array[i]); } printf("\n"); }
// Function to print eklements of an array
Function to print eklements of an array
[ "Function", "to", "print", "eklements", "of", "an", "array" ]
void printArray(int array[], int size) { for (int i = 0; i < size; ++i) { printf("%d ", array[i]); } printf("\n"); }
[ "void", "printArray", "(", "int", "array", "[", "]", ",", "int", "size", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "++", "i", ")", "{", "printf", "(", "\"", "\"", ",", "array", "[", "i", "]", ")", ";", "}", "printf", "(", "\"", "\\n", "\"", ")", ";", "}" ]
Function to print eklements of an array
[ "Function", "to", "print", "eklements", "of", "an", "array" ]
[]
[ { "param": "array", "type": "int" }, { "param": "size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "array", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1628bbcb9e5af01a0aa89ee5a8495a2c299b20ac
Tam-Lin/zos-tools-and-toys
sparse/sparse.c
[ "Apache-2.0" ]
C
display_errno
char
char * display_errno(int num) { switch (num) { case 0 : return("no error"); break; case EACCES : return("EACCES"); break; case EAGAIN : return("EAGAIN"); break; case EBUSY : return("EBUSY"); break; case EEXIST : return("EEXIST"); break; case EINTR : return("EINTR"); break; case EINVAL : return("EINVAL"); break; case EIO : return("EIO"); break; case EISDIR : return("EISDIR"); break; case ELOOP : return("ELOOP"); break; case EMFILE : return("EMFILE"); break; case ENAMETOOLONG: return("ENAMETOOLONG"); break; case ENFILE : return("ENFILE"); break; case ENOENT : return("ENOENT"); break; case ENOMEM : return("ENOMEM"); break; case ENOSPC : return("ENOSPC"); break; case ENOSYS : return("ENOSYS"); break; case ENOTDIR : return("ENOTDIR"); break; case ENXIO : return("ENXIO"); break; case EOVERFLOW: return("EOVERFLOW"); break; case EPERM : return("EPERM"); break; case EROFS : return("EROFS"); break; default: return("unknown"); } }
/*----------------------------------------------------------*/ /* Function: display_errno */ /* Purpose: Converts an errno value into an errno name */ /*----------------------------------------------------------*/
display_errno Purpose: Converts an errno value into an errno name
[ "display_errno", "Purpose", ":", "Converts", "an", "errno", "value", "into", "an", "errno", "name" ]
char * display_errno(int num) { switch (num) { case 0 : return("no error"); break; case EACCES : return("EACCES"); break; case EAGAIN : return("EAGAIN"); break; case EBUSY : return("EBUSY"); break; case EEXIST : return("EEXIST"); break; case EINTR : return("EINTR"); break; case EINVAL : return("EINVAL"); break; case EIO : return("EIO"); break; case EISDIR : return("EISDIR"); break; case ELOOP : return("ELOOP"); break; case EMFILE : return("EMFILE"); break; case ENAMETOOLONG: return("ENAMETOOLONG"); break; case ENFILE : return("ENFILE"); break; case ENOENT : return("ENOENT"); break; case ENOMEM : return("ENOMEM"); break; case ENOSPC : return("ENOSPC"); break; case ENOSYS : return("ENOSYS"); break; case ENOTDIR : return("ENOTDIR"); break; case ENXIO : return("ENXIO"); break; case EOVERFLOW: return("EOVERFLOW"); break; case EPERM : return("EPERM"); break; case EROFS : return("EROFS"); break; default: return("unknown"); } }
[ "char", "*", "display_errno", "(", "int", "num", ")", "{", "switch", "(", "num", ")", "{", "case", "0", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EACCES", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EAGAIN", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EBUSY", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EEXIST", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EINTR", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EINVAL", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EIO", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EISDIR", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "ELOOP", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EMFILE", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "ENAMETOOLONG", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "ENFILE", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "ENOENT", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "ENOMEM", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "ENOSPC", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "ENOSYS", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "ENOTDIR", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "ENXIO", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EOVERFLOW", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EPERM", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "case", "EROFS", ":", "return", "(", "\"", "\"", ")", ";", "break", ";", "default", ":", "return", "(", "\"", "\"", ")", ";", "}", "}" ]
Function: display_errno Purpose: Converts an errno value into an errno name
[ "Function", ":", "display_errno", "Purpose", ":", "Converts", "an", "errno", "value", "into", "an", "errno", "name" ]
[]
[ { "param": "num", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "num", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5134fb5203356d345f3cec4e0fe11107557ab8eb
sfstewman/forthtoy
Source/interp.c
[ "MIT" ]
C
encode_instr_int
nan
static union forth_instruction encode_instr_int(enum FORTH_VM_CODES opcode, int32_t arg) { register union forth_instruction instr; instr.whole = 0; instr.bytes[0] = opcode; if ((arg >= 0) && (arg < 0x400000)) { instr.bytes[1] = ((arg & 0x3f0000) >> 16) | FORTH_FLAG_ENCODED; instr.half[1] = arg & 0xffff; } else if ((arg < 0) && (-arg < 0x400000)) { arg = -arg; instr.bytes[1] = ((arg & 0x3f0000) >> 16) | FORTH_FLAG_ENCODED | FORTH_FLAG_NEGATE; instr.half[1] = arg & 0xffff; } return instr; }
// If the argument cannot be encoded, the return value will have the // bytes[1] field set to zero
If the argument cannot be encoded, the return value will have the bytes[1] field set to zero
[ "If", "the", "argument", "cannot", "be", "encoded", "the", "return", "value", "will", "have", "the", "bytes", "[", "1", "]", "field", "set", "to", "zero" ]
static union forth_instruction encode_instr_int(enum FORTH_VM_CODES opcode, int32_t arg) { register union forth_instruction instr; instr.whole = 0; instr.bytes[0] = opcode; if ((arg >= 0) && (arg < 0x400000)) { instr.bytes[1] = ((arg & 0x3f0000) >> 16) | FORTH_FLAG_ENCODED; instr.half[1] = arg & 0xffff; } else if ((arg < 0) && (-arg < 0x400000)) { arg = -arg; instr.bytes[1] = ((arg & 0x3f0000) >> 16) | FORTH_FLAG_ENCODED | FORTH_FLAG_NEGATE; instr.half[1] = arg & 0xffff; } return instr; }
[ "static", "union", "forth_instruction", "encode_instr_int", "(", "enum", "FORTH_VM_CODES", "opcode", ",", "int32_t", "arg", ")", "{", "register", "union", "forth_instruction", "instr", ";", "instr", ".", "whole", "=", "0", ";", "instr", ".", "bytes", "[", "0", "]", "=", "opcode", ";", "if", "(", "(", "arg", ">=", "0", ")", "&&", "(", "arg", "<", "0x400000", ")", ")", "{", "instr", ".", "bytes", "[", "1", "]", "=", "(", "(", "arg", "&", "0x3f0000", ")", ">>", "16", ")", "|", "FORTH_FLAG_ENCODED", ";", "instr", ".", "half", "[", "1", "]", "=", "arg", "&", "0xffff", ";", "}", "else", "if", "(", "(", "arg", "<", "0", ")", "&&", "(", "-", "arg", "<", "0x400000", ")", ")", "{", "arg", "=", "-", "arg", ";", "instr", ".", "bytes", "[", "1", "]", "=", "(", "(", "arg", "&", "0x3f0000", ")", ">>", "16", ")", "|", "FORTH_FLAG_ENCODED", "|", "FORTH_FLAG_NEGATE", ";", "instr", ".", "half", "[", "1", "]", "=", "arg", "&", "0xffff", ";", "}", "return", "instr", ";", "}" ]
If the argument cannot be encoded, the return value will have the bytes[1] field set to zero
[ "If", "the", "argument", "cannot", "be", "encoded", "the", "return", "value", "will", "have", "the", "bytes", "[", "1", "]", "field", "set", "to", "zero" ]
[]
[ { "param": "opcode", "type": "enum FORTH_VM_CODES" }, { "param": "arg", "type": "int32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "opcode", "type": "enum FORTH_VM_CODES", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg", "type": "int32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cb65ac2a9272d60ec25eef30d6b072a31492862
Ivan-Velickovic/sel4_riscv_vmm
src/vmm.c
[ "BSD-2-Clause" ]
C
irq_server_node_handle_irq
void
static void irq_server_node_handle_irq(struct irq_server_node *n, seL4_Word badge) { struct irq_data *irqs; irqs = n->irqs; /* Mask out reserved bits */ badge = badge & n->badge_mask; /* For each bit, call the registered handler */ while (badge) { int irq_idx; struct irq_data *irq; irq_idx = CTZL(badge); irq = &irqs[irq_idx]; irq->cb(irq); badge &= ~BIT(irq_idx); } }
/* Executes the registered callback for incoming IRQS */
Executes the registered callback for incoming IRQS
[ "Executes", "the", "registered", "callback", "for", "incoming", "IRQS" ]
static void irq_server_node_handle_irq(struct irq_server_node *n, seL4_Word badge) { struct irq_data *irqs; irqs = n->irqs; badge = badge & n->badge_mask; while (badge) { int irq_idx; struct irq_data *irq; irq_idx = CTZL(badge); irq = &irqs[irq_idx]; irq->cb(irq); badge &= ~BIT(irq_idx); } }
[ "static", "void", "irq_server_node_handle_irq", "(", "struct", "irq_server_node", "*", "n", ",", "seL4_Word", "badge", ")", "{", "struct", "irq_data", "*", "irqs", ";", "irqs", "=", "n", "->", "irqs", ";", "badge", "=", "badge", "&", "n", "->", "badge_mask", ";", "while", "(", "badge", ")", "{", "int", "irq_idx", ";", "struct", "irq_data", "*", "irq", ";", "irq_idx", "=", "CTZL", "(", "badge", ")", ";", "irq", "=", "&", "irqs", "[", "irq_idx", "]", ";", "irq", "->", "cb", "(", "irq", ")", ";", "badge", "&=", "~", "BIT", "(", "irq_idx", ")", ";", "}", "}" ]
Executes the registered callback for incoming IRQS
[ "Executes", "the", "registered", "callback", "for", "incoming", "IRQS" ]
[ "/* Mask out reserved bits */", "/* For each bit, call the registered handler */" ]
[ { "param": "n", "type": "struct irq_server_node" }, { "param": "badge", "type": "seL4_Word" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": "struct irq_server_node", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "badge", "type": "seL4_Word", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cb65ac2a9272d60ec25eef30d6b072a31492862
Ivan-Velickovic/sel4_riscv_vmm
src/vmm.c
[ "BSD-2-Clause" ]
C
irq_bind
seL4_CPtr
static seL4_CPtr irq_bind(irq_t irq, seL4_CPtr notification_cap, int idx, vka_t *vka, simple_t *simple) { seL4_CPtr irq_cap, bnotification_cap; cspacepath_t irq_path, notification_path, bnotification_path; seL4_Word badge; int err; /* Create an IRQ cap */ err = vka_cspace_alloc(vka, &irq_cap); if (err != 0) { ZF_LOGE("Failed to allocate cslot for irq\n"); return seL4_CapNull; } vka_cspace_make_path(vka, irq_cap, &irq_path); err = simple_get_IRQ_handler(simple, irq, irq_path); if (err != seL4_NoError) { ZF_LOGE("Failed to get cap to irq_number %d\n", irq); vka_cspace_free(vka, irq_cap); return seL4_CapNull; } /* Badge the provided endpoint. The bit position of the badge tells us the array * index of the associated IRQ data. */ err = vka_cspace_alloc(vka, &bnotification_cap); if (err != 0) { ZF_LOGE("Failed to allocate cslot for irq\n"); vka_cspace_free(vka, irq_cap); return seL4_CapNull; } vka_cspace_make_path(vka, notification_cap, &notification_path); vka_cspace_make_path(vka, bnotification_cap, &bnotification_path); badge = BIT(idx); err = vka_cnode_mint(&bnotification_path, &notification_path, seL4_AllRights, badge); if (err != seL4_NoError) { ZF_LOGE("Failed to badge IRQ notification endpoint\n"); vka_cspace_free(vka, irq_cap); vka_cspace_free(vka, bnotification_cap); return seL4_CapNull; } /* bind the IRQ cap to our badged endpoint */ err = seL4_IRQHandler_SetNotification(irq_cap, bnotification_cap); if (err != seL4_NoError) { ZF_LOGE("Failed to bind IRQ handler to notification\n"); vka_cspace_free(vka, irq_cap); vka_cspace_free(vka, bnotification_cap); return seL4_CapNull; } /* Finally ACK any pending IRQ and enable the IRQ */ seL4_IRQHandler_Ack(irq_cap); ZF_LOGD("Registered IRQ %d with badge 0x%lx\n", irq, BIT(idx)); return irq_cap; }
/* Binds and IRQ to an endpoint */
Binds and IRQ to an endpoint
[ "Binds", "and", "IRQ", "to", "an", "endpoint" ]
static seL4_CPtr irq_bind(irq_t irq, seL4_CPtr notification_cap, int idx, vka_t *vka, simple_t *simple) { seL4_CPtr irq_cap, bnotification_cap; cspacepath_t irq_path, notification_path, bnotification_path; seL4_Word badge; int err; err = vka_cspace_alloc(vka, &irq_cap); if (err != 0) { ZF_LOGE("Failed to allocate cslot for irq\n"); return seL4_CapNull; } vka_cspace_make_path(vka, irq_cap, &irq_path); err = simple_get_IRQ_handler(simple, irq, irq_path); if (err != seL4_NoError) { ZF_LOGE("Failed to get cap to irq_number %d\n", irq); vka_cspace_free(vka, irq_cap); return seL4_CapNull; } err = vka_cspace_alloc(vka, &bnotification_cap); if (err != 0) { ZF_LOGE("Failed to allocate cslot for irq\n"); vka_cspace_free(vka, irq_cap); return seL4_CapNull; } vka_cspace_make_path(vka, notification_cap, &notification_path); vka_cspace_make_path(vka, bnotification_cap, &bnotification_path); badge = BIT(idx); err = vka_cnode_mint(&bnotification_path, &notification_path, seL4_AllRights, badge); if (err != seL4_NoError) { ZF_LOGE("Failed to badge IRQ notification endpoint\n"); vka_cspace_free(vka, irq_cap); vka_cspace_free(vka, bnotification_cap); return seL4_CapNull; } err = seL4_IRQHandler_SetNotification(irq_cap, bnotification_cap); if (err != seL4_NoError) { ZF_LOGE("Failed to bind IRQ handler to notification\n"); vka_cspace_free(vka, irq_cap); vka_cspace_free(vka, bnotification_cap); return seL4_CapNull; } seL4_IRQHandler_Ack(irq_cap); ZF_LOGD("Registered IRQ %d with badge 0x%lx\n", irq, BIT(idx)); return irq_cap; }
[ "static", "seL4_CPtr", "irq_bind", "(", "irq_t", "irq", ",", "seL4_CPtr", "notification_cap", ",", "int", "idx", ",", "vka_t", "*", "vka", ",", "simple_t", "*", "simple", ")", "{", "seL4_CPtr", "irq_cap", ",", "bnotification_cap", ";", "cspacepath_t", "irq_path", ",", "notification_path", ",", "bnotification_path", ";", "seL4_Word", "badge", ";", "int", "err", ";", "err", "=", "vka_cspace_alloc", "(", "vka", ",", "&", "irq_cap", ")", ";", "if", "(", "err", "!=", "0", ")", "{", "ZF_LOGE", "(", "\"", "\\n", "\"", ")", ";", "return", "seL4_CapNull", ";", "}", "vka_cspace_make_path", "(", "vka", ",", "irq_cap", ",", "&", "irq_path", ")", ";", "err", "=", "simple_get_IRQ_handler", "(", "simple", ",", "irq", ",", "irq_path", ")", ";", "if", "(", "err", "!=", "seL4_NoError", ")", "{", "ZF_LOGE", "(", "\"", "\\n", "\"", ",", "irq", ")", ";", "vka_cspace_free", "(", "vka", ",", "irq_cap", ")", ";", "return", "seL4_CapNull", ";", "}", "err", "=", "vka_cspace_alloc", "(", "vka", ",", "&", "bnotification_cap", ")", ";", "if", "(", "err", "!=", "0", ")", "{", "ZF_LOGE", "(", "\"", "\\n", "\"", ")", ";", "vka_cspace_free", "(", "vka", ",", "irq_cap", ")", ";", "return", "seL4_CapNull", ";", "}", "vka_cspace_make_path", "(", "vka", ",", "notification_cap", ",", "&", "notification_path", ")", ";", "vka_cspace_make_path", "(", "vka", ",", "bnotification_cap", ",", "&", "bnotification_path", ")", ";", "badge", "=", "BIT", "(", "idx", ")", ";", "err", "=", "vka_cnode_mint", "(", "&", "bnotification_path", ",", "&", "notification_path", ",", "seL4_AllRights", ",", "badge", ")", ";", "if", "(", "err", "!=", "seL4_NoError", ")", "{", "ZF_LOGE", "(", "\"", "\\n", "\"", ")", ";", "vka_cspace_free", "(", "vka", ",", "irq_cap", ")", ";", "vka_cspace_free", "(", "vka", ",", "bnotification_cap", ")", ";", "return", "seL4_CapNull", ";", "}", "err", "=", "seL4_IRQHandler_SetNotification", "(", "irq_cap", ",", "bnotification_cap", ")", ";", "if", "(", "err", "!=", "seL4_NoError", ")", "{", "ZF_LOGE", "(", "\"", "\\n", "\"", ")", ";", "vka_cspace_free", "(", "vka", ",", "irq_cap", ")", ";", "vka_cspace_free", "(", "vka", ",", "bnotification_cap", ")", ";", "return", "seL4_CapNull", ";", "}", "seL4_IRQHandler_Ack", "(", "irq_cap", ")", ";", "ZF_LOGD", "(", "\"", "\\n", "\"", ",", "irq", ",", "BIT", "(", "idx", ")", ")", ";", "return", "irq_cap", ";", "}" ]
Binds and IRQ to an endpoint
[ "Binds", "and", "IRQ", "to", "an", "endpoint" ]
[ "/* Create an IRQ cap */", "/* Badge the provided endpoint. The bit position of the badge tells us the array\n * index of the associated IRQ data. */", "/* bind the IRQ cap to our badged endpoint */", "/* Finally ACK any pending IRQ and enable the IRQ */" ]
[ { "param": "irq", "type": "irq_t" }, { "param": "notification_cap", "type": "seL4_CPtr" }, { "param": "idx", "type": "int" }, { "param": "vka", "type": "vka_t" }, { "param": "simple", "type": "simple_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "irq", "type": "irq_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "notification_cap", "type": "seL4_CPtr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "idx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vka", "type": "vka_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "simple", "type": "simple_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cb65ac2a9272d60ec25eef30d6b072a31492862
Ivan-Velickovic/sel4_riscv_vmm
src/vmm.c
[ "BSD-2-Clause" ]
C
irq_server_node_register_irq
null
struct irq_data *irq_server_node_register_irq(irq_server_node_t n, irq_t irq, irq_handler_fn cb, void *token, vka_t *vka, seL4_CPtr cspace, simple_t *simple) { struct irq_data *irqs; int i; irqs = n->irqs; for (i = 0; i < NIRQS_PER_NODE; i++) { /* If a cap has not been registered and the bit in the mask is not set */ if (irqs[i].cap == seL4_CapNull && (n->badge_mask & BIT(i))) { irqs[i].cap = irq_bind(irq, n->notification, i, vka, simple); if (irqs[i].cap == seL4_CapNull) { ZF_LOGD("Failed to bind IRQ\n"); return NULL; } irqs[i].irq = irq; irqs[i].cb = cb; irqs[i].token = token; return &irqs[i]; } } return NULL; }
/* Registers an IRQ callback and enabled the IRQ */
Registers an IRQ callback and enabled the IRQ
[ "Registers", "an", "IRQ", "callback", "and", "enabled", "the", "IRQ" ]
struct irq_data *irq_server_node_register_irq(irq_server_node_t n, irq_t irq, irq_handler_fn cb, void *token, vka_t *vka, seL4_CPtr cspace, simple_t *simple) { struct irq_data *irqs; int i; irqs = n->irqs; for (i = 0; i < NIRQS_PER_NODE; i++) { if (irqs[i].cap == seL4_CapNull && (n->badge_mask & BIT(i))) { irqs[i].cap = irq_bind(irq, n->notification, i, vka, simple); if (irqs[i].cap == seL4_CapNull) { ZF_LOGD("Failed to bind IRQ\n"); return NULL; } irqs[i].irq = irq; irqs[i].cb = cb; irqs[i].token = token; return &irqs[i]; } } return NULL; }
[ "struct", "irq_data", "*", "irq_server_node_register_irq", "(", "irq_server_node_t", "n", ",", "irq_t", "irq", ",", "irq_handler_fn", "cb", ",", "void", "*", "token", ",", "vka_t", "*", "vka", ",", "seL4_CPtr", "cspace", ",", "simple_t", "*", "simple", ")", "{", "struct", "irq_data", "*", "irqs", ";", "int", "i", ";", "irqs", "=", "n", "->", "irqs", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NIRQS_PER_NODE", ";", "i", "++", ")", "{", "if", "(", "irqs", "[", "i", "]", ".", "cap", "==", "seL4_CapNull", "&&", "(", "n", "->", "badge_mask", "&", "BIT", "(", "i", ")", ")", ")", "{", "irqs", "[", "i", "]", ".", "cap", "=", "irq_bind", "(", "irq", ",", "n", "->", "notification", ",", "i", ",", "vka", ",", "simple", ")", ";", "if", "(", "irqs", "[", "i", "]", ".", "cap", "==", "seL4_CapNull", ")", "{", "ZF_LOGD", "(", "\"", "\\n", "\"", ")", ";", "return", "NULL", ";", "}", "irqs", "[", "i", "]", ".", "irq", "=", "irq", ";", "irqs", "[", "i", "]", ".", "cb", "=", "cb", ";", "irqs", "[", "i", "]", ".", "token", "=", "token", ";", "return", "&", "irqs", "[", "i", "]", ";", "}", "}", "return", "NULL", ";", "}" ]
Registers an IRQ callback and enabled the IRQ
[ "Registers", "an", "IRQ", "callback", "and", "enabled", "the", "IRQ" ]
[ "/* If a cap has not been registered and the bit in the mask is not set */" ]
[ { "param": "n", "type": "irq_server_node_t" }, { "param": "irq", "type": "irq_t" }, { "param": "cb", "type": "irq_handler_fn" }, { "param": "token", "type": "void" }, { "param": "vka", "type": "vka_t" }, { "param": "cspace", "type": "seL4_CPtr" }, { "param": "simple", "type": "simple_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": "irq_server_node_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "irq", "type": "irq_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cb", "type": "irq_handler_fn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "token", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vka", "type": "vka_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cspace", "type": "seL4_CPtr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "simple", "type": "simple_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cb65ac2a9272d60ec25eef30d6b072a31492862
Ivan-Velickovic/sel4_riscv_vmm
src/vmm.c
[ "BSD-2-Clause" ]
C
irq_server_node_new
null
struct irq_server_node *irq_server_node_new(seL4_CPtr notification, seL4_Word badge_mask) { struct irq_server_node *n; n = calloc(1, sizeof(*n)); if (n) { n->notification = notification; n->badge_mask = badge_mask; } return n; }
/* Creates a new IRQ server node which contains Thread data and registered IRQ data. */
Creates a new IRQ server node which contains Thread data and registered IRQ data.
[ "Creates", "a", "new", "IRQ", "server", "node", "which", "contains", "Thread", "data", "and", "registered", "IRQ", "data", "." ]
struct irq_server_node *irq_server_node_new(seL4_CPtr notification, seL4_Word badge_mask) { struct irq_server_node *n; n = calloc(1, sizeof(*n)); if (n) { n->notification = notification; n->badge_mask = badge_mask; } return n; }
[ "struct", "irq_server_node", "*", "irq_server_node_new", "(", "seL4_CPtr", "notification", ",", "seL4_Word", "badge_mask", ")", "{", "struct", "irq_server_node", "*", "n", ";", "n", "=", "calloc", "(", "1", ",", "sizeof", "(", "*", "n", ")", ")", ";", "if", "(", "n", ")", "{", "n", "->", "notification", "=", "notification", ";", "n", "->", "badge_mask", "=", "badge_mask", ";", "}", "return", "n", ";", "}" ]
Creates a new IRQ server node which contains Thread data and registered IRQ data.
[ "Creates", "a", "new", "IRQ", "server", "node", "which", "contains", "Thread", "data", "and", "registered", "IRQ", "data", "." ]
[]
[ { "param": "notification", "type": "seL4_CPtr" }, { "param": "badge_mask", "type": "seL4_Word" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "notification", "type": "seL4_CPtr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "badge_mask", "type": "seL4_Word", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cb65ac2a9272d60ec25eef30d6b072a31492862
Ivan-Velickovic/sel4_riscv_vmm
src/vmm.c
[ "BSD-2-Clause" ]
C
_irq_thread_entry
void
static void _irq_thread_entry(struct irq_server_thread *st) { seL4_CPtr sep; seL4_CPtr notification; uintptr_t node_ptr; seL4_Word label; sep = st->delivery_sep; notification = st->node->notification; node_ptr = (uintptr_t)st->node; label = st->label; ZF_LOGD("thread started. Waiting on endpoint %d\n", notification); while (1) { seL4_Word badge; seL4_Wait(notification, &badge); assert(badge != 0); if (sep != seL4_CapNull) { /* Synchronous endpoint registered. Send IPC */ seL4_MessageInfo_t info = seL4_MessageInfo_new(label, 0, 0, 2); seL4_SetMR(0, badge); seL4_SetMR(1, node_ptr); seL4_Send(sep, info); } else { /* No synchronous endpoint. Call the handler directly */ irq_server_node_handle_irq(st->node, badge); } } }
/* IRQ handler thread. Wait on a notification object for IRQs. When one arrives, send a * synchronous message to the registered endpoint. If no synchronous endpoint was * registered, call the appropriate handler function directly (must be thread safe) */
IRQ handler thread. Wait on a notification object for IRQs. When one arrives, send a synchronous message to the registered endpoint. If no synchronous endpoint was registered, call the appropriate handler function directly (must be thread safe)
[ "IRQ", "handler", "thread", ".", "Wait", "on", "a", "notification", "object", "for", "IRQs", ".", "When", "one", "arrives", "send", "a", "synchronous", "message", "to", "the", "registered", "endpoint", ".", "If", "no", "synchronous", "endpoint", "was", "registered", "call", "the", "appropriate", "handler", "function", "directly", "(", "must", "be", "thread", "safe", ")" ]
static void _irq_thread_entry(struct irq_server_thread *st) { seL4_CPtr sep; seL4_CPtr notification; uintptr_t node_ptr; seL4_Word label; sep = st->delivery_sep; notification = st->node->notification; node_ptr = (uintptr_t)st->node; label = st->label; ZF_LOGD("thread started. Waiting on endpoint %d\n", notification); while (1) { seL4_Word badge; seL4_Wait(notification, &badge); assert(badge != 0); if (sep != seL4_CapNull) { seL4_MessageInfo_t info = seL4_MessageInfo_new(label, 0, 0, 2); seL4_SetMR(0, badge); seL4_SetMR(1, node_ptr); seL4_Send(sep, info); } else { irq_server_node_handle_irq(st->node, badge); } } }
[ "static", "void", "_irq_thread_entry", "(", "struct", "irq_server_thread", "*", "st", ")", "{", "seL4_CPtr", "sep", ";", "seL4_CPtr", "notification", ";", "uintptr_t", "node_ptr", ";", "seL4_Word", "label", ";", "sep", "=", "st", "->", "delivery_sep", ";", "notification", "=", "st", "->", "node", "->", "notification", ";", "node_ptr", "=", "(", "uintptr_t", ")", "st", "->", "node", ";", "label", "=", "st", "->", "label", ";", "ZF_LOGD", "(", "\"", "\\n", "\"", ",", "notification", ")", ";", "while", "(", "1", ")", "{", "seL4_Word", "badge", ";", "seL4_Wait", "(", "notification", ",", "&", "badge", ")", ";", "assert", "(", "badge", "!=", "0", ")", ";", "if", "(", "sep", "!=", "seL4_CapNull", ")", "{", "seL4_MessageInfo_t", "info", "=", "seL4_MessageInfo_new", "(", "label", ",", "0", ",", "0", ",", "2", ")", ";", "seL4_SetMR", "(", "0", ",", "badge", ")", ";", "seL4_SetMR", "(", "1", ",", "node_ptr", ")", ";", "seL4_Send", "(", "sep", ",", "info", ")", ";", "}", "else", "{", "irq_server_node_handle_irq", "(", "st", "->", "node", ",", "badge", ")", ";", "}", "}", "}" ]
IRQ handler thread.
[ "IRQ", "handler", "thread", "." ]
[ "/* Synchronous endpoint registered. Send IPC */", "/* No synchronous endpoint. Call the handler directly */" ]
[ { "param": "st", "type": "struct irq_server_thread" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "st", "type": "struct irq_server_thread", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cb65ac2a9272d60ec25eef30d6b072a31492862
Ivan-Velickovic/sel4_riscv_vmm
src/vmm.c
[ "BSD-2-Clause" ]
C
irq_server_thread_new
null
struct irq_server_thread *irq_server_thread_new(vspace_t *vspace, vka_t *vka, seL4_CPtr cspace, seL4_Word priority, simple_t *simple, seL4_Word label, seL4_CPtr sep) { struct irq_server_thread *st; int err; /* Allocate memory for the structure */ st = malloc(sizeof(*st)); if (st == NULL) { return NULL; } st->node = irq_server_node_new(0, MASK(NIRQS_PER_NODE)); if (st->node == NULL) { free(st); return NULL; } /* Initialise structure */ st->delivery_sep = sep; st->label = label; st->next = NULL; /* Create an endpoint to listen on */ err = vka_alloc_notification(vka, &st->notification); if (err) { ZF_LOGE("Failed to allocate IRQ notification endpoint for IRQ server thread\n"); return NULL; } st->node->notification = st->notification.cptr; /* Create the IRQ thread */ sel4utils_thread_config_t config = thread_config_default(simple, cspace, seL4_NilData, 0, priority); err = sel4utils_configure_thread_config(vka, vspace, vspace, config, &st->thread); if (err) { ZF_LOGE("Failed to configure IRQ server thread\n"); return NULL; } /* Start the thread */ err = sel4utils_start_thread(&st->thread, (void *)_irq_thread_entry, st, NULL, 1); seL4_DebugNameThread(st->thread.tcb.cptr, "irqserver"); if (err) { ZF_LOGE("Failed to start IRQ server thread\n"); return NULL; } return st; }
/* Creates a new thread for an IRQ server */
Creates a new thread for an IRQ server
[ "Creates", "a", "new", "thread", "for", "an", "IRQ", "server" ]
struct irq_server_thread *irq_server_thread_new(vspace_t *vspace, vka_t *vka, seL4_CPtr cspace, seL4_Word priority, simple_t *simple, seL4_Word label, seL4_CPtr sep) { struct irq_server_thread *st; int err; st = malloc(sizeof(*st)); if (st == NULL) { return NULL; } st->node = irq_server_node_new(0, MASK(NIRQS_PER_NODE)); if (st->node == NULL) { free(st); return NULL; } st->delivery_sep = sep; st->label = label; st->next = NULL; err = vka_alloc_notification(vka, &st->notification); if (err) { ZF_LOGE("Failed to allocate IRQ notification endpoint for IRQ server thread\n"); return NULL; } st->node->notification = st->notification.cptr; sel4utils_thread_config_t config = thread_config_default(simple, cspace, seL4_NilData, 0, priority); err = sel4utils_configure_thread_config(vka, vspace, vspace, config, &st->thread); if (err) { ZF_LOGE("Failed to configure IRQ server thread\n"); return NULL; } err = sel4utils_start_thread(&st->thread, (void *)_irq_thread_entry, st, NULL, 1); seL4_DebugNameThread(st->thread.tcb.cptr, "irqserver"); if (err) { ZF_LOGE("Failed to start IRQ server thread\n"); return NULL; } return st; }
[ "struct", "irq_server_thread", "*", "irq_server_thread_new", "(", "vspace_t", "*", "vspace", ",", "vka_t", "*", "vka", ",", "seL4_CPtr", "cspace", ",", "seL4_Word", "priority", ",", "simple_t", "*", "simple", ",", "seL4_Word", "label", ",", "seL4_CPtr", "sep", ")", "{", "struct", "irq_server_thread", "*", "st", ";", "int", "err", ";", "st", "=", "malloc", "(", "sizeof", "(", "*", "st", ")", ")", ";", "if", "(", "st", "==", "NULL", ")", "{", "return", "NULL", ";", "}", "st", "->", "node", "=", "irq_server_node_new", "(", "0", ",", "MASK", "(", "NIRQS_PER_NODE", ")", ")", ";", "if", "(", "st", "->", "node", "==", "NULL", ")", "{", "free", "(", "st", ")", ";", "return", "NULL", ";", "}", "st", "->", "delivery_sep", "=", "sep", ";", "st", "->", "label", "=", "label", ";", "st", "->", "next", "=", "NULL", ";", "err", "=", "vka_alloc_notification", "(", "vka", ",", "&", "st", "->", "notification", ")", ";", "if", "(", "err", ")", "{", "ZF_LOGE", "(", "\"", "\\n", "\"", ")", ";", "return", "NULL", ";", "}", "st", "->", "node", "->", "notification", "=", "st", "->", "notification", ".", "cptr", ";", "sel4utils_thread_config_t", "config", "=", "thread_config_default", "(", "simple", ",", "cspace", ",", "seL4_NilData", ",", "0", ",", "priority", ")", ";", "err", "=", "sel4utils_configure_thread_config", "(", "vka", ",", "vspace", ",", "vspace", ",", "config", ",", "&", "st", "->", "thread", ")", ";", "if", "(", "err", ")", "{", "ZF_LOGE", "(", "\"", "\\n", "\"", ")", ";", "return", "NULL", ";", "}", "err", "=", "sel4utils_start_thread", "(", "&", "st", "->", "thread", ",", "(", "void", "*", ")", "_irq_thread_entry", ",", "st", ",", "NULL", ",", "1", ")", ";", "seL4_DebugNameThread", "(", "st", "->", "thread", ".", "tcb", ".", "cptr", ",", "\"", "\"", ")", ";", "if", "(", "err", ")", "{", "ZF_LOGE", "(", "\"", "\\n", "\"", ")", ";", "return", "NULL", ";", "}", "return", "st", ";", "}" ]
Creates a new thread for an IRQ server
[ "Creates", "a", "new", "thread", "for", "an", "IRQ", "server" ]
[ "/* Allocate memory for the structure */", "/* Initialise structure */", "/* Create an endpoint to listen on */", "/* Create the IRQ thread */", "/* Start the thread */" ]
[ { "param": "vspace", "type": "vspace_t" }, { "param": "vka", "type": "vka_t" }, { "param": "cspace", "type": "seL4_CPtr" }, { "param": "priority", "type": "seL4_Word" }, { "param": "simple", "type": "simple_t" }, { "param": "label", "type": "seL4_Word" }, { "param": "sep", "type": "seL4_CPtr" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "vspace", "type": "vspace_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vka", "type": "vka_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cspace", "type": "seL4_CPtr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "priority", "type": "seL4_Word", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "simple", "type": "simple_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "label", "type": "seL4_Word", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sep", "type": "seL4_CPtr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cb65ac2a9272d60ec25eef30d6b072a31492862
Ivan-Velickovic/sel4_riscv_vmm
src/vmm.c
[ "BSD-2-Clause" ]
C
irq_server_register_irq
null
struct irq_data *irq_server_register_irq(irq_server_t irq_server, irq_t irq, irq_handler_fn cb, void *token) { struct irq_server_thread *st; struct irq_data *irq_data; /* Try to assign the IRQ to an existing node */ for (st = irq_server->server_threads; st != NULL; st = st->next) { irq_data = irq_server_node_register_irq(st->node, irq, cb, token, irq_server->vka, irq_server->cspace, &irq_server->simple); if (irq_data) { return irq_data; } } /* Try to create a new node */ if (st == NULL && irq_server->max_irqs < 0) { /* Create the node */ ZF_LOGD("Spawning new IRQ server thread\n"); st = irq_server_thread_new(irq_server->vspace, irq_server->vka, irq_server->cspace, irq_server->thread_priority, &irq_server->simple, irq_server->label, irq_server->delivery_ep); #if CONFIG_MAX_NUM_NODES > 1 seL4_TCB_SetAffinity(st->thread.tcb.cptr, irq_server->affinity); #endif if (st == NULL) { ZF_LOGE("Failed to create server thread\n"); return NULL; } st->next = irq_server->server_threads; irq_server->server_threads = st; irq_data = irq_server_node_register_irq(st->node, irq, cb, token, irq_server->vka, irq_server->cspace, &irq_server->simple); if (irq_data) { return irq_data; } } /* Give up */ ZF_LOGD("Failed to register for IRQ %d\n", irq); return NULL; }
/* Register for a function to be called when an IRQ arrives */
Register for a function to be called when an IRQ arrives
[ "Register", "for", "a", "function", "to", "be", "called", "when", "an", "IRQ", "arrives" ]
struct irq_data *irq_server_register_irq(irq_server_t irq_server, irq_t irq, irq_handler_fn cb, void *token) { struct irq_server_thread *st; struct irq_data *irq_data; for (st = irq_server->server_threads; st != NULL; st = st->next) { irq_data = irq_server_node_register_irq(st->node, irq, cb, token, irq_server->vka, irq_server->cspace, &irq_server->simple); if (irq_data) { return irq_data; } } if (st == NULL && irq_server->max_irqs < 0) { ZF_LOGD("Spawning new IRQ server thread\n"); st = irq_server_thread_new(irq_server->vspace, irq_server->vka, irq_server->cspace, irq_server->thread_priority, &irq_server->simple, irq_server->label, irq_server->delivery_ep); #if CONFIG_MAX_NUM_NODES > 1 seL4_TCB_SetAffinity(st->thread.tcb.cptr, irq_server->affinity); #endif if (st == NULL) { ZF_LOGE("Failed to create server thread\n"); return NULL; } st->next = irq_server->server_threads; irq_server->server_threads = st; irq_data = irq_server_node_register_irq(st->node, irq, cb, token, irq_server->vka, irq_server->cspace, &irq_server->simple); if (irq_data) { return irq_data; } } ZF_LOGD("Failed to register for IRQ %d\n", irq); return NULL; }
[ "struct", "irq_data", "*", "irq_server_register_irq", "(", "irq_server_t", "irq_server", ",", "irq_t", "irq", ",", "irq_handler_fn", "cb", ",", "void", "*", "token", ")", "{", "struct", "irq_server_thread", "*", "st", ";", "struct", "irq_data", "*", "irq_data", ";", "for", "(", "st", "=", "irq_server", "->", "server_threads", ";", "st", "!=", "NULL", ";", "st", "=", "st", "->", "next", ")", "{", "irq_data", "=", "irq_server_node_register_irq", "(", "st", "->", "node", ",", "irq", ",", "cb", ",", "token", ",", "irq_server", "->", "vka", ",", "irq_server", "->", "cspace", ",", "&", "irq_server", "->", "simple", ")", ";", "if", "(", "irq_data", ")", "{", "return", "irq_data", ";", "}", "}", "if", "(", "st", "==", "NULL", "&&", "irq_server", "->", "max_irqs", "<", "0", ")", "{", "ZF_LOGD", "(", "\"", "\\n", "\"", ")", ";", "st", "=", "irq_server_thread_new", "(", "irq_server", "->", "vspace", ",", "irq_server", "->", "vka", ",", "irq_server", "->", "cspace", ",", "irq_server", "->", "thread_priority", ",", "&", "irq_server", "->", "simple", ",", "irq_server", "->", "label", ",", "irq_server", "->", "delivery_ep", ")", ";", "#if", "CONFIG_MAX_NUM_NODES", ">", "1", "\n", "seL4_TCB_SetAffinity", "(", "st", "->", "thread", ".", "tcb", ".", "cptr", ",", "irq_server", "->", "affinity", ")", ";", "#endif", "if", "(", "st", "==", "NULL", ")", "{", "ZF_LOGE", "(", "\"", "\\n", "\"", ")", ";", "return", "NULL", ";", "}", "st", "->", "next", "=", "irq_server", "->", "server_threads", ";", "irq_server", "->", "server_threads", "=", "st", ";", "irq_data", "=", "irq_server_node_register_irq", "(", "st", "->", "node", ",", "irq", ",", "cb", ",", "token", ",", "irq_server", "->", "vka", ",", "irq_server", "->", "cspace", ",", "&", "irq_server", "->", "simple", ")", ";", "if", "(", "irq_data", ")", "{", "return", "irq_data", ";", "}", "}", "ZF_LOGD", "(", "\"", "\\n", "\"", ",", "irq", ")", ";", "return", "NULL", ";", "}" ]
Register for a function to be called when an IRQ arrives
[ "Register", "for", "a", "function", "to", "be", "called", "when", "an", "IRQ", "arrives" ]
[ "/* Try to assign the IRQ to an existing node */", "/* Try to create a new node */", "/* Create the node */", "/* Give up */" ]
[ { "param": "irq_server", "type": "irq_server_t" }, { "param": "irq", "type": "irq_t" }, { "param": "cb", "type": "irq_handler_fn" }, { "param": "token", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "irq_server", "type": "irq_server_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "irq", "type": "irq_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cb", "type": "irq_handler_fn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "token", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1cb65ac2a9272d60ec25eef30d6b072a31492862
Ivan-Velickovic/sel4_riscv_vmm
src/vmm.c
[ "BSD-2-Clause" ]
C
gva_to_gpa
seL4_Word
static seL4_Word gva_to_gpa(vm_t *vm, seL4_Word va, int vcpu_id) { int level = 2; assert(vcpu_id >=0 && vcpu_id < CONFIG_MAX_NUM_NODES); uint64_t *ppt = &pt[vcpu_id][0]; bzero(ppt, 4096); seL4_Word satp = 0; seL4_CPtr vcpu = vm_get_vcpu(vm, vcpu_id); seL4_RISCV_VCPU_ReadRegs_t res = seL4_RISCV_VCPU_ReadRegs(vcpu, seL4_VCPUReg_SATP); assert(!res.error); satp = res.value; DPW("satp %lx\n", satp); assert((satp >> 60) == SV39_MODE); seL4_Word ppn = GET_PPN(satp); seL4_Word gpa = ppn << PPN_SHIFT; uint64_t pte = 0; // read in the page table while (level > 0) { DPW("copy in %lx level %d\n", gpa, level); if (gpa == 0) { while (1); } vm_copyin(vm, ppt, gpa, sizeof(uint64_t) * 512); for (int i = 0; i < 512; i++) { if (ppt[i] != 0) { DPW("pte %d %lx\n", i, ppt[i]); } } int vpn = GET_VPN(va, level); pte = ppt[vpn]; DPW("index %d pte %lx gpa %lx level %d\n", vpn, pte, gpa, level); if (pte & PTE_V && (pte & PTE_R || pte & PTE_X)) { /* we reach a leaf page */ if (level == 2) { /* 1 GiB page */ DPW("pa %lx %lx level %d\n", PTE_GET_1G(pte), PTE_GET_1G(pte) << 30, level); return (PTE_GET_1G(pte) << 30) | (va & 0x3fffffff); } if (level == 1) { /* 2 MiB page */ DPW("pa %lx %lx level %d\n", PTE_GET_2M(pte), PTE_GET_2M(pte) << 21, level); DPW("return %lx\n", (PTE_GET_2M(pte) << 21) | (va & (BIT(22) - 1))); return (PTE_GET_2M(pte) << 21) | (va & (BIT(22) - 1)); } if (level == 0) { /* 4 KiB page */ return ((PTE_GET_4K(pte) << 12) | (va & (BIT(13) - 1))); } } gpa = (pte >> 10) << 12; level--; } DPW("invalid GVA TO GPA translation \n"); assert(!"invalid"); return 0; }
/* translate guest va to guest pa Sv39 */
translate guest va to guest pa Sv39
[ "translate", "guest", "va", "to", "guest", "pa", "Sv39" ]
static seL4_Word gva_to_gpa(vm_t *vm, seL4_Word va, int vcpu_id) { int level = 2; assert(vcpu_id >=0 && vcpu_id < CONFIG_MAX_NUM_NODES); uint64_t *ppt = &pt[vcpu_id][0]; bzero(ppt, 4096); seL4_Word satp = 0; seL4_CPtr vcpu = vm_get_vcpu(vm, vcpu_id); seL4_RISCV_VCPU_ReadRegs_t res = seL4_RISCV_VCPU_ReadRegs(vcpu, seL4_VCPUReg_SATP); assert(!res.error); satp = res.value; DPW("satp %lx\n", satp); assert((satp >> 60) == SV39_MODE); seL4_Word ppn = GET_PPN(satp); seL4_Word gpa = ppn << PPN_SHIFT; uint64_t pte = 0; while (level > 0) { DPW("copy in %lx level %d\n", gpa, level); if (gpa == 0) { while (1); } vm_copyin(vm, ppt, gpa, sizeof(uint64_t) * 512); for (int i = 0; i < 512; i++) { if (ppt[i] != 0) { DPW("pte %d %lx\n", i, ppt[i]); } } int vpn = GET_VPN(va, level); pte = ppt[vpn]; DPW("index %d pte %lx gpa %lx level %d\n", vpn, pte, gpa, level); if (pte & PTE_V && (pte & PTE_R || pte & PTE_X)) { if (level == 2) { DPW("pa %lx %lx level %d\n", PTE_GET_1G(pte), PTE_GET_1G(pte) << 30, level); return (PTE_GET_1G(pte) << 30) | (va & 0x3fffffff); } if (level == 1) { DPW("pa %lx %lx level %d\n", PTE_GET_2M(pte), PTE_GET_2M(pte) << 21, level); DPW("return %lx\n", (PTE_GET_2M(pte) << 21) | (va & (BIT(22) - 1))); return (PTE_GET_2M(pte) << 21) | (va & (BIT(22) - 1)); } if (level == 0) { return ((PTE_GET_4K(pte) << 12) | (va & (BIT(13) - 1))); } } gpa = (pte >> 10) << 12; level--; } DPW("invalid GVA TO GPA translation \n"); assert(!"invalid"); return 0; }
[ "static", "seL4_Word", "gva_to_gpa", "(", "vm_t", "*", "vm", ",", "seL4_Word", "va", ",", "int", "vcpu_id", ")", "{", "int", "level", "=", "2", ";", "assert", "(", "vcpu_id", ">=", "0", "&&", "vcpu_id", "<", "CONFIG_MAX_NUM_NODES", ")", ";", "uint64_t", "*", "ppt", "=", "&", "pt", "[", "vcpu_id", "]", "[", "0", "]", ";", "bzero", "(", "ppt", ",", "4096", ")", ";", "seL4_Word", "satp", "=", "0", ";", "seL4_CPtr", "vcpu", "=", "vm_get_vcpu", "(", "vm", ",", "vcpu_id", ")", ";", "seL4_RISCV_VCPU_ReadRegs_t", "res", "=", "seL4_RISCV_VCPU_ReadRegs", "(", "vcpu", ",", "seL4_VCPUReg_SATP", ")", ";", "assert", "(", "!", "res", ".", "error", ")", ";", "satp", "=", "res", ".", "value", ";", "DPW", "(", "\"", "\\n", "\"", ",", "satp", ")", ";", "assert", "(", "(", "satp", ">>", "60", ")", "==", "SV39_MODE", ")", ";", "seL4_Word", "ppn", "=", "GET_PPN", "(", "satp", ")", ";", "seL4_Word", "gpa", "=", "ppn", "<<", "PPN_SHIFT", ";", "uint64_t", "pte", "=", "0", ";", "while", "(", "level", ">", "0", ")", "{", "DPW", "(", "\"", "\\n", "\"", ",", "gpa", ",", "level", ")", ";", "if", "(", "gpa", "==", "0", ")", "{", "while", "(", "1", ")", ";", "}", "vm_copyin", "(", "vm", ",", "ppt", ",", "gpa", ",", "sizeof", "(", "uint64_t", ")", "*", "512", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "512", ";", "i", "++", ")", "{", "if", "(", "ppt", "[", "i", "]", "!=", "0", ")", "{", "DPW", "(", "\"", "\\n", "\"", ",", "i", ",", "ppt", "[", "i", "]", ")", ";", "}", "}", "int", "vpn", "=", "GET_VPN", "(", "va", ",", "level", ")", ";", "pte", "=", "ppt", "[", "vpn", "]", ";", "DPW", "(", "\"", "\\n", "\"", ",", "vpn", ",", "pte", ",", "gpa", ",", "level", ")", ";", "if", "(", "pte", "&", "PTE_V", "&&", "(", "pte", "&", "PTE_R", "||", "pte", "&", "PTE_X", ")", ")", "{", "if", "(", "level", "==", "2", ")", "{", "DPW", "(", "\"", "\\n", "\"", ",", "PTE_GET_1G", "(", "pte", ")", ",", "PTE_GET_1G", "(", "pte", ")", "<<", "30", ",", "level", ")", ";", "return", "(", "PTE_GET_1G", "(", "pte", ")", "<<", "30", ")", "|", "(", "va", "&", "0x3fffffff", ")", ";", "}", "if", "(", "level", "==", "1", ")", "{", "DPW", "(", "\"", "\\n", "\"", ",", "PTE_GET_2M", "(", "pte", ")", ",", "PTE_GET_2M", "(", "pte", ")", "<<", "21", ",", "level", ")", ";", "DPW", "(", "\"", "\\n", "\"", ",", "(", "PTE_GET_2M", "(", "pte", ")", "<<", "21", ")", "|", "(", "va", "&", "(", "BIT", "(", "22", ")", "-", "1", ")", ")", ")", ";", "return", "(", "PTE_GET_2M", "(", "pte", ")", "<<", "21", ")", "|", "(", "va", "&", "(", "BIT", "(", "22", ")", "-", "1", ")", ")", ";", "}", "if", "(", "level", "==", "0", ")", "{", "return", "(", "(", "PTE_GET_4K", "(", "pte", ")", "<<", "12", ")", "|", "(", "va", "&", "(", "BIT", "(", "13", ")", "-", "1", ")", ")", ")", ";", "}", "}", "gpa", "=", "(", "pte", ">>", "10", ")", "<<", "12", ";", "level", "--", ";", "}", "DPW", "(", "\"", "\\n", "\"", ")", ";", "assert", "(", "!", "\"", "\"", ")", ";", "return", "0", ";", "}" ]
translate guest va to guest pa Sv39
[ "translate", "guest", "va", "to", "guest", "pa", "Sv39" ]
[ "// read in the page table ", "/* we reach a leaf page */", "/* 1 GiB page */", "/* 2 MiB page */", "/* 4 KiB page */" ]
[ { "param": "vm", "type": "vm_t" }, { "param": "va", "type": "seL4_Word" }, { "param": "vcpu_id", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "vm", "type": "vm_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "va", "type": "seL4_Word", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vcpu_id", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2014d10091a2be6e06abb0fd4b2921ec0c71c036
ModelDBRepository/168950
cells/ifun/ifun.c
[ "CC-BY-3.0" ]
C
init_genrand
void
void init_genrand(unsigned long s) { int j; state[0]= s & 0xffffffffUL; for (j=1; j<NR; j++) { state[j] = (1812433253UL * (state[j-1] ^ (state[j-1] >> 30)) + j); /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ /* In the previous versions, MSBs of the seed affect */ /* only MSBs of the array state[]. */ /* 2002/01/09 modified by Makoto Matsumoto */ state[j] &= 0xffffffffUL; /* for >32 bit machines */ } left = 1; initf = 1; }
/* initializes state[N] with a seed */
initializes state[N] with a seed
[ "initializes", "state", "[", "N", "]", "with", "a", "seed" ]
void init_genrand(unsigned long s) { int j; state[0]= s & 0xffffffffUL; for (j=1; j<NR; j++) { state[j] = (1812433253UL * (state[j-1] ^ (state[j-1] >> 30)) + j); state[j] &= 0xffffffffUL; } left = 1; initf = 1; }
[ "void", "init_genrand", "(", "unsigned", "long", "s", ")", "{", "int", "j", ";", "state", "[", "0", "]", "=", "s", "&", "0xffffffffUL", ";", "for", "(", "j", "=", "1", ";", "j", "<", "NR", ";", "j", "++", ")", "{", "state", "[", "j", "]", "=", "(", "1812433253UL", "*", "(", "state", "[", "j", "-", "1", "]", "^", "(", "state", "[", "j", "-", "1", "]", ">>", "30", ")", ")", "+", "j", ")", ";", "state", "[", "j", "]", "&=", "0xffffffffUL", ";", "}", "left", "=", "1", ";", "initf", "=", "1", ";", "}" ]
initializes state[N] with a seed
[ "initializes", "state", "[", "N", "]", "with", "a", "seed" ]
[ "/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */", "/* In the previous versions, MSBs of the seed affect */", "/* only MSBs of the array state[]. */", "/* 2002/01/09 modified by Makoto Matsumoto */", "/* for >32 bit machines */" ]
[ { "param": "s", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2014d10091a2be6e06abb0fd4b2921ec0c71c036
ModelDBRepository/168950
cells/ifun/ifun.c
[ "CC-BY-3.0" ]
C
random_matrix_index
int
int *random_matrix_index(double *r, int N, double Pr) { int i, j, n; int *w; w = (int *)malloc(N*N*sizeof(int)); for(i = 0; i < N; i++){ n = 0; for(j = 0; j < N; j++){ if (genrand_real2() < Pr){ //r[wid(i,j)] w[wid(i,n)] = j; n++; //fprintf(stdout, "r: %f", r[wid(i,j)]); //fprintf(stdout, "conn: %i", j); } } w[wid(i,n)] = -1; } return w; }
// This function takes a seed for the random number generator and // returns the random matrix w_{ij} (Eq.(2.1) in p.1033). // The matrix is the size of N*N, and the i th row represents the list // of indices for presynaptic neurons of neuron i. The connection // probability is Pr. // Each row terminates with -1 so that the program can know // the end of the list. //const unsigned long
This function takes a seed for the random number generator and returns the random matrix w_{ij} (Eq.(2.1) in p.1033). The matrix is the size of N*N, and the i th row represents the list of indices for presynaptic neurons of neuron i. The connection probability is Pr. Each row terminates with -1 so that the program can know the end of the list. const unsigned long
[ "This", "function", "takes", "a", "seed", "for", "the", "random", "number", "generator", "and", "returns", "the", "random", "matrix", "w_", "{", "ij", "}", "(", "Eq", ".", "(", "2", ".", "1", ")", "in", "p", ".", "1033", ")", ".", "The", "matrix", "is", "the", "size", "of", "N", "*", "N", "and", "the", "i", "th", "row", "represents", "the", "list", "of", "indices", "for", "presynaptic", "neurons", "of", "neuron", "i", ".", "The", "connection", "probability", "is", "Pr", ".", "Each", "row", "terminates", "with", "-", "1", "so", "that", "the", "program", "can", "know", "the", "end", "of", "the", "list", ".", "const", "unsigned", "long" ]
int *random_matrix_index(double *r, int N, double Pr) { int i, j, n; int *w; w = (int *)malloc(N*N*sizeof(int)); for(i = 0; i < N; i++){ n = 0; for(j = 0; j < N; j++){ if (genrand_real2() < Pr){ w[wid(i,n)] = j; n++; } } w[wid(i,n)] = -1; } return w; }
[ "int", "*", "random_matrix_index", "(", "double", "*", "r", ",", "int", "N", ",", "double", "Pr", ")", "{", "int", "i", ",", "j", ",", "n", ";", "int", "*", "w", ";", "w", "=", "(", "int", "*", ")", "malloc", "(", "N", "*", "N", "*", "sizeof", "(", "int", ")", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "n", "=", "0", ";", "for", "(", "j", "=", "0", ";", "j", "<", "N", ";", "j", "++", ")", "{", "if", "(", "genrand_real2", "(", ")", "<", "Pr", ")", "{", "w", "[", "wid", "(", "i", ",", "n", ")", "]", "=", "j", ";", "n", "++", ";", "}", "}", "w", "[", "wid", "(", "i", ",", "n", ")", "]", "=", "-1", ";", "}", "return", "w", ";", "}" ]
This function takes a seed for the random number generator and returns the random matrix w_{ij} (Eq.
[ "This", "function", "takes", "a", "seed", "for", "the", "random", "number", "generator", "and", "returns", "the", "random", "matrix", "w_", "{", "ij", "}", "(", "Eq", "." ]
[ "//r[wid(i,j)]", "//fprintf(stdout, \"r: %f\", r[wid(i,j)]);", "//fprintf(stdout, \"conn: %i\", j);" ]
[ { "param": "r", "type": "double" }, { "param": "N", "type": "int" }, { "param": "Pr", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "r", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "N", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "Pr", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2014d10091a2be6e06abb0fd4b2921ec0c71c036
ModelDBRepository/168950
cells/ifun/ifun.c
[ "CC-BY-3.0" ]
C
run
void
void run(const int *w, double *z, double *ih0, double *I, double tau, int N, double kappa, int T, double *rand) { int t, i, n; double u[N], q[N], f[N], ih[N]; // coef[N]; double r, tempih, tempih_pos, coeftemp; const double decay = exp(-1.0/tau); const double coef = 2.0*kappa/N; // const double varinh0 = ih0[3]; double *coefinh; coefinh = (double *)malloc(N*N*sizeof(double)); for(i = 0; i < N; i++){ q[i] = 0; if (genrand_real2() < ih0[2]){ // random ipis/contralateral mf input rand[i] f[i] = -1; }else{ f[i] = 1; } ih[i] = ih0[0] + (ih0[1]*ih0[0])*random_normal(); //fprintf(stdout, "ih: %i: %f\n ", i, ih[i]); //coef[i] = 2.0 * ( kappa + (kappa/2)*random_normal() ) / N; for(n = 0; n < N; n++) { coeftemp = coef + (varinh0*coef)*random_normal(); coefinh[wid(i,n)] = (coeftemp > 0) ? coeftemp : 0; //fprintf(stdout, "uinh: %i: %i %f %f\n ", n, c, coeftemp, coefinh[widu(n,c)]); } } // Iterative calculation of Eq. (2.1) for(t = 1; t < T; t++){ for(i = 0; i < N; i++){ q[i] = z[zid(t-1,i)] + decay*q[i]; } for(i = 0; i < N; i++){ r = 0; // the list of presynaptic neurons is terminated with -1. for(n = 0; w[wid(i,n)] >= 0; n++){ r += coefinh[wid(i,n)]*q[w[wid(i,n)]]; //coef[i] } tempih = ih[i] + f[i]*ih[i]*I[t]; //ih0[0] tempih_pos = (tempih > 0) ? tempih : 0; u[i] = tempih_pos - r + rand[1]*ih0[0]*random_normal(); //zid(t,i) } for(i = 0; i < N; i++){ z[zid(t,i)] = (u[i] > 0) ? u[i] : 0; } } }
// This function takes the random matrix w and the empty array of // the neural activity z, and fill the array z.
This function takes the random matrix w and the empty array of the neural activity z, and fill the array z.
[ "This", "function", "takes", "the", "random", "matrix", "w", "and", "the", "empty", "array", "of", "the", "neural", "activity", "z", "and", "fill", "the", "array", "z", "." ]
void run(const int *w, double *z, double *ih0, double *I, double tau, int N, double kappa, int T, double *rand) { int t, i, n; double u[N], q[N], f[N], ih[N]; double r, tempih, tempih_pos, coeftemp; const double decay = exp(-1.0/tau); const double coef = 2.0*kappa/N; const double varinh0 = ih0[3]; double *coefinh; coefinh = (double *)malloc(N*N*sizeof(double)); for(i = 0; i < N; i++){ q[i] = 0; if (genrand_real2() < ih0[2]){ random ipis/contralateral mf input rand[i] f[i] = -1; }else{ f[i] = 1; } ih[i] = ih0[0] + (ih0[1]*ih0[0])*random_normal(); fprintf(stdout, "ih: %i: %f\n ", i, ih[i]); coef[i] = 2.0 * ( kappa + (kappa/2)*random_normal() ) / N; for(n = 0; n < N; n++) { coeftemp = coef + (varinh0*coef)*random_normal(); coefinh[wid(i,n)] = (coeftemp > 0) ? coeftemp : 0; fprintf(stdout, "uinh: %i: %i %f %f\n ", n, c, coeftemp, coefinh[widu(n,c)]); } } Iterative calculation of Eq. (2.1) for(t = 1; t < T; t++){ for(i = 0; i < N; i++){ q[i] = z[zid(t-1,i)] + decay*q[i]; } for(i = 0; i < N; i++){ r = 0; the list of presynaptic neurons is terminated with -1. for(n = 0; w[wid(i,n)] >= 0; n++){ r += coefinh[wid(i,n)]*q[w[wid(i,n)]]; coef[i] } tempih = ih[i] + f[i]*ih[i]*I[t]; ih0[0] tempih_pos = (tempih > 0) ? tempih : 0; u[i] = tempih_pos - r + rand[1]*ih0[0]*random_normal(); zid(t,i) } for(i = 0; i < N; i++){ z[zid(t,i)] = (u[i] > 0) ? u[i] : 0; } } }
[ "void", "run", "(", "const", "int", "*", "w", ",", "double", "*", "z", ",", "double", "*", "ih0", ",", "double", "*", "I", ",", "double", "tau", ",", "int", "N", ",", "double", "kappa", ",", "int", "T", ",", "double", "*", "rand", ")", "{", "int", "t", ",", "i", ",", "n", ";", "double", "u", "[", "N", "]", ",", "q", "[", "N", "]", ",", "f", "[", "N", "]", ",", "ih", "[", "N", "]", ";", "double", "r", ",", "tempih", ",", "tempih_pos", ",", "coeftemp", ";", "const", "double", "decay", "=", "exp", "(", "-1.0", "/", "tau", ")", ";", "const", "double", "coef", "=", "2.0", "*", "kappa", "/", "N", ";", "const", "double", "varinh0", "=", "ih0", "[", "3", "]", ";", "double", "*", "coefinh", ";", "coefinh", "=", "(", "double", "*", ")", "malloc", "(", "N", "*", "N", "*", "sizeof", "(", "double", ")", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "q", "[", "i", "]", "=", "0", ";", "if", "(", "genrand_real2", "(", ")", "<", "ih0", "[", "2", "]", ")", "{", "f", "[", "i", "]", "=", "-1", ";", "}", "else", "{", "f", "[", "i", "]", "=", "1", ";", "}", "ih", "[", "i", "]", "=", "ih0", "[", "0", "]", "+", "(", "ih0", "[", "1", "]", "*", "ih0", "[", "0", "]", ")", "*", "random_normal", "(", ")", ";", "for", "(", "n", "=", "0", ";", "n", "<", "N", ";", "n", "++", ")", "{", "coeftemp", "=", "coef", "+", "(", "varinh0", "*", "coef", ")", "*", "random_normal", "(", ")", ";", "coefinh", "[", "wid", "(", "i", ",", "n", ")", "]", "=", "(", "coeftemp", ">", "0", ")", "?", "coeftemp", ":", "0", ";", "}", "}", "for", "(", "t", "=", "1", ";", "t", "<", "T", ";", "t", "++", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "q", "[", "i", "]", "=", "z", "[", "zid", "(", "t", "-", "1", ",", "i", ")", "]", "+", "decay", "*", "q", "[", "i", "]", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "r", "=", "0", ";", "for", "(", "n", "=", "0", ";", "w", "[", "wid", "(", "i", ",", "n", ")", "]", ">=", "0", ";", "n", "++", ")", "{", "r", "+=", "coefinh", "[", "wid", "(", "i", ",", "n", ")", "]", "*", "q", "[", "w", "[", "wid", "(", "i", ",", "n", ")", "]", "]", ";", "}", "tempih", "=", "ih", "[", "i", "]", "+", "f", "[", "i", "]", "*", "ih", "[", "i", "]", "*", "I", "[", "t", "]", ";", "tempih_pos", "=", "(", "tempih", ">", "0", ")", "?", "tempih", ":", "0", ";", "u", "[", "i", "]", "=", "tempih_pos", "-", "r", "+", "rand", "[", "1", "]", "*", "ih0", "[", "0", "]", "*", "random_normal", "(", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "z", "[", "zid", "(", "t", ",", "i", ")", "]", "=", "(", "u", "[", "i", "]", ">", "0", ")", "?", "u", "[", "i", "]", ":", "0", ";", "}", "}", "}" ]
This function takes the random matrix w and the empty array of the neural activity z, and fill the array z.
[ "This", "function", "takes", "the", "random", "matrix", "w", "and", "the", "empty", "array", "of", "the", "neural", "activity", "z", "and", "fill", "the", "array", "z", "." ]
[ "// coef[N];", "//", "// random ipis/contralateral mf input rand[i]", "//fprintf(stdout, \"ih: %i: %f\\n \", i, ih[i]);", "//coef[i] = 2.0 * ( kappa + (kappa/2)*random_normal() ) / N;", "//fprintf(stdout, \"uinh: %i: %i %f %f\\n \", n, c, coeftemp, coefinh[widu(n,c)]);", "// Iterative calculation of Eq. (2.1)", "// the list of presynaptic neurons is terminated with -1.", "//coef[i]", "//ih0[0] \t", "//zid(t,i)" ]
[ { "param": "w", "type": "int" }, { "param": "z", "type": "double" }, { "param": "ih0", "type": "double" }, { "param": "I", "type": "double" }, { "param": "tau", "type": "double" }, { "param": "N", "type": "int" }, { "param": "kappa", "type": "double" }, { "param": "T", "type": "int" }, { "param": "rand", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "w", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "z", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ih0", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "I", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tau", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "N", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "kappa", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "T", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rand", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c1cade682e39781b48b9c9cf66c544a9c8a83fb7
ECHibiki/EroSomnia
Point and Click Game1/Graphics.h
[ "MIT" ]
C
prcnt
int
static int prcnt(float percent, char axis, SDL_Window*window) { int windowWidth; int windowHeight; SDL_GetWindowSize(window, &windowWidth, &windowHeight); if (axis == 'x') return percent * windowWidth; else if (axis == 'y') return percent * windowHeight; else return 0; }
//static instantiation of prcnt method using determined window paramater
static instantiation of prcnt method using determined window paramater
[ "static", "instantiation", "of", "prcnt", "method", "using", "determined", "window", "paramater" ]
static int prcnt(float percent, char axis, SDL_Window*window) { int windowWidth; int windowHeight; SDL_GetWindowSize(window, &windowWidth, &windowHeight); if (axis == 'x') return percent * windowWidth; else if (axis == 'y') return percent * windowHeight; else return 0; }
[ "static", "int", "prcnt", "(", "float", "percent", ",", "char", "axis", ",", "SDL_Window", "*", "window", ")", "{", "int", "windowWidth", ";", "int", "windowHeight", ";", "SDL_GetWindowSize", "(", "window", ",", "&", "windowWidth", ",", "&", "windowHeight", ")", ";", "if", "(", "axis", "==", "'", "'", ")", "return", "percent", "*", "windowWidth", ";", "else", "if", "(", "axis", "==", "'", "'", ")", "return", "percent", "*", "windowHeight", ";", "else", "return", "0", ";", "}" ]
static instantiation of prcnt method using determined window paramater
[ "static", "instantiation", "of", "prcnt", "method", "using", "determined", "window", "paramater" ]
[]
[ { "param": "percent", "type": "float" }, { "param": "axis", "type": "char" }, { "param": "window", "type": "SDL_Window" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "percent", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "axis", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "window", "type": "SDL_Window", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c1cade682e39781b48b9c9cf66c544a9c8a83fb7
ECHibiki/EroSomnia
Point and Click Game1/Graphics.h
[ "MIT" ]
C
prcnt
int
int prcnt(float percent, char axis) { int windowWidth; int windowHeight; SDL_GetWindowSize(window, &windowWidth, &windowHeight); if (axis == 'x') return percent * windowWidth; else if (axis == 'y') return percent * windowHeight; else return 0; }
//nonstatic instantiation of prcnt method using predetermined window paramater
nonstatic instantiation of prcnt method using predetermined window paramater
[ "nonstatic", "instantiation", "of", "prcnt", "method", "using", "predetermined", "window", "paramater" ]
int prcnt(float percent, char axis) { int windowWidth; int windowHeight; SDL_GetWindowSize(window, &windowWidth, &windowHeight); if (axis == 'x') return percent * windowWidth; else if (axis == 'y') return percent * windowHeight; else return 0; }
[ "int", "prcnt", "(", "float", "percent", ",", "char", "axis", ")", "{", "int", "windowWidth", ";", "int", "windowHeight", ";", "SDL_GetWindowSize", "(", "window", ",", "&", "windowWidth", ",", "&", "windowHeight", ")", ";", "if", "(", "axis", "==", "'", "'", ")", "return", "percent", "*", "windowWidth", ";", "else", "if", "(", "axis", "==", "'", "'", ")", "return", "percent", "*", "windowHeight", ";", "else", "return", "0", ";", "}" ]
nonstatic instantiation of prcnt method using predetermined window paramater
[ "nonstatic", "instantiation", "of", "prcnt", "method", "using", "predetermined", "window", "paramater" ]
[]
[ { "param": "percent", "type": "float" }, { "param": "axis", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "percent", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "axis", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
46b5af3a680675afcf7e1ac79e0aa186c5275288
OUNAVCON/nrf24L01_plus
MQXLITE/kernel/mqx_utils.c
[ "MIT" ]
C
_mqx_get_kernel_data
pointer
pointer _mqx_get_kernel_data ( void ) { /* Body */ KERNEL_DATA_STRUCT_PTR kernel_data; _GET_KERNEL_DATA(kernel_data); return (pointer) kernel_data; }
/*! * \brief Gets a pointer to kernel data. * * The address of kernel data corresponds to START_OF_KERNEL_MEMORY in the MQX * initialization structure that the application used to start MQX on the processor. * * \return Pointer to kernel data. * * \see MQX_INITIALIZATION_STRUCT */
\brief Gets a pointer to kernel data. The address of kernel data corresponds to START_OF_KERNEL_MEMORY in the MQX initialization structure that the application used to start MQX on the processor. \return Pointer to kernel data.
[ "\\", "brief", "Gets", "a", "pointer", "to", "kernel", "data", ".", "The", "address", "of", "kernel", "data", "corresponds", "to", "START_OF_KERNEL_MEMORY", "in", "the", "MQX", "initialization", "structure", "that", "the", "application", "used", "to", "start", "MQX", "on", "the", "processor", ".", "\\", "return", "Pointer", "to", "kernel", "data", "." ]
pointer _mqx_get_kernel_data ( void ) { KERNEL_DATA_STRUCT_PTR kernel_data; _GET_KERNEL_DATA(kernel_data); return (pointer) kernel_data; }
[ "pointer", "_mqx_get_kernel_data", "(", "void", ")", "{", "KERNEL_DATA_STRUCT_PTR", "kernel_data", ";", "_GET_KERNEL_DATA", "(", "kernel_data", ")", ";", "return", "(", "pointer", ")", "kernel_data", ";", "}" ]
\brief Gets a pointer to kernel data.
[ "\\", "brief", "Gets", "a", "pointer", "to", "kernel", "data", "." ]
[ "/* Body */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
46b5af3a680675afcf7e1ac79e0aa186c5275288
OUNAVCON/nrf24L01_plus
MQXLITE/kernel/mqx_utils.c
[ "MIT" ]
C
_mqx_get_counter
_mqx_uint
_mqx_uint _mqx_get_counter ( void ) { /* Body */ register KERNEL_DATA_STRUCT_PTR kernel_data; _mqx_uint return_value; _GET_KERNEL_DATA(kernel_data); _INT_DISABLE(); /* * Increment counter, and ensure it is not zero. * If it is zero, set it to one. */ if ( ++kernel_data->COUNTER == 0 ) { kernel_data->COUNTER = 1; } /* Endif */ return_value = kernel_data->COUNTER; _INT_ENABLE(); return (return_value); }
/*! * \brief Gets a unique number. * * This function increments the counter and then returns value of the counter. * \n This provides a unique number for whoever requires it. * * \note The unique number will never be 0. * * \return 16-bit number for 16-bit processors or a 32-bit number for 32-bit * processors (unique for the processor and never 0). */
\brief Gets a unique number. This function increments the counter and then returns value of the counter. \n This provides a unique number for whoever requires it. \note The unique number will never be 0. \return 16-bit number for 16-bit processors or a 32-bit number for 32-bit processors (unique for the processor and never 0).
[ "\\", "brief", "Gets", "a", "unique", "number", ".", "This", "function", "increments", "the", "counter", "and", "then", "returns", "value", "of", "the", "counter", ".", "\\", "n", "This", "provides", "a", "unique", "number", "for", "whoever", "requires", "it", ".", "\\", "note", "The", "unique", "number", "will", "never", "be", "0", ".", "\\", "return", "16", "-", "bit", "number", "for", "16", "-", "bit", "processors", "or", "a", "32", "-", "bit", "number", "for", "32", "-", "bit", "processors", "(", "unique", "for", "the", "processor", "and", "never", "0", ")", "." ]
_mqx_uint _mqx_get_counter ( void ) { register KERNEL_DATA_STRUCT_PTR kernel_data; _mqx_uint return_value; _GET_KERNEL_DATA(kernel_data); _INT_DISABLE(); if ( ++kernel_data->COUNTER == 0 ) { kernel_data->COUNTER = 1; } return_value = kernel_data->COUNTER; _INT_ENABLE(); return (return_value); }
[ "_mqx_uint", "_mqx_get_counter", "(", "void", ")", "{", "register", "KERNEL_DATA_STRUCT_PTR", "kernel_data", ";", "_mqx_uint", "return_value", ";", "_GET_KERNEL_DATA", "(", "kernel_data", ")", ";", "_INT_DISABLE", "(", ")", ";", "if", "(", "++", "kernel_data", "->", "COUNTER", "==", "0", ")", "{", "kernel_data", "->", "COUNTER", "=", "1", ";", "}", "return_value", "=", "kernel_data", "->", "COUNTER", ";", "_INT_ENABLE", "(", ")", ";", "return", "(", "return_value", ")", ";", "}" ]
\brief Gets a unique number.
[ "\\", "brief", "Gets", "a", "unique", "number", "." ]
[ "/* Body */", "/*\n * Increment counter, and ensure it is not zero.\n * If it is zero, set it to one.\n */", "/* Endif */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
46b5af3a680675afcf7e1ac79e0aa186c5275288
OUNAVCON/nrf24L01_plus
MQXLITE/kernel/mqx_utils.c
[ "MIT" ]
C
_mqx_get_initialization
MQX_INITIALIZATION_STRUCT_PTR
MQX_INITIALIZATION_STRUCT_PTR _mqx_get_initialization ( void ) { /* Body */ KERNEL_DATA_STRUCT_PTR kernel_data; _GET_KERNEL_DATA(kernel_data); return ((MQX_INITIALIZATION_STRUCT_PTR) & kernel_data->INIT); }
/*! * \brief Gets a pointer to the MQX initialization structure for this processor. * * \return Pointer to the MQX initialization structure in kernel data. * * \see _mqxlite_init * \see MQX_INITIALIZATION_STRUCT */
\brief Gets a pointer to the MQX initialization structure for this processor. \return Pointer to the MQX initialization structure in kernel data.
[ "\\", "brief", "Gets", "a", "pointer", "to", "the", "MQX", "initialization", "structure", "for", "this", "processor", ".", "\\", "return", "Pointer", "to", "the", "MQX", "initialization", "structure", "in", "kernel", "data", "." ]
MQX_INITIALIZATION_STRUCT_PTR _mqx_get_initialization ( void ) { KERNEL_DATA_STRUCT_PTR kernel_data; _GET_KERNEL_DATA(kernel_data); return ((MQX_INITIALIZATION_STRUCT_PTR) & kernel_data->INIT); }
[ "MQX_INITIALIZATION_STRUCT_PTR", "_mqx_get_initialization", "(", "void", ")", "{", "KERNEL_DATA_STRUCT_PTR", "kernel_data", ";", "_GET_KERNEL_DATA", "(", "kernel_data", ")", ";", "return", "(", "(", "MQX_INITIALIZATION_STRUCT_PTR", ")", "&", "kernel_data", "->", "INIT", ")", ";", "}" ]
\brief Gets a pointer to the MQX initialization structure for this processor.
[ "\\", "brief", "Gets", "a", "pointer", "to", "the", "MQX", "initialization", "structure", "for", "this", "processor", "." ]
[ "/* Body */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
46b5af3a680675afcf7e1ac79e0aa186c5275288
OUNAVCON/nrf24L01_plus
MQXLITE/kernel/mqx_utils.c
[ "MIT" ]
C
_mqx_get_exit_handler
MQX_EXIT_FPTR
MQX_EXIT_FPTR _mqx_get_exit_handler (void) { /* Body */ #if MQX_EXIT_ENABLED KERNEL_DATA_STRUCT_PTR kernel_data; _GET_KERNEL_DATA(kernel_data); return (kernel_data->EXIT_HANDLER); #else return NULL; #endif /* MQX_EXIT_ENABLED */ }
/*! * \brief Gets a pointer to the MQX exit handler function called when MQX exits. * * \return Pointer to the MQX exit handler. * * \see _mqx_exit * \see _mqx_set_exit_handler */
\brief Gets a pointer to the MQX exit handler function called when MQX exits. \return Pointer to the MQX exit handler.
[ "\\", "brief", "Gets", "a", "pointer", "to", "the", "MQX", "exit", "handler", "function", "called", "when", "MQX", "exits", ".", "\\", "return", "Pointer", "to", "the", "MQX", "exit", "handler", "." ]
MQX_EXIT_FPTR _mqx_get_exit_handler (void) { #if MQX_EXIT_ENABLED KERNEL_DATA_STRUCT_PTR kernel_data; _GET_KERNEL_DATA(kernel_data); return (kernel_data->EXIT_HANDLER); #else return NULL; #endif }
[ "MQX_EXIT_FPTR", "_mqx_get_exit_handler", "(", "void", ")", "{", "#if", "MQX_EXIT_ENABLED", "\n", "KERNEL_DATA_STRUCT_PTR", "kernel_data", ";", "_GET_KERNEL_DATA", "(", "kernel_data", ")", ";", "return", "(", "kernel_data", "->", "EXIT_HANDLER", ")", ";", "#else", "return", "NULL", ";", "#endif", "}" ]
\brief Gets a pointer to the MQX exit handler function called when MQX exits.
[ "\\", "brief", "Gets", "a", "pointer", "to", "the", "MQX", "exit", "handler", "function", "called", "when", "MQX", "exits", "." ]
[ "/* Body */", "/* MQX_EXIT_ENABLED */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
46b5af3a680675afcf7e1ac79e0aa186c5275288
OUNAVCON/nrf24L01_plus
MQXLITE/kernel/mqx_utils.c
[ "MIT" ]
C
_mqx_set_exit_handler
void
void _mqx_set_exit_handler ( MQX_EXIT_FPTR entry ) { /* Body */ #if MQX_EXIT_ENABLED KERNEL_DATA_STRUCT_PTR kernel_data; _GET_KERNEL_DATA(kernel_data); _KLOGE2(KLOG_mqx_set_exit_handler, entry); kernel_data->EXIT_HANDLER = entry; _KLOGX1(KLOG_mqx_set_exit_handler); #endif /* MQX_EXIT_ENABLED */ }
/*! * \brief Sets a pointer to the MQX exit handler function called when MQX exits. * * \param[in] entry Pointer to the exit handler. * * \see _mqx_exit * \see _mqx_get_exit_handler */
\brief Sets a pointer to the MQX exit handler function called when MQX exits. \param[in] entry Pointer to the exit handler.
[ "\\", "brief", "Sets", "a", "pointer", "to", "the", "MQX", "exit", "handler", "function", "called", "when", "MQX", "exits", ".", "\\", "param", "[", "in", "]", "entry", "Pointer", "to", "the", "exit", "handler", "." ]
void _mqx_set_exit_handler ( MQX_EXIT_FPTR entry ) { #if MQX_EXIT_ENABLED KERNEL_DATA_STRUCT_PTR kernel_data; _GET_KERNEL_DATA(kernel_data); _KLOGE2(KLOG_mqx_set_exit_handler, entry); kernel_data->EXIT_HANDLER = entry; _KLOGX1(KLOG_mqx_set_exit_handler); #endif }
[ "void", "_mqx_set_exit_handler", "(", "MQX_EXIT_FPTR", "entry", ")", "{", "#if", "MQX_EXIT_ENABLED", "\n", "KERNEL_DATA_STRUCT_PTR", "kernel_data", ";", "_GET_KERNEL_DATA", "(", "kernel_data", ")", ";", "_KLOGE2", "(", "KLOG_mqx_set_exit_handler", ",", "entry", ")", ";", "kernel_data", "->", "EXIT_HANDLER", "=", "entry", ";", "_KLOGX1", "(", "KLOG_mqx_set_exit_handler", ")", ";", "#endif", "}" ]
\brief Sets a pointer to the MQX exit handler function called when MQX exits.
[ "\\", "brief", "Sets", "a", "pointer", "to", "the", "MQX", "exit", "handler", "function", "called", "when", "MQX", "exits", "." ]
[ "/* Body */", "/* MQX_EXIT_ENABLED */" ]
[ { "param": "entry", "type": "MQX_EXIT_FPTR" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "entry", "type": "MQX_EXIT_FPTR", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
46b5af3a680675afcf7e1ac79e0aa186c5275288
OUNAVCON/nrf24L01_plus
MQXLITE/kernel/mqx_utils.c
[ "MIT" ]
C
_mqx_init_kernel_data_internal
void
void _mqx_init_kernel_data_internal ( void ) { /* Body */ KERNEL_DATA_STRUCT_PTR kernel_data; TASK_TEMPLATE_STRUCT_PTR task_template_ptr; TD_STRUCT_PTR td_ptr; _mqx_uint priority_levels; _mqx_uint i; _GET_KERNEL_DATA(kernel_data); /* Store the configuration used when the kernel was compiled */ kernel_data->CONFIG1 = MQX_CNFG1; kernel_data->CONFIG2 = MQX_CNFG2; /* Store the addressability of the processor. How many bits in a byte. */ kernel_data->ADDRESSING_CAPABILITY = PSP_MEMORY_ADDRESSING_CAPABILITY; /* Indicate the endianess of the target */ kernel_data->ENDIANESS = PSP_ENDIAN; /* Store PSP memory alignment information */ #if PSP_MEM_STOREBLOCK_ALIGNMENT != 0 kernel_data->PSP_CFG_MEM_STOREBLOCK_ALIGNMENT = PSP_MEM_STOREBLOCK_ALIGNMENT; #endif kernel_data->PSP_CFG_MEMORY_ALIGNMENT = PSP_MEMORY_ALIGNMENT; kernel_data->PSP_CFG_STACK_ALIGNMENT = PSP_STACK_ALIGNMENT; /* Set IPC id for compatibility */ #if MQX_USE_IPC kernel_data->MY_IPC_ID = BUILD_TASKID(kernel_data->INIT.PROCESSOR_NUMBER, 1); #endif /* Store location of current interrupt vector table */ #if MQX_EXIT_ENABLED kernel_data->USERS_VBR = (_mqx_max_type)_int_get_vector_table(); #endif #if MQX_CHECK_ERRORS if (kernel_data->INIT.TASK_TEMPLATE_LIST == NULL) { _mqx_exit(MQX_INVALID_POINTER); } /* Endif */ #endif #if MQX_HAS_TIME_SLICE /* Set the default scheduling policy for created tasks */ kernel_data->SCHED_POLICY = MQX_SCHED_FIFO; #endif #if MQX_KD_HAS_COUNTER /* Initialize the kernel counter. */ kernel_data->COUNTER = 1U; #endif /* Set up the disable and enable priority levels */ _psp_set_kernel_disable_level(); /* * Initialize the system task so that functions which update the * task error code can be called. * The system task never runs, but it's TD is used for error codes * during initialization, and for storage of memory blocks assigned * to the system. */ td_ptr = (TD_STRUCT_PTR) & kernel_data->SYSTEM_TD; kernel_data->ACTIVE_PTR = td_ptr; kernel_data->ACTIVE_SR = kernel_data->DISABLE_SR; td_ptr->TASK_SR = kernel_data->DISABLE_SR; td_ptr->TASK_ID = BUILD_TASKID(kernel_data->INIT.PROCESSOR_NUMBER, SYSTEM_TASK_NUMBER); td_ptr->STATE = BLOCKED; /* Initialize the light weight semaphores queue */ _QUEUE_INIT(&kernel_data->LWSEM, 0); #if MQX_ENABLE_USER_MODE _QUEUE_INIT(&kernel_data->USR_LWSEM, 0); #endif #if MQX_HAS_TICK /* Set up the timeout queue */ _QUEUE_INIT(&kernel_data->TIMEOUT_QUEUE, 0); #endif /* * Compute the number of MQX priority levels needed. This is done * by determining the task that has the lowest priority (highest number) */ priority_levels = 0; task_template_ptr = kernel_data->INIT.TASK_TEMPLATE_LIST; for (i = 0; task_template_ptr->TASK_TEMPLATE_INDEX && (i < MQX_MAXIMUM_NUMBER_OF_TASK_TEMPLATES); ++i, ++task_template_ptr) { if (priority_levels < task_template_ptr->TASK_PRIORITY) { priority_levels = task_template_ptr->TASK_PRIORITY; } /* Endif */ } /* Endfor */ kernel_data->LOWEST_TASK_PRIORITY = priority_levels; #if MQX_USE_IDLE_TASK /* * Initialize the task template for the IDLE Task. * NOTE that the idle task runs at 1 level lower than any user task. */ task_template_ptr = (TASK_TEMPLATE_STRUCT_PTR)&kernel_data->IDLE_TASK_TEMPLATE; task_template_ptr->TASK_TEMPLATE_INDEX = IDLE_TASK; task_template_ptr->TASK_STACKSIZE = kernel_data->INIT.IDLE_TASK_STACK_SIZE; task_template_ptr->TASK_NAME = "_mqx_idle_task"; task_template_ptr->TASK_ADDRESS = _mqx_idle_task; task_template_ptr->TASK_PRIORITY = priority_levels + 1; #endif /* * Initialize the linked list of all TDs in the system. * Initially zero. Not including system TD */ _QUEUE_INIT(&kernel_data->TD_LIST, 0); /* Set the TD counter */ kernel_data->TASK_NUMBER = 1; }
/*! * \private * * \brief Initializes the static parts of the kernel data structure. * * Care has to be taken when calling functions within this file, as the kernel is * not running yet. Specifically, functions which rely on _mqx_get_kernel_data * can not be called. */
\private \brief Initializes the static parts of the kernel data structure. Care has to be taken when calling functions within this file, as the kernel is not running yet. Specifically, functions which rely on _mqx_get_kernel_data can not be called.
[ "\\", "private", "\\", "brief", "Initializes", "the", "static", "parts", "of", "the", "kernel", "data", "structure", ".", "Care", "has", "to", "be", "taken", "when", "calling", "functions", "within", "this", "file", "as", "the", "kernel", "is", "not", "running", "yet", ".", "Specifically", "functions", "which", "rely", "on", "_mqx_get_kernel_data", "can", "not", "be", "called", "." ]
void _mqx_init_kernel_data_internal ( void ) { KERNEL_DATA_STRUCT_PTR kernel_data; TASK_TEMPLATE_STRUCT_PTR task_template_ptr; TD_STRUCT_PTR td_ptr; _mqx_uint priority_levels; _mqx_uint i; _GET_KERNEL_DATA(kernel_data); kernel_data->CONFIG1 = MQX_CNFG1; kernel_data->CONFIG2 = MQX_CNFG2; kernel_data->ADDRESSING_CAPABILITY = PSP_MEMORY_ADDRESSING_CAPABILITY; kernel_data->ENDIANESS = PSP_ENDIAN; #if PSP_MEM_STOREBLOCK_ALIGNMENT != 0 kernel_data->PSP_CFG_MEM_STOREBLOCK_ALIGNMENT = PSP_MEM_STOREBLOCK_ALIGNMENT; #endif kernel_data->PSP_CFG_MEMORY_ALIGNMENT = PSP_MEMORY_ALIGNMENT; kernel_data->PSP_CFG_STACK_ALIGNMENT = PSP_STACK_ALIGNMENT; #if MQX_USE_IPC kernel_data->MY_IPC_ID = BUILD_TASKID(kernel_data->INIT.PROCESSOR_NUMBER, 1); #endif #if MQX_EXIT_ENABLED kernel_data->USERS_VBR = (_mqx_max_type)_int_get_vector_table(); #endif #if MQX_CHECK_ERRORS if (kernel_data->INIT.TASK_TEMPLATE_LIST == NULL) { _mqx_exit(MQX_INVALID_POINTER); } #endif #if MQX_HAS_TIME_SLICE kernel_data->SCHED_POLICY = MQX_SCHED_FIFO; #endif #if MQX_KD_HAS_COUNTER kernel_data->COUNTER = 1U; #endif _psp_set_kernel_disable_level(); td_ptr = (TD_STRUCT_PTR) & kernel_data->SYSTEM_TD; kernel_data->ACTIVE_PTR = td_ptr; kernel_data->ACTIVE_SR = kernel_data->DISABLE_SR; td_ptr->TASK_SR = kernel_data->DISABLE_SR; td_ptr->TASK_ID = BUILD_TASKID(kernel_data->INIT.PROCESSOR_NUMBER, SYSTEM_TASK_NUMBER); td_ptr->STATE = BLOCKED; _QUEUE_INIT(&kernel_data->LWSEM, 0); #if MQX_ENABLE_USER_MODE _QUEUE_INIT(&kernel_data->USR_LWSEM, 0); #endif #if MQX_HAS_TICK _QUEUE_INIT(&kernel_data->TIMEOUT_QUEUE, 0); #endif priority_levels = 0; task_template_ptr = kernel_data->INIT.TASK_TEMPLATE_LIST; for (i = 0; task_template_ptr->TASK_TEMPLATE_INDEX && (i < MQX_MAXIMUM_NUMBER_OF_TASK_TEMPLATES); ++i, ++task_template_ptr) { if (priority_levels < task_template_ptr->TASK_PRIORITY) { priority_levels = task_template_ptr->TASK_PRIORITY; } } kernel_data->LOWEST_TASK_PRIORITY = priority_levels; #if MQX_USE_IDLE_TASK task_template_ptr = (TASK_TEMPLATE_STRUCT_PTR)&kernel_data->IDLE_TASK_TEMPLATE; task_template_ptr->TASK_TEMPLATE_INDEX = IDLE_TASK; task_template_ptr->TASK_STACKSIZE = kernel_data->INIT.IDLE_TASK_STACK_SIZE; task_template_ptr->TASK_NAME = "_mqx_idle_task"; task_template_ptr->TASK_ADDRESS = _mqx_idle_task; task_template_ptr->TASK_PRIORITY = priority_levels + 1; #endif _QUEUE_INIT(&kernel_data->TD_LIST, 0); kernel_data->TASK_NUMBER = 1; }
[ "void", "_mqx_init_kernel_data_internal", "(", "void", ")", "{", "KERNEL_DATA_STRUCT_PTR", "kernel_data", ";", "TASK_TEMPLATE_STRUCT_PTR", "task_template_ptr", ";", "TD_STRUCT_PTR", "td_ptr", ";", "_mqx_uint", "priority_levels", ";", "_mqx_uint", "i", ";", "_GET_KERNEL_DATA", "(", "kernel_data", ")", ";", "kernel_data", "->", "CONFIG1", "=", "MQX_CNFG1", ";", "kernel_data", "->", "CONFIG2", "=", "MQX_CNFG2", ";", "kernel_data", "->", "ADDRESSING_CAPABILITY", "=", "PSP_MEMORY_ADDRESSING_CAPABILITY", ";", "kernel_data", "->", "ENDIANESS", "=", "PSP_ENDIAN", ";", "#if", "PSP_MEM_STOREBLOCK_ALIGNMENT", "!=", "0", "\n", "kernel_data", "->", "PSP_CFG_MEM_STOREBLOCK_ALIGNMENT", "=", "PSP_MEM_STOREBLOCK_ALIGNMENT", ";", "#endif", "kernel_data", "->", "PSP_CFG_MEMORY_ALIGNMENT", "=", "PSP_MEMORY_ALIGNMENT", ";", "kernel_data", "->", "PSP_CFG_STACK_ALIGNMENT", "=", "PSP_STACK_ALIGNMENT", ";", "#if", "MQX_USE_IPC", "\n", "kernel_data", "->", "MY_IPC_ID", "=", "BUILD_TASKID", "(", "kernel_data", "->", "INIT", ".", "PROCESSOR_NUMBER", ",", "1", ")", ";", "#endif", "#if", "MQX_EXIT_ENABLED", "\n", "kernel_data", "->", "USERS_VBR", "=", "(", "_mqx_max_type", ")", "_int_get_vector_table", "(", ")", ";", "#endif", "#if", "MQX_CHECK_ERRORS", "\n", "if", "(", "kernel_data", "->", "INIT", ".", "TASK_TEMPLATE_LIST", "==", "NULL", ")", "{", "_mqx_exit", "(", "MQX_INVALID_POINTER", ")", ";", "}", "#endif", "#if", "MQX_HAS_TIME_SLICE", "\n", "kernel_data", "->", "SCHED_POLICY", "=", "MQX_SCHED_FIFO", ";", "#endif", "#if", "MQX_KD_HAS_COUNTER", "\n", "kernel_data", "->", "COUNTER", "=", "1U", ";", "#endif", "_psp_set_kernel_disable_level", "(", ")", ";", "td_ptr", "=", "(", "TD_STRUCT_PTR", ")", "&", "kernel_data", "->", "SYSTEM_TD", ";", "kernel_data", "->", "ACTIVE_PTR", "=", "td_ptr", ";", "kernel_data", "->", "ACTIVE_SR", "=", "kernel_data", "->", "DISABLE_SR", ";", "td_ptr", "->", "TASK_SR", "=", "kernel_data", "->", "DISABLE_SR", ";", "td_ptr", "->", "TASK_ID", "=", "BUILD_TASKID", "(", "kernel_data", "->", "INIT", ".", "PROCESSOR_NUMBER", ",", "SYSTEM_TASK_NUMBER", ")", ";", "td_ptr", "->", "STATE", "=", "BLOCKED", ";", "_QUEUE_INIT", "(", "&", "kernel_data", "->", "LWSEM", ",", "0", ")", ";", "#if", "MQX_ENABLE_USER_MODE", "\n", "_QUEUE_INIT", "(", "&", "kernel_data", "->", "USR_LWSEM", ",", "0", ")", ";", "#endif", "#if", "MQX_HAS_TICK", "\n", "_QUEUE_INIT", "(", "&", "kernel_data", "->", "TIMEOUT_QUEUE", ",", "0", ")", ";", "#endif", "priority_levels", "=", "0", ";", "task_template_ptr", "=", "kernel_data", "->", "INIT", ".", "TASK_TEMPLATE_LIST", ";", "for", "(", "i", "=", "0", ";", "task_template_ptr", "->", "TASK_TEMPLATE_INDEX", "&&", "(", "i", "<", "MQX_MAXIMUM_NUMBER_OF_TASK_TEMPLATES", ")", ";", "++", "i", ",", "++", "task_template_ptr", ")", "{", "if", "(", "priority_levels", "<", "task_template_ptr", "->", "TASK_PRIORITY", ")", "{", "priority_levels", "=", "task_template_ptr", "->", "TASK_PRIORITY", ";", "}", "}", "kernel_data", "->", "LOWEST_TASK_PRIORITY", "=", "priority_levels", ";", "#if", "MQX_USE_IDLE_TASK", "\n", "task_template_ptr", "=", "(", "TASK_TEMPLATE_STRUCT_PTR", ")", "&", "kernel_data", "->", "IDLE_TASK_TEMPLATE", ";", "task_template_ptr", "->", "TASK_TEMPLATE_INDEX", "=", "IDLE_TASK", ";", "task_template_ptr", "->", "TASK_STACKSIZE", "=", "kernel_data", "->", "INIT", ".", "IDLE_TASK_STACK_SIZE", ";", "task_template_ptr", "->", "TASK_NAME", "=", "\"", "\"", ";", "task_template_ptr", "->", "TASK_ADDRESS", "=", "_mqx_idle_task", ";", "task_template_ptr", "->", "TASK_PRIORITY", "=", "priority_levels", "+", "1", ";", "#endif", "_QUEUE_INIT", "(", "&", "kernel_data", "->", "TD_LIST", ",", "0", ")", ";", "kernel_data", "->", "TASK_NUMBER", "=", "1", ";", "}" ]
\private \brief Initializes the static parts of the kernel data structure.
[ "\\", "private", "\\", "brief", "Initializes", "the", "static", "parts", "of", "the", "kernel", "data", "structure", "." ]
[ "/* Body */", "/* Store the configuration used when the kernel was compiled */", "/* Store the addressability of the processor. How many bits in a byte. */", "/* Indicate the endianess of the target */", "/* Store PSP memory alignment information */", "/* Set IPC id for compatibility */", "/* Store location of current interrupt vector table */", "/* Endif */", "/* Set the default scheduling policy for created tasks */", "/* Initialize the kernel counter. */", "/* Set up the disable and enable priority levels */", "/*\n * Initialize the system task so that functions which update the\n * task error code can be called.\n * The system task never runs, but it's TD is used for error codes\n * during initialization, and for storage of memory blocks assigned\n * to the system.\n */", "/* Initialize the light weight semaphores queue */", "/* Set up the timeout queue */", "/*\n * Compute the number of MQX priority levels needed. This is done\n * by determining the task that has the lowest priority (highest number)\n */", "/* Endif */", "/* Endfor */", "/*\n * Initialize the task template for the IDLE Task.\n * NOTE that the idle task runs at 1 level lower than any user task.\n */", "/*\n * Initialize the linked list of all TDs in the system.\n * Initially zero. Not including system TD\n */", "/* Set the TD counter */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
c82f2ffbc3851ac5834eb548214ca7099b99a48f
OUNAVCON/nrf24L01_plus
MQXLITE/kernel/mqxlite.c
[ "MIT" ]
C
_mqx_exit
void
void _mqx_exit ( _mqx_uint error ) { /* Body */ KERNEL_DATA_STRUCT_PTR kernel_data; _int_disable(); _GET_KERNEL_DATA(kernel_data); _KLOGE2(KLOG_mqx_exit, error); #if MQX_EXIT_ENABLED kernel_data->USERS_ERROR = error; if (kernel_data->EXIT_HANDLER) { (*kernel_data->EXIT_HANDLER)(); }/* Endif */ MQX_LONGJMP( _mqx_exit_jump_buffer_internal, 1 ); #else while (TRUE) { } /* Endwhile */ #endif /* MQX_EXIT_ENABLED */ }
/*! * \brief Terminate the MQX application and return to the environment that started * the application. * * The function returns back to the environment that called _mqxlite(). If the * application has installed the MQX exit handler (_mqx_set_exit_handler()), * _mqx_exit() calls the MQX exit handler before it exits. By default, * _bsp_exit_handler() is installed as the MQX exit handler in each BSP. * * \note * It is important to ensure that the environment (boot call stack) the MQX is * returning to is in the consistent state. This is not provided by distributed * MQX BSPs, because the boot stack is reused (rewritten) by MQX Kernel data. Set * the boot stack outside of Kernel data section to support correct _mqx_exit * functionality. * * \param[in] error Error code to return to the function that called _mqxlite_init() * or _mqxlite(). * * \warning Behavior depends on the BSP. * * \see mqxlite_init * \see mqxlite */
\brief Terminate the MQX application and return to the environment that started the application. The function returns back to the environment that called _mqxlite(). If the application has installed the MQX exit handler (_mqx_set_exit_handler()), _mqx_exit() calls the MQX exit handler before it exits. By default, _bsp_exit_handler() is installed as the MQX exit handler in each BSP. \note It is important to ensure that the environment (boot call stack) the MQX is returning to is in the consistent state. This is not provided by distributed MQX BSPs, because the boot stack is reused (rewritten) by MQX Kernel data. Set the boot stack outside of Kernel data section to support correct _mqx_exit functionality. \param[in] error Error code to return to the function that called _mqxlite_init() or _mqxlite(). \warning Behavior depends on the BSP. \see mqxlite_init \see mqxlite
[ "\\", "brief", "Terminate", "the", "MQX", "application", "and", "return", "to", "the", "environment", "that", "started", "the", "application", ".", "The", "function", "returns", "back", "to", "the", "environment", "that", "called", "_mqxlite", "()", ".", "If", "the", "application", "has", "installed", "the", "MQX", "exit", "handler", "(", "_mqx_set_exit_handler", "()", ")", "_mqx_exit", "()", "calls", "the", "MQX", "exit", "handler", "before", "it", "exits", ".", "By", "default", "_bsp_exit_handler", "()", "is", "installed", "as", "the", "MQX", "exit", "handler", "in", "each", "BSP", ".", "\\", "note", "It", "is", "important", "to", "ensure", "that", "the", "environment", "(", "boot", "call", "stack", ")", "the", "MQX", "is", "returning", "to", "is", "in", "the", "consistent", "state", ".", "This", "is", "not", "provided", "by", "distributed", "MQX", "BSPs", "because", "the", "boot", "stack", "is", "reused", "(", "rewritten", ")", "by", "MQX", "Kernel", "data", ".", "Set", "the", "boot", "stack", "outside", "of", "Kernel", "data", "section", "to", "support", "correct", "_mqx_exit", "functionality", ".", "\\", "param", "[", "in", "]", "error", "Error", "code", "to", "return", "to", "the", "function", "that", "called", "_mqxlite_init", "()", "or", "_mqxlite", "()", ".", "\\", "warning", "Behavior", "depends", "on", "the", "BSP", ".", "\\", "see", "mqxlite_init", "\\", "see", "mqxlite" ]
void _mqx_exit ( _mqx_uint error ) { KERNEL_DATA_STRUCT_PTR kernel_data; _int_disable(); _GET_KERNEL_DATA(kernel_data); _KLOGE2(KLOG_mqx_exit, error); #if MQX_EXIT_ENABLED kernel_data->USERS_ERROR = error; if (kernel_data->EXIT_HANDLER) { (*kernel_data->EXIT_HANDLER)(); } MQX_LONGJMP( _mqx_exit_jump_buffer_internal, 1 ); #else while (TRUE) { } #endif }
[ "void", "_mqx_exit", "(", "_mqx_uint", "error", ")", "{", "KERNEL_DATA_STRUCT_PTR", "kernel_data", ";", "_int_disable", "(", ")", ";", "_GET_KERNEL_DATA", "(", "kernel_data", ")", ";", "_KLOGE2", "(", "KLOG_mqx_exit", ",", "error", ")", ";", "#if", "MQX_EXIT_ENABLED", "\n", "kernel_data", "->", "USERS_ERROR", "=", "error", ";", "if", "(", "kernel_data", "->", "EXIT_HANDLER", ")", "{", "(", "*", "kernel_data", "->", "EXIT_HANDLER", ")", "(", ")", ";", "}", "MQX_LONGJMP", "(", "_mqx_exit_jump_buffer_internal", ",", "1", ")", ";", "#else", "while", "(", "TRUE", ")", "{", "}", "#endif", "}" ]
\brief Terminate the MQX application and return to the environment that started the application.
[ "\\", "brief", "Terminate", "the", "MQX", "application", "and", "return", "to", "the", "environment", "that", "started", "the", "application", "." ]
[ "/* Body */", "/* Endif */", "/* Endwhile */", "/* MQX_EXIT_ENABLED */" ]
[ { "param": "error", "type": "_mqx_uint" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "error", "type": "_mqx_uint", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c13a0b2686cbe778f862d422dd4db909f344e349
OUNAVCON/nrf24L01_plus
MQXLITE/psp/cortex_m/int_pvta.c
[ "MIT" ]
C
_int_get_previous_vector_table
_psp_code_addr
_psp_code_addr _int_get_previous_vector_table ( void ) { /* Body */ register KERNEL_DATA_STRUCT_PTR kernel_data; _GET_KERNEL_DATA(kernel_data); return( (_psp_code_addr)kernel_data->USERS_VBR ); }
/*! * \brief Gets the address of the interrupt vector table that MQX might have * created when it started. * * The function is useful if you are installing third-party debuggers or monitors. * * \return Address of the interrupt vector table that MQX creates when it starts. * * \see _int_get_vector_table * \see _int_set_vector_table */
\brief Gets the address of the interrupt vector table that MQX might have created when it started. The function is useful if you are installing third-party debuggers or monitors. \return Address of the interrupt vector table that MQX creates when it starts.
[ "\\", "brief", "Gets", "the", "address", "of", "the", "interrupt", "vector", "table", "that", "MQX", "might", "have", "created", "when", "it", "started", ".", "The", "function", "is", "useful", "if", "you", "are", "installing", "third", "-", "party", "debuggers", "or", "monitors", ".", "\\", "return", "Address", "of", "the", "interrupt", "vector", "table", "that", "MQX", "creates", "when", "it", "starts", "." ]
_psp_code_addr _int_get_previous_vector_table ( void ) { register KERNEL_DATA_STRUCT_PTR kernel_data; _GET_KERNEL_DATA(kernel_data); return( (_psp_code_addr)kernel_data->USERS_VBR ); }
[ "_psp_code_addr", "_int_get_previous_vector_table", "(", "void", ")", "{", "register", "KERNEL_DATA_STRUCT_PTR", "kernel_data", ";", "_GET_KERNEL_DATA", "(", "kernel_data", ")", ";", "return", "(", "(", "_psp_code_addr", ")", "kernel_data", "->", "USERS_VBR", ")", ";", "}" ]
\brief Gets the address of the interrupt vector table that MQX might have created when it started.
[ "\\", "brief", "Gets", "the", "address", "of", "the", "interrupt", "vector", "table", "that", "MQX", "might", "have", "created", "when", "it", "started", "." ]
[ "/* Body */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
60b81a31d069ea0e748e1804c02db5b0c79b3147
OUNAVCON/nrf24L01_plus
Generated_Code/SM1.c
[ "MIT" ]
C
SM1_Interrupt
void
void SM1_Interrupt(LDD_RTOS_TISRParameter _isrParameter) { /* {MQXLite RTOS Adapter} ISR parameter is passed as parameter from RTOS interrupt dispatcher */ SM1_TDeviceDataPtr DeviceDataPrv = (SM1_TDeviceDataPtr)_isrParameter; uint32_t StatReg = SPI_PDD_GetInterruptFlags(SPI0_BASE_PTR); /* Read status register */ uint16_t Data; /* Temporary variable for data */ if ((StatReg & SPI_PDD_RX_FIFO_OVERFLOW_INT) != 0U) { /* Is any error flag set? */ SPI_PDD_ClearInterruptFlags(SPI0_BASE_PTR,SPI_PDD_RX_FIFO_OVERFLOW_INT); /* Clear error flags */ } if ((StatReg & SPI_PDD_RX_FIFO_DRAIN_INT_DMA) != 0U) { /* Is any char in HW buffer? */ Data = (uint16_t)SPI_PDD_ReadPopRxFIFOReg(SPI0_BASE_PTR); /* Read character from receiver */ SPI_PDD_ClearInterruptFlags(SPI0_BASE_PTR,SPI_PDD_RX_FIFO_DRAIN_INT_DMA); /* Clear Rx FIFO drain flags */ if (DeviceDataPrv->InpDataNumReq != 0x00U) { /* Is the receive block operation pending? */ *(DeviceDataPrv->InpDataPtr++) = (uint8_t)Data; /* Put a character to the receive buffer and increment pointer to receive buffer */ DeviceDataPrv->InpRecvDataNum++; /* Increment received char. counter */ if (DeviceDataPrv->InpRecvDataNum == DeviceDataPrv->InpDataNumReq) { /* Is the requested number of characters received? */ DeviceDataPrv->InpDataNumReq = 0x00U; /* If yes then clear number of requested characters to be received. */ SM1_OnBlockReceived(DeviceDataPrv->UserData); } } } if ((StatReg & SPI_PDD_TX_FIFO_FILL_INT_DMA) != 0U) { /* Is HW buffer empty? */ if (DeviceDataPrv->OutSentDataNum < DeviceDataPrv->OutDataNumReq) { /* Is number of sent characters less than the number of requested incoming characters? */ DeviceDataPrv->OutSentDataNum++; /* Increment the counter of sent characters. */ SPI_PDD_WriteMasterPushTxFIFOReg(SPI0_BASE_PTR, (uint32_t)(*((uint8_t *)DeviceDataPrv->OutDataPtr++) | DeviceDataPrv->TxCommand)); /* Put a character with command to the transmit register and increment pointer to the transmitt buffer */ if (DeviceDataPrv->OutSentDataNum == DeviceDataPrv->OutDataNumReq) { DeviceDataPrv->OutDataNumReq = 0x00U; /* Clear the counter of characters to be send by SendBlock() */ SM1_OnBlockSent(DeviceDataPrv->UserData); } } else { SPI_PDD_DisableDmasInterrupts(SPI0_BASE_PTR, SPI_PDD_TX_FIFO_FILL_INT_DMA); /* Disable TX interrupt */ } SPI_PDD_ClearInterruptFlags(SPI0_BASE_PTR,SPI_PDD_TX_FIFO_FILL_INT_DMA); /* Clear Tx FIFO fill flags */ } }
/* ** =================================================================== ** Method : SM1_Interrupt (component SPIMaster_LDD) ** ** Description : ** The ISR function handling the device receive/transmit ** interrupt. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */
Method : SM1_Interrupt (component SPIMaster_LDD) Description : The ISR function handling the device receive/transmit interrupt. This method is internal. It is used by Processor Expert only.
[ "Method", ":", "SM1_Interrupt", "(", "component", "SPIMaster_LDD", ")", "Description", ":", "The", "ISR", "function", "handling", "the", "device", "receive", "/", "transmit", "interrupt", ".", "This", "method", "is", "internal", ".", "It", "is", "used", "by", "Processor", "Expert", "only", "." ]
void SM1_Interrupt(LDD_RTOS_TISRParameter _isrParameter) { SM1_TDeviceDataPtr DeviceDataPrv = (SM1_TDeviceDataPtr)_isrParameter; uint32_t StatReg = SPI_PDD_GetInterruptFlags(SPI0_BASE_PTR); uint16_t Data; if ((StatReg & SPI_PDD_RX_FIFO_OVERFLOW_INT) != 0U) { SPI_PDD_ClearInterruptFlags(SPI0_BASE_PTR,SPI_PDD_RX_FIFO_OVERFLOW_INT); } if ((StatReg & SPI_PDD_RX_FIFO_DRAIN_INT_DMA) != 0U) { Data = (uint16_t)SPI_PDD_ReadPopRxFIFOReg(SPI0_BASE_PTR); SPI_PDD_ClearInterruptFlags(SPI0_BASE_PTR,SPI_PDD_RX_FIFO_DRAIN_INT_DMA); if (DeviceDataPrv->InpDataNumReq != 0x00U) { *(DeviceDataPrv->InpDataPtr++) = (uint8_t)Data; DeviceDataPrv->InpRecvDataNum++; if (DeviceDataPrv->InpRecvDataNum == DeviceDataPrv->InpDataNumReq) { DeviceDataPrv->InpDataNumReq = 0x00U; SM1_OnBlockReceived(DeviceDataPrv->UserData); } } } if ((StatReg & SPI_PDD_TX_FIFO_FILL_INT_DMA) != 0U) { if (DeviceDataPrv->OutSentDataNum < DeviceDataPrv->OutDataNumReq) { DeviceDataPrv->OutSentDataNum++; SPI_PDD_WriteMasterPushTxFIFOReg(SPI0_BASE_PTR, (uint32_t)(*((uint8_t *)DeviceDataPrv->OutDataPtr++) | DeviceDataPrv->TxCommand)); if (DeviceDataPrv->OutSentDataNum == DeviceDataPrv->OutDataNumReq) { DeviceDataPrv->OutDataNumReq = 0x00U; SM1_OnBlockSent(DeviceDataPrv->UserData); } } else { SPI_PDD_DisableDmasInterrupts(SPI0_BASE_PTR, SPI_PDD_TX_FIFO_FILL_INT_DMA); } SPI_PDD_ClearInterruptFlags(SPI0_BASE_PTR,SPI_PDD_TX_FIFO_FILL_INT_DMA); } }
[ "void", "SM1_Interrupt", "(", "LDD_RTOS_TISRParameter", "_isrParameter", ")", "{", "SM1_TDeviceDataPtr", "DeviceDataPrv", "=", "(", "SM1_TDeviceDataPtr", ")", "_isrParameter", ";", "uint32_t", "StatReg", "=", "SPI_PDD_GetInterruptFlags", "(", "SPI0_BASE_PTR", ")", ";", "uint16_t", "Data", ";", "if", "(", "(", "StatReg", "&", "SPI_PDD_RX_FIFO_OVERFLOW_INT", ")", "!=", "0U", ")", "{", "SPI_PDD_ClearInterruptFlags", "(", "SPI0_BASE_PTR", ",", "SPI_PDD_RX_FIFO_OVERFLOW_INT", ")", ";", "}", "if", "(", "(", "StatReg", "&", "SPI_PDD_RX_FIFO_DRAIN_INT_DMA", ")", "!=", "0U", ")", "{", "Data", "=", "(", "uint16_t", ")", "SPI_PDD_ReadPopRxFIFOReg", "(", "SPI0_BASE_PTR", ")", ";", "SPI_PDD_ClearInterruptFlags", "(", "SPI0_BASE_PTR", ",", "SPI_PDD_RX_FIFO_DRAIN_INT_DMA", ")", ";", "if", "(", "DeviceDataPrv", "->", "InpDataNumReq", "!=", "0x00U", ")", "{", "*", "(", "DeviceDataPrv", "->", "InpDataPtr", "++", ")", "=", "(", "uint8_t", ")", "Data", ";", "DeviceDataPrv", "->", "InpRecvDataNum", "++", ";", "if", "(", "DeviceDataPrv", "->", "InpRecvDataNum", "==", "DeviceDataPrv", "->", "InpDataNumReq", ")", "{", "DeviceDataPrv", "->", "InpDataNumReq", "=", "0x00U", ";", "SM1_OnBlockReceived", "(", "DeviceDataPrv", "->", "UserData", ")", ";", "}", "}", "}", "if", "(", "(", "StatReg", "&", "SPI_PDD_TX_FIFO_FILL_INT_DMA", ")", "!=", "0U", ")", "{", "if", "(", "DeviceDataPrv", "->", "OutSentDataNum", "<", "DeviceDataPrv", "->", "OutDataNumReq", ")", "{", "DeviceDataPrv", "->", "OutSentDataNum", "++", ";", "SPI_PDD_WriteMasterPushTxFIFOReg", "(", "SPI0_BASE_PTR", ",", "(", "uint32_t", ")", "(", "*", "(", "(", "uint8_t", "*", ")", "DeviceDataPrv", "->", "OutDataPtr", "++", ")", "|", "DeviceDataPrv", "->", "TxCommand", ")", ")", ";", "if", "(", "DeviceDataPrv", "->", "OutSentDataNum", "==", "DeviceDataPrv", "->", "OutDataNumReq", ")", "{", "DeviceDataPrv", "->", "OutDataNumReq", "=", "0x00U", ";", "SM1_OnBlockSent", "(", "DeviceDataPrv", "->", "UserData", ")", ";", "}", "}", "else", "{", "SPI_PDD_DisableDmasInterrupts", "(", "SPI0_BASE_PTR", ",", "SPI_PDD_TX_FIFO_FILL_INT_DMA", ")", ";", "}", "SPI_PDD_ClearInterruptFlags", "(", "SPI0_BASE_PTR", ",", "SPI_PDD_TX_FIFO_FILL_INT_DMA", ")", ";", "}", "}" ]
Method : SM1_Interrupt (component SPIMaster_LDD) Description : The ISR function handling the device receive/transmit interrupt.
[ "Method", ":", "SM1_Interrupt", "(", "component", "SPIMaster_LDD", ")", "Description", ":", "The", "ISR", "function", "handling", "the", "device", "receive", "/", "transmit", "interrupt", "." ]
[ "/* {MQXLite RTOS Adapter} ISR parameter is passed as parameter from RTOS interrupt dispatcher */", "/* Read status register */", "/* Temporary variable for data */", "/* Is any error flag set? */", "/* Clear error flags */", "/* Is any char in HW buffer? */", "/* Read character from receiver */", "/* Clear Rx FIFO drain flags */", "/* Is the receive block operation pending? */", "/* Put a character to the receive buffer and increment pointer to receive buffer */", "/* Increment received char. counter */", "/* Is the requested number of characters received? */", "/* If yes then clear number of requested characters to be received. */", "/* Is HW buffer empty? */", "/* Is number of sent characters less than the number of requested incoming characters? */", "/* Increment the counter of sent characters. */", "/* Put a character with command to the transmit register and increment pointer to the transmitt buffer */", "/* Clear the counter of characters to be send by SendBlock() */", "/* Disable TX interrupt */", "/* Clear Tx FIFO fill flags */" ]
[ { "param": "_isrParameter", "type": "LDD_RTOS_TISRParameter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "_isrParameter", "type": "LDD_RTOS_TISRParameter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
60b81a31d069ea0e748e1804c02db5b0c79b3147
OUNAVCON/nrf24L01_plus
Generated_Code/SM1.c
[ "MIT" ]
C
HWEnDi
void
static void HWEnDi(LDD_TDeviceData *DeviceDataPtr) { if (((SM1_TDeviceDataPtr)DeviceDataPtr)->EnMode) { /* Enable device? */ ((SM1_TDeviceDataPtr)DeviceDataPtr)->OutDataNumReq = 0x00U; /* Clear the counter of requested outgoing characters. */ ((SM1_TDeviceDataPtr)DeviceDataPtr)->OutSentDataNum = 0x00U; /* Clear the counter of sent characters. */ ((SM1_TDeviceDataPtr)DeviceDataPtr)->InpDataNumReq = 0x00U; /* Clear the counter of requested incoming characters. */ ((SM1_TDeviceDataPtr)DeviceDataPtr)->InpRecvDataNum = 0x00U; /* Clear the counter of received characters. */ SPI_PDD_EnableDevice(SPI0_BASE_PTR,PDD_ENABLE); /* Enable device */ SPI_PDD_ClearTxFIFO(SPI0_BASE_PTR); /* Clear Tx FIFO */ SPI_PDD_ClearRxFIFO(SPI0_BASE_PTR); /* Clear Rx FIFO */ SPI_PDD_ClearInterruptFlags(SPI0_BASE_PTR,SPI_PDD_ALL_INT); /* Clear all HW flags */ SPI_PDD_EnableHaltMode(SPI0_BASE_PTR,PDD_DISABLE); /* Leave the STOPPED mode */ } else { SPI_PDD_EnableHaltMode(SPI0_BASE_PTR,PDD_ENABLE); /* Enter to STOPPED mode */ SPI_PDD_EnableDevice(SPI0_BASE_PTR,PDD_DISABLE); /* Disable device */ } }
/* ** =================================================================== ** Method : HWEnDi (component SPIMaster_LDD) ** ** Description : ** Enables or disables the peripheral(s) associated with the ** component. The method is called automatically as a part of the ** Enable and Disable methods and several internal methods. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */
Method : HWEnDi (component SPIMaster_LDD) Description : Enables or disables the peripheral(s) associated with the component. The method is called automatically as a part of the Enable and Disable methods and several internal methods. This method is internal. It is used by Processor Expert only.
[ "Method", ":", "HWEnDi", "(", "component", "SPIMaster_LDD", ")", "Description", ":", "Enables", "or", "disables", "the", "peripheral", "(", "s", ")", "associated", "with", "the", "component", ".", "The", "method", "is", "called", "automatically", "as", "a", "part", "of", "the", "Enable", "and", "Disable", "methods", "and", "several", "internal", "methods", ".", "This", "method", "is", "internal", ".", "It", "is", "used", "by", "Processor", "Expert", "only", "." ]
static void HWEnDi(LDD_TDeviceData *DeviceDataPtr) { if (((SM1_TDeviceDataPtr)DeviceDataPtr)->EnMode) { ((SM1_TDeviceDataPtr)DeviceDataPtr)->OutDataNumReq = 0x00U; ((SM1_TDeviceDataPtr)DeviceDataPtr)->OutSentDataNum = 0x00U; ((SM1_TDeviceDataPtr)DeviceDataPtr)->InpDataNumReq = 0x00U; ((SM1_TDeviceDataPtr)DeviceDataPtr)->InpRecvDataNum = 0x00U; SPI_PDD_EnableDevice(SPI0_BASE_PTR,PDD_ENABLE); SPI_PDD_ClearTxFIFO(SPI0_BASE_PTR); SPI_PDD_ClearRxFIFO(SPI0_BASE_PTR); SPI_PDD_ClearInterruptFlags(SPI0_BASE_PTR,SPI_PDD_ALL_INT); SPI_PDD_EnableHaltMode(SPI0_BASE_PTR,PDD_DISABLE); } else { SPI_PDD_EnableHaltMode(SPI0_BASE_PTR,PDD_ENABLE); SPI_PDD_EnableDevice(SPI0_BASE_PTR,PDD_DISABLE); } }
[ "static", "void", "HWEnDi", "(", "LDD_TDeviceData", "*", "DeviceDataPtr", ")", "{", "if", "(", "(", "(", "SM1_TDeviceDataPtr", ")", "DeviceDataPtr", ")", "->", "EnMode", ")", "{", "(", "(", "SM1_TDeviceDataPtr", ")", "DeviceDataPtr", ")", "->", "OutDataNumReq", "=", "0x00U", ";", "(", "(", "SM1_TDeviceDataPtr", ")", "DeviceDataPtr", ")", "->", "OutSentDataNum", "=", "0x00U", ";", "(", "(", "SM1_TDeviceDataPtr", ")", "DeviceDataPtr", ")", "->", "InpDataNumReq", "=", "0x00U", ";", "(", "(", "SM1_TDeviceDataPtr", ")", "DeviceDataPtr", ")", "->", "InpRecvDataNum", "=", "0x00U", ";", "SPI_PDD_EnableDevice", "(", "SPI0_BASE_PTR", ",", "PDD_ENABLE", ")", ";", "SPI_PDD_ClearTxFIFO", "(", "SPI0_BASE_PTR", ")", ";", "SPI_PDD_ClearRxFIFO", "(", "SPI0_BASE_PTR", ")", ";", "SPI_PDD_ClearInterruptFlags", "(", "SPI0_BASE_PTR", ",", "SPI_PDD_ALL_INT", ")", ";", "SPI_PDD_EnableHaltMode", "(", "SPI0_BASE_PTR", ",", "PDD_DISABLE", ")", ";", "}", "else", "{", "SPI_PDD_EnableHaltMode", "(", "SPI0_BASE_PTR", ",", "PDD_ENABLE", ")", ";", "SPI_PDD_EnableDevice", "(", "SPI0_BASE_PTR", ",", "PDD_DISABLE", ")", ";", "}", "}" ]
Method : HWEnDi (component SPIMaster_LDD) Description : Enables or disables the peripheral(s) associated with the component.
[ "Method", ":", "HWEnDi", "(", "component", "SPIMaster_LDD", ")", "Description", ":", "Enables", "or", "disables", "the", "peripheral", "(", "s", ")", "associated", "with", "the", "component", "." ]
[ "/* Enable device? */", "/* Clear the counter of requested outgoing characters. */", "/* Clear the counter of sent characters. */", "/* Clear the counter of requested incoming characters. */", "/* Clear the counter of received characters. */", "/* Enable device */", "/* Clear Tx FIFO */", "/* Clear Rx FIFO */", "/* Clear all HW flags */", "/* Leave the STOPPED mode */", "/* Enter to STOPPED mode */", "/* Disable device */" ]
[ { "param": "DeviceDataPtr", "type": "LDD_TDeviceData" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "DeviceDataPtr", "type": "LDD_TDeviceData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
60b81a31d069ea0e748e1804c02db5b0c79b3147
OUNAVCON/nrf24L01_plus
Generated_Code/SM1.c
[ "MIT" ]
C
SM1_SetClockConfiguration
void
void SM1_SetClockConfiguration(LDD_TDeviceData *DeviceDataPtr, LDD_TClockConfiguration ClockConfiguration) { SM1_TDeviceData *DeviceDataPrv = (SM1_TDeviceData *)DeviceDataPtr; switch (ClockConfiguration) { case CPU_CLOCK_CONFIG_0: DeviceDataPrv->EnMode = TRUE; /* Set the flag "device enabled" in the actual speed CPU mode */ SPI_PDD_WriteMasterClockTransferAttributeReg(SPI0_BASE_PTR,0U,0xBA56CCC1U); /* Set required configuration */ break; default: DeviceDataPrv->EnMode = FALSE; /* Set the flag "device disabled" in the actual speed CPU mode */ break; } HWEnDi(DeviceDataPtr); /* Enable/disable device according to status flags */ }
/* ** =================================================================== ** Method : SM1_SetClockConfiguration (component SPIMaster_LDD) ** ** Description : ** This method changes the clock configuration. During a clock ** configuration change the component changes it`s setting ** immediately upon a request. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */
Method : SM1_SetClockConfiguration (component SPIMaster_LDD) Description : This method changes the clock configuration. During a clock configuration change the component changes it`s setting immediately upon a request. This method is internal. It is used by Processor Expert only.
[ "Method", ":", "SM1_SetClockConfiguration", "(", "component", "SPIMaster_LDD", ")", "Description", ":", "This", "method", "changes", "the", "clock", "configuration", ".", "During", "a", "clock", "configuration", "change", "the", "component", "changes", "it", "`", "s", "setting", "immediately", "upon", "a", "request", ".", "This", "method", "is", "internal", ".", "It", "is", "used", "by", "Processor", "Expert", "only", "." ]
void SM1_SetClockConfiguration(LDD_TDeviceData *DeviceDataPtr, LDD_TClockConfiguration ClockConfiguration) { SM1_TDeviceData *DeviceDataPrv = (SM1_TDeviceData *)DeviceDataPtr; switch (ClockConfiguration) { case CPU_CLOCK_CONFIG_0: DeviceDataPrv->EnMode = TRUE; SPI_PDD_WriteMasterClockTransferAttributeReg(SPI0_BASE_PTR,0U,0xBA56CCC1U); break; default: DeviceDataPrv->EnMode = FALSE; break; } HWEnDi(DeviceDataPtr); }
[ "void", "SM1_SetClockConfiguration", "(", "LDD_TDeviceData", "*", "DeviceDataPtr", ",", "LDD_TClockConfiguration", "ClockConfiguration", ")", "{", "SM1_TDeviceData", "*", "DeviceDataPrv", "=", "(", "SM1_TDeviceData", "*", ")", "DeviceDataPtr", ";", "switch", "(", "ClockConfiguration", ")", "{", "case", "CPU_CLOCK_CONFIG_0", ":", "DeviceDataPrv", "->", "EnMode", "=", "TRUE", ";", "SPI_PDD_WriteMasterClockTransferAttributeReg", "(", "SPI0_BASE_PTR", ",", "0U", ",", "0xBA56CCC1U", ")", ";", "break", ";", "default", ":", "DeviceDataPrv", "->", "EnMode", "=", "FALSE", ";", "break", ";", "}", "HWEnDi", "(", "DeviceDataPtr", ")", ";", "}" ]
Method : SM1_SetClockConfiguration (component SPIMaster_LDD) Description : This method changes the clock configuration.
[ "Method", ":", "SM1_SetClockConfiguration", "(", "component", "SPIMaster_LDD", ")", "Description", ":", "This", "method", "changes", "the", "clock", "configuration", "." ]
[ "/* Set the flag \"device enabled\" in the actual speed CPU mode */", "/* Set required configuration */", "/* Set the flag \"device disabled\" in the actual speed CPU mode */", "/* Enable/disable device according to status flags */" ]
[ { "param": "DeviceDataPtr", "type": "LDD_TDeviceData" }, { "param": "ClockConfiguration", "type": "LDD_TClockConfiguration" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "DeviceDataPtr", "type": "LDD_TDeviceData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ClockConfiguration", "type": "LDD_TClockConfiguration", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bec5895ca5b3872a9481f5cdeee9553dafdcf176
joeljk13/C-Libs
src/alloc.c
[ "MIT" ]
C
mem_fail
void
static void mem_fail(size_t bytes, int line, const char *file) { ASSUME(line >= 0); ASSUME(file != NULL); fprintf(stderr, "Memory failure!\n\tLine: %i\n\tFile: %s\n\tBytes: %zu\n", line, file, bytes); }
// The line might not always be exactly right, but it should be close enough to // identify where the error occured
The line might not always be exactly right, but it should be close enough to identify where the error occured
[ "The", "line", "might", "not", "always", "be", "exactly", "right", "but", "it", "should", "be", "close", "enough", "to", "identify", "where", "the", "error", "occured" ]
static void mem_fail(size_t bytes, int line, const char *file) { ASSUME(line >= 0); ASSUME(file != NULL); fprintf(stderr, "Memory failure!\n\tLine: %i\n\tFile: %s\n\tBytes: %zu\n", line, file, bytes); }
[ "static", "void", "mem_fail", "(", "size_t", "bytes", ",", "int", "line", ",", "const", "char", "*", "file", ")", "{", "ASSUME", "(", "line", ">=", "0", ")", ";", "ASSUME", "(", "file", "!=", "NULL", ")", ";", "fprintf", "(", "stderr", ",", "\"", "\\n", "\\t", "\\n", "\\t", "\\n", "\\t", "\\n", "\"", ",", "line", ",", "file", ",", "bytes", ")", ";", "}" ]
The line might not always be exactly right, but it should be close enough to identify where the error occured
[ "The", "line", "might", "not", "always", "be", "exactly", "right", "but", "it", "should", "be", "close", "enough", "to", "identify", "where", "the", "error", "occured" ]
[]
[ { "param": "bytes", "type": "size_t" }, { "param": "line", "type": "int" }, { "param": "file", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bytes", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "line", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "file", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cb6b3d528cfa772bb42409af522156816e2ca025
PubInv/PIRDS-logger
pirds_logger.c
[ "MIT" ]
C
copy_file
int
int copy_file(char path_to_read_file[], char path_to_write_file[]) { char chr; FILE *stream_for_write, *stream_for_read; if ((stream_for_write = fopen(path_to_write_file, "w")) == NULL) { fprintf(stderr, "%s: %s\n", "Impossible to create a file", path_to_write_file); return -1; } if ((stream_for_read = fopen(path_to_read_file, "r")) == NULL) { fprintf(stderr, "%s: %s\n", "Impossible to read a file", path_to_read_file); return -1; } while (!feof(stream_for_read)) { char chr = fgetc(stream_for_read); fputc(chr, stream_for_write); } fclose(stream_for_write); fclose(stream_for_read); return 0; }
/** * Copy content from one file to other file. */
Copy content from one file to other file.
[ "Copy", "content", "from", "one", "file", "to", "other", "file", "." ]
int copy_file(char path_to_read_file[], char path_to_write_file[]) { char chr; FILE *stream_for_write, *stream_for_read; if ((stream_for_write = fopen(path_to_write_file, "w")) == NULL) { fprintf(stderr, "%s: %s\n", "Impossible to create a file", path_to_write_file); return -1; } if ((stream_for_read = fopen(path_to_read_file, "r")) == NULL) { fprintf(stderr, "%s: %s\n", "Impossible to read a file", path_to_read_file); return -1; } while (!feof(stream_for_read)) { char chr = fgetc(stream_for_read); fputc(chr, stream_for_write); } fclose(stream_for_write); fclose(stream_for_read); return 0; }
[ "int", "copy_file", "(", "char", "path_to_read_file", "[", "]", ",", "char", "path_to_write_file", "[", "]", ")", "{", "char", "chr", ";", "FILE", "*", "stream_for_write", ",", "*", "stream_for_read", ";", "if", "(", "(", "stream_for_write", "=", "fopen", "(", "path_to_write_file", ",", "\"", "\"", ")", ")", "==", "NULL", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "\"", "\"", ",", "path_to_write_file", ")", ";", "return", "-1", ";", "}", "if", "(", "(", "stream_for_read", "=", "fopen", "(", "path_to_read_file", ",", "\"", "\"", ")", ")", "==", "NULL", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "\"", "\"", ",", "path_to_read_file", ")", ";", "return", "-1", ";", "}", "while", "(", "!", "feof", "(", "stream_for_read", ")", ")", "{", "char", "chr", "=", "fgetc", "(", "stream_for_read", ")", ";", "fputc", "(", "chr", ",", "stream_for_write", ")", ";", "}", "fclose", "(", "stream_for_write", ")", ";", "fclose", "(", "stream_for_read", ")", ";", "return", "0", ";", "}" ]
Copy content from one file to other file.
[ "Copy", "content", "from", "one", "file", "to", "other", "file", "." ]
[]
[ { "param": "path_to_read_file", "type": "char" }, { "param": "path_to_write_file", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path_to_read_file", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "path_to_write_file", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cb6b3d528cfa772bb42409af522156816e2ca025
PubInv/PIRDS-logger
pirds_logger.c
[ "MIT" ]
C
print_json
void
void print_json(void *buff) { char *ptr = strchr(buff, '\n'); if (ptr) *ptr = '\0'; if ((ptr = strchr(buff, '\r'))) *ptr = '\0'; fprintf(gFOUTPUT, "%s\n", (char *)buff); }
// I'm confused as to what this does! - rlr
I'm confused as to what this does. - rlr
[ "I", "'", "m", "confused", "as", "to", "what", "this", "does", ".", "-", "rlr" ]
void print_json(void *buff) { char *ptr = strchr(buff, '\n'); if (ptr) *ptr = '\0'; if ((ptr = strchr(buff, '\r'))) *ptr = '\0'; fprintf(gFOUTPUT, "%s\n", (char *)buff); }
[ "void", "print_json", "(", "void", "*", "buff", ")", "{", "char", "*", "ptr", "=", "strchr", "(", "buff", ",", "'", "\\n", "'", ")", ";", "if", "(", "ptr", ")", "*", "ptr", "=", "'", "\\0", "'", ";", "if", "(", "(", "ptr", "=", "strchr", "(", "buff", ",", "'", "\\r", "'", ")", ")", ")", "*", "ptr", "=", "'", "\\0", "'", ";", "fprintf", "(", "gFOUTPUT", ",", "\"", "\\n", "\"", ",", "(", "char", "*", ")", "buff", ")", ";", "}" ]
I'm confused as to what this does!
[ "I", "'", "m", "confused", "as", "to", "what", "this", "does!" ]
[]
[ { "param": "buff", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buff", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4bb887fe641374e0de486f47708401b506bbf374
ict-wzq/RedisGraph
src/commands/cmd_dispatcher.c
[ "Ruby", "ISC", "MIT" ]
C
_read_flags
int
static int _read_flags(RedisModuleString **argv, int argc, bool *compact, long long *timeout, char **errmsg) { ASSERT(compact); ASSERT(timeout); // set defaults *timeout = 0; // no timeout *compact = false; // verbose // GRAPH.QUERY <GRAPH_KEY> <QUERY> // make sure we've got more than 3 arguments if(argc <= 3) return REDISMODULE_OK; // scan arguments for(int i = 3; i < argc; i++) { const char *arg = RedisModule_StringPtrLen(argv[i], NULL); // compact result-set if(!strcasecmp(arg, "--compact")) { *compact = true; continue; } // query timeout if(!strcasecmp(arg, "timeout")) { int err = REDISMODULE_ERR; if(i < argc - 1) { i++; // Set the current argument to the timeout value. err = RedisModule_StringToLongLong(argv[i], timeout); } // Emit error on missing, negative, or non-numeric timeout values. if(err != REDISMODULE_OK || *timeout < 0) { asprintf(errmsg, "Failed to parse query timeout value"); return REDISMODULE_ERR; } } } return REDISMODULE_OK; }
// Read configuration flags, returning REDIS_MODULE_ERR if flag parsing failed.
Read configuration flags, returning REDIS_MODULE_ERR if flag parsing failed.
[ "Read", "configuration", "flags", "returning", "REDIS_MODULE_ERR", "if", "flag", "parsing", "failed", "." ]
static int _read_flags(RedisModuleString **argv, int argc, bool *compact, long long *timeout, char **errmsg) { ASSERT(compact); ASSERT(timeout); *timeout = 0; *compact = false; if(argc <= 3) return REDISMODULE_OK; for(int i = 3; i < argc; i++) { const char *arg = RedisModule_StringPtrLen(argv[i], NULL); if(!strcasecmp(arg, "--compact")) { *compact = true; continue; } if(!strcasecmp(arg, "timeout")) { int err = REDISMODULE_ERR; if(i < argc - 1) { i++; err = RedisModule_StringToLongLong(argv[i], timeout); } if(err != REDISMODULE_OK || *timeout < 0) { asprintf(errmsg, "Failed to parse query timeout value"); return REDISMODULE_ERR; } } } return REDISMODULE_OK; }
[ "static", "int", "_read_flags", "(", "RedisModuleString", "*", "*", "argv", ",", "int", "argc", ",", "bool", "*", "compact", ",", "long", "long", "*", "timeout", ",", "char", "*", "*", "errmsg", ")", "{", "ASSERT", "(", "compact", ")", ";", "ASSERT", "(", "timeout", ")", ";", "*", "timeout", "=", "0", ";", "*", "compact", "=", "false", ";", "if", "(", "argc", "<=", "3", ")", "return", "REDISMODULE_OK", ";", "for", "(", "int", "i", "=", "3", ";", "i", "<", "argc", ";", "i", "++", ")", "{", "const", "char", "*", "arg", "=", "RedisModule_StringPtrLen", "(", "argv", "[", "i", "]", ",", "NULL", ")", ";", "if", "(", "!", "strcasecmp", "(", "arg", ",", "\"", "\"", ")", ")", "{", "*", "compact", "=", "true", ";", "continue", ";", "}", "if", "(", "!", "strcasecmp", "(", "arg", ",", "\"", "\"", ")", ")", "{", "int", "err", "=", "REDISMODULE_ERR", ";", "if", "(", "i", "<", "argc", "-", "1", ")", "{", "i", "++", ";", "err", "=", "RedisModule_StringToLongLong", "(", "argv", "[", "i", "]", ",", "timeout", ")", ";", "}", "if", "(", "err", "!=", "REDISMODULE_OK", "||", "*", "timeout", "<", "0", ")", "{", "asprintf", "(", "errmsg", ",", "\"", "\"", ")", ";", "return", "REDISMODULE_ERR", ";", "}", "}", "}", "return", "REDISMODULE_OK", ";", "}" ]
Read configuration flags, returning REDIS_MODULE_ERR if flag parsing failed.
[ "Read", "configuration", "flags", "returning", "REDIS_MODULE_ERR", "if", "flag", "parsing", "failed", "." ]
[ "// set defaults\r", "// no timeout\r", "// verbose\r", "// GRAPH.QUERY <GRAPH_KEY> <QUERY>\r", "// make sure we've got more than 3 arguments\r", "// scan arguments\r", "// compact result-set\r", "// query timeout\r", "// Set the current argument to the timeout value.\r", "// Emit error on missing, negative, or non-numeric timeout values.\r" ]
[ { "param": "argv", "type": "RedisModuleString" }, { "param": "argc", "type": "int" }, { "param": "compact", "type": "bool" }, { "param": "timeout", "type": "long long" }, { "param": "errmsg", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argv", "type": "RedisModuleString", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "compact", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "timeout", "type": "long long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "errmsg", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4bb887fe641374e0de486f47708401b506bbf374
ict-wzq/RedisGraph
src/commands/cmd_dispatcher.c
[ "Ruby", "ISC", "MIT" ]
C
_validate_command_arity
bool
static inline bool _validate_command_arity(GRAPH_Commands cmd, int arity) { switch(cmd) { case CMD_QUERY: case CMD_RO_QUERY: case CMD_EXPLAIN: case CMD_PROFILE: // Expect a command, graph name, a query, and optional config flags. return arity >= 3 && arity <= 6; case CMD_SLOWLOG: // Expect just a command and graph name. return arity == 2; default: assert("encountered unhandled query type" && false); } }
// Return true if the command has a valid number of arguments.
Return true if the command has a valid number of arguments.
[ "Return", "true", "if", "the", "command", "has", "a", "valid", "number", "of", "arguments", "." ]
static inline bool _validate_command_arity(GRAPH_Commands cmd, int arity) { switch(cmd) { case CMD_QUERY: case CMD_RO_QUERY: case CMD_EXPLAIN: case CMD_PROFILE: return arity >= 3 && arity <= 6; case CMD_SLOWLOG: return arity == 2; default: assert("encountered unhandled query type" && false); } }
[ "static", "inline", "bool", "_validate_command_arity", "(", "GRAPH_Commands", "cmd", ",", "int", "arity", ")", "{", "switch", "(", "cmd", ")", "{", "case", "CMD_QUERY", ":", "case", "CMD_RO_QUERY", ":", "case", "CMD_EXPLAIN", ":", "case", "CMD_PROFILE", ":", "return", "arity", ">=", "3", "&&", "arity", "<=", "6", ";", "case", "CMD_SLOWLOG", ":", "return", "arity", "==", "2", ";", "default", ":", "assert", "(", "\"", "\"", "&&", "false", ")", ";", "}", "}" ]
Return true if the command has a valid number of arguments.
[ "Return", "true", "if", "the", "command", "has", "a", "valid", "number", "of", "arguments", "." ]
[ "// Expect a command, graph name, a query, and optional config flags.\r", "// Expect just a command and graph name.\r" ]
[ { "param": "cmd", "type": "GRAPH_Commands" }, { "param": "arity", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "GRAPH_Commands", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arity", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
_leftMostNode
AlgebraicExpression
static AlgebraicExpression *_leftMostNode(AlgebraicExpression *exp) { AlgebraicExpression *left_most = exp; while(left_most->type == AL_OPERATION && AlgebraicExpression_ChildCount(left_most) > 0) { left_most = FIRST_CHILD(left_most); } return left_most; }
// Locate the left most node in `exp`
Locate the left most node in `exp`
[ "Locate", "the", "left", "most", "node", "in", "`", "exp", "`" ]
static AlgebraicExpression *_leftMostNode(AlgebraicExpression *exp) { AlgebraicExpression *left_most = exp; while(left_most->type == AL_OPERATION && AlgebraicExpression_ChildCount(left_most) > 0) { left_most = FIRST_CHILD(left_most); } return left_most; }
[ "static", "AlgebraicExpression", "*", "_leftMostNode", "(", "AlgebraicExpression", "*", "exp", ")", "{", "AlgebraicExpression", "*", "left_most", "=", "exp", ";", "while", "(", "left_most", "->", "type", "==", "AL_OPERATION", "&&", "AlgebraicExpression_ChildCount", "(", "left_most", ")", ">", "0", ")", "{", "left_most", "=", "FIRST_CHILD", "(", "left_most", ")", ";", "}", "return", "left_most", ";", "}" ]
Locate the left most node in `exp`
[ "Locate", "the", "left", "most", "node", "in", "`", "exp", "`" ]
[]
[ { "param": "exp", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "exp", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
_rightMostNode
AlgebraicExpression
static AlgebraicExpression *_rightMostNode(AlgebraicExpression *exp) { AlgebraicExpression *right_most = exp; while(right_most->type == AL_OPERATION && AlgebraicExpression_ChildCount(right_most) > 0) { right_most = LAST_CHILD(right_most); } return right_most; }
// Locate the right most node in `exp`
Locate the right most node in `exp`
[ "Locate", "the", "right", "most", "node", "in", "`", "exp", "`" ]
static AlgebraicExpression *_rightMostNode(AlgebraicExpression *exp) { AlgebraicExpression *right_most = exp; while(right_most->type == AL_OPERATION && AlgebraicExpression_ChildCount(right_most) > 0) { right_most = LAST_CHILD(right_most); } return right_most; }
[ "static", "AlgebraicExpression", "*", "_rightMostNode", "(", "AlgebraicExpression", "*", "exp", ")", "{", "AlgebraicExpression", "*", "right_most", "=", "exp", ";", "while", "(", "right_most", "->", "type", "==", "AL_OPERATION", "&&", "AlgebraicExpression_ChildCount", "(", "right_most", ")", ">", "0", ")", "{", "right_most", "=", "LAST_CHILD", "(", "right_most", ")", ";", "}", "return", "right_most", ";", "}" ]
Locate the right most node in `exp`
[ "Locate", "the", "right", "most", "node", "in", "`", "exp", "`" ]
[]
[ { "param": "exp", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "exp", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_NewOperand
AlgebraicExpression
AlgebraicExpression *AlgebraicExpression_NewOperand ( GrB_Matrix mat, // Matrix. bool diagonal, // Is operand a diagonal matrix? const char *src, // Operand row domain (src node). const char *dest, // Operand column domain (destination node). const char *edge, // Operand alias (edge). const char *label // Label attached to matrix. ) { AlgebraicExpression *node = rm_malloc(sizeof(AlgebraicExpression)); node->type = AL_OPERAND; node->operand.matrix = mat; node->operand.diagonal = diagonal; node->operand.bfree = false; node->operand.src = src; node->operand.dest = dest; node->operand.edge = edge; node->operand.label = label; return node; }
// Create a new AlgebraicExpression operand node.
Create a new AlgebraicExpression operand node.
[ "Create", "a", "new", "AlgebraicExpression", "operand", "node", "." ]
AlgebraicExpression *AlgebraicExpression_NewOperand ( GrB_Matrix mat, bool diagonal, const char *src, const char *dest, const char *edge, const char *label ) { AlgebraicExpression *node = rm_malloc(sizeof(AlgebraicExpression)); node->type = AL_OPERAND; node->operand.matrix = mat; node->operand.diagonal = diagonal; node->operand.bfree = false; node->operand.src = src; node->operand.dest = dest; node->operand.edge = edge; node->operand.label = label; return node; }
[ "AlgebraicExpression", "*", "AlgebraicExpression_NewOperand", "(", "GrB_Matrix", "mat", ",", "bool", "diagonal", ",", "const", "char", "*", "src", ",", "const", "char", "*", "dest", ",", "const", "char", "*", "edge", ",", "const", "char", "*", "label", ")", "{", "AlgebraicExpression", "*", "node", "=", "rm_malloc", "(", "sizeof", "(", "AlgebraicExpression", ")", ")", ";", "node", "->", "type", "=", "AL_OPERAND", ";", "node", "->", "operand", ".", "matrix", "=", "mat", ";", "node", "->", "operand", ".", "diagonal", "=", "diagonal", ";", "node", "->", "operand", ".", "bfree", "=", "false", ";", "node", "->", "operand", ".", "src", "=", "src", ";", "node", "->", "operand", ".", "dest", "=", "dest", ";", "node", "->", "operand", ".", "edge", "=", "edge", ";", "node", "->", "operand", ".", "label", "=", "label", ";", "return", "node", ";", "}" ]
Create a new AlgebraicExpression operand node.
[ "Create", "a", "new", "AlgebraicExpression", "operand", "node", "." ]
[ "// Matrix.\r", "// Is operand a diagonal matrix?\r", "// Operand row domain (src node).\r", "// Operand column domain (destination node).\r", "// Operand alias (edge).\r", "// Label attached to matrix.\r" ]
[ { "param": "mat", "type": "GrB_Matrix" }, { "param": "diagonal", "type": "bool" }, { "param": "src", "type": "char" }, { "param": "dest", "type": "char" }, { "param": "edge", "type": "char" }, { "param": "label", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mat", "type": "GrB_Matrix", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "diagonal", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dest", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "edge", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "label", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
_AlgebraicExpression_Operation_Source
char
static const char *_AlgebraicExpression_Operation_Source ( AlgebraicExpression *root, // Root of expression. bool transposed // Is root transposed ) { switch(root->operation.op) { case AL_EXP_ADD: // Src (A+B) = Src(A) // Src (Transpose(A+B)) = Src (Transpose(A)+Transpose(B)) = Src (Transpose(A)) return _AlgebraicExpression_Source(FIRST_CHILD(root), transposed); case AL_EXP_MUL: // Src (A*B) = Src(A) // Src (Transpose(A*B)) = Src (Transpose(B)*Transpose(A)) = Src (Transpose(B)) if(transposed) return _AlgebraicExpression_Source(LAST_CHILD(root), transposed); else return _AlgebraicExpression_Source(FIRST_CHILD(root), transposed); case AL_EXP_TRANSPOSE: // Src (Transpose(Transpose(A))) = Src(A) // Negate transpose. return _AlgebraicExpression_Source(FIRST_CHILD(root), !transposed); default: assert("Unknown algebraic expression operation" && false); } }
// Returns the source entity alias (row domain) // Taking into consideration transpose
Returns the source entity alias (row domain) Taking into consideration transpose
[ "Returns", "the", "source", "entity", "alias", "(", "row", "domain", ")", "Taking", "into", "consideration", "transpose" ]
static const char *_AlgebraicExpression_Operation_Source ( AlgebraicExpression *root, bool transposed ) { switch(root->operation.op) { case AL_EXP_ADD: return _AlgebraicExpression_Source(FIRST_CHILD(root), transposed); case AL_EXP_MUL: if(transposed) return _AlgebraicExpression_Source(LAST_CHILD(root), transposed); else return _AlgebraicExpression_Source(FIRST_CHILD(root), transposed); case AL_EXP_TRANSPOSE: return _AlgebraicExpression_Source(FIRST_CHILD(root), !transposed); default: assert("Unknown algebraic expression operation" && false); } }
[ "static", "const", "char", "*", "_AlgebraicExpression_Operation_Source", "(", "AlgebraicExpression", "*", "root", ",", "bool", "transposed", ")", "{", "switch", "(", "root", "->", "operation", ".", "op", ")", "{", "case", "AL_EXP_ADD", ":", "return", "_AlgebraicExpression_Source", "(", "FIRST_CHILD", "(", "root", ")", ",", "transposed", ")", ";", "case", "AL_EXP_MUL", ":", "if", "(", "transposed", ")", "return", "_AlgebraicExpression_Source", "(", "LAST_CHILD", "(", "root", ")", ",", "transposed", ")", ";", "else", "return", "_AlgebraicExpression_Source", "(", "FIRST_CHILD", "(", "root", ")", ",", "transposed", ")", ";", "case", "AL_EXP_TRANSPOSE", ":", "return", "_AlgebraicExpression_Source", "(", "FIRST_CHILD", "(", "root", ")", ",", "!", "transposed", ")", ";", "default", ":", "assert", "(", "\"", "\"", "&&", "false", ")", ";", "}", "}" ]
Returns the source entity alias (row domain) Taking into consideration transpose
[ "Returns", "the", "source", "entity", "alias", "(", "row", "domain", ")", "Taking", "into", "consideration", "transpose" ]
[ "// Root of expression.\r", "// Is root transposed\r", "// Src (A+B) = Src(A)\r", "// Src (Transpose(A+B)) = Src (Transpose(A)+Transpose(B)) = Src (Transpose(A))\r", "// Src (A*B) = Src(A)\r", "// Src (Transpose(A*B)) = Src (Transpose(B)*Transpose(A)) = Src (Transpose(B))\r", "// Src (Transpose(Transpose(A))) = Src(A)\r", "// Negate transpose.\r" ]
[ { "param": "root", "type": "AlgebraicExpression" }, { "param": "transposed", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "transposed", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
_AlgebraicExpression_Operand_Source
char
static const char *_AlgebraicExpression_Operand_Source ( AlgebraicExpression *root, // Root of expression. bool transposed // Is root transposed ) { return (transposed) ? root->operand.dest : root->operand.src; }
// Returns the source entity alias (row domain) // Taking into consideration transpose
Returns the source entity alias (row domain) Taking into consideration transpose
[ "Returns", "the", "source", "entity", "alias", "(", "row", "domain", ")", "Taking", "into", "consideration", "transpose" ]
static const char *_AlgebraicExpression_Operand_Source ( AlgebraicExpression *root, bool transposed ) { return (transposed) ? root->operand.dest : root->operand.src; }
[ "static", "const", "char", "*", "_AlgebraicExpression_Operand_Source", "(", "AlgebraicExpression", "*", "root", ",", "bool", "transposed", ")", "{", "return", "(", "transposed", ")", "?", "root", "->", "operand", ".", "dest", ":", "root", "->", "operand", ".", "src", ";", "}" ]
Returns the source entity alias (row domain) Taking into consideration transpose
[ "Returns", "the", "source", "entity", "alias", "(", "row", "domain", ")", "Taking", "into", "consideration", "transpose" ]
[ "// Root of expression.\r", "// Is root transposed\r" ]
[ { "param": "root", "type": "AlgebraicExpression" }, { "param": "transposed", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "transposed", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
_AlgebraicExpression_Source
char
static const char *_AlgebraicExpression_Source ( AlgebraicExpression *root, // Root of expression. bool transposed // Is root transposed ) { assert(root); switch(root->type) { case AL_OPERATION: return _AlgebraicExpression_Operation_Source(root, transposed); case AL_OPERAND: return _AlgebraicExpression_Operand_Source(root, transposed); default: assert("Unknown algebraic expression node type" && false); } }
// Returns the source entity alias (row domain) // Taking into consideration transpose
Returns the source entity alias (row domain) Taking into consideration transpose
[ "Returns", "the", "source", "entity", "alias", "(", "row", "domain", ")", "Taking", "into", "consideration", "transpose" ]
static const char *_AlgebraicExpression_Source ( AlgebraicExpression *root, bool transposed ) { assert(root); switch(root->type) { case AL_OPERATION: return _AlgebraicExpression_Operation_Source(root, transposed); case AL_OPERAND: return _AlgebraicExpression_Operand_Source(root, transposed); default: assert("Unknown algebraic expression node type" && false); } }
[ "static", "const", "char", "*", "_AlgebraicExpression_Source", "(", "AlgebraicExpression", "*", "root", ",", "bool", "transposed", ")", "{", "assert", "(", "root", ")", ";", "switch", "(", "root", "->", "type", ")", "{", "case", "AL_OPERATION", ":", "return", "_AlgebraicExpression_Operation_Source", "(", "root", ",", "transposed", ")", ";", "case", "AL_OPERAND", ":", "return", "_AlgebraicExpression_Operand_Source", "(", "root", ",", "transposed", ")", ";", "default", ":", "assert", "(", "\"", "\"", "&&", "false", ")", ";", "}", "}" ]
Returns the source entity alias (row domain) Taking into consideration transpose
[ "Returns", "the", "source", "entity", "alias", "(", "row", "domain", ")", "Taking", "into", "consideration", "transpose" ]
[ "// Root of expression.\r", "// Is root transposed\r" ]
[ { "param": "root", "type": "AlgebraicExpression" }, { "param": "transposed", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "transposed", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_Source
char
const char *AlgebraicExpression_Source ( AlgebraicExpression *root // Root of expression. ) { assert(root); return _AlgebraicExpression_Source(root, false); }
// Returns the source entity alias, row domain.
Returns the source entity alias, row domain.
[ "Returns", "the", "source", "entity", "alias", "row", "domain", "." ]
const char *AlgebraicExpression_Source ( AlgebraicExpression *root ) { assert(root); return _AlgebraicExpression_Source(root, false); }
[ "const", "char", "*", "AlgebraicExpression_Source", "(", "AlgebraicExpression", "*", "root", ")", "{", "assert", "(", "root", ")", ";", "return", "_AlgebraicExpression_Source", "(", "root", ",", "false", ")", ";", "}" ]
Returns the source entity alias, row domain.
[ "Returns", "the", "source", "entity", "alias", "row", "domain", "." ]
[ "// Root of expression.\r" ]
[ { "param": "root", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_Destination
char
const char *AlgebraicExpression_Destination ( AlgebraicExpression *root // Root of expression. ) { assert(root); // Dest(exp) = Src(Transpose(exp)) // Gotta love it! return _AlgebraicExpression_Source(root, true); }
// Returns the destination entity alias represented by the right-most operand column domain.
Returns the destination entity alias represented by the right-most operand column domain.
[ "Returns", "the", "destination", "entity", "alias", "represented", "by", "the", "right", "-", "most", "operand", "column", "domain", "." ]
const char *AlgebraicExpression_Destination ( AlgebraicExpression *root ) { assert(root); return _AlgebraicExpression_Source(root, true); }
[ "const", "char", "*", "AlgebraicExpression_Destination", "(", "AlgebraicExpression", "*", "root", ")", "{", "assert", "(", "root", ")", ";", "return", "_AlgebraicExpression_Source", "(", "root", ",", "true", ")", ";", "}" ]
Returns the destination entity alias represented by the right-most operand column domain.
[ "Returns", "the", "destination", "entity", "alias", "represented", "by", "the", "right", "-", "most", "operand", "column", "domain", "." ]
[ "// Root of expression.\r", "// Dest(exp) = Src(Transpose(exp))\r", "// Gotta love it!\r" ]
[ { "param": "root", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_Edge
char
const char *AlgebraicExpression_Edge ( const AlgebraicExpression *root // Root of expression. ) { assert(root); uint child_count = 0; const char *edge = NULL; switch(root->type) { case AL_OPERATION: child_count = AlgebraicExpression_ChildCount(root); for(uint i = 0; i < child_count; i++) { edge = AlgebraicExpression_Edge(CHILD_AT(root, i)); if(edge) return edge; } break; case AL_OPERAND: return root->operand.edge; } return NULL; }
/* Returns the first edge alias encountered. * if no edge alias is found NULL is returned. */
Returns the first edge alias encountered. if no edge alias is found NULL is returned.
[ "Returns", "the", "first", "edge", "alias", "encountered", ".", "if", "no", "edge", "alias", "is", "found", "NULL", "is", "returned", "." ]
const char *AlgebraicExpression_Edge ( const AlgebraicExpression *root ) { assert(root); uint child_count = 0; const char *edge = NULL; switch(root->type) { case AL_OPERATION: child_count = AlgebraicExpression_ChildCount(root); for(uint i = 0; i < child_count; i++) { edge = AlgebraicExpression_Edge(CHILD_AT(root, i)); if(edge) return edge; } break; case AL_OPERAND: return root->operand.edge; } return NULL; }
[ "const", "char", "*", "AlgebraicExpression_Edge", "(", "const", "AlgebraicExpression", "*", "root", ")", "{", "assert", "(", "root", ")", ";", "uint", "child_count", "=", "0", ";", "const", "char", "*", "edge", "=", "NULL", ";", "switch", "(", "root", "->", "type", ")", "{", "case", "AL_OPERATION", ":", "child_count", "=", "AlgebraicExpression_ChildCount", "(", "root", ")", ";", "for", "(", "uint", "i", "=", "0", ";", "i", "<", "child_count", ";", "i", "++", ")", "{", "edge", "=", "AlgebraicExpression_Edge", "(", "CHILD_AT", "(", "root", ",", "i", ")", ")", ";", "if", "(", "edge", ")", "return", "edge", ";", "}", "break", ";", "case", "AL_OPERAND", ":", "return", "root", "->", "operand", ".", "edge", ";", "}", "return", "NULL", ";", "}" ]
Returns the first edge alias encountered.
[ "Returns", "the", "first", "edge", "alias", "encountered", "." ]
[ "// Root of expression.\r" ]
[ { "param": "root", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_ChildCount
uint
uint AlgebraicExpression_ChildCount ( const AlgebraicExpression *root // Root of expression. ) { // Empty expression. if(!root) return 0; if(root->type == AL_OPERATION) return array_len(root->operation.children); else return 0; }
// Returns the number of child nodes directly under root.
Returns the number of child nodes directly under root.
[ "Returns", "the", "number", "of", "child", "nodes", "directly", "under", "root", "." ]
uint AlgebraicExpression_ChildCount ( const AlgebraicExpression *root ) { if(!root) return 0; if(root->type == AL_OPERATION) return array_len(root->operation.children); else return 0; }
[ "uint", "AlgebraicExpression_ChildCount", "(", "const", "AlgebraicExpression", "*", "root", ")", "{", "if", "(", "!", "root", ")", "return", "0", ";", "if", "(", "root", "->", "type", "==", "AL_OPERATION", ")", "return", "array_len", "(", "root", "->", "operation", ".", "children", ")", ";", "else", "return", "0", ";", "}" ]
Returns the number of child nodes directly under root.
[ "Returns", "the", "number", "of", "child", "nodes", "directly", "under", "root", "." ]
[ "// Root of expression.\r", "// Empty expression.\r" ]
[ { "param": "root", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_OperandCount
uint
uint AlgebraicExpression_OperandCount ( const AlgebraicExpression *root ) { // Empty expression. if(!root) return 0; uint operand_count = 0; uint child_count = 0; switch(root->type) { case AL_OPERATION: child_count = AlgebraicExpression_ChildCount(root); for(uint i = 0; i < child_count; i++) { operand_count += AlgebraicExpression_OperandCount(CHILD_AT(root, i)); } break; case AL_OPERAND: operand_count = 1; break; default: assert("Unknow algebraic expression node type" && false); break; } return operand_count; }
// Returns the number of operands in expression.
Returns the number of operands in expression.
[ "Returns", "the", "number", "of", "operands", "in", "expression", "." ]
uint AlgebraicExpression_OperandCount ( const AlgebraicExpression *root ) { if(!root) return 0; uint operand_count = 0; uint child_count = 0; switch(root->type) { case AL_OPERATION: child_count = AlgebraicExpression_ChildCount(root); for(uint i = 0; i < child_count; i++) { operand_count += AlgebraicExpression_OperandCount(CHILD_AT(root, i)); } break; case AL_OPERAND: operand_count = 1; break; default: assert("Unknow algebraic expression node type" && false); break; } return operand_count; }
[ "uint", "AlgebraicExpression_OperandCount", "(", "const", "AlgebraicExpression", "*", "root", ")", "{", "if", "(", "!", "root", ")", "return", "0", ";", "uint", "operand_count", "=", "0", ";", "uint", "child_count", "=", "0", ";", "switch", "(", "root", "->", "type", ")", "{", "case", "AL_OPERATION", ":", "child_count", "=", "AlgebraicExpression_ChildCount", "(", "root", ")", ";", "for", "(", "uint", "i", "=", "0", ";", "i", "<", "child_count", ";", "i", "++", ")", "{", "operand_count", "+=", "AlgebraicExpression_OperandCount", "(", "CHILD_AT", "(", "root", ",", "i", ")", ")", ";", "}", "break", ";", "case", "AL_OPERAND", ":", "operand_count", "=", "1", ";", "break", ";", "default", ":", "assert", "(", "\"", "\"", "&&", "false", ")", ";", "break", ";", "}", "return", "operand_count", ";", "}" ]
Returns the number of operands in expression.
[ "Returns", "the", "number", "of", "operands", "in", "expression", "." ]
[ "// Empty expression.\r" ]
[ { "param": "root", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_OperationCount
uint
uint AlgebraicExpression_OperationCount ( const AlgebraicExpression *root, AL_EXP_OP op_type ) { // Empty expression. if(!root) return 0; uint op_count = 0; if(root->type == AL_OPERATION) { if(root->operation.op & op_type) op_count = 1; uint child_count = AlgebraicExpression_ChildCount(root); for(uint i = 0; i < child_count; i++) { op_count += AlgebraicExpression_OperationCount(CHILD_AT(root, i), op_type); } } return op_count; }
// Returns the number of operations in expression.
Returns the number of operations in expression.
[ "Returns", "the", "number", "of", "operations", "in", "expression", "." ]
uint AlgebraicExpression_OperationCount ( const AlgebraicExpression *root, AL_EXP_OP op_type ) { if(!root) return 0; uint op_count = 0; if(root->type == AL_OPERATION) { if(root->operation.op & op_type) op_count = 1; uint child_count = AlgebraicExpression_ChildCount(root); for(uint i = 0; i < child_count; i++) { op_count += AlgebraicExpression_OperationCount(CHILD_AT(root, i), op_type); } } return op_count; }
[ "uint", "AlgebraicExpression_OperationCount", "(", "const", "AlgebraicExpression", "*", "root", ",", "AL_EXP_OP", "op_type", ")", "{", "if", "(", "!", "root", ")", "return", "0", ";", "uint", "op_count", "=", "0", ";", "if", "(", "root", "->", "type", "==", "AL_OPERATION", ")", "{", "if", "(", "root", "->", "operation", ".", "op", "&", "op_type", ")", "op_count", "=", "1", ";", "uint", "child_count", "=", "AlgebraicExpression_ChildCount", "(", "root", ")", ";", "for", "(", "uint", "i", "=", "0", ";", "i", "<", "child_count", ";", "i", "++", ")", "{", "op_count", "+=", "AlgebraicExpression_OperationCount", "(", "CHILD_AT", "(", "root", ",", "i", ")", ",", "op_type", ")", ";", "}", "}", "return", "op_count", ";", "}" ]
Returns the number of operations in expression.
[ "Returns", "the", "number", "of", "operations", "in", "expression", "." ]
[ "// Empty expression.\r" ]
[ { "param": "root", "type": "AlgebraicExpression" }, { "param": "op_type", "type": "AL_EXP_OP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op_type", "type": "AL_EXP_OP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_Transposed
bool
bool AlgebraicExpression_Transposed ( const AlgebraicExpression *root // Root of expression. ) { // Empty expression. if(!root) return false; //TODO: handle cases such as T(A) + T(B). return (root->type == AL_OPERATION && root->operation.op == AL_EXP_TRANSPOSE); }
// Returns true if entire expression is transposed.
Returns true if entire expression is transposed.
[ "Returns", "true", "if", "entire", "expression", "is", "transposed", "." ]
bool AlgebraicExpression_Transposed ( const AlgebraicExpression *root ) { if(!root) return false; return (root->type == AL_OPERATION && root->operation.op == AL_EXP_TRANSPOSE); }
[ "bool", "AlgebraicExpression_Transposed", "(", "const", "AlgebraicExpression", "*", "root", ")", "{", "if", "(", "!", "root", ")", "return", "false", ";", "return", "(", "root", "->", "type", "==", "AL_OPERATION", "&&", "root", "->", "operation", ".", "op", "==", "AL_EXP_TRANSPOSE", ")", ";", "}" ]
Returns true if entire expression is transposed.
[ "Returns", "true", "if", "entire", "expression", "is", "transposed", "." ]
[ "// Root of expression.\r", "// Empty expression.\r", "//TODO: handle cases such as T(A) + T(B).\r" ]
[ { "param": "root", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_ContainsOp
bool
bool AlgebraicExpression_ContainsOp ( const AlgebraicExpression *root, AL_EXP_OP op ) { // Empty expression. if(!root) return false; if(root->type == AL_OPERATION) { if(root->operation.op == op) return true; uint child_count = AlgebraicExpression_ChildCount(root); for(uint i = 0; i < child_count; i++) { if(AlgebraicExpression_ContainsOp(CHILD_AT(root, i), op)) return true; } } return false; }
// Returns true if expression contains operation.
Returns true if expression contains operation.
[ "Returns", "true", "if", "expression", "contains", "operation", "." ]
bool AlgebraicExpression_ContainsOp ( const AlgebraicExpression *root, AL_EXP_OP op ) { if(!root) return false; if(root->type == AL_OPERATION) { if(root->operation.op == op) return true; uint child_count = AlgebraicExpression_ChildCount(root); for(uint i = 0; i < child_count; i++) { if(AlgebraicExpression_ContainsOp(CHILD_AT(root, i), op)) return true; } } return false; }
[ "bool", "AlgebraicExpression_ContainsOp", "(", "const", "AlgebraicExpression", "*", "root", ",", "AL_EXP_OP", "op", ")", "{", "if", "(", "!", "root", ")", "return", "false", ";", "if", "(", "root", "->", "type", "==", "AL_OPERATION", ")", "{", "if", "(", "root", "->", "operation", ".", "op", "==", "op", ")", "return", "true", ";", "uint", "child_count", "=", "AlgebraicExpression_ChildCount", "(", "root", ")", ";", "for", "(", "uint", "i", "=", "0", ";", "i", "<", "child_count", ";", "i", "++", ")", "{", "if", "(", "AlgebraicExpression_ContainsOp", "(", "CHILD_AT", "(", "root", ",", "i", ")", ",", "op", ")", ")", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if expression contains operation.
[ "Returns", "true", "if", "expression", "contains", "operation", "." ]
[ "// Empty expression.\r" ]
[ { "param": "root", "type": "AlgebraicExpression" }, { "param": "op", "type": "AL_EXP_OP" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "AL_EXP_OP", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_DiagonalOperand
bool
bool AlgebraicExpression_DiagonalOperand ( const AlgebraicExpression *root, // Root of expression. uint operand_idx // Operand position (LTR, zero based). ) { // Empty expression. if(!root) return false; const AlgebraicExpression *op = _AlgebraicExpression_GetOperand(root, operand_idx); assert(op && op->type == AL_OPERAND); return op->operand.diagonal; }
// Checks to see if operand at position `operand_idx` is a diagonal matrix.
Checks to see if operand at position `operand_idx` is a diagonal matrix.
[ "Checks", "to", "see", "if", "operand", "at", "position", "`", "operand_idx", "`", "is", "a", "diagonal", "matrix", "." ]
bool AlgebraicExpression_DiagonalOperand ( const AlgebraicExpression *root, uint operand_idx ) { if(!root) return false; const AlgebraicExpression *op = _AlgebraicExpression_GetOperand(root, operand_idx); assert(op && op->type == AL_OPERAND); return op->operand.diagonal; }
[ "bool", "AlgebraicExpression_DiagonalOperand", "(", "const", "AlgebraicExpression", "*", "root", ",", "uint", "operand_idx", ")", "{", "if", "(", "!", "root", ")", "return", "false", ";", "const", "AlgebraicExpression", "*", "op", "=", "_AlgebraicExpression_GetOperand", "(", "root", ",", "operand_idx", ")", ";", "assert", "(", "op", "&&", "op", "->", "type", "==", "AL_OPERAND", ")", ";", "return", "op", "->", "operand", ".", "diagonal", ";", "}" ]
Checks to see if operand at position `operand_idx` is a diagonal matrix.
[ "Checks", "to", "see", "if", "operand", "at", "position", "`", "operand_idx", "`", "is", "a", "diagonal", "matrix", "." ]
[ "// Root of expression.\r", "// Operand position (LTR, zero based).\r", "// Empty expression.\r" ]
[ { "param": "root", "type": "AlgebraicExpression" }, { "param": "operand_idx", "type": "uint" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "operand_idx", "type": "uint", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_AddChild
void
void AlgebraicExpression_AddChild ( AlgebraicExpression *root, // Root to attach child to. AlgebraicExpression *child // Child node to attach. ) { assert(root && root->type == AL_OPERATION); root->operation.children = array_append(root->operation.children, child); }
// Adds child node to root children list.
Adds child node to root children list.
[ "Adds", "child", "node", "to", "root", "children", "list", "." ]
void AlgebraicExpression_AddChild ( AlgebraicExpression *root, AlgebraicExpression *child ) { assert(root && root->type == AL_OPERATION); root->operation.children = array_append(root->operation.children, child); }
[ "void", "AlgebraicExpression_AddChild", "(", "AlgebraicExpression", "*", "root", ",", "AlgebraicExpression", "*", "child", ")", "{", "assert", "(", "root", "&&", "root", "->", "type", "==", "AL_OPERATION", ")", ";", "root", "->", "operation", ".", "children", "=", "array_append", "(", "root", "->", "operation", ".", "children", ",", "child", ")", ";", "}" ]
Adds child node to root children list.
[ "Adds", "child", "node", "to", "root", "children", "list", "." ]
[ "// Root to attach child to.\r", "// Child node to attach.\r" ]
[ { "param": "root", "type": "AlgebraicExpression" }, { "param": "child", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "child", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_RemoveSource
AlgebraicExpression
AlgebraicExpression *AlgebraicExpression_RemoveSource ( AlgebraicExpression **root // Root from which to remove left most child. ) { ASSERT(*root); bool transpose = false; AlgebraicExpression *prev = *root; AlgebraicExpression *current = *root; while(current->type == AL_OPERATION) { prev = current; switch(current->operation.op) { case AL_EXP_TRANSPOSE: transpose = !transpose; current = FIRST_CHILD(current); // transpose have only one child break; case AL_EXP_ADD: // Addition order of operands is not effected by transpose current = FIRST_CHILD(current); break; case AL_EXP_MUL: // Multiplication order of operands depends on transpose if(transpose) current = LAST_CHILD(current); else current = FIRST_CHILD(current); break; default: ASSERT("Unknown algebraic expression operation" && false); } } ASSERT(current->type == AL_OPERAND); if(prev == current) { /* Expression is just a single operand * return operand and update root to NULL. */ *root = NULL; return current; } switch(prev->operation.op) { case AL_EXP_TRANSPOSE: case AL_EXP_ADD: /* Transpose ops only have one child and the order of operands for * addition is not modified by transposition, so always remove the source. */ current = _AlgebraicExpression_OperationRemoveSource(prev); break; case AL_EXP_MUL: /* Remove the destination if we're in a transposed context, * otherwise remove the source. */ if(transpose) current = _AlgebraicExpression_OperationRemoveDest(prev); else current = _AlgebraicExpression_OperationRemoveSource(prev); break; default: ASSERT("Unknown algebraic expression operation" && false); } uint child_count = AlgebraicExpression_ChildCount(prev); if(child_count == 1) { /* If we just previous operation only has one remaining child, * it can be replaced by that child: * MUL(A,B) after removing A will become just B * Currently, this point is unreachable for transpose ops, * as at this point their child is always an operation. * If that changes, logic should be added such that: * TRANSPOSE(A) after removing A should become NULL. */ AlgebraicExpression *replacement = _AlgebraicExpression_OperationRemoveDest(prev); _AlgebraicExpression_InplaceRepurpose(prev, replacement); } return current; }
// Remove leftmost child node from root.
Remove leftmost child node from root.
[ "Remove", "leftmost", "child", "node", "from", "root", "." ]
AlgebraicExpression *AlgebraicExpression_RemoveSource ( AlgebraicExpression **root ) { ASSERT(*root); bool transpose = false; AlgebraicExpression *prev = *root; AlgebraicExpression *current = *root; while(current->type == AL_OPERATION) { prev = current; switch(current->operation.op) { case AL_EXP_TRANSPOSE: transpose = !transpose; current = FIRST_CHILD(current); break; case AL_EXP_ADD: current = FIRST_CHILD(current); break; case AL_EXP_MUL: if(transpose) current = LAST_CHILD(current); else current = FIRST_CHILD(current); break; default: ASSERT("Unknown algebraic expression operation" && false); } } ASSERT(current->type == AL_OPERAND); if(prev == current) { *root = NULL; return current; } switch(prev->operation.op) { case AL_EXP_TRANSPOSE: case AL_EXP_ADD: current = _AlgebraicExpression_OperationRemoveSource(prev); break; case AL_EXP_MUL: if(transpose) current = _AlgebraicExpression_OperationRemoveDest(prev); else current = _AlgebraicExpression_OperationRemoveSource(prev); break; default: ASSERT("Unknown algebraic expression operation" && false); } uint child_count = AlgebraicExpression_ChildCount(prev); if(child_count == 1) { AlgebraicExpression *replacement = _AlgebraicExpression_OperationRemoveDest(prev); _AlgebraicExpression_InplaceRepurpose(prev, replacement); } return current; }
[ "AlgebraicExpression", "*", "AlgebraicExpression_RemoveSource", "(", "AlgebraicExpression", "*", "*", "root", ")", "{", "ASSERT", "(", "*", "root", ")", ";", "bool", "transpose", "=", "false", ";", "AlgebraicExpression", "*", "prev", "=", "*", "root", ";", "AlgebraicExpression", "*", "current", "=", "*", "root", ";", "while", "(", "current", "->", "type", "==", "AL_OPERATION", ")", "{", "prev", "=", "current", ";", "switch", "(", "current", "->", "operation", ".", "op", ")", "{", "case", "AL_EXP_TRANSPOSE", ":", "transpose", "=", "!", "transpose", ";", "current", "=", "FIRST_CHILD", "(", "current", ")", ";", "break", ";", "case", "AL_EXP_ADD", ":", "current", "=", "FIRST_CHILD", "(", "current", ")", ";", "break", ";", "case", "AL_EXP_MUL", ":", "if", "(", "transpose", ")", "current", "=", "LAST_CHILD", "(", "current", ")", ";", "else", "current", "=", "FIRST_CHILD", "(", "current", ")", ";", "break", ";", "default", ":", "ASSERT", "(", "\"", "\"", "&&", "false", ")", ";", "}", "}", "ASSERT", "(", "current", "->", "type", "==", "AL_OPERAND", ")", ";", "if", "(", "prev", "==", "current", ")", "{", "*", "root", "=", "NULL", ";", "return", "current", ";", "}", "switch", "(", "prev", "->", "operation", ".", "op", ")", "{", "case", "AL_EXP_TRANSPOSE", ":", "case", "AL_EXP_ADD", ":", "current", "=", "_AlgebraicExpression_OperationRemoveSource", "(", "prev", ")", ";", "break", ";", "case", "AL_EXP_MUL", ":", "if", "(", "transpose", ")", "current", "=", "_AlgebraicExpression_OperationRemoveDest", "(", "prev", ")", ";", "else", "current", "=", "_AlgebraicExpression_OperationRemoveSource", "(", "prev", ")", ";", "break", ";", "default", ":", "ASSERT", "(", "\"", "\"", "&&", "false", ")", ";", "}", "uint", "child_count", "=", "AlgebraicExpression_ChildCount", "(", "prev", ")", ";", "if", "(", "child_count", "==", "1", ")", "{", "AlgebraicExpression", "*", "replacement", "=", "_AlgebraicExpression_OperationRemoveDest", "(", "prev", ")", ";", "_AlgebraicExpression_InplaceRepurpose", "(", "prev", ",", "replacement", ")", ";", "}", "return", "current", ";", "}" ]
Remove leftmost child node from root.
[ "Remove", "leftmost", "child", "node", "from", "root", "." ]
[ "// Root from which to remove left most child.\r", "// transpose have only one child\r", "// Addition order of operands is not effected by transpose\r", "// Multiplication order of operands depends on transpose\r", "/* Expression is just a single operand\r\n\t\t * return operand and update root to NULL. */", "/* Transpose ops only have one child and the order of operands for\r\n\t\t * addition is not modified by transposition, so always remove the source. */", "/* Remove the destination if we're in a transposed context,\r\n\t\t * otherwise remove the source. */", "/* If we just previous operation only has one remaining child,\r\n\t\t * it can be replaced by that child:\r\n\t\t * MUL(A,B) after removing A will become just B\r\n\t\t * Currently, this point is unreachable for transpose ops,\r\n\t\t * as at this point their child is always an operation.\r\n\t\t * If that changes, logic should be added such that:\r\n\t\t * TRANSPOSE(A) after removing A should become NULL. */" ]
[ { "param": "root", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_RemoveDest
AlgebraicExpression
AlgebraicExpression *AlgebraicExpression_RemoveDest ( AlgebraicExpression **root // Root from which to remove left most child. ) { assert(*root); bool transpose = false; AlgebraicExpression *prev = *root; AlgebraicExpression *current = *root; while(current->type == AL_OPERATION) { prev = current; switch(current->operation.op) { case AL_EXP_TRANSPOSE: transpose = !transpose; current = LAST_CHILD(current); // transpose have only one child break; case AL_EXP_ADD: // Addition order of operands is not effected by transpose current = LAST_CHILD(current); break; case AL_EXP_MUL: // Multiplication order of operands depends on transpose if(transpose) current = FIRST_CHILD(current); else current = LAST_CHILD(current); break; default: ASSERT("Unknown algebraic expression operation" && false); } } ASSERT(current->type == AL_OPERAND); if(prev == current) { /* Expression is just a single operand * return operand and update root to NULL. */ *root = NULL; return current; } switch(prev->operation.op) { case AL_EXP_TRANSPOSE: case AL_EXP_ADD: /* Transpose ops only have one child and the order of operands for * addition is not modified by transposition, so always remove the destination. */ current = _AlgebraicExpression_OperationRemoveDest(prev); break; case AL_EXP_MUL: // Remove the source if we're in a transposed context, // otherwise remove the destination. if(transpose) { current = _AlgebraicExpression_OperationRemoveSource(prev); } else { current = _AlgebraicExpression_OperationRemoveDest(prev); } break; default: ASSERT("Unknown algebraic expression operation" && false); } uint child_count = AlgebraicExpression_ChildCount(prev); if(child_count == 1) { /* If we just previous operation only has one remaining child, * it can be replaced by that child: * MUL(A,B) after removing A will become just B * Currently, this point is unreachable for transpose ops, * as at this point their child is always an operation. * If that changes, logic should be added such that: * TRANSPOSE(A) after removing A should become NULL. */ AlgebraicExpression *replacement = _AlgebraicExpression_OperationRemoveDest(prev); _AlgebraicExpression_InplaceRepurpose(prev, replacement); } return current; }
// Remove right most child node from root.
Remove right most child node from root.
[ "Remove", "right", "most", "child", "node", "from", "root", "." ]
AlgebraicExpression *AlgebraicExpression_RemoveDest ( AlgebraicExpression **root ) { assert(*root); bool transpose = false; AlgebraicExpression *prev = *root; AlgebraicExpression *current = *root; while(current->type == AL_OPERATION) { prev = current; switch(current->operation.op) { case AL_EXP_TRANSPOSE: transpose = !transpose; current = LAST_CHILD(current); break; case AL_EXP_ADD: current = LAST_CHILD(current); break; case AL_EXP_MUL: if(transpose) current = FIRST_CHILD(current); else current = LAST_CHILD(current); break; default: ASSERT("Unknown algebraic expression operation" && false); } } ASSERT(current->type == AL_OPERAND); if(prev == current) { *root = NULL; return current; } switch(prev->operation.op) { case AL_EXP_TRANSPOSE: case AL_EXP_ADD: current = _AlgebraicExpression_OperationRemoveDest(prev); break; case AL_EXP_MUL: if(transpose) { current = _AlgebraicExpression_OperationRemoveSource(prev); } else { current = _AlgebraicExpression_OperationRemoveDest(prev); } break; default: ASSERT("Unknown algebraic expression operation" && false); } uint child_count = AlgebraicExpression_ChildCount(prev); if(child_count == 1) { AlgebraicExpression *replacement = _AlgebraicExpression_OperationRemoveDest(prev); _AlgebraicExpression_InplaceRepurpose(prev, replacement); } return current; }
[ "AlgebraicExpression", "*", "AlgebraicExpression_RemoveDest", "(", "AlgebraicExpression", "*", "*", "root", ")", "{", "assert", "(", "*", "root", ")", ";", "bool", "transpose", "=", "false", ";", "AlgebraicExpression", "*", "prev", "=", "*", "root", ";", "AlgebraicExpression", "*", "current", "=", "*", "root", ";", "while", "(", "current", "->", "type", "==", "AL_OPERATION", ")", "{", "prev", "=", "current", ";", "switch", "(", "current", "->", "operation", ".", "op", ")", "{", "case", "AL_EXP_TRANSPOSE", ":", "transpose", "=", "!", "transpose", ";", "current", "=", "LAST_CHILD", "(", "current", ")", ";", "break", ";", "case", "AL_EXP_ADD", ":", "current", "=", "LAST_CHILD", "(", "current", ")", ";", "break", ";", "case", "AL_EXP_MUL", ":", "if", "(", "transpose", ")", "current", "=", "FIRST_CHILD", "(", "current", ")", ";", "else", "current", "=", "LAST_CHILD", "(", "current", ")", ";", "break", ";", "default", ":", "ASSERT", "(", "\"", "\"", "&&", "false", ")", ";", "}", "}", "ASSERT", "(", "current", "->", "type", "==", "AL_OPERAND", ")", ";", "if", "(", "prev", "==", "current", ")", "{", "*", "root", "=", "NULL", ";", "return", "current", ";", "}", "switch", "(", "prev", "->", "operation", ".", "op", ")", "{", "case", "AL_EXP_TRANSPOSE", ":", "case", "AL_EXP_ADD", ":", "current", "=", "_AlgebraicExpression_OperationRemoveDest", "(", "prev", ")", ";", "break", ";", "case", "AL_EXP_MUL", ":", "if", "(", "transpose", ")", "{", "current", "=", "_AlgebraicExpression_OperationRemoveSource", "(", "prev", ")", ";", "}", "else", "{", "current", "=", "_AlgebraicExpression_OperationRemoveDest", "(", "prev", ")", ";", "}", "break", ";", "default", ":", "ASSERT", "(", "\"", "\"", "&&", "false", ")", ";", "}", "uint", "child_count", "=", "AlgebraicExpression_ChildCount", "(", "prev", ")", ";", "if", "(", "child_count", "==", "1", ")", "{", "AlgebraicExpression", "*", "replacement", "=", "_AlgebraicExpression_OperationRemoveDest", "(", "prev", ")", ";", "_AlgebraicExpression_InplaceRepurpose", "(", "prev", ",", "replacement", ")", ";", "}", "return", "current", ";", "}" ]
Remove right most child node from root.
[ "Remove", "right", "most", "child", "node", "from", "root", "." ]
[ "// Root from which to remove left most child.\r", "// transpose have only one child\r", "// Addition order of operands is not effected by transpose\r", "// Multiplication order of operands depends on transpose\r", "/* Expression is just a single operand\r\n\t\t * return operand and update root to NULL. */", "/* Transpose ops only have one child and the order of operands for\r\n\t\t\t * addition is not modified by transposition, so always remove the destination. */", "// Remove the source if we're in a transposed context,\r", "// otherwise remove the destination.\r", "/* If we just previous operation only has one remaining child,\r\n\t\t * it can be replaced by that child:\r\n\t\t * MUL(A,B) after removing A will become just B\r\n\t\t * Currently, this point is unreachable for transpose ops,\r\n\t\t * as at this point their child is always an operation.\r\n\t\t * If that changes, logic should be added such that:\r\n\t\t * TRANSPOSE(A) after removing A should become NULL. */" ]
[ { "param": "root", "type": "AlgebraicExpression" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_MultiplyToTheLeft
void
void AlgebraicExpression_MultiplyToTheLeft ( AlgebraicExpression **root, GrB_Matrix m ) { assert(root && m); AlgebraicExpression *rhs = *root; /* Assuming new operand inherits (src, dest and edge) from * from the current left most operand. */ AlgebraicExpression *left_most_operand = _leftMostNode(rhs); AlgebraicExpression *lhs = AlgebraicExpression_NewOperand(m, false, left_most_operand->operand.src, left_most_operand->operand.dest, NULL, NULL); *root = _AlgebraicExpression_MultiplyToTheLeft(lhs, rhs); }
/* Multiply root to the left with op. * Updates root. */
Multiply root to the left with op. Updates root.
[ "Multiply", "root", "to", "the", "left", "with", "op", ".", "Updates", "root", "." ]
void AlgebraicExpression_MultiplyToTheLeft ( AlgebraicExpression **root, GrB_Matrix m ) { assert(root && m); AlgebraicExpression *rhs = *root; AlgebraicExpression *left_most_operand = _leftMostNode(rhs); AlgebraicExpression *lhs = AlgebraicExpression_NewOperand(m, false, left_most_operand->operand.src, left_most_operand->operand.dest, NULL, NULL); *root = _AlgebraicExpression_MultiplyToTheLeft(lhs, rhs); }
[ "void", "AlgebraicExpression_MultiplyToTheLeft", "(", "AlgebraicExpression", "*", "*", "root", ",", "GrB_Matrix", "m", ")", "{", "assert", "(", "root", "&&", "m", ")", ";", "AlgebraicExpression", "*", "rhs", "=", "*", "root", ";", "AlgebraicExpression", "*", "left_most_operand", "=", "_leftMostNode", "(", "rhs", ")", ";", "AlgebraicExpression", "*", "lhs", "=", "AlgebraicExpression_NewOperand", "(", "m", ",", "false", ",", "left_most_operand", "->", "operand", ".", "src", ",", "left_most_operand", "->", "operand", ".", "dest", ",", "NULL", ",", "NULL", ")", ";", "*", "root", "=", "_AlgebraicExpression_MultiplyToTheLeft", "(", "lhs", ",", "rhs", ")", ";", "}" ]
Multiply root to the left with op.
[ "Multiply", "root", "to", "the", "left", "with", "op", "." ]
[ "/* Assuming new operand inherits (src, dest and edge) from\r\n\t * from the current left most operand. */" ]
[ { "param": "root", "type": "AlgebraicExpression" }, { "param": "m", "type": "GrB_Matrix" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "m", "type": "GrB_Matrix", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
83e161f77a57684e3abef050b7b51eeacbdcbc03
ict-wzq/RedisGraph
src/arithmetic/algebraic_expression/algebraic_expression.c
[ "Ruby", "ISC", "MIT" ]
C
AlgebraicExpression_MultiplyToTheRight
void
void AlgebraicExpression_MultiplyToTheRight ( AlgebraicExpression **root, GrB_Matrix m ) { assert(root && m); AlgebraicExpression *lhs = *root; /* Assuming new operand inherits (src, dest and edge) from * from the current right most operand. */ AlgebraicExpression *right_most_operand = _rightMostNode(lhs); AlgebraicExpression *rhs = AlgebraicExpression_NewOperand(m, false, right_most_operand->operand.src, right_most_operand->operand.dest, NULL, NULL); *root = _AlgebraicExpression_MultiplyToTheRight(lhs, rhs); }
/* Multiply root to the right with op. * Updates root. */
Multiply root to the right with op. Updates root.
[ "Multiply", "root", "to", "the", "right", "with", "op", ".", "Updates", "root", "." ]
void AlgebraicExpression_MultiplyToTheRight ( AlgebraicExpression **root, GrB_Matrix m ) { assert(root && m); AlgebraicExpression *lhs = *root; AlgebraicExpression *right_most_operand = _rightMostNode(lhs); AlgebraicExpression *rhs = AlgebraicExpression_NewOperand(m, false, right_most_operand->operand.src, right_most_operand->operand.dest, NULL, NULL); *root = _AlgebraicExpression_MultiplyToTheRight(lhs, rhs); }
[ "void", "AlgebraicExpression_MultiplyToTheRight", "(", "AlgebraicExpression", "*", "*", "root", ",", "GrB_Matrix", "m", ")", "{", "assert", "(", "root", "&&", "m", ")", ";", "AlgebraicExpression", "*", "lhs", "=", "*", "root", ";", "AlgebraicExpression", "*", "right_most_operand", "=", "_rightMostNode", "(", "lhs", ")", ";", "AlgebraicExpression", "*", "rhs", "=", "AlgebraicExpression_NewOperand", "(", "m", ",", "false", ",", "right_most_operand", "->", "operand", ".", "src", ",", "right_most_operand", "->", "operand", ".", "dest", ",", "NULL", ",", "NULL", ")", ";", "*", "root", "=", "_AlgebraicExpression_MultiplyToTheRight", "(", "lhs", ",", "rhs", ")", ";", "}" ]
Multiply root to the right with op.
[ "Multiply", "root", "to", "the", "right", "with", "op", "." ]
[ "/* Assuming new operand inherits (src, dest and edge) from\r\n\t * from the current right most operand. */" ]
[ { "param": "root", "type": "AlgebraicExpression" }, { "param": "m", "type": "GrB_Matrix" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "AlgebraicExpression", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "m", "type": "GrB_Matrix", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ff8f49061c4cea14e9a704e0a30e1901c648402
ict-wzq/RedisGraph
src/config.c
[ "Ruby", "ISC", "MIT" ]
C
_Config_SetThreadCount
int
static int _Config_SetThreadCount(RedisModuleCtx *ctx, RedisModuleString *count_str) { long long thread_count; int res = _Config_ParsePositiveInteger(count_str, &thread_count); // Exit with error if integer parsing fails or thread count is outside of the valid range 1-INT_MAX. if(res != REDISMODULE_OK || thread_count > INT_MAX) { const char *invalid_arg = RedisModule_StringPtrLen(count_str, NULL); RedisModule_Log(ctx, "warning", "Received invalid value '%s' as thread count argument", invalid_arg); return REDISMODULE_ERR; } // Emit notice but do not fail if the specified thread count is greater than the system's // number of cores (which is already set as the default value). if(thread_count > config.thread_count) { RedisModule_Log(ctx, "notice", "Number of threads: %d greater then number of cores: %d.", thread_count, config.thread_count); } // Set the thread count in the configuration. config.thread_count = thread_count; return REDISMODULE_OK; }
// If the user has specified a thread pool size, update the configuration. // Returns REDISMODULE_OK on success and REDISMODULE_ERR if the argument was invalid.
If the user has specified a thread pool size, update the configuration. Returns REDISMODULE_OK on success and REDISMODULE_ERR if the argument was invalid.
[ "If", "the", "user", "has", "specified", "a", "thread", "pool", "size", "update", "the", "configuration", ".", "Returns", "REDISMODULE_OK", "on", "success", "and", "REDISMODULE_ERR", "if", "the", "argument", "was", "invalid", "." ]
static int _Config_SetThreadCount(RedisModuleCtx *ctx, RedisModuleString *count_str) { long long thread_count; int res = _Config_ParsePositiveInteger(count_str, &thread_count); if(res != REDISMODULE_OK || thread_count > INT_MAX) { const char *invalid_arg = RedisModule_StringPtrLen(count_str, NULL); RedisModule_Log(ctx, "warning", "Received invalid value '%s' as thread count argument", invalid_arg); return REDISMODULE_ERR; } if(thread_count > config.thread_count) { RedisModule_Log(ctx, "notice", "Number of threads: %d greater then number of cores: %d.", thread_count, config.thread_count); } config.thread_count = thread_count; return REDISMODULE_OK; }
[ "static", "int", "_Config_SetThreadCount", "(", "RedisModuleCtx", "*", "ctx", ",", "RedisModuleString", "*", "count_str", ")", "{", "long", "long", "thread_count", ";", "int", "res", "=", "_Config_ParsePositiveInteger", "(", "count_str", ",", "&", "thread_count", ")", ";", "if", "(", "res", "!=", "REDISMODULE_OK", "||", "thread_count", ">", "INT_MAX", ")", "{", "const", "char", "*", "invalid_arg", "=", "RedisModule_StringPtrLen", "(", "count_str", ",", "NULL", ")", ";", "RedisModule_Log", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ",", "invalid_arg", ")", ";", "return", "REDISMODULE_ERR", ";", "}", "if", "(", "thread_count", ">", "config", ".", "thread_count", ")", "{", "RedisModule_Log", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ",", "thread_count", ",", "config", ".", "thread_count", ")", ";", "}", "config", ".", "thread_count", "=", "thread_count", ";", "return", "REDISMODULE_OK", ";", "}" ]
If the user has specified a thread pool size, update the configuration.
[ "If", "the", "user", "has", "specified", "a", "thread", "pool", "size", "update", "the", "configuration", "." ]
[ "// Exit with error if integer parsing fails or thread count is outside of the valid range 1-INT_MAX.\r", "// Emit notice but do not fail if the specified thread count is greater than the system's\r", "// number of cores (which is already set as the default value).\r", "// Set the thread count in the configuration.\r" ]
[ { "param": "ctx", "type": "RedisModuleCtx" }, { "param": "count_str", "type": "RedisModuleString" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": "RedisModuleCtx", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count_str", "type": "RedisModuleString", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ff8f49061c4cea14e9a704e0a30e1901c648402
ict-wzq/RedisGraph
src/config.c
[ "Ruby", "ISC", "MIT" ]
C
_Config_SetOMPThreadCount
int
static int _Config_SetOMPThreadCount(RedisModuleCtx *ctx, RedisModuleString *count_str) { long long omp_thread_count; int res = _Config_ParsePositiveInteger(count_str, &omp_thread_count); // Exit with error if integer parsing fails or OpenMP thread count is outside of the valid range 1-INT_MAX. if(res != REDISMODULE_OK || omp_thread_count > INT_MAX) { const char *invalid_arg = RedisModule_StringPtrLen(count_str, NULL); RedisModule_Log(ctx, "warning", "Specified invalid maximum '%s' for OpenMP thread count", invalid_arg); return REDISMODULE_ERR; } // Set the OpenMP thread count in the configuration. config.omp_thread_count = omp_thread_count; return REDISMODULE_OK; }
// If the user has specified a maximum number of OpenMP threads, update the configuration. // Returns REDISMODULE_OK on success and REDISMODULE_ERR if the argument was invalid.
If the user has specified a maximum number of OpenMP threads, update the configuration. Returns REDISMODULE_OK on success and REDISMODULE_ERR if the argument was invalid.
[ "If", "the", "user", "has", "specified", "a", "maximum", "number", "of", "OpenMP", "threads", "update", "the", "configuration", ".", "Returns", "REDISMODULE_OK", "on", "success", "and", "REDISMODULE_ERR", "if", "the", "argument", "was", "invalid", "." ]
static int _Config_SetOMPThreadCount(RedisModuleCtx *ctx, RedisModuleString *count_str) { long long omp_thread_count; int res = _Config_ParsePositiveInteger(count_str, &omp_thread_count); if(res != REDISMODULE_OK || omp_thread_count > INT_MAX) { const char *invalid_arg = RedisModule_StringPtrLen(count_str, NULL); RedisModule_Log(ctx, "warning", "Specified invalid maximum '%s' for OpenMP thread count", invalid_arg); return REDISMODULE_ERR; } config.omp_thread_count = omp_thread_count; return REDISMODULE_OK; }
[ "static", "int", "_Config_SetOMPThreadCount", "(", "RedisModuleCtx", "*", "ctx", ",", "RedisModuleString", "*", "count_str", ")", "{", "long", "long", "omp_thread_count", ";", "int", "res", "=", "_Config_ParsePositiveInteger", "(", "count_str", ",", "&", "omp_thread_count", ")", ";", "if", "(", "res", "!=", "REDISMODULE_OK", "||", "omp_thread_count", ">", "INT_MAX", ")", "{", "const", "char", "*", "invalid_arg", "=", "RedisModule_StringPtrLen", "(", "count_str", ",", "NULL", ")", ";", "RedisModule_Log", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ",", "invalid_arg", ")", ";", "return", "REDISMODULE_ERR", ";", "}", "config", ".", "omp_thread_count", "=", "omp_thread_count", ";", "return", "REDISMODULE_OK", ";", "}" ]
If the user has specified a maximum number of OpenMP threads, update the configuration.
[ "If", "the", "user", "has", "specified", "a", "maximum", "number", "of", "OpenMP", "threads", "update", "the", "configuration", "." ]
[ "// Exit with error if integer parsing fails or OpenMP thread count is outside of the valid range 1-INT_MAX.\r", "// Set the OpenMP thread count in the configuration.\r" ]
[ { "param": "ctx", "type": "RedisModuleCtx" }, { "param": "count_str", "type": "RedisModuleString" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": "RedisModuleCtx", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count_str", "type": "RedisModuleString", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ff8f49061c4cea14e9a704e0a30e1901c648402
ict-wzq/RedisGraph
src/config.c
[ "Ruby", "ISC", "MIT" ]
C
_Config_SetVirtualKeyEntitiesThreshold
int
static int _Config_SetVirtualKeyEntitiesThreshold(RedisModuleCtx *ctx, RedisModuleString *entity_count_str) { long long entity_count; int res = _Config_ParsePositiveInteger(entity_count_str, &entity_count); // Exit with error if integer parsing fails. if(res != REDISMODULE_OK) { const char *invalid_arg = RedisModule_StringPtrLen(entity_count_str, NULL); RedisModule_Log(ctx, "warning", "Could not parse virtual key size argument '%s' as an integer", invalid_arg); return REDISMODULE_ERR; } // Log the new entity threshold. RedisModule_Log(ctx, "notice", "Max number of entities per graph meta key set to %lld.", entity_count); // Update the entity count in the configuration. config.vkey_entity_count = entity_count; return REDISMODULE_OK; }
// If the user has specified a maximum number of entities per virtual key, update the configuration. // Returns REDISMODULE_OK on success and REDISMODULE_ERR if the argument was invalid.
If the user has specified a maximum number of entities per virtual key, update the configuration. Returns REDISMODULE_OK on success and REDISMODULE_ERR if the argument was invalid.
[ "If", "the", "user", "has", "specified", "a", "maximum", "number", "of", "entities", "per", "virtual", "key", "update", "the", "configuration", ".", "Returns", "REDISMODULE_OK", "on", "success", "and", "REDISMODULE_ERR", "if", "the", "argument", "was", "invalid", "." ]
static int _Config_SetVirtualKeyEntitiesThreshold(RedisModuleCtx *ctx, RedisModuleString *entity_count_str) { long long entity_count; int res = _Config_ParsePositiveInteger(entity_count_str, &entity_count); if(res != REDISMODULE_OK) { const char *invalid_arg = RedisModule_StringPtrLen(entity_count_str, NULL); RedisModule_Log(ctx, "warning", "Could not parse virtual key size argument '%s' as an integer", invalid_arg); return REDISMODULE_ERR; } RedisModule_Log(ctx, "notice", "Max number of entities per graph meta key set to %lld.", entity_count); config.vkey_entity_count = entity_count; return REDISMODULE_OK; }
[ "static", "int", "_Config_SetVirtualKeyEntitiesThreshold", "(", "RedisModuleCtx", "*", "ctx", ",", "RedisModuleString", "*", "entity_count_str", ")", "{", "long", "long", "entity_count", ";", "int", "res", "=", "_Config_ParsePositiveInteger", "(", "entity_count_str", ",", "&", "entity_count", ")", ";", "if", "(", "res", "!=", "REDISMODULE_OK", ")", "{", "const", "char", "*", "invalid_arg", "=", "RedisModule_StringPtrLen", "(", "entity_count_str", ",", "NULL", ")", ";", "RedisModule_Log", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ",", "invalid_arg", ")", ";", "return", "REDISMODULE_ERR", ";", "}", "RedisModule_Log", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ",", "entity_count", ")", ";", "config", ".", "vkey_entity_count", "=", "entity_count", ";", "return", "REDISMODULE_OK", ";", "}" ]
If the user has specified a maximum number of entities per virtual key, update the configuration.
[ "If", "the", "user", "has", "specified", "a", "maximum", "number", "of", "entities", "per", "virtual", "key", "update", "the", "configuration", "." ]
[ "// Exit with error if integer parsing fails.\r", "// Log the new entity threshold.\r", "// Update the entity count in the configuration.\r" ]
[ { "param": "ctx", "type": "RedisModuleCtx" }, { "param": "entity_count_str", "type": "RedisModuleString" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": "RedisModuleCtx", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "entity_count_str", "type": "RedisModuleString", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ff8f49061c4cea14e9a704e0a30e1901c648402
ict-wzq/RedisGraph
src/config.c
[ "Ruby", "ISC", "MIT" ]
C
_Config_SetCacheSize
int
static int _Config_SetCacheSize(RedisModuleCtx *ctx, RedisModuleString *cache_size_str) { long long cache_size; int res = _Config_ParsePositiveInteger(cache_size_str, &cache_size); // Exit with error if integer parsing fails. if(res != REDISMODULE_OK) { const char *invalid_arg = RedisModule_StringPtrLen(cache_size_str, NULL); RedisModule_Log(ctx, "warning", "Could not parse cache size argument '%s' as an integer", invalid_arg); return REDISMODULE_ERR; } // Log the cache size. RedisModule_Log(ctx, "notice", "Cache size is set to %lld.", cache_size); // Update the cache size in the configuration. config.cache_size = cache_size; return REDISMODULE_OK; }
// If the user has specified the cache size, update the configuration. // Returns REDISMODULE_OK on success and REDISMODULE_ERR if the argument was invalid.
If the user has specified the cache size, update the configuration. Returns REDISMODULE_OK on success and REDISMODULE_ERR if the argument was invalid.
[ "If", "the", "user", "has", "specified", "the", "cache", "size", "update", "the", "configuration", ".", "Returns", "REDISMODULE_OK", "on", "success", "and", "REDISMODULE_ERR", "if", "the", "argument", "was", "invalid", "." ]
static int _Config_SetCacheSize(RedisModuleCtx *ctx, RedisModuleString *cache_size_str) { long long cache_size; int res = _Config_ParsePositiveInteger(cache_size_str, &cache_size); if(res != REDISMODULE_OK) { const char *invalid_arg = RedisModule_StringPtrLen(cache_size_str, NULL); RedisModule_Log(ctx, "warning", "Could not parse cache size argument '%s' as an integer", invalid_arg); return REDISMODULE_ERR; } RedisModule_Log(ctx, "notice", "Cache size is set to %lld.", cache_size); config.cache_size = cache_size; return REDISMODULE_OK; }
[ "static", "int", "_Config_SetCacheSize", "(", "RedisModuleCtx", "*", "ctx", ",", "RedisModuleString", "*", "cache_size_str", ")", "{", "long", "long", "cache_size", ";", "int", "res", "=", "_Config_ParsePositiveInteger", "(", "cache_size_str", ",", "&", "cache_size", ")", ";", "if", "(", "res", "!=", "REDISMODULE_OK", ")", "{", "const", "char", "*", "invalid_arg", "=", "RedisModule_StringPtrLen", "(", "cache_size_str", ",", "NULL", ")", ";", "RedisModule_Log", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ",", "invalid_arg", ")", ";", "return", "REDISMODULE_ERR", ";", "}", "RedisModule_Log", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ",", "cache_size", ")", ";", "config", ".", "cache_size", "=", "cache_size", ";", "return", "REDISMODULE_OK", ";", "}" ]
If the user has specified the cache size, update the configuration.
[ "If", "the", "user", "has", "specified", "the", "cache", "size", "update", "the", "configuration", "." ]
[ "// Exit with error if integer parsing fails.\r", "// Log the cache size.\r", "// Update the cache size in the configuration.\r" ]
[ { "param": "ctx", "type": "RedisModuleCtx" }, { "param": "cache_size_str", "type": "RedisModuleString" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": "RedisModuleCtx", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cache_size_str", "type": "RedisModuleString", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ff8f49061c4cea14e9a704e0a30e1901c648402
ict-wzq/RedisGraph
src/config.c
[ "Ruby", "ISC", "MIT" ]
C
_Config_SetToDefaults
void
static void _Config_SetToDefaults(RedisModuleCtx *ctx) { // The thread pool's default size is equal to the system's number of cores. int CPUCount = sysconf(_SC_NPROCESSORS_ONLN); config.thread_count = (CPUCount != -1) ? CPUCount : 1; // Use the GraphBLAS-defined number of OpenMP threads by default. GxB_get(GxB_NTHREADS, &config.omp_thread_count); if(Redis_Version_GreaterOrEqual(6, 0, 0)) { // The default entity count of virtual keys for server versions >= 6 is set by macro. config.vkey_entity_count = VKEY_MAX_ENTITY_COUNT_DEFAULT; } else { // For redis-server versions below 6.0.0, we will not split the graph into virtual keys. config.vkey_entity_count = VKEY_ENTITY_COUNT_UNLIMITED; } // MEMCHECK compile flag; #ifdef MEMCHECK // Disable async delete during memcheck. config.async_delete = false; RedisModule_Log(ctx, "notice", "Graph deletion will be done synchronously."); #else // Always perform async delete when no checking for memory issues. config.async_delete = true; RedisModule_Log(ctx, "notice", "Graph deletion will be done asynchronously."); #endif // Always build transposed matrices by default. config.maintain_transposed_matrices = true; config.cache_size = CACHE_SIZE_DEFAULT; }
// Initialize every module-level configuration to its default value.
Initialize every module-level configuration to its default value.
[ "Initialize", "every", "module", "-", "level", "configuration", "to", "its", "default", "value", "." ]
static void _Config_SetToDefaults(RedisModuleCtx *ctx) { int CPUCount = sysconf(_SC_NPROCESSORS_ONLN); config.thread_count = (CPUCount != -1) ? CPUCount : 1; GxB_get(GxB_NTHREADS, &config.omp_thread_count); if(Redis_Version_GreaterOrEqual(6, 0, 0)) { config.vkey_entity_count = VKEY_MAX_ENTITY_COUNT_DEFAULT; } else { config.vkey_entity_count = VKEY_ENTITY_COUNT_UNLIMITED; } #ifdef MEMCHECK config.async_delete = false; RedisModule_Log(ctx, "notice", "Graph deletion will be done synchronously."); #else config.async_delete = true; RedisModule_Log(ctx, "notice", "Graph deletion will be done asynchronously."); #endif config.maintain_transposed_matrices = true; config.cache_size = CACHE_SIZE_DEFAULT; }
[ "static", "void", "_Config_SetToDefaults", "(", "RedisModuleCtx", "*", "ctx", ")", "{", "int", "CPUCount", "=", "sysconf", "(", "_SC_NPROCESSORS_ONLN", ")", ";", "config", ".", "thread_count", "=", "(", "CPUCount", "!=", "-1", ")", "?", "CPUCount", ":", "1", ";", "GxB_get", "(", "GxB_NTHREADS", ",", "&", "config", ".", "omp_thread_count", ")", ";", "if", "(", "Redis_Version_GreaterOrEqual", "(", "6", ",", "0", ",", "0", ")", ")", "{", "config", ".", "vkey_entity_count", "=", "VKEY_MAX_ENTITY_COUNT_DEFAULT", ";", "}", "else", "{", "config", ".", "vkey_entity_count", "=", "VKEY_ENTITY_COUNT_UNLIMITED", ";", "}", "#ifdef", "MEMCHECK", "config", ".", "async_delete", "=", "false", ";", "RedisModule_Log", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ")", ";", "#else", "config", ".", "async_delete", "=", "true", ";", "RedisModule_Log", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ")", ";", "#endif", "config", ".", "maintain_transposed_matrices", "=", "true", ";", "config", ".", "cache_size", "=", "CACHE_SIZE_DEFAULT", ";", "}" ]
Initialize every module-level configuration to its default value.
[ "Initialize", "every", "module", "-", "level", "configuration", "to", "its", "default", "value", "." ]
[ "// The thread pool's default size is equal to the system's number of cores.\r", "// Use the GraphBLAS-defined number of OpenMP threads by default.\r", "// The default entity count of virtual keys for server versions >= 6 is set by macro.\r", "// For redis-server versions below 6.0.0, we will not split the graph into virtual keys.\r", "// MEMCHECK compile flag;\r", "// Disable async delete during memcheck.\r", "// Always perform async delete when no checking for memory issues.\r", "// Always build transposed matrices by default.\r" ]
[ { "param": "ctx", "type": "RedisModuleCtx" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": "RedisModuleCtx", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
27333e1c65af248ec9a24c2944ee103e28be1ad6
ict-wzq/RedisGraph
src/execution_plan/optimizations/compact_filters.c
[ "Ruby", "ISC", "MIT" ]
C
_compactFilter
bool
static inline bool _compactFilter(OpBase *op) { assert(op->type == OPType_FILTER); OpFilter *filter_op = (OpFilter *)op; return FilterTree_Compact(filter_op->filterTree); }
// Try to compact a filter.
Try to compact a filter.
[ "Try", "to", "compact", "a", "filter", "." ]
static inline bool _compactFilter(OpBase *op) { assert(op->type == OPType_FILTER); OpFilter *filter_op = (OpFilter *)op; return FilterTree_Compact(filter_op->filterTree); }
[ "static", "inline", "bool", "_compactFilter", "(", "OpBase", "*", "op", ")", "{", "assert", "(", "op", "->", "type", "==", "OPType_FILTER", ")", ";", "OpFilter", "*", "filter_op", "=", "(", "OpFilter", "*", ")", "op", ";", "return", "FilterTree_Compact", "(", "filter_op", "->", "filterTree", ")", ";", "}" ]
Try to compact a filter.
[ "Try", "to", "compact", "a", "filter", "." ]
[]
[ { "param": "op", "type": "OpBase" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "op", "type": "OpBase", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
27333e1c65af248ec9a24c2944ee103e28be1ad6
ict-wzq/RedisGraph
src/execution_plan/optimizations/compact_filters.c
[ "Ruby", "ISC", "MIT" ]
C
_removeTrueFilter
void
static void _removeTrueFilter(ExecutionPlan *plan, OpBase *op) { assert(op->type == OPType_FILTER); OpFilter *filter_op = (OpFilter *)op; FT_FilterNode *root = filter_op->filterTree; // We can only have a contant expression in this point (after compaction). assert(root->t == FT_N_EXP); // Evaluate the expression, and check if it is a 'true' value. SIValue bool_val = AR_EXP_Evaluate(root->exp.exp, NULL); assert(SI_TYPE(bool_val) == T_BOOL); if(SIValue_IsTrue(bool_val)) { ExecutionPlan_RemoveOp(plan, op); OpBase_Free(op); } }
// In case the compacted filter resolved to 'true', remove it from the execution plan.
In case the compacted filter resolved to 'true', remove it from the execution plan.
[ "In", "case", "the", "compacted", "filter", "resolved", "to", "'", "true", "'", "remove", "it", "from", "the", "execution", "plan", "." ]
static void _removeTrueFilter(ExecutionPlan *plan, OpBase *op) { assert(op->type == OPType_FILTER); OpFilter *filter_op = (OpFilter *)op; FT_FilterNode *root = filter_op->filterTree; assert(root->t == FT_N_EXP); SIValue bool_val = AR_EXP_Evaluate(root->exp.exp, NULL); assert(SI_TYPE(bool_val) == T_BOOL); if(SIValue_IsTrue(bool_val)) { ExecutionPlan_RemoveOp(plan, op); OpBase_Free(op); } }
[ "static", "void", "_removeTrueFilter", "(", "ExecutionPlan", "*", "plan", ",", "OpBase", "*", "op", ")", "{", "assert", "(", "op", "->", "type", "==", "OPType_FILTER", ")", ";", "OpFilter", "*", "filter_op", "=", "(", "OpFilter", "*", ")", "op", ";", "FT_FilterNode", "*", "root", "=", "filter_op", "->", "filterTree", ";", "assert", "(", "root", "->", "t", "==", "FT_N_EXP", ")", ";", "SIValue", "bool_val", "=", "AR_EXP_Evaluate", "(", "root", "->", "exp", ".", "exp", ",", "NULL", ")", ";", "assert", "(", "SI_TYPE", "(", "bool_val", ")", "==", "T_BOOL", ")", ";", "if", "(", "SIValue_IsTrue", "(", "bool_val", ")", ")", "{", "ExecutionPlan_RemoveOp", "(", "plan", ",", "op", ")", ";", "OpBase_Free", "(", "op", ")", ";", "}", "}" ]
In case the compacted filter resolved to 'true', remove it from the execution plan.
[ "In", "case", "the", "compacted", "filter", "resolved", "to", "'", "true", "'", "remove", "it", "from", "the", "execution", "plan", "." ]
[ "// We can only have a contant expression in this point (after compaction).\r", "// Evaluate the expression, and check if it is a 'true' value.\r" ]
[ { "param": "plan", "type": "ExecutionPlan" }, { "param": "op", "type": "OpBase" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "plan", "type": "ExecutionPlan", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "OpBase", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ecec66e2027b355f663d4976b322116cbc8a4c66
ict-wzq/RedisGraph
src/arithmetic/entity_funcs/entity_funcs.c
[ "Ruby", "ISC", "MIT" ]
C
AR_ID
SIValue
SIValue AR_ID(SIValue *argv, int argc) { if(SI_TYPE(argv[0]) == T_NULL) return SI_NullVal(); GraphEntity *graph_entity = (GraphEntity *)argv[0].ptrval; return SI_LongVal(ENTITY_GET_ID(graph_entity)); }
/* returns the id of a relationship or node. */
returns the id of a relationship or node.
[ "returns", "the", "id", "of", "a", "relationship", "or", "node", "." ]
SIValue AR_ID(SIValue *argv, int argc) { if(SI_TYPE(argv[0]) == T_NULL) return SI_NullVal(); GraphEntity *graph_entity = (GraphEntity *)argv[0].ptrval; return SI_LongVal(ENTITY_GET_ID(graph_entity)); }
[ "SIValue", "AR_ID", "(", "SIValue", "*", "argv", ",", "int", "argc", ")", "{", "if", "(", "SI_TYPE", "(", "argv", "[", "0", "]", ")", "==", "T_NULL", ")", "return", "SI_NullVal", "(", ")", ";", "GraphEntity", "*", "graph_entity", "=", "(", "GraphEntity", "*", ")", "argv", "[", "0", "]", ".", "ptrval", ";", "return", "SI_LongVal", "(", "ENTITY_GET_ID", "(", "graph_entity", ")", ")", ";", "}" ]
returns the id of a relationship or node.
[ "returns", "the", "id", "of", "a", "relationship", "or", "node", "." ]
[]
[ { "param": "argv", "type": "SIValue" }, { "param": "argc", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argv", "type": "SIValue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ecec66e2027b355f663d4976b322116cbc8a4c66
ict-wzq/RedisGraph
src/arithmetic/entity_funcs/entity_funcs.c
[ "Ruby", "ISC", "MIT" ]
C
AR_LABELS
SIValue
SIValue AR_LABELS(SIValue *argv, int argc) { if(SI_TYPE(argv[0]) == T_NULL) return SI_NullVal(); char *label = ""; Node *node = argv[0].ptrval; GraphContext *gc = QueryCtx_GetGraphCtx(); Graph *g = gc->g; int labelID = Graph_GetNodeLabel(g, ENTITY_GET_ID(node)); if(labelID != GRAPH_NO_LABEL) label = gc->node_schemas[labelID]->name; return SI_ConstStringVal(label); }
/* returns a string representations the label of a node. */
returns a string representations the label of a node.
[ "returns", "a", "string", "representations", "the", "label", "of", "a", "node", "." ]
SIValue AR_LABELS(SIValue *argv, int argc) { if(SI_TYPE(argv[0]) == T_NULL) return SI_NullVal(); char *label = ""; Node *node = argv[0].ptrval; GraphContext *gc = QueryCtx_GetGraphCtx(); Graph *g = gc->g; int labelID = Graph_GetNodeLabel(g, ENTITY_GET_ID(node)); if(labelID != GRAPH_NO_LABEL) label = gc->node_schemas[labelID]->name; return SI_ConstStringVal(label); }
[ "SIValue", "AR_LABELS", "(", "SIValue", "*", "argv", ",", "int", "argc", ")", "{", "if", "(", "SI_TYPE", "(", "argv", "[", "0", "]", ")", "==", "T_NULL", ")", "return", "SI_NullVal", "(", ")", ";", "char", "*", "label", "=", "\"", "\"", ";", "Node", "*", "node", "=", "argv", "[", "0", "]", ".", "ptrval", ";", "GraphContext", "*", "gc", "=", "QueryCtx_GetGraphCtx", "(", ")", ";", "Graph", "*", "g", "=", "gc", "->", "g", ";", "int", "labelID", "=", "Graph_GetNodeLabel", "(", "g", ",", "ENTITY_GET_ID", "(", "node", ")", ")", ";", "if", "(", "labelID", "!=", "GRAPH_NO_LABEL", ")", "label", "=", "gc", "->", "node_schemas", "[", "labelID", "]", "->", "name", ";", "return", "SI_ConstStringVal", "(", "label", ")", ";", "}" ]
returns a string representations the label of a node.
[ "returns", "a", "string", "representations", "the", "label", "of", "a", "node", "." ]
[]
[ { "param": "argv", "type": "SIValue" }, { "param": "argc", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argv", "type": "SIValue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ecec66e2027b355f663d4976b322116cbc8a4c66
ict-wzq/RedisGraph
src/arithmetic/entity_funcs/entity_funcs.c
[ "Ruby", "ISC", "MIT" ]
C
AR_TYPE
SIValue
SIValue AR_TYPE(SIValue *argv, int argc) { if(SI_TYPE(argv[0]) == T_NULL) return SI_NullVal(); char *type = ""; Edge *e = argv[0].ptrval; GraphContext *gc = QueryCtx_GetGraphCtx(); int id = Graph_GetEdgeRelation(gc->g, e); if(id != GRAPH_NO_RELATION) type = gc->relation_schemas[id]->name; return SI_ConstStringVal(type); }
/* returns a string representation of the type of a relation. */
returns a string representation of the type of a relation.
[ "returns", "a", "string", "representation", "of", "the", "type", "of", "a", "relation", "." ]
SIValue AR_TYPE(SIValue *argv, int argc) { if(SI_TYPE(argv[0]) == T_NULL) return SI_NullVal(); char *type = ""; Edge *e = argv[0].ptrval; GraphContext *gc = QueryCtx_GetGraphCtx(); int id = Graph_GetEdgeRelation(gc->g, e); if(id != GRAPH_NO_RELATION) type = gc->relation_schemas[id]->name; return SI_ConstStringVal(type); }
[ "SIValue", "AR_TYPE", "(", "SIValue", "*", "argv", ",", "int", "argc", ")", "{", "if", "(", "SI_TYPE", "(", "argv", "[", "0", "]", ")", "==", "T_NULL", ")", "return", "SI_NullVal", "(", ")", ";", "char", "*", "type", "=", "\"", "\"", ";", "Edge", "*", "e", "=", "argv", "[", "0", "]", ".", "ptrval", ";", "GraphContext", "*", "gc", "=", "QueryCtx_GetGraphCtx", "(", ")", ";", "int", "id", "=", "Graph_GetEdgeRelation", "(", "gc", "->", "g", ",", "e", ")", ";", "if", "(", "id", "!=", "GRAPH_NO_RELATION", ")", "type", "=", "gc", "->", "relation_schemas", "[", "id", "]", "->", "name", ";", "return", "SI_ConstStringVal", "(", "type", ")", ";", "}" ]
returns a string representation of the type of a relation.
[ "returns", "a", "string", "representation", "of", "the", "type", "of", "a", "relation", "." ]
[]
[ { "param": "argv", "type": "SIValue" }, { "param": "argc", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argv", "type": "SIValue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f213d51459d57dca32cd48957544a4f036595ef0
Comp-UFSCar/operating-systems
projects/histogram/src/histogram.c
[ "MIT" ]
C
sequential_histogram
void
void sequential_histogram(double *values, int n_values, int *bins, int n_bins, double min, double max, double h) { int i, j, count; double min_t, max_t; for (j = 0; j < n_bins; j++) { count = 0; min_t = min + j * h; max_t = min + (j+1) * h; for(i = 0; i < n_values; i++) if(values[i] > min_t && values[i] <= max_t) count++; bins[j] = count; } }
// // Sequential Histogram. // // Compute an histogram based on values and the bins passed. //
Sequential Histogram. Compute an histogram based on values and the bins passed.
[ "Sequential", "Histogram", ".", "Compute", "an", "histogram", "based", "on", "values", "and", "the", "bins", "passed", "." ]
void sequential_histogram(double *values, int n_values, int *bins, int n_bins, double min, double max, double h) { int i, j, count; double min_t, max_t; for (j = 0; j < n_bins; j++) { count = 0; min_t = min + j * h; max_t = min + (j+1) * h; for(i = 0; i < n_values; i++) if(values[i] > min_t && values[i] <= max_t) count++; bins[j] = count; } }
[ "void", "sequential_histogram", "(", "double", "*", "values", ",", "int", "n_values", ",", "int", "*", "bins", ",", "int", "n_bins", ",", "double", "min", ",", "double", "max", ",", "double", "h", ")", "{", "int", "i", ",", "j", ",", "count", ";", "double", "min_t", ",", "max_t", ";", "for", "(", "j", "=", "0", ";", "j", "<", "n_bins", ";", "j", "++", ")", "{", "count", "=", "0", ";", "min_t", "=", "min", "+", "j", "*", "h", ";", "max_t", "=", "min", "+", "(", "j", "+", "1", ")", "*", "h", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n_values", ";", "i", "++", ")", "if", "(", "values", "[", "i", "]", ">", "min_t", "&&", "values", "[", "i", "]", "<=", "max_t", ")", "count", "++", ";", "bins", "[", "j", "]", "=", "count", ";", "}", "}" ]
Sequential Histogram.
[ "Sequential", "Histogram", "." ]
[]
[ { "param": "values", "type": "double" }, { "param": "n_values", "type": "int" }, { "param": "bins", "type": "int" }, { "param": "n_bins", "type": "int" }, { "param": "min", "type": "double" }, { "param": "max", "type": "double" }, { "param": "h", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "values", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n_values", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bins", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n_bins", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "min", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "max", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "h", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f213d51459d57dca32cd48957544a4f036595ef0
Comp-UFSCar/operating-systems
projects/histogram/src/histogram.c
[ "MIT" ]
C
histogram_worker
void
void histogram_worker(void *thread_params) { int i, j, count; double min_t, max_t; histogram_params_t *params = (histogram_params_t *)thread_params; // `ceil` and double division is used to distribute `n_bins % n_threads` // equally between the threads. // Although the last thread may get fewer bins to compute, this is still // a better strategy than giving `n_bins % n_threads` to the last thread. int start = ceil(params->rank * (double) params->n_bins / params->n_threads), end = min(params->n_bins, ceil((params->rank + 1) * (double)params->n_bins / params->n_threads)); for (j = start; j < end; j++) { count = 0; min_t = params->min + j * params->h; max_t = params->min + (j + 1) * params->h; for (i = 0; i < params->n_values; i++) if (params->values[i] > min_t && params->values[i] <= max_t) count++; params->bins[j] = count; } }
// // Histogram Worker. // // Parallel worker for computing bins' values. // // Parameters // ---------- // thread_params : histogram_params_t // Parameters used for this worker, such as rank, // pointers and reference counters. //
Histogram Worker. Parallel worker for computing bins' values. Parameters thread_params : histogram_params_t Parameters used for this worker, such as rank, pointers and reference counters.
[ "Histogram", "Worker", ".", "Parallel", "worker", "for", "computing", "bins", "'", "values", ".", "Parameters", "thread_params", ":", "histogram_params_t", "Parameters", "used", "for", "this", "worker", "such", "as", "rank", "pointers", "and", "reference", "counters", "." ]
void histogram_worker(void *thread_params) { int i, j, count; double min_t, max_t; histogram_params_t *params = (histogram_params_t *)thread_params; int start = ceil(params->rank * (double) params->n_bins / params->n_threads), end = min(params->n_bins, ceil((params->rank + 1) * (double)params->n_bins / params->n_threads)); for (j = start; j < end; j++) { count = 0; min_t = params->min + j * params->h; max_t = params->min + (j + 1) * params->h; for (i = 0; i < params->n_values; i++) if (params->values[i] > min_t && params->values[i] <= max_t) count++; params->bins[j] = count; } }
[ "void", "histogram_worker", "(", "void", "*", "thread_params", ")", "{", "int", "i", ",", "j", ",", "count", ";", "double", "min_t", ",", "max_t", ";", "histogram_params_t", "*", "params", "=", "(", "histogram_params_t", "*", ")", "thread_params", ";", "int", "start", "=", "ceil", "(", "params", "->", "rank", "*", "(", "double", ")", "params", "->", "n_bins", "/", "params", "->", "n_threads", ")", ",", "end", "=", "min", "(", "params", "->", "n_bins", ",", "ceil", "(", "(", "params", "->", "rank", "+", "1", ")", "*", "(", "double", ")", "params", "->", "n_bins", "/", "params", "->", "n_threads", ")", ")", ";", "for", "(", "j", "=", "start", ";", "j", "<", "end", ";", "j", "++", ")", "{", "count", "=", "0", ";", "min_t", "=", "params", "->", "min", "+", "j", "*", "params", "->", "h", ";", "max_t", "=", "params", "->", "min", "+", "(", "j", "+", "1", ")", "*", "params", "->", "h", ";", "for", "(", "i", "=", "0", ";", "i", "<", "params", "->", "n_values", ";", "i", "++", ")", "if", "(", "params", "->", "values", "[", "i", "]", ">", "min_t", "&&", "params", "->", "values", "[", "i", "]", "<=", "max_t", ")", "count", "++", ";", "params", "->", "bins", "[", "j", "]", "=", "count", ";", "}", "}" ]
Histogram Worker.
[ "Histogram", "Worker", "." ]
[ "// `ceil` and double division is used to distribute `n_bins % n_threads`", "// equally between the threads.", "// Although the last thread may get fewer bins to compute, this is still", "// a better strategy than giving `n_bins % n_threads` to the last thread." ]
[ { "param": "thread_params", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "thread_params", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f213d51459d57dca32cd48957544a4f036595ef0
Comp-UFSCar/operating-systems
projects/histogram/src/histogram.c
[ "MIT" ]
C
parallel_histogram
void
void parallel_histogram(double *values, int n_values, int *bins, int n_bins, double min, double max, double h, int n_threads) { int i, failed; pthread_t *workers = (pthread_t *) malloc(n_threads * sizeof(pthread_t)); histogram_params_t *params = (histogram_params_t *)malloc(n_threads * sizeof(histogram_params_t)); for (i = 0; i < n_threads; i++) { params[i].rank = i; params[i].bins = bins; params[i].values = values; params[i].n_values = n_values; params[i].n_threads = n_threads; params[i].bins = bins; params[i].n_bins = n_bins; params[i].min = min; params[i].max = max; params[i].h = h; failed = pthread_create(&workers[i], NULL, histogram_worker, (void *) &params[i]); if (failed) { fprintf(stderr, "Failed to create thread (code: %d).\n", failed); exit(EXIT_FAILURE); } } for (i = 0; i < n_threads; i++) pthread_join(workers[i], NULL); free(workers); }
// // Parallel Histogram. // // Compute an histogram based on values and bins passed. // // Parameters // ---------- // n_threads : int // number of threads workers (threads) used in the computation. //
Parallel Histogram. Compute an histogram based on values and bins passed. Parameters n_threads : int number of threads workers (threads) used in the computation.
[ "Parallel", "Histogram", ".", "Compute", "an", "histogram", "based", "on", "values", "and", "bins", "passed", ".", "Parameters", "n_threads", ":", "int", "number", "of", "threads", "workers", "(", "threads", ")", "used", "in", "the", "computation", "." ]
void parallel_histogram(double *values, int n_values, int *bins, int n_bins, double min, double max, double h, int n_threads) { int i, failed; pthread_t *workers = (pthread_t *) malloc(n_threads * sizeof(pthread_t)); histogram_params_t *params = (histogram_params_t *)malloc(n_threads * sizeof(histogram_params_t)); for (i = 0; i < n_threads; i++) { params[i].rank = i; params[i].bins = bins; params[i].values = values; params[i].n_values = n_values; params[i].n_threads = n_threads; params[i].bins = bins; params[i].n_bins = n_bins; params[i].min = min; params[i].max = max; params[i].h = h; failed = pthread_create(&workers[i], NULL, histogram_worker, (void *) &params[i]); if (failed) { fprintf(stderr, "Failed to create thread (code: %d).\n", failed); exit(EXIT_FAILURE); } } for (i = 0; i < n_threads; i++) pthread_join(workers[i], NULL); free(workers); }
[ "void", "parallel_histogram", "(", "double", "*", "values", ",", "int", "n_values", ",", "int", "*", "bins", ",", "int", "n_bins", ",", "double", "min", ",", "double", "max", ",", "double", "h", ",", "int", "n_threads", ")", "{", "int", "i", ",", "failed", ";", "pthread_t", "*", "workers", "=", "(", "pthread_t", "*", ")", "malloc", "(", "n_threads", "*", "sizeof", "(", "pthread_t", ")", ")", ";", "histogram_params_t", "*", "params", "=", "(", "histogram_params_t", "*", ")", "malloc", "(", "n_threads", "*", "sizeof", "(", "histogram_params_t", ")", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n_threads", ";", "i", "++", ")", "{", "params", "[", "i", "]", ".", "rank", "=", "i", ";", "params", "[", "i", "]", ".", "bins", "=", "bins", ";", "params", "[", "i", "]", ".", "values", "=", "values", ";", "params", "[", "i", "]", ".", "n_values", "=", "n_values", ";", "params", "[", "i", "]", ".", "n_threads", "=", "n_threads", ";", "params", "[", "i", "]", ".", "bins", "=", "bins", ";", "params", "[", "i", "]", ".", "n_bins", "=", "n_bins", ";", "params", "[", "i", "]", ".", "min", "=", "min", ";", "params", "[", "i", "]", ".", "max", "=", "max", ";", "params", "[", "i", "]", ".", "h", "=", "h", ";", "failed", "=", "pthread_create", "(", "&", "workers", "[", "i", "]", ",", "NULL", ",", "histogram_worker", ",", "(", "void", "*", ")", "&", "params", "[", "i", "]", ")", ";", "if", "(", "failed", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "failed", ")", ";", "exit", "(", "EXIT_FAILURE", ")", ";", "}", "}", "for", "(", "i", "=", "0", ";", "i", "<", "n_threads", ";", "i", "++", ")", "pthread_join", "(", "workers", "[", "i", "]", ",", "NULL", ")", ";", "free", "(", "workers", ")", ";", "}" ]
Parallel Histogram.
[ "Parallel", "Histogram", "." ]
[]
[ { "param": "values", "type": "double" }, { "param": "n_values", "type": "int" }, { "param": "bins", "type": "int" }, { "param": "n_bins", "type": "int" }, { "param": "min", "type": "double" }, { "param": "max", "type": "double" }, { "param": "h", "type": "double" }, { "param": "n_threads", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "values", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n_values", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bins", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n_bins", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "min", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "max", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "h", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n_threads", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
36f3ad88e4feb922eabcc8e4bb7a267e901a70c7
Comp-UFSCar/operating-systems
projects/chat-with-pipes/message.c
[ "MIT" ]
C
IsPrivateMessage
int
int IsPrivateMessage ( ChatMessage _m ) { return _m.message[0] == '@'; }
/** * Verify if message typed is directed to only one user */
Verify if message typed is directed to only one user
[ "Verify", "if", "message", "typed", "is", "directed", "to", "only", "one", "user" ]
int IsPrivateMessage ( ChatMessage _m ) { return _m.message[0] == '@'; }
[ "int", "IsPrivateMessage", "(", "ChatMessage", "_m", ")", "{", "return", "_m", ".", "message", "[", "0", "]", "==", "'", "'", ";", "}" ]
Verify if message typed is directed to only one user
[ "Verify", "if", "message", "typed", "is", "directed", "to", "only", "one", "user" ]
[]
[ { "param": "_m", "type": "ChatMessage" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "_m", "type": "ChatMessage", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
36f3ad88e4feb922eabcc8e4bb7a267e901a70c7
Comp-UFSCar/operating-systems
projects/chat-with-pipes/message.c
[ "MIT" ]
C
GetPrivateUsername
char
char * GetPrivateUsername ( ChatMessage _m, char * _username ) { int i = 1; while ( _m.message[i] != ' ' ) { _username[i - 1] = _m.message[i]; i++; } _username[i - 1] = '\0'; printf ("Private username found: %s.\n", _username); return _username; }
/** * Get username related with private message */
Get username related with private message
[ "Get", "username", "related", "with", "private", "message" ]
char * GetPrivateUsername ( ChatMessage _m, char * _username ) { int i = 1; while ( _m.message[i] != ' ' ) { _username[i - 1] = _m.message[i]; i++; } _username[i - 1] = '\0'; printf ("Private username found: %s.\n", _username); return _username; }
[ "char", "*", "GetPrivateUsername", "(", "ChatMessage", "_m", ",", "char", "*", "_username", ")", "{", "int", "i", "=", "1", ";", "while", "(", "_m", ".", "message", "[", "i", "]", "!=", "'", "'", ")", "{", "_username", "[", "i", "-", "1", "]", "=", "_m", ".", "message", "[", "i", "]", ";", "i", "++", ";", "}", "_username", "[", "i", "-", "1", "]", "=", "'", "\\0", "'", ";", "printf", "(", "\"", "\\n", "\"", ",", "_username", ")", ";", "return", "_username", ";", "}" ]
Get username related with private message
[ "Get", "username", "related", "with", "private", "message" ]
[]
[ { "param": "_m", "type": "ChatMessage" }, { "param": "_username", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "_m", "type": "ChatMessage", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "_username", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6308646ebe6faeea14e4f0dcc53509807b0c872a
Comp-UFSCar/operating-systems
projects/zip-pass-cracking/src/pass_queued.c
[ "MIT" ]
C
crack_password
int
int crack_password (char* filename, int n_threads) { int i, failed; int queue_size = 500000 / n_threads, chunk_size = .01 * 500000, // 1% of total. n_chunks = 500000 / chunk_size; cracking_state.done = 0; cracking_state.password_found = -1; cracking_state.filename = filename; cracking_state.n_threads = n_threads; cracking_state.command_template = "unzip -P%d -t %s 2>&1"; for (i = 0; i < n_threads; i++) { failed = pthread_create(&workers[i], NULL, pass_cracker, (void *)i); if (failed) { fprintf(stderr, "Failed to create thread (code: %d).\n", failed); exit(EXIT_FAILURE); } // Create each worker's queue. queues[i] = queue_new(queue_size); } int thread = 0; for (i = 0; i < n_chunks; i++) { // Create a chunk (an interval of the 500000 possible passwords). chunk_t *c = (chunk_t *) malloc(sizeof(chunk_t)); c->start = (i) * chunk_size; c->end = (i + 1) * chunk_size; // Give the chunk to a thread. queue_add(queues[thread], c); // Move to the next thread, which has // fewer enqueued tasks than the previous. thread = (thread + 1) % n_threads; } printf("Checking if finished... "); while (!cracking_state.done) printf(" No.\n"); // Sleep for a while to prevent high CPU usage. sleep(2000); printf("Checking if finished... "); printf("Yes.\n"); // Password was found! Issue an order to abort search. // Notice we don't really join. We don't even care if they finished or not // before returning the password found. for (i = 0; i < n_threads; i++) { queue_add(queues[n_threads], CANCEL_CRACKING_PROCESS); } return cracking_state.password_found; }
/// /// Crack Password. /// /// Parallel API wrapper. ///
Crack Password. Parallel API wrapper.
[ "Crack", "Password", ".", "Parallel", "API", "wrapper", "." ]
int crack_password (char* filename, int n_threads) { int i, failed; int queue_size = 500000 / n_threads, chunk_size = .01 * 500000, n_chunks = 500000 / chunk_size; cracking_state.done = 0; cracking_state.password_found = -1; cracking_state.filename = filename; cracking_state.n_threads = n_threads; cracking_state.command_template = "unzip -P%d -t %s 2>&1"; for (i = 0; i < n_threads; i++) { failed = pthread_create(&workers[i], NULL, pass_cracker, (void *)i); if (failed) { fprintf(stderr, "Failed to create thread (code: %d).\n", failed); exit(EXIT_FAILURE); } queues[i] = queue_new(queue_size); } int thread = 0; for (i = 0; i < n_chunks; i++) { chunk_t *c = (chunk_t *) malloc(sizeof(chunk_t)); c->start = (i) * chunk_size; c->end = (i + 1) * chunk_size; queue_add(queues[thread], c); thread = (thread + 1) % n_threads; } printf("Checking if finished... "); while (!cracking_state.done) printf(" No.\n"); sleep(2000); printf("Checking if finished... "); printf("Yes.\n"); for (i = 0; i < n_threads; i++) { queue_add(queues[n_threads], CANCEL_CRACKING_PROCESS); } return cracking_state.password_found; }
[ "int", "crack_password", "(", "char", "*", "filename", ",", "int", "n_threads", ")", "{", "int", "i", ",", "failed", ";", "int", "queue_size", "=", "500000", "/", "n_threads", ",", "chunk_size", "=", ".01", "*", "500000", ",", "n_chunks", "=", "500000", "/", "chunk_size", ";", "cracking_state", ".", "done", "=", "0", ";", "cracking_state", ".", "password_found", "=", "-1", ";", "cracking_state", ".", "filename", "=", "filename", ";", "cracking_state", ".", "n_threads", "=", "n_threads", ";", "cracking_state", ".", "command_template", "=", "\"", "\"", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n_threads", ";", "i", "++", ")", "{", "failed", "=", "pthread_create", "(", "&", "workers", "[", "i", "]", ",", "NULL", ",", "pass_cracker", ",", "(", "void", "*", ")", "i", ")", ";", "if", "(", "failed", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "failed", ")", ";", "exit", "(", "EXIT_FAILURE", ")", ";", "}", "queues", "[", "i", "]", "=", "queue_new", "(", "queue_size", ")", ";", "}", "int", "thread", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n_chunks", ";", "i", "++", ")", "{", "chunk_t", "*", "c", "=", "(", "chunk_t", "*", ")", "malloc", "(", "sizeof", "(", "chunk_t", ")", ")", ";", "c", "->", "start", "=", "(", "i", ")", "*", "chunk_size", ";", "c", "->", "end", "=", "(", "i", "+", "1", ")", "*", "chunk_size", ";", "queue_add", "(", "queues", "[", "thread", "]", ",", "c", ")", ";", "thread", "=", "(", "thread", "+", "1", ")", "%", "n_threads", ";", "}", "printf", "(", "\"", "\"", ")", ";", "while", "(", "!", "cracking_state", ".", "done", ")", "printf", "(", "\"", "\\n", "\"", ")", ";", "sleep", "(", "2000", ")", ";", "printf", "(", "\"", "\"", ")", ";", "printf", "(", "\"", "\\n", "\"", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n_threads", ";", "i", "++", ")", "{", "queue_add", "(", "queues", "[", "n_threads", "]", ",", "CANCEL_CRACKING_PROCESS", ")", ";", "}", "return", "cracking_state", ".", "password_found", ";", "}" ]
Crack Password.
[ "Crack", "Password", "." ]
[ "// 1% of total.", "// Create each worker's queue.", "// Create a chunk (an interval of the 500000 possible passwords).", "// Give the chunk to a thread.", "// Move to the next thread, which has", "// fewer enqueued tasks than the previous.", "// Sleep for a while to prevent high CPU usage.", "// Password was found! Issue an order to abort search.", "// Notice we don't really join. We don't even care if they finished or not", "// before returning the password found." ]
[ { "param": "filename", "type": "char" }, { "param": "n_threads", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n_threads", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fdd7733e6e8b865f1ff45fe7c307c9145907862
Comp-UFSCar/operating-systems
projects/gauss-elimination/compute_gold.c
[ "MIT" ]
C
compute_gold
int
int compute_gold(float* U, unsigned int num_elements){ unsigned int i, j, k; for (k = 0; k < num_elements; k++){ for (j = (k + 1); j < num_elements; j++){ // Reduce the current row if (U[num_elements*k + k] == 0){ printf("Numerical instability detected. The principal diagonal element is zero. \n"); return 0; } U[num_elements * k + j] = (float)(U[num_elements * k + j] / U[num_elements * k + k]); // Division step } U[num_elements * k + k] = 1; // Set the principal diagonal entry in U to be 1 for (i = (k+1); i < num_elements; i++){ for (j = (k+1); j < num_elements; j++) U[num_elements * i + j] = U[num_elements * i + j] - (U[num_elements * i + k] * U[num_elements * k + j]); // Elimination step U[num_elements * i + k] = 0; } } return 1; }
// Perform Gaussian elimination in place on the U matrix
Perform Gaussian elimination in place on the U matrix
[ "Perform", "Gaussian", "elimination", "in", "place", "on", "the", "U", "matrix" ]
int compute_gold(float* U, unsigned int num_elements){ unsigned int i, j, k; for (k = 0; k < num_elements; k++){ for (j = (k + 1); j < num_elements; j++){ if (U[num_elements*k + k] == 0){ printf("Numerical instability detected. The principal diagonal element is zero. \n"); return 0; } U[num_elements * k + j] = (float)(U[num_elements * k + j] / U[num_elements * k + k]); } U[num_elements * k + k] = 1; for (i = (k+1); i < num_elements; i++){ for (j = (k+1); j < num_elements; j++) U[num_elements * i + j] = U[num_elements * i + j] - (U[num_elements * i + k] * U[num_elements * k + j]); U[num_elements * i + k] = 0; } } return 1; }
[ "int", "compute_gold", "(", "float", "*", "U", ",", "unsigned", "int", "num_elements", ")", "{", "unsigned", "int", "i", ",", "j", ",", "k", ";", "for", "(", "k", "=", "0", ";", "k", "<", "num_elements", ";", "k", "++", ")", "{", "for", "(", "j", "=", "(", "k", "+", "1", ")", ";", "j", "<", "num_elements", ";", "j", "++", ")", "{", "if", "(", "U", "[", "num_elements", "*", "k", "+", "k", "]", "==", "0", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "return", "0", ";", "}", "U", "[", "num_elements", "*", "k", "+", "j", "]", "=", "(", "float", ")", "(", "U", "[", "num_elements", "*", "k", "+", "j", "]", "/", "U", "[", "num_elements", "*", "k", "+", "k", "]", ")", ";", "}", "U", "[", "num_elements", "*", "k", "+", "k", "]", "=", "1", ";", "for", "(", "i", "=", "(", "k", "+", "1", ")", ";", "i", "<", "num_elements", ";", "i", "++", ")", "{", "for", "(", "j", "=", "(", "k", "+", "1", ")", ";", "j", "<", "num_elements", ";", "j", "++", ")", "U", "[", "num_elements", "*", "i", "+", "j", "]", "=", "U", "[", "num_elements", "*", "i", "+", "j", "]", "-", "(", "U", "[", "num_elements", "*", "i", "+", "k", "]", "*", "U", "[", "num_elements", "*", "k", "+", "j", "]", ")", ";", "U", "[", "num_elements", "*", "i", "+", "k", "]", "=", "0", ";", "}", "}", "return", "1", ";", "}" ]
Perform Gaussian elimination in place on the U matrix
[ "Perform", "Gaussian", "elimination", "in", "place", "on", "the", "U", "matrix" ]
[ "// Reduce the current row", "// Division step", "// Set the principal diagonal entry in U to be 1 ", "// Elimination step" ]
[ { "param": "U", "type": "float" }, { "param": "num_elements", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "U", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num_elements", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3aa83d2b63848ec745fd0a378b23e87fa20e362d
Comp-UFSCar/operating-systems
projects/chat-with-pipes/client.c
[ "MIT" ]
C
ExitHandler
void
static void ExitHandler ( int signalNumber ) { // informing the server that this client is leaving requester = open (CONNECTION_REQUESTER, O_WRONLY); strcpy (self.message, CONNECTION_CLOSE_TOKEN); SendChatMessage (requester, self); close (requester); close (sender); close (receiver); printf ("\nBye, %s.\n", self.username); exit (0); }
/** * Signals the exit of this client to the server * * @param signalNumber */
Signals the exit of this client to the server @param signalNumber
[ "Signals", "the", "exit", "of", "this", "client", "to", "the", "server", "@param", "signalNumber" ]
static void ExitHandler ( int signalNumber ) { requester = open (CONNECTION_REQUESTER, O_WRONLY); strcpy (self.message, CONNECTION_CLOSE_TOKEN); SendChatMessage (requester, self); close (requester); close (sender); close (receiver); printf ("\nBye, %s.\n", self.username); exit (0); }
[ "static", "void", "ExitHandler", "(", "int", "signalNumber", ")", "{", "requester", "=", "open", "(", "CONNECTION_REQUESTER", ",", "O_WRONLY", ")", ";", "strcpy", "(", "self", ".", "message", ",", "CONNECTION_CLOSE_TOKEN", ")", ";", "SendChatMessage", "(", "requester", ",", "self", ")", ";", "close", "(", "requester", ")", ";", "close", "(", "sender", ")", ";", "close", "(", "receiver", ")", ";", "printf", "(", "\"", "\\n", "\\n", "\"", ",", "self", ".", "username", ")", ";", "exit", "(", "0", ")", ";", "}" ]
Signals the exit of this client to the server
[ "Signals", "the", "exit", "of", "this", "client", "to", "the", "server" ]
[ "// informing the server that this client is leaving" ]
[ { "param": "signalNumber", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "signalNumber", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3aa83d2b63848ec745fd0a378b23e87fa20e362d
Comp-UFSCar/operating-systems
projects/chat-with-pipes/client.c
[ "MIT" ]
C
ClientReceiver
void
void * ClientReceiver ( void * ptr ) { char receiverSocket [MAX_USERNAME_SIZE + 19]; strcpy (receiverSocket, "/tmp/ldlink"); strcat (receiverSocket, self.username); while ( true ) { receiver = open (receiverSocket, O_RDONLY); ChatMessage current = ReadChatMessage (receiver); close (receiver); if ( strcmp (current.username, "\0") == 0 ) continue; printf ("<<Self %s>> %s says: %s\n", self.username, current.username, current.message); } }
/** * Handle receiving of messages from the server * */
Handle receiving of messages from the server
[ "Handle", "receiving", "of", "messages", "from", "the", "server" ]
void * ClientReceiver ( void * ptr ) { char receiverSocket [MAX_USERNAME_SIZE + 19]; strcpy (receiverSocket, "/tmp/ldlink"); strcat (receiverSocket, self.username); while ( true ) { receiver = open (receiverSocket, O_RDONLY); ChatMessage current = ReadChatMessage (receiver); close (receiver); if ( strcmp (current.username, "\0") == 0 ) continue; printf ("<<Self %s>> %s says: %s\n", self.username, current.username, current.message); } }
[ "void", "*", "ClientReceiver", "(", "void", "*", "ptr", ")", "{", "char", "receiverSocket", "[", "MAX_USERNAME_SIZE", "+", "19", "]", ";", "strcpy", "(", "receiverSocket", ",", "\"", "\"", ")", ";", "strcat", "(", "receiverSocket", ",", "self", ".", "username", ")", ";", "while", "(", "true", ")", "{", "receiver", "=", "open", "(", "receiverSocket", ",", "O_RDONLY", ")", ";", "ChatMessage", "current", "=", "ReadChatMessage", "(", "receiver", ")", ";", "close", "(", "receiver", ")", ";", "if", "(", "strcmp", "(", "current", ".", "username", ",", "\"", "\\0", "\"", ")", "==", "0", ")", "continue", ";", "printf", "(", "\"", "\\n", "\"", ",", "self", ".", "username", ",", "current", ".", "username", ",", "current", ".", "message", ")", ";", "}", "}" ]
Handle receiving of messages from the server
[ "Handle", "receiving", "of", "messages", "from", "the", "server" ]
[]
[ { "param": "ptr", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
819d14c26e52f65df4d7f23758269a5e6e5f7a05
klevzoff/metismex
src/METIS_SepPartition_mex.c
[ "MIT" ]
C
mexFunction
void
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Argument checking if (nrhs != 5) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong input."); if (nlhs != 3) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong output."); // Input and output variables idx_t nvtxs = (idx_t) mxGetScalar(nvtxs_in); idx_t *xadj; GetIdxArray(xadj_in,&xadj); idx_t *adjncy; GetIdxArray(adjncy_in,&adjncy); idx_t *vwgt; GetIdxArray(vwgt_in,&vwgt); idx_t options[METIS_NOPTIONS]; GetOptions(options_in, options); idx_t *sepidx; idx_t *lgraphidx; idx_t *rgraphidx; // Metis main function idx_t i, nnvtxs=0; idx_t ptlgraph, ptrgraph, ptsep; graph_t *graph=NULL; ctrl_t *ctrl; idx_t *piperm; idx_t snvtxs[3]; idx_t *where; /* set up malloc cleaning code and signal catchers */ if (!gk_malloc_init()) CheckReturn( METIS_ERROR_MEMORY, FUNC_NAME ); // set up the run time parameters ctrl = SetupCtrl(METIS_OP_OMETIS, options, 1, 3, NULL, NULL); // prune the dense columns if (ctrl->pfactor > 0.0) { piperm = imalloc(nvtxs, "OMETIS: piperm"); graph = PruneGraph(ctrl, nvtxs, xadj, adjncy, vwgt, piperm, ctrl->pfactor); if (graph == NULL) { // if there was no prunning, cleanup the pfactor gk_free((void **)&piperm, LTERM); ctrl->pfactor = 0.0; } else { nnvtxs = graph->nvtxs; // disable compression if prunning took place ctrl->compress = 0; } } // compress the graph if (ctrl->compress) ctrl->compress = 0; // if no prunning and no compression, setup the graph in the normal way. if (ctrl->pfactor == 0.0 && ctrl->compress == 0) graph = SetupGraph(ctrl, nvtxs, 1, xadj, adjncy, vwgt, NULL, NULL); ASSERT(CheckGraph(graph, ctrl->numflag, 1)); /* allocate workspace memory */ AllocateWorkSpace(ctrl, graph); MlevelNodeBisectionMultiple(ctrl, graph); snvtxs[0] = 0; snvtxs[1] = 0; snvtxs[2] = 0; if (ctrl->pfactor > 0.0) snvtxs[2] += nvtxs-nnvtxs; where = graph->where; for (i=0; i<graph->nvtxs; i++) snvtxs[where[i]]++; lgraphidx = (idx_t*) mxCalloc (snvtxs[0], sizeof(idx_t)); rgraphidx = (idx_t*) mxCalloc (snvtxs[1], sizeof(idx_t)); sepidx = (idx_t*) mxCalloc (snvtxs[2], sizeof(idx_t)); ptlgraph = 0; ptrgraph = 0; ptsep = 0; if (ctrl->pfactor > 0.0) { for (i=0; i<graph->nvtxs; i++) if (where[i] == 0) lgraphidx[ptlgraph++] = piperm[i]; else if (where[i] == 1) rgraphidx[ptrgraph++] = piperm[i]; else sepidx[ptsep++] = piperm[i]; for (i=nnvtxs; i<nvtxs; i++) sepidx[ptsep++] = piperm[i]; gk_free((void **)&piperm, LTERM); } else { for (i=0; i<graph->nvtxs; i++) if (where[i] == 0) lgraphidx[ptlgraph++] = i; else if (where[i] == 1) rgraphidx[ptrgraph++] = i; else sepidx[ptsep++] = i; } /* clean up */ FreeCtrl(&ctrl); // Output lgraphidx_out = mxCreateDoubleMatrix(1,ptlgraph,mxREAL); mxSetData(lgraphidx_out,mxMalloc(sizeof(double)*ptlgraph)); double *lgraphidx_out_pr = mxGetPr(lgraphidx_out); for(idx_t i=0; i<ptlgraph; i++) lgraphidx_out_pr[i] = (double) lgraphidx[i]; rgraphidx_out = mxCreateDoubleMatrix(1,ptrgraph,mxREAL); mxSetData(rgraphidx_out,mxMalloc(sizeof(double)*ptrgraph)); double *rgraphidx_out_pr = mxGetPr(rgraphidx_out); for(idx_t i=0; i<ptrgraph; i++) rgraphidx_out_pr[i] = (double) rgraphidx[i]; sepidx_out = mxCreateDoubleMatrix(1,ptsep,mxREAL); mxSetData(sepidx_out,mxMalloc(sizeof(double)*ptsep)); double *sepidx_out_pr = mxGetPr(sepidx_out); for(idx_t i=0; i<ptsep; i++) sepidx_out_pr[i] = (double) sepidx[i]; }
/************************************************************************** * mexFunction: gateway routine for MATLAB interface. ***************************************************************************/
gateway routine for MATLAB interface.
[ "gateway", "routine", "for", "MATLAB", "interface", "." ]
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { if (nrhs != 5) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong input."); if (nlhs != 3) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong output."); idx_t nvtxs = (idx_t) mxGetScalar(nvtxs_in); idx_t *xadj; GetIdxArray(xadj_in,&xadj); idx_t *adjncy; GetIdxArray(adjncy_in,&adjncy); idx_t *vwgt; GetIdxArray(vwgt_in,&vwgt); idx_t options[METIS_NOPTIONS]; GetOptions(options_in, options); idx_t *sepidx; idx_t *lgraphidx; idx_t *rgraphidx; idx_t i, nnvtxs=0; idx_t ptlgraph, ptrgraph, ptsep; graph_t *graph=NULL; ctrl_t *ctrl; idx_t *piperm; idx_t snvtxs[3]; idx_t *where; if (!gk_malloc_init()) CheckReturn( METIS_ERROR_MEMORY, FUNC_NAME ); ctrl = SetupCtrl(METIS_OP_OMETIS, options, 1, 3, NULL, NULL); if (ctrl->pfactor > 0.0) { piperm = imalloc(nvtxs, "OMETIS: piperm"); graph = PruneGraph(ctrl, nvtxs, xadj, adjncy, vwgt, piperm, ctrl->pfactor); if (graph == NULL) { gk_free((void **)&piperm, LTERM); ctrl->pfactor = 0.0; } else { nnvtxs = graph->nvtxs; ctrl->compress = 0; } } if (ctrl->compress) ctrl->compress = 0; if (ctrl->pfactor == 0.0 && ctrl->compress == 0) graph = SetupGraph(ctrl, nvtxs, 1, xadj, adjncy, vwgt, NULL, NULL); ASSERT(CheckGraph(graph, ctrl->numflag, 1)); AllocateWorkSpace(ctrl, graph); MlevelNodeBisectionMultiple(ctrl, graph); snvtxs[0] = 0; snvtxs[1] = 0; snvtxs[2] = 0; if (ctrl->pfactor > 0.0) snvtxs[2] += nvtxs-nnvtxs; where = graph->where; for (i=0; i<graph->nvtxs; i++) snvtxs[where[i]]++; lgraphidx = (idx_t*) mxCalloc (snvtxs[0], sizeof(idx_t)); rgraphidx = (idx_t*) mxCalloc (snvtxs[1], sizeof(idx_t)); sepidx = (idx_t*) mxCalloc (snvtxs[2], sizeof(idx_t)); ptlgraph = 0; ptrgraph = 0; ptsep = 0; if (ctrl->pfactor > 0.0) { for (i=0; i<graph->nvtxs; i++) if (where[i] == 0) lgraphidx[ptlgraph++] = piperm[i]; else if (where[i] == 1) rgraphidx[ptrgraph++] = piperm[i]; else sepidx[ptsep++] = piperm[i]; for (i=nnvtxs; i<nvtxs; i++) sepidx[ptsep++] = piperm[i]; gk_free((void **)&piperm, LTERM); } else { for (i=0; i<graph->nvtxs; i++) if (where[i] == 0) lgraphidx[ptlgraph++] = i; else if (where[i] == 1) rgraphidx[ptrgraph++] = i; else sepidx[ptsep++] = i; } FreeCtrl(&ctrl); lgraphidx_out = mxCreateDoubleMatrix(1,ptlgraph,mxREAL); mxSetData(lgraphidx_out,mxMalloc(sizeof(double)*ptlgraph)); double *lgraphidx_out_pr = mxGetPr(lgraphidx_out); for(idx_t i=0; i<ptlgraph; i++) lgraphidx_out_pr[i] = (double) lgraphidx[i]; rgraphidx_out = mxCreateDoubleMatrix(1,ptrgraph,mxREAL); mxSetData(rgraphidx_out,mxMalloc(sizeof(double)*ptrgraph)); double *rgraphidx_out_pr = mxGetPr(rgraphidx_out); for(idx_t i=0; i<ptrgraph; i++) rgraphidx_out_pr[i] = (double) rgraphidx[i]; sepidx_out = mxCreateDoubleMatrix(1,ptsep,mxREAL); mxSetData(sepidx_out,mxMalloc(sizeof(double)*ptsep)); double *sepidx_out_pr = mxGetPr(sepidx_out); for(idx_t i=0; i<ptsep; i++) sepidx_out_pr[i] = (double) sepidx[i]; }
[ "void", "mexFunction", "(", "int", "nlhs", ",", "mxArray", "*", "plhs", "[", "]", ",", "int", "nrhs", ",", "const", "mxArray", "*", "prhs", "[", "]", ")", "{", "if", "(", "nrhs", "!=", "5", ")", "mexErrMsgIdAndTxt", "(", "FUNC_NAME", ",", "\"", "\"", ")", ";", "if", "(", "nlhs", "!=", "3", ")", "mexErrMsgIdAndTxt", "(", "FUNC_NAME", ",", "\"", "\"", ")", ";", "idx_t", "nvtxs", "=", "(", "idx_t", ")", "mxGetScalar", "(", "nvtxs_in", ")", ";", "idx_t", "*", "xadj", ";", "GetIdxArray", "(", "xadj_in", ",", "&", "xadj", ")", ";", "idx_t", "*", "adjncy", ";", "GetIdxArray", "(", "adjncy_in", ",", "&", "adjncy", ")", ";", "idx_t", "*", "vwgt", ";", "GetIdxArray", "(", "vwgt_in", ",", "&", "vwgt", ")", ";", "idx_t", "options", "[", "METIS_NOPTIONS", "]", ";", "GetOptions", "(", "options_in", ",", "options", ")", ";", "idx_t", "*", "sepidx", ";", "idx_t", "*", "lgraphidx", ";", "idx_t", "*", "rgraphidx", ";", "idx_t", "i", ",", "nnvtxs", "=", "0", ";", "idx_t", "ptlgraph", ",", "ptrgraph", ",", "ptsep", ";", "graph_t", "*", "graph", "=", "NULL", ";", "ctrl_t", "*", "ctrl", ";", "idx_t", "*", "piperm", ";", "idx_t", "snvtxs", "[", "3", "]", ";", "idx_t", "*", "where", ";", "if", "(", "!", "gk_malloc_init", "(", ")", ")", "CheckReturn", "(", "METIS_ERROR_MEMORY", ",", "FUNC_NAME", ")", ";", "ctrl", "=", "SetupCtrl", "(", "METIS_OP_OMETIS", ",", "options", ",", "1", ",", "3", ",", "NULL", ",", "NULL", ")", ";", "if", "(", "ctrl", "->", "pfactor", ">", "0.0", ")", "{", "piperm", "=", "imalloc", "(", "nvtxs", ",", "\"", "\"", ")", ";", "graph", "=", "PruneGraph", "(", "ctrl", ",", "nvtxs", ",", "xadj", ",", "adjncy", ",", "vwgt", ",", "piperm", ",", "ctrl", "->", "pfactor", ")", ";", "if", "(", "graph", "==", "NULL", ")", "{", "gk_free", "(", "(", "void", "*", "*", ")", "&", "piperm", ",", "LTERM", ")", ";", "ctrl", "->", "pfactor", "=", "0.0", ";", "}", "else", "{", "nnvtxs", "=", "graph", "->", "nvtxs", ";", "ctrl", "->", "compress", "=", "0", ";", "}", "}", "if", "(", "ctrl", "->", "compress", ")", "ctrl", "->", "compress", "=", "0", ";", "if", "(", "ctrl", "->", "pfactor", "==", "0.0", "&&", "ctrl", "->", "compress", "==", "0", ")", "graph", "=", "SetupGraph", "(", "ctrl", ",", "nvtxs", ",", "1", ",", "xadj", ",", "adjncy", ",", "vwgt", ",", "NULL", ",", "NULL", ")", ";", "ASSERT", "(", "CheckGraph", "(", "graph", ",", "ctrl", "->", "numflag", ",", "1", ")", ")", ";", "AllocateWorkSpace", "(", "ctrl", ",", "graph", ")", ";", "MlevelNodeBisectionMultiple", "(", "ctrl", ",", "graph", ")", ";", "snvtxs", "[", "0", "]", "=", "0", ";", "snvtxs", "[", "1", "]", "=", "0", ";", "snvtxs", "[", "2", "]", "=", "0", ";", "if", "(", "ctrl", "->", "pfactor", ">", "0.0", ")", "snvtxs", "[", "2", "]", "+=", "nvtxs", "-", "nnvtxs", ";", "where", "=", "graph", "->", "where", ";", "for", "(", "i", "=", "0", ";", "i", "<", "graph", "->", "nvtxs", ";", "i", "++", ")", "snvtxs", "[", "where", "[", "i", "]", "]", "++", ";", "lgraphidx", "=", "(", "idx_t", "*", ")", "mxCalloc", "(", "snvtxs", "[", "0", "]", ",", "sizeof", "(", "idx_t", ")", ")", ";", "rgraphidx", "=", "(", "idx_t", "*", ")", "mxCalloc", "(", "snvtxs", "[", "1", "]", ",", "sizeof", "(", "idx_t", ")", ")", ";", "sepidx", "=", "(", "idx_t", "*", ")", "mxCalloc", "(", "snvtxs", "[", "2", "]", ",", "sizeof", "(", "idx_t", ")", ")", ";", "ptlgraph", "=", "0", ";", "ptrgraph", "=", "0", ";", "ptsep", "=", "0", ";", "if", "(", "ctrl", "->", "pfactor", ">", "0.0", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "graph", "->", "nvtxs", ";", "i", "++", ")", "if", "(", "where", "[", "i", "]", "==", "0", ")", "lgraphidx", "[", "ptlgraph", "++", "]", "=", "piperm", "[", "i", "]", ";", "else", "if", "(", "where", "[", "i", "]", "==", "1", ")", "rgraphidx", "[", "ptrgraph", "++", "]", "=", "piperm", "[", "i", "]", ";", "else", "sepidx", "[", "ptsep", "++", "]", "=", "piperm", "[", "i", "]", ";", "for", "(", "i", "=", "nnvtxs", ";", "i", "<", "nvtxs", ";", "i", "++", ")", "sepidx", "[", "ptsep", "++", "]", "=", "piperm", "[", "i", "]", ";", "gk_free", "(", "(", "void", "*", "*", ")", "&", "piperm", ",", "LTERM", ")", ";", "}", "else", "{", "for", "(", "i", "=", "0", ";", "i", "<", "graph", "->", "nvtxs", ";", "i", "++", ")", "if", "(", "where", "[", "i", "]", "==", "0", ")", "lgraphidx", "[", "ptlgraph", "++", "]", "=", "i", ";", "else", "if", "(", "where", "[", "i", "]", "==", "1", ")", "rgraphidx", "[", "ptrgraph", "++", "]", "=", "i", ";", "else", "sepidx", "[", "ptsep", "++", "]", "=", "i", ";", "}", "FreeCtrl", "(", "&", "ctrl", ")", ";", "lgraphidx_out", "=", "mxCreateDoubleMatrix", "(", "1", ",", "ptlgraph", ",", "mxREAL", ")", ";", "mxSetData", "(", "lgraphidx_out", ",", "mxMalloc", "(", "sizeof", "(", "double", ")", "*", "ptlgraph", ")", ")", ";", "double", "*", "lgraphidx_out_pr", "=", "mxGetPr", "(", "lgraphidx_out", ")", ";", "for", "(", "idx_t", "i", "=", "0", ";", "i", "<", "ptlgraph", ";", "i", "++", ")", "lgraphidx_out_pr", "[", "i", "]", "=", "(", "double", ")", "lgraphidx", "[", "i", "]", ";", "rgraphidx_out", "=", "mxCreateDoubleMatrix", "(", "1", ",", "ptrgraph", ",", "mxREAL", ")", ";", "mxSetData", "(", "rgraphidx_out", ",", "mxMalloc", "(", "sizeof", "(", "double", ")", "*", "ptrgraph", ")", ")", ";", "double", "*", "rgraphidx_out_pr", "=", "mxGetPr", "(", "rgraphidx_out", ")", ";", "for", "(", "idx_t", "i", "=", "0", ";", "i", "<", "ptrgraph", ";", "i", "++", ")", "rgraphidx_out_pr", "[", "i", "]", "=", "(", "double", ")", "rgraphidx", "[", "i", "]", ";", "sepidx_out", "=", "mxCreateDoubleMatrix", "(", "1", ",", "ptsep", ",", "mxREAL", ")", ";", "mxSetData", "(", "sepidx_out", ",", "mxMalloc", "(", "sizeof", "(", "double", ")", "*", "ptsep", ")", ")", ";", "double", "*", "sepidx_out_pr", "=", "mxGetPr", "(", "sepidx_out", ")", ";", "for", "(", "idx_t", "i", "=", "0", ";", "i", "<", "ptsep", ";", "i", "++", ")", "sepidx_out_pr", "[", "i", "]", "=", "(", "double", ")", "sepidx", "[", "i", "]", ";", "}" ]
mexFunction: gateway routine for MATLAB interface.
[ "mexFunction", ":", "gateway", "routine", "for", "MATLAB", "interface", "." ]
[ "// Argument checking", "// Input and output variables", "// Metis main function", "/* set up malloc cleaning code and signal catchers */", "// set up the run time parameters", "// prune the dense columns", "// if there was no prunning, cleanup the pfactor", "// disable compression if prunning took place", "// compress the graph", "// if no prunning and no compression, setup the graph in the normal way.", "/* allocate workspace memory */", "/* clean up */", "// Output" ]
[ { "param": "nlhs", "type": "int" }, { "param": "plhs", "type": "mxArray" }, { "param": "nrhs", "type": "int" }, { "param": "prhs", "type": "mxArray" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "nlhs", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "plhs", "type": "mxArray", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nrhs", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prhs", "type": "mxArray", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c950c18594cca6efa26edf2b327ba1b58d1b232f
klevzoff/metismex
src/METIS_PartMeshDual_mex.c
[ "MIT" ]
C
mexFunction
void
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Argument checking if (nrhs != 10) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong input."); if (nlhs != 3) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong output."); // Input and output variables idx_t ne = (idx_t) mxGetScalar(ne_in); idx_t nn = (idx_t) mxGetScalar(nn_in); idx_t *eptr; GetIdxArray(eptr_in,&eptr); idx_t *eind; GetIdxArray(eind_in,&eind); idx_t *vwgt; GetIdxArray(vwgt_in,&vwgt); idx_t *vsize; GetIdxArray(vsize_in,&vsize); idx_t ncommon = (idx_t) mxGetScalar(ncommon_in); idx_t nparts = (idx_t) mxGetScalar(nparts_in); real_t *tpwgts; GetRealArray(tpwgts_in,&tpwgts); idx_t options[METIS_NOPTIONS]; GetOptions(options_in, options); idx_t objval; idx_t *epart = (idx_t*) mxCalloc (ne, sizeof(idx_t)); idx_t *npart = (idx_t*) mxCalloc (nn, sizeof(idx_t)); // Metis main function int info = METIS_PartMeshDual( &ne, &nn, eptr, eind, vwgt, vsize, &ncommon, &nparts, tpwgts, options, &objval, epart, npart); CheckReturn(info, FUNC_NAME); // Output objval_out = mxCreateDoubleScalar( (double) objval ); epart_out = mxCreateDoubleMatrix(1,ne,mxREAL); mxSetData(epart_out,mxMalloc(sizeof(double)*ne)); double *epart_out_pr = mxGetPr(epart_out); for(idx_t i=0; i<ne; i++) epart_out_pr[i] = (double) epart[i]; npart_out = mxCreateDoubleMatrix(1,nn,mxREAL); mxSetData(npart_out,mxMalloc(sizeof(double)*nn)); double *npart_out_pr = mxGetPr(npart_out); for(idx_t i=0; i<nn; i++) npart_out_pr[i] = (double) npart[i]; }
/************************************************************************** * mexFunction: gateway routine for MATLAB interface. ***************************************************************************/
gateway routine for MATLAB interface.
[ "gateway", "routine", "for", "MATLAB", "interface", "." ]
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { if (nrhs != 10) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong input."); if (nlhs != 3) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong output."); idx_t ne = (idx_t) mxGetScalar(ne_in); idx_t nn = (idx_t) mxGetScalar(nn_in); idx_t *eptr; GetIdxArray(eptr_in,&eptr); idx_t *eind; GetIdxArray(eind_in,&eind); idx_t *vwgt; GetIdxArray(vwgt_in,&vwgt); idx_t *vsize; GetIdxArray(vsize_in,&vsize); idx_t ncommon = (idx_t) mxGetScalar(ncommon_in); idx_t nparts = (idx_t) mxGetScalar(nparts_in); real_t *tpwgts; GetRealArray(tpwgts_in,&tpwgts); idx_t options[METIS_NOPTIONS]; GetOptions(options_in, options); idx_t objval; idx_t *epart = (idx_t*) mxCalloc (ne, sizeof(idx_t)); idx_t *npart = (idx_t*) mxCalloc (nn, sizeof(idx_t)); int info = METIS_PartMeshDual( &ne, &nn, eptr, eind, vwgt, vsize, &ncommon, &nparts, tpwgts, options, &objval, epart, npart); CheckReturn(info, FUNC_NAME); objval_out = mxCreateDoubleScalar( (double) objval ); epart_out = mxCreateDoubleMatrix(1,ne,mxREAL); mxSetData(epart_out,mxMalloc(sizeof(double)*ne)); double *epart_out_pr = mxGetPr(epart_out); for(idx_t i=0; i<ne; i++) epart_out_pr[i] = (double) epart[i]; npart_out = mxCreateDoubleMatrix(1,nn,mxREAL); mxSetData(npart_out,mxMalloc(sizeof(double)*nn)); double *npart_out_pr = mxGetPr(npart_out); for(idx_t i=0; i<nn; i++) npart_out_pr[i] = (double) npart[i]; }
[ "void", "mexFunction", "(", "int", "nlhs", ",", "mxArray", "*", "plhs", "[", "]", ",", "int", "nrhs", ",", "const", "mxArray", "*", "prhs", "[", "]", ")", "{", "if", "(", "nrhs", "!=", "10", ")", "mexErrMsgIdAndTxt", "(", "FUNC_NAME", ",", "\"", "\"", ")", ";", "if", "(", "nlhs", "!=", "3", ")", "mexErrMsgIdAndTxt", "(", "FUNC_NAME", ",", "\"", "\"", ")", ";", "idx_t", "ne", "=", "(", "idx_t", ")", "mxGetScalar", "(", "ne_in", ")", ";", "idx_t", "nn", "=", "(", "idx_t", ")", "mxGetScalar", "(", "nn_in", ")", ";", "idx_t", "*", "eptr", ";", "GetIdxArray", "(", "eptr_in", ",", "&", "eptr", ")", ";", "idx_t", "*", "eind", ";", "GetIdxArray", "(", "eind_in", ",", "&", "eind", ")", ";", "idx_t", "*", "vwgt", ";", "GetIdxArray", "(", "vwgt_in", ",", "&", "vwgt", ")", ";", "idx_t", "*", "vsize", ";", "GetIdxArray", "(", "vsize_in", ",", "&", "vsize", ")", ";", "idx_t", "ncommon", "=", "(", "idx_t", ")", "mxGetScalar", "(", "ncommon_in", ")", ";", "idx_t", "nparts", "=", "(", "idx_t", ")", "mxGetScalar", "(", "nparts_in", ")", ";", "real_t", "*", "tpwgts", ";", "GetRealArray", "(", "tpwgts_in", ",", "&", "tpwgts", ")", ";", "idx_t", "options", "[", "METIS_NOPTIONS", "]", ";", "GetOptions", "(", "options_in", ",", "options", ")", ";", "idx_t", "objval", ";", "idx_t", "*", "epart", "=", "(", "idx_t", "*", ")", "mxCalloc", "(", "ne", ",", "sizeof", "(", "idx_t", ")", ")", ";", "idx_t", "*", "npart", "=", "(", "idx_t", "*", ")", "mxCalloc", "(", "nn", ",", "sizeof", "(", "idx_t", ")", ")", ";", "int", "info", "=", "METIS_PartMeshDual", "(", "&", "ne", ",", "&", "nn", ",", "eptr", ",", "eind", ",", "vwgt", ",", "vsize", ",", "&", "ncommon", ",", "&", "nparts", ",", "tpwgts", ",", "options", ",", "&", "objval", ",", "epart", ",", "npart", ")", ";", "CheckReturn", "(", "info", ",", "FUNC_NAME", ")", ";", "objval_out", "=", "mxCreateDoubleScalar", "(", "(", "double", ")", "objval", ")", ";", "epart_out", "=", "mxCreateDoubleMatrix", "(", "1", ",", "ne", ",", "mxREAL", ")", ";", "mxSetData", "(", "epart_out", ",", "mxMalloc", "(", "sizeof", "(", "double", ")", "*", "ne", ")", ")", ";", "double", "*", "epart_out_pr", "=", "mxGetPr", "(", "epart_out", ")", ";", "for", "(", "idx_t", "i", "=", "0", ";", "i", "<", "ne", ";", "i", "++", ")", "epart_out_pr", "[", "i", "]", "=", "(", "double", ")", "epart", "[", "i", "]", ";", "npart_out", "=", "mxCreateDoubleMatrix", "(", "1", ",", "nn", ",", "mxREAL", ")", ";", "mxSetData", "(", "npart_out", ",", "mxMalloc", "(", "sizeof", "(", "double", ")", "*", "nn", ")", ")", ";", "double", "*", "npart_out_pr", "=", "mxGetPr", "(", "npart_out", ")", ";", "for", "(", "idx_t", "i", "=", "0", ";", "i", "<", "nn", ";", "i", "++", ")", "npart_out_pr", "[", "i", "]", "=", "(", "double", ")", "npart", "[", "i", "]", ";", "}" ]
mexFunction: gateway routine for MATLAB interface.
[ "mexFunction", ":", "gateway", "routine", "for", "MATLAB", "interface", "." ]
[ "// Argument checking", "// Input and output variables", "// Metis main function", "// Output" ]
[ { "param": "nlhs", "type": "int" }, { "param": "plhs", "type": "mxArray" }, { "param": "nrhs", "type": "int" }, { "param": "prhs", "type": "mxArray" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "nlhs", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "plhs", "type": "mxArray", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nrhs", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prhs", "type": "mxArray", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
be714e749a11229a367a202116496a62d13e5e06
klevzoff/metismex
src/METIS_PartGraphRecursive_mex.c
[ "MIT" ]
C
mexFunction
void
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Argument checking if (nrhs != 11) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong input."); if (nlhs != 2) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong output."); // Input and output variables idx_t nvtxs = (idx_t) mxGetScalar(nvtxs_in); idx_t ncon = (idx_t) mxGetScalar(ncon_in); idx_t *xadj; GetIdxArray(xadj_in,&xadj); idx_t *adjncy; GetIdxArray(adjncy_in,&adjncy); idx_t *vwgt; GetIdxArray(vwgt_in,&vwgt); idx_t *vsize; GetIdxArray(vsize_in,&vsize); idx_t *adjwgt; GetIdxArray(adjwgt_in,&adjwgt); idx_t nparts = (idx_t) mxGetScalar(nparts_in); real_t *tpwgts; GetRealArray(tpwgts_in,&tpwgts); real_t *ubvec; GetRealArray(ubvec_in,&ubvec); idx_t options[METIS_NOPTIONS]; GetOptions(options_in, options); idx_t objval; idx_t *part = (idx_t*) mxCalloc (nvtxs, sizeof(idx_t)); // Metis main function int info = METIS_PartGraphRecursive( &nvtxs, &ncon, xadj, adjncy, vwgt, vsize, adjwgt, &nparts, tpwgts, ubvec, options, &objval, part); CheckReturn(info, FUNC_NAME); // Output objval_out = mxCreateDoubleScalar( (double) objval ); part_out = mxCreateDoubleMatrix(1,nvtxs,mxREAL); mxSetData(part_out,mxMalloc(sizeof(double)*nvtxs)); double *part_out_pr = mxGetPr(part_out); for(idx_t i=0; i<nvtxs; i++) part_out_pr[i] = (double) part[i]; }
/************************************************************************** * mexFunction: gateway routine for MATLAB interface. ***************************************************************************/
gateway routine for MATLAB interface.
[ "gateway", "routine", "for", "MATLAB", "interface", "." ]
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { if (nrhs != 11) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong input."); if (nlhs != 2) mexErrMsgIdAndTxt(FUNC_NAME, "Wrong output."); idx_t nvtxs = (idx_t) mxGetScalar(nvtxs_in); idx_t ncon = (idx_t) mxGetScalar(ncon_in); idx_t *xadj; GetIdxArray(xadj_in,&xadj); idx_t *adjncy; GetIdxArray(adjncy_in,&adjncy); idx_t *vwgt; GetIdxArray(vwgt_in,&vwgt); idx_t *vsize; GetIdxArray(vsize_in,&vsize); idx_t *adjwgt; GetIdxArray(adjwgt_in,&adjwgt); idx_t nparts = (idx_t) mxGetScalar(nparts_in); real_t *tpwgts; GetRealArray(tpwgts_in,&tpwgts); real_t *ubvec; GetRealArray(ubvec_in,&ubvec); idx_t options[METIS_NOPTIONS]; GetOptions(options_in, options); idx_t objval; idx_t *part = (idx_t*) mxCalloc (nvtxs, sizeof(idx_t)); int info = METIS_PartGraphRecursive( &nvtxs, &ncon, xadj, adjncy, vwgt, vsize, adjwgt, &nparts, tpwgts, ubvec, options, &objval, part); CheckReturn(info, FUNC_NAME); objval_out = mxCreateDoubleScalar( (double) objval ); part_out = mxCreateDoubleMatrix(1,nvtxs,mxREAL); mxSetData(part_out,mxMalloc(sizeof(double)*nvtxs)); double *part_out_pr = mxGetPr(part_out); for(idx_t i=0; i<nvtxs; i++) part_out_pr[i] = (double) part[i]; }
[ "void", "mexFunction", "(", "int", "nlhs", ",", "mxArray", "*", "plhs", "[", "]", ",", "int", "nrhs", ",", "const", "mxArray", "*", "prhs", "[", "]", ")", "{", "if", "(", "nrhs", "!=", "11", ")", "mexErrMsgIdAndTxt", "(", "FUNC_NAME", ",", "\"", "\"", ")", ";", "if", "(", "nlhs", "!=", "2", ")", "mexErrMsgIdAndTxt", "(", "FUNC_NAME", ",", "\"", "\"", ")", ";", "idx_t", "nvtxs", "=", "(", "idx_t", ")", "mxGetScalar", "(", "nvtxs_in", ")", ";", "idx_t", "ncon", "=", "(", "idx_t", ")", "mxGetScalar", "(", "ncon_in", ")", ";", "idx_t", "*", "xadj", ";", "GetIdxArray", "(", "xadj_in", ",", "&", "xadj", ")", ";", "idx_t", "*", "adjncy", ";", "GetIdxArray", "(", "adjncy_in", ",", "&", "adjncy", ")", ";", "idx_t", "*", "vwgt", ";", "GetIdxArray", "(", "vwgt_in", ",", "&", "vwgt", ")", ";", "idx_t", "*", "vsize", ";", "GetIdxArray", "(", "vsize_in", ",", "&", "vsize", ")", ";", "idx_t", "*", "adjwgt", ";", "GetIdxArray", "(", "adjwgt_in", ",", "&", "adjwgt", ")", ";", "idx_t", "nparts", "=", "(", "idx_t", ")", "mxGetScalar", "(", "nparts_in", ")", ";", "real_t", "*", "tpwgts", ";", "GetRealArray", "(", "tpwgts_in", ",", "&", "tpwgts", ")", ";", "real_t", "*", "ubvec", ";", "GetRealArray", "(", "ubvec_in", ",", "&", "ubvec", ")", ";", "idx_t", "options", "[", "METIS_NOPTIONS", "]", ";", "GetOptions", "(", "options_in", ",", "options", ")", ";", "idx_t", "objval", ";", "idx_t", "*", "part", "=", "(", "idx_t", "*", ")", "mxCalloc", "(", "nvtxs", ",", "sizeof", "(", "idx_t", ")", ")", ";", "int", "info", "=", "METIS_PartGraphRecursive", "(", "&", "nvtxs", ",", "&", "ncon", ",", "xadj", ",", "adjncy", ",", "vwgt", ",", "vsize", ",", "adjwgt", ",", "&", "nparts", ",", "tpwgts", ",", "ubvec", ",", "options", ",", "&", "objval", ",", "part", ")", ";", "CheckReturn", "(", "info", ",", "FUNC_NAME", ")", ";", "objval_out", "=", "mxCreateDoubleScalar", "(", "(", "double", ")", "objval", ")", ";", "part_out", "=", "mxCreateDoubleMatrix", "(", "1", ",", "nvtxs", ",", "mxREAL", ")", ";", "mxSetData", "(", "part_out", ",", "mxMalloc", "(", "sizeof", "(", "double", ")", "*", "nvtxs", ")", ")", ";", "double", "*", "part_out_pr", "=", "mxGetPr", "(", "part_out", ")", ";", "for", "(", "idx_t", "i", "=", "0", ";", "i", "<", "nvtxs", ";", "i", "++", ")", "part_out_pr", "[", "i", "]", "=", "(", "double", ")", "part", "[", "i", "]", ";", "}" ]
mexFunction: gateway routine for MATLAB interface.
[ "mexFunction", ":", "gateway", "routine", "for", "MATLAB", "interface", "." ]
[ "// Argument checking", "// Input and output variables", "// Metis main function", "// Output" ]
[ { "param": "nlhs", "type": "int" }, { "param": "plhs", "type": "mxArray" }, { "param": "nrhs", "type": "int" }, { "param": "prhs", "type": "mxArray" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "nlhs", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "plhs", "type": "mxArray", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nrhs", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prhs", "type": "mxArray", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
68b82e2ed5bab63314edaeb2feb7a3799fd068ba
Advance2000/linphone
coreapi/upnp.c
[ "BSD-2-Clause" ]
C
linphone_upnp_igd_print
void
void linphone_upnp_igd_print(void *cookie, upnp_igd_print_level level, const char *fmt, va_list list) { int ortp_level = ORTP_DEBUG; switch(level) { case UPNP_IGD_MESSAGE: ortp_level = ORTP_MESSAGE; break; case UPNP_IGD_WARNING: ortp_level = ORTP_DEBUG; // Too verbose otherwise break; case UPNP_IGD_ERROR: ortp_level = ORTP_DEBUG; // Too verbose otherwise break; default: break; } ortp_logv(ortp_level, fmt, list); }
/* Convert uPnP IGD logs to ortp logs */
Convert uPnP IGD logs to ortp logs
[ "Convert", "uPnP", "IGD", "logs", "to", "ortp", "logs" ]
void linphone_upnp_igd_print(void *cookie, upnp_igd_print_level level, const char *fmt, va_list list) { int ortp_level = ORTP_DEBUG; switch(level) { case UPNP_IGD_MESSAGE: ortp_level = ORTP_MESSAGE; break; case UPNP_IGD_WARNING: ortp_level = ORTP_DEBUG; break; case UPNP_IGD_ERROR: ortp_level = ORTP_DEBUG; break; default: break; } ortp_logv(ortp_level, fmt, list); }
[ "void", "linphone_upnp_igd_print", "(", "void", "*", "cookie", ",", "upnp_igd_print_level", "level", ",", "const", "char", "*", "fmt", ",", "va_list", "list", ")", "{", "int", "ortp_level", "=", "ORTP_DEBUG", ";", "switch", "(", "level", ")", "{", "case", "UPNP_IGD_MESSAGE", ":", "ortp_level", "=", "ORTP_MESSAGE", ";", "break", ";", "case", "UPNP_IGD_WARNING", ":", "ortp_level", "=", "ORTP_DEBUG", ";", "break", ";", "case", "UPNP_IGD_ERROR", ":", "ortp_level", "=", "ORTP_DEBUG", ";", "break", ";", "default", ":", "break", ";", "}", "ortp_logv", "(", "ortp_level", ",", "fmt", ",", "list", ")", ";", "}" ]
Convert uPnP IGD logs to ortp logs
[ "Convert", "uPnP", "IGD", "logs", "to", "ortp", "logs" ]
[ "// Too verbose otherwise", "// Too verbose otherwise" ]
[ { "param": "cookie", "type": "void" }, { "param": "level", "type": "upnp_igd_print_level" }, { "param": "fmt", "type": "char" }, { "param": "list", "type": "va_list" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cookie", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "level", "type": "upnp_igd_print_level", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fmt", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "list", "type": "va_list", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1b2a01022e909b7507eb6f35a5af8bd60b892604
Advance2000/linphone
coreapi/player.c
[ "BSD-2-Clause" ]
C
linphone_player_open
int
int linphone_player_open(LinphonePlayer *obj, const char *filename, LinphonePlayerEofCallback cb, void *user_data){ obj->user_data=user_data; obj->cb=cb; return obj->open(obj,filename); }
/** * Open a new source on this player. * @param obj the player * @param filename file to open. * @param cb a callback used to notify end of play. * @param user_data a user-data provided in the callback to help the application to retrieve its context. * @return 0 if successful, -1 otherwise **/
Open a new source on this player. @param obj the player @param filename file to open. @param cb a callback used to notify end of play. @param user_data a user-data provided in the callback to help the application to retrieve its context. @return 0 if successful, -1 otherwise
[ "Open", "a", "new", "source", "on", "this", "player", ".", "@param", "obj", "the", "player", "@param", "filename", "file", "to", "open", ".", "@param", "cb", "a", "callback", "used", "to", "notify", "end", "of", "play", ".", "@param", "user_data", "a", "user", "-", "data", "provided", "in", "the", "callback", "to", "help", "the", "application", "to", "retrieve", "its", "context", ".", "@return", "0", "if", "successful", "-", "1", "otherwise" ]
int linphone_player_open(LinphonePlayer *obj, const char *filename, LinphonePlayerEofCallback cb, void *user_data){ obj->user_data=user_data; obj->cb=cb; return obj->open(obj,filename); }
[ "int", "linphone_player_open", "(", "LinphonePlayer", "*", "obj", ",", "const", "char", "*", "filename", ",", "LinphonePlayerEofCallback", "cb", ",", "void", "*", "user_data", ")", "{", "obj", "->", "user_data", "=", "user_data", ";", "obj", "->", "cb", "=", "cb", ";", "return", "obj", "->", "open", "(", "obj", ",", "filename", ")", ";", "}" ]
Open a new source on this player.
[ "Open", "a", "new", "source", "on", "this", "player", "." ]
[]
[ { "param": "obj", "type": "LinphonePlayer" }, { "param": "filename", "type": "char" }, { "param": "cb", "type": "LinphonePlayerEofCallback" }, { "param": "user_data", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "LinphonePlayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cb", "type": "LinphonePlayerEofCallback", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "user_data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2ca3fad47ce7b915d1c5ee36d09ab155c550bbcc
Advance2000/linphone
tester/message_tester.c
[ "BSD-2-Clause" ]
C
file_transfer_received
void
void file_transfer_received(LinphoneChatMessage *msg, const LinphoneContent* content, const LinphoneBuffer *buffer){ FILE* file=NULL; char *receive_file = bc_tester_file("receive_file.dump"); LinphoneChatRoom *cr = linphone_chat_message_get_chat_room(msg); LinphoneCore *lc = linphone_chat_room_get_core(cr); if (!linphone_chat_message_get_user_data(msg)) { /*first chunk, creating file*/ file = fopen(receive_file,"wb"); linphone_chat_message_set_user_data(msg,(void*)file); /*store fd for next chunks*/ } ms_free(receive_file); file = (FILE*)linphone_chat_message_get_user_data(msg); if (linphone_buffer_is_empty(buffer)) { /* tranfer complete */ stats* counters = get_stats(lc); counters->number_of_LinphoneFileTransferDownloadSuccessful++; fclose(file); } else { /* store content on a file*/ if (fwrite(linphone_buffer_get_content(buffer),linphone_buffer_get_size(buffer),1,file)==-1){ ms_error("file_transfer_received(): write() failed: %s",strerror(errno)); } } }
/** * function invoked when a file transfer is received. * */
function invoked when a file transfer is received.
[ "function", "invoked", "when", "a", "file", "transfer", "is", "received", "." ]
void file_transfer_received(LinphoneChatMessage *msg, const LinphoneContent* content, const LinphoneBuffer *buffer){ FILE* file=NULL; char *receive_file = bc_tester_file("receive_file.dump"); LinphoneChatRoom *cr = linphone_chat_message_get_chat_room(msg); LinphoneCore *lc = linphone_chat_room_get_core(cr); if (!linphone_chat_message_get_user_data(msg)) { file = fopen(receive_file,"wb"); linphone_chat_message_set_user_data(msg,(void*)file); } ms_free(receive_file); file = (FILE*)linphone_chat_message_get_user_data(msg); if (linphone_buffer_is_empty(buffer)) { stats* counters = get_stats(lc); counters->number_of_LinphoneFileTransferDownloadSuccessful++; fclose(file); } else { if (fwrite(linphone_buffer_get_content(buffer),linphone_buffer_get_size(buffer),1,file)==-1){ ms_error("file_transfer_received(): write() failed: %s",strerror(errno)); } } }
[ "void", "file_transfer_received", "(", "LinphoneChatMessage", "*", "msg", ",", "const", "LinphoneContent", "*", "content", ",", "const", "LinphoneBuffer", "*", "buffer", ")", "{", "FILE", "*", "file", "=", "NULL", ";", "char", "*", "receive_file", "=", "bc_tester_file", "(", "\"", "\"", ")", ";", "LinphoneChatRoom", "*", "cr", "=", "linphone_chat_message_get_chat_room", "(", "msg", ")", ";", "LinphoneCore", "*", "lc", "=", "linphone_chat_room_get_core", "(", "cr", ")", ";", "if", "(", "!", "linphone_chat_message_get_user_data", "(", "msg", ")", ")", "{", "file", "=", "fopen", "(", "receive_file", ",", "\"", "\"", ")", ";", "linphone_chat_message_set_user_data", "(", "msg", ",", "(", "void", "*", ")", "file", ")", ";", "}", "ms_free", "(", "receive_file", ")", ";", "file", "=", "(", "FILE", "*", ")", "linphone_chat_message_get_user_data", "(", "msg", ")", ";", "if", "(", "linphone_buffer_is_empty", "(", "buffer", ")", ")", "{", "stats", "*", "counters", "=", "get_stats", "(", "lc", ")", ";", "counters", "->", "number_of_LinphoneFileTransferDownloadSuccessful", "++", ";", "fclose", "(", "file", ")", ";", "}", "else", "{", "if", "(", "fwrite", "(", "linphone_buffer_get_content", "(", "buffer", ")", ",", "linphone_buffer_get_size", "(", "buffer", ")", ",", "1", ",", "file", ")", "==", "-1", ")", "{", "ms_error", "(", "\"", "\"", ",", "strerror", "(", "errno", ")", ")", ";", "}", "}", "}" ]
function invoked when a file transfer is received.
[ "function", "invoked", "when", "a", "file", "transfer", "is", "received", "." ]
[ "/*first chunk, creating file*/", "/*store fd for next chunks*/", "/* tranfer complete */", "/* store content on a file*/" ]
[ { "param": "msg", "type": "LinphoneChatMessage" }, { "param": "content", "type": "LinphoneContent" }, { "param": "buffer", "type": "LinphoneBuffer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "msg", "type": "LinphoneChatMessage", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "content", "type": "LinphoneContent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buffer", "type": "LinphoneBuffer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2ca3fad47ce7b915d1c5ee36d09ab155c550bbcc
Advance2000/linphone
tester/message_tester.c
[ "BSD-2-Clause" ]
C
tester_file_transfer_send
LinphoneBuffer
LinphoneBuffer * tester_file_transfer_send(LinphoneChatMessage *msg, const LinphoneContent* content, size_t offset, size_t size){ LinphoneBuffer *lb; size_t file_size; size_t size_to_send; uint8_t *buf; FILE *file_to_send = linphone_chat_message_get_user_data(msg); fseek(file_to_send, 0, SEEK_END); file_size = ftell(file_to_send); fseek(file_to_send, offset, SEEK_SET); size_to_send = MIN(size, file_size - offset); buf = ms_malloc(size_to_send); if (fread(buf, size_to_send, 1, file_to_send)!=size_to_send){ // reaching end of file, close it fclose(file_to_send); } lb = linphone_buffer_new_from_data(buf, size_to_send); ms_free(buf); return lb; }
/* * function called when the file transfer is initiated. file content should be feed into object LinphoneContent * */
function called when the file transfer is initiated. file content should be feed into object LinphoneContent
[ "function", "called", "when", "the", "file", "transfer", "is", "initiated", ".", "file", "content", "should", "be", "feed", "into", "object", "LinphoneContent" ]
LinphoneBuffer * tester_file_transfer_send(LinphoneChatMessage *msg, const LinphoneContent* content, size_t offset, size_t size){ LinphoneBuffer *lb; size_t file_size; size_t size_to_send; uint8_t *buf; FILE *file_to_send = linphone_chat_message_get_user_data(msg); fseek(file_to_send, 0, SEEK_END); file_size = ftell(file_to_send); fseek(file_to_send, offset, SEEK_SET); size_to_send = MIN(size, file_size - offset); buf = ms_malloc(size_to_send); if (fread(buf, size_to_send, 1, file_to_send)!=size_to_send){ fclose(file_to_send); } lb = linphone_buffer_new_from_data(buf, size_to_send); ms_free(buf); return lb; }
[ "LinphoneBuffer", "*", "tester_file_transfer_send", "(", "LinphoneChatMessage", "*", "msg", ",", "const", "LinphoneContent", "*", "content", ",", "size_t", "offset", ",", "size_t", "size", ")", "{", "LinphoneBuffer", "*", "lb", ";", "size_t", "file_size", ";", "size_t", "size_to_send", ";", "uint8_t", "*", "buf", ";", "FILE", "*", "file_to_send", "=", "linphone_chat_message_get_user_data", "(", "msg", ")", ";", "fseek", "(", "file_to_send", ",", "0", ",", "SEEK_END", ")", ";", "file_size", "=", "ftell", "(", "file_to_send", ")", ";", "fseek", "(", "file_to_send", ",", "offset", ",", "SEEK_SET", ")", ";", "size_to_send", "=", "MIN", "(", "size", ",", "file_size", "-", "offset", ")", ";", "buf", "=", "ms_malloc", "(", "size_to_send", ")", ";", "if", "(", "fread", "(", "buf", ",", "size_to_send", ",", "1", ",", "file_to_send", ")", "!=", "size_to_send", ")", "{", "fclose", "(", "file_to_send", ")", ";", "}", "lb", "=", "linphone_buffer_new_from_data", "(", "buf", ",", "size_to_send", ")", ";", "ms_free", "(", "buf", ")", ";", "return", "lb", ";", "}" ]
function called when the file transfer is initiated.
[ "function", "called", "when", "the", "file", "transfer", "is", "initiated", "." ]
[ "// reaching end of file, close it" ]
[ { "param": "msg", "type": "LinphoneChatMessage" }, { "param": "content", "type": "LinphoneContent" }, { "param": "offset", "type": "size_t" }, { "param": "size", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "msg", "type": "LinphoneChatMessage", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "content", "type": "LinphoneContent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
84e529091d8c89757d76d6662494054bbe6c4bbb
Advance2000/linphone
coreapi/bellesip_sal/sal_op_call_transfer.c
[ "BSD-2-Clause" ]
C
sal_call_get_replaces
SalOp
SalOp *sal_call_get_replaces(SalOp *op){ if (op && op->replaces){ belle_sip_dialog_t* dialog=belle_sip_provider_find_dialog(op->base.root->prov ,belle_sip_header_replaces_get_call_id(op->replaces) ,belle_sip_header_replaces_get_from_tag(op->replaces) ,belle_sip_header_replaces_get_to_tag(op->replaces)); if (dialog) { return (SalOp*)belle_sip_dialog_get_application_data(dialog); } } return NULL; }
/* returns the SalOp of a call that should be replaced by h, if any */
returns the SalOp of a call that should be replaced by h, if any
[ "returns", "the", "SalOp", "of", "a", "call", "that", "should", "be", "replaced", "by", "h", "if", "any" ]
SalOp *sal_call_get_replaces(SalOp *op){ if (op && op->replaces){ belle_sip_dialog_t* dialog=belle_sip_provider_find_dialog(op->base.root->prov ,belle_sip_header_replaces_get_call_id(op->replaces) ,belle_sip_header_replaces_get_from_tag(op->replaces) ,belle_sip_header_replaces_get_to_tag(op->replaces)); if (dialog) { return (SalOp*)belle_sip_dialog_get_application_data(dialog); } } return NULL; }
[ "SalOp", "*", "sal_call_get_replaces", "(", "SalOp", "*", "op", ")", "{", "if", "(", "op", "&&", "op", "->", "replaces", ")", "{", "belle_sip_dialog_t", "*", "dialog", "=", "belle_sip_provider_find_dialog", "(", "op", "->", "base", ".", "root", "->", "prov", ",", "belle_sip_header_replaces_get_call_id", "(", "op", "->", "replaces", ")", ",", "belle_sip_header_replaces_get_from_tag", "(", "op", "->", "replaces", ")", ",", "belle_sip_header_replaces_get_to_tag", "(", "op", "->", "replaces", ")", ")", ";", "if", "(", "dialog", ")", "{", "return", "(", "SalOp", "*", ")", "belle_sip_dialog_get_application_data", "(", "dialog", ")", ";", "}", "}", "return", "NULL", ";", "}" ]
returns the SalOp of a call that should be replaced by h, if any
[ "returns", "the", "SalOp", "of", "a", "call", "that", "should", "be", "replaced", "by", "h", "if", "any" ]
[]
[ { "param": "op", "type": "SalOp" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "op", "type": "SalOp", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
190ea6be77de289e44881b7f455de856593f60f9
Advance2000/linphone
coreapi/lime.c
[ "BSD-2-Clause" ]
C
lime_strToUint8
void
void lime_strToUint8(uint8_t *outputBytes, uint8_t *inputString, uint16_t inputStringLength) { int i; for (i=0; i<inputStringLength/2; i++) { outputBytes[i] = (lime_charToByte(inputString[2*i]))<<4 | lime_charToByte(inputString[2*i+1]); } }
/** * @brief Convert an hexadecimal string into the corresponding byte buffer * * @param[out] outputBytes The output bytes buffer, must have a length of half the input string buffer * @param[in] inputString The input string buffer, must be hexadecimal(it is not checked by function, any non hexa char is converted to 0) * @param[in] inputStringLength The lenght in chars of the string buffer, output is half this length */
@brief Convert an hexadecimal string into the corresponding byte buffer @param[out] outputBytes The output bytes buffer, must have a length of half the input string buffer @param[in] inputString The input string buffer, must be hexadecimal(it is not checked by function, any non hexa char is converted to 0) @param[in] inputStringLength The lenght in chars of the string buffer, output is half this length
[ "@brief", "Convert", "an", "hexadecimal", "string", "into", "the", "corresponding", "byte", "buffer", "@param", "[", "out", "]", "outputBytes", "The", "output", "bytes", "buffer", "must", "have", "a", "length", "of", "half", "the", "input", "string", "buffer", "@param", "[", "in", "]", "inputString", "The", "input", "string", "buffer", "must", "be", "hexadecimal", "(", "it", "is", "not", "checked", "by", "function", "any", "non", "hexa", "char", "is", "converted", "to", "0", ")", "@param", "[", "in", "]", "inputStringLength", "The", "lenght", "in", "chars", "of", "the", "string", "buffer", "output", "is", "half", "this", "length" ]
void lime_strToUint8(uint8_t *outputBytes, uint8_t *inputString, uint16_t inputStringLength) { int i; for (i=0; i<inputStringLength/2; i++) { outputBytes[i] = (lime_charToByte(inputString[2*i]))<<4 | lime_charToByte(inputString[2*i+1]); } }
[ "void", "lime_strToUint8", "(", "uint8_t", "*", "outputBytes", ",", "uint8_t", "*", "inputString", ",", "uint16_t", "inputStringLength", ")", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "inputStringLength", "/", "2", ";", "i", "++", ")", "{", "outputBytes", "[", "i", "]", "=", "(", "lime_charToByte", "(", "inputString", "[", "2", "*", "i", "]", ")", ")", "<<", "4", "|", "lime_charToByte", "(", "inputString", "[", "2", "*", "i", "+", "1", "]", ")", ";", "}", "}" ]
@brief Convert an hexadecimal string into the corresponding byte buffer @param[out] outputBytes The output bytes buffer, must have a length of half the input string buffer @param[in] inputString The input string buffer, must be hexadecimal(it is not checked by function, any non hexa char is converted to 0) @param[in] inputStringLength The lenght in chars of the string buffer, output is half this length
[ "@brief", "Convert", "an", "hexadecimal", "string", "into", "the", "corresponding", "byte", "buffer", "@param", "[", "out", "]", "outputBytes", "The", "output", "bytes", "buffer", "must", "have", "a", "length", "of", "half", "the", "input", "string", "buffer", "@param", "[", "in", "]", "inputString", "The", "input", "string", "buffer", "must", "be", "hexadecimal", "(", "it", "is", "not", "checked", "by", "function", "any", "non", "hexa", "char", "is", "converted", "to", "0", ")", "@param", "[", "in", "]", "inputStringLength", "The", "lenght", "in", "chars", "of", "the", "string", "buffer", "output", "is", "half", "this", "length" ]
[]
[ { "param": "outputBytes", "type": "uint8_t" }, { "param": "inputString", "type": "uint8_t" }, { "param": "inputStringLength", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "outputBytes", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "inputString", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "inputStringLength", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
190ea6be77de289e44881b7f455de856593f60f9
Advance2000/linphone
coreapi/lime.c
[ "BSD-2-Clause" ]
C
lime_int8ToStr
void
void lime_int8ToStr(uint8_t *outputString, uint8_t *inputBytes, uint16_t inputBytesLength) { int i; for (i=0; i<inputBytesLength; i++) { outputString[2*i] = lime_byteToChar((inputBytes[i]>>4)&0x0F); outputString[2*i+1] = lime_byteToChar(inputBytes[i]&0x0F); } }
/** * @brief Convert a byte buffer into the corresponding hexadecimal string * * @param[out] outputString The output string buffer, must have a length of twice the input bytes buffer * @param[in] inputBytes The input bytes buffer * @param[in] inputBytesLength The lenght in bytes buffer, output is twice this length */
@brief Convert a byte buffer into the corresponding hexadecimal string @param[out] outputString The output string buffer, must have a length of twice the input bytes buffer @param[in] inputBytes The input bytes buffer @param[in] inputBytesLength The lenght in bytes buffer, output is twice this length
[ "@brief", "Convert", "a", "byte", "buffer", "into", "the", "corresponding", "hexadecimal", "string", "@param", "[", "out", "]", "outputString", "The", "output", "string", "buffer", "must", "have", "a", "length", "of", "twice", "the", "input", "bytes", "buffer", "@param", "[", "in", "]", "inputBytes", "The", "input", "bytes", "buffer", "@param", "[", "in", "]", "inputBytesLength", "The", "lenght", "in", "bytes", "buffer", "output", "is", "twice", "this", "length" ]
void lime_int8ToStr(uint8_t *outputString, uint8_t *inputBytes, uint16_t inputBytesLength) { int i; for (i=0; i<inputBytesLength; i++) { outputString[2*i] = lime_byteToChar((inputBytes[i]>>4)&0x0F); outputString[2*i+1] = lime_byteToChar(inputBytes[i]&0x0F); } }
[ "void", "lime_int8ToStr", "(", "uint8_t", "*", "outputString", ",", "uint8_t", "*", "inputBytes", ",", "uint16_t", "inputBytesLength", ")", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "inputBytesLength", ";", "i", "++", ")", "{", "outputString", "[", "2", "*", "i", "]", "=", "lime_byteToChar", "(", "(", "inputBytes", "[", "i", "]", ">>", "4", ")", "&", "0x0F", ")", ";", "outputString", "[", "2", "*", "i", "+", "1", "]", "=", "lime_byteToChar", "(", "inputBytes", "[", "i", "]", "&", "0x0F", ")", ";", "}", "}" ]
@brief Convert a byte buffer into the corresponding hexadecimal string @param[out] outputString The output string buffer, must have a length of twice the input bytes buffer @param[in] inputBytes The input bytes buffer @param[in] inputBytesLength The lenght in bytes buffer, output is twice this length
[ "@brief", "Convert", "a", "byte", "buffer", "into", "the", "corresponding", "hexadecimal", "string", "@param", "[", "out", "]", "outputString", "The", "output", "string", "buffer", "must", "have", "a", "length", "of", "twice", "the", "input", "bytes", "buffer", "@param", "[", "in", "]", "inputBytes", "The", "input", "bytes", "buffer", "@param", "[", "in", "]", "inputBytesLength", "The", "lenght", "in", "bytes", "buffer", "output", "is", "twice", "this", "length" ]
[]
[ { "param": "outputString", "type": "uint8_t" }, { "param": "inputBytes", "type": "uint8_t" }, { "param": "inputBytesLength", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "outputString", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "inputBytes", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "inputBytesLength", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
190ea6be77de289e44881b7f455de856593f60f9
Advance2000/linphone
coreapi/lime.c
[ "BSD-2-Clause" ]
C
lime_getSelfZid
int
static int lime_getSelfZid(xmlDocPtr cacheBuffer, uint8_t selfZid[25]) { xmlNodePtr cur; xmlChar *selfZidHex; if (cacheBuffer == NULL ) { return LIME_INVALID_CACHE; } cur = xmlDocGetRootElement(cacheBuffer); /* if we found a root element, parse its children node */ if (cur!=NULL) { cur = cur->xmlChildrenNode; } selfZidHex = NULL; while (cur!=NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"selfZID"))){ /* self ZID found, extract it */ selfZidHex = xmlNodeListGetString(cacheBuffer, cur->xmlChildrenNode, 1); /* copy it to the output buffer and add the null termination */ memcpy(selfZid, selfZidHex, 24); selfZid[24]='\0'; break; } cur = cur->next; } /* did we found a ZID? */ if (selfZidHex == NULL) { return LIME_INVALID_CACHE; } xmlFree(selfZidHex); return 0; }
/** * @brief Retrieve selfZID from cache * * @param[in] cacheBuffer The xmlDoc containing current cache * @param[out] selfZid The ZID found as a 24 hexa char string null terminated * * @return 0 on success, error code otherwise */
@brief Retrieve selfZID from cache @param[in] cacheBuffer The xmlDoc containing current cache @param[out] selfZid The ZID found as a 24 hexa char string null terminated @return 0 on success, error code otherwise
[ "@brief", "Retrieve", "selfZID", "from", "cache", "@param", "[", "in", "]", "cacheBuffer", "The", "xmlDoc", "containing", "current", "cache", "@param", "[", "out", "]", "selfZid", "The", "ZID", "found", "as", "a", "24", "hexa", "char", "string", "null", "terminated", "@return", "0", "on", "success", "error", "code", "otherwise" ]
static int lime_getSelfZid(xmlDocPtr cacheBuffer, uint8_t selfZid[25]) { xmlNodePtr cur; xmlChar *selfZidHex; if (cacheBuffer == NULL ) { return LIME_INVALID_CACHE; } cur = xmlDocGetRootElement(cacheBuffer); if (cur!=NULL) { cur = cur->xmlChildrenNode; } selfZidHex = NULL; while (cur!=NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"selfZID"))){ selfZidHex = xmlNodeListGetString(cacheBuffer, cur->xmlChildrenNode, 1); memcpy(selfZid, selfZidHex, 24); selfZid[24]='\0'; break; } cur = cur->next; } if (selfZidHex == NULL) { return LIME_INVALID_CACHE; } xmlFree(selfZidHex); return 0; }
[ "static", "int", "lime_getSelfZid", "(", "xmlDocPtr", "cacheBuffer", ",", "uint8_t", "selfZid", "[", "25", "]", ")", "{", "xmlNodePtr", "cur", ";", "xmlChar", "*", "selfZidHex", ";", "if", "(", "cacheBuffer", "==", "NULL", ")", "{", "return", "LIME_INVALID_CACHE", ";", "}", "cur", "=", "xmlDocGetRootElement", "(", "cacheBuffer", ")", ";", "if", "(", "cur", "!=", "NULL", ")", "{", "cur", "=", "cur", "->", "xmlChildrenNode", ";", "}", "selfZidHex", "=", "NULL", ";", "while", "(", "cur", "!=", "NULL", ")", "{", "if", "(", "(", "!", "xmlStrcmp", "(", "cur", "->", "name", ",", "(", "const", "xmlChar", "*", ")", "\"", "\"", ")", ")", ")", "{", "selfZidHex", "=", "xmlNodeListGetString", "(", "cacheBuffer", ",", "cur", "->", "xmlChildrenNode", ",", "1", ")", ";", "memcpy", "(", "selfZid", ",", "selfZidHex", ",", "24", ")", ";", "selfZid", "[", "24", "]", "=", "'", "\\0", "'", ";", "break", ";", "}", "cur", "=", "cur", "->", "next", ";", "}", "if", "(", "selfZidHex", "==", "NULL", ")", "{", "return", "LIME_INVALID_CACHE", ";", "}", "xmlFree", "(", "selfZidHex", ")", ";", "return", "0", ";", "}" ]
@brief Retrieve selfZID from cache @param[in] cacheBuffer The xmlDoc containing current cache @param[out] selfZid The ZID found as a 24 hexa char string null terminated
[ "@brief", "Retrieve", "selfZID", "from", "cache", "@param", "[", "in", "]", "cacheBuffer", "The", "xmlDoc", "containing", "current", "cache", "@param", "[", "out", "]", "selfZid", "The", "ZID", "found", "as", "a", "24", "hexa", "char", "string", "null", "terminated" ]
[ "/* if we found a root element, parse its children node */", "/* self ZID found, extract it */", "/* copy it to the output buffer and add the null termination */", "/* did we found a ZID? */" ]
[ { "param": "cacheBuffer", "type": "xmlDocPtr" }, { "param": "selfZid", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cacheBuffer", "type": "xmlDocPtr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "selfZid", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
190ea6be77de289e44881b7f455de856593f60f9
Advance2000/linphone
coreapi/lime.c
[ "BSD-2-Clause" ]
C
lime_deriveKey
int
static int lime_deriveKey(limeKey_t *key) { uint8_t inputData[55]; uint8_t derivedKey[32]; if (key == NULL) { return LIME_UNABLE_TO_DERIVE_KEY; } #if 0 /*not doing anything yet since key and sessionId are array, not pointers*/ if ((key->key == NULL) || (key->sessionId == NULL)) { return LIME_UNABLE_TO_DERIVE_KEY; } #endif /* Derivation is made derived Key = HMAC_SHA256(Key, 0x0000001||"MessageKey"||0x00||SessionId||SessionIndex||0x00000100)*/ /* total data to be hashed is 55 bytes : 4 + 10 + 1 + 32 + 4 + 4 */ inputData[0] = 0x00; inputData[1] = 0x00; inputData[2] = 0x00; inputData[3] = 0x01; memcpy(inputData+4, "MessageKey", 10); inputData[14] = 0x00; memcpy(inputData+15, key->sessionId, 32); inputData[47] = (uint8_t)((key->sessionIndex>>24)&0x000000FF); inputData[48] = (uint8_t)((key->sessionIndex>>16)&0x000000FF); inputData[49] = (uint8_t)((key->sessionIndex>>8)&0x000000FF); inputData[50] = (uint8_t)(key->sessionIndex&0x000000FF); inputData[51] = 0x00; inputData[52] = 0x00; inputData[53] = 0x01; inputData[54] = 0x00; /* derive the key in a temp buffer */ #if POLARSSL_VERSION_NUMBER >= 0x01030000 /* for Polarssl version 1.3 */ sha256_hmac(key->key, 32, inputData, 55, derivedKey, 0); /* last param to zero to select SHA256 and not SHA224 */ #else /* for Polarssl version 1.2 */ sha2_hmac(key->key, 32, inputData, 55, derivedKey, 0); /* last param to zero to select SHA256 and not SHA224 */ #endif /* POLARSSL_VERSION_NUMBER */ /* overwrite the old key with the derived one */ memcpy(key->key, derivedKey, 32); /* increment the session Index */ key->sessionIndex += 1; return 0; }
/** * @brief Derive in place the key given in parameter and increment session index * Derivation is made derived Key = HMAC_SHA256(Key, 0x0000001||"MessageKey"||0x00||SessionId||SessionIndex||256) * * @param[in/out] key The structure containing the original key which will be overwritten, the sessionId and SessionIndex * * @return 0 on success, error code otherwise */
@param[in/out] key The structure containing the original key which will be overwritten, the sessionId and SessionIndex @return 0 on success, error code otherwise
[ "@param", "[", "in", "/", "out", "]", "key", "The", "structure", "containing", "the", "original", "key", "which", "will", "be", "overwritten", "the", "sessionId", "and", "SessionIndex", "@return", "0", "on", "success", "error", "code", "otherwise" ]
static int lime_deriveKey(limeKey_t *key) { uint8_t inputData[55]; uint8_t derivedKey[32]; if (key == NULL) { return LIME_UNABLE_TO_DERIVE_KEY; } #if 0 if ((key->key == NULL) || (key->sessionId == NULL)) { return LIME_UNABLE_TO_DERIVE_KEY; } #endif inputData[0] = 0x00; inputData[1] = 0x00; inputData[2] = 0x00; inputData[3] = 0x01; memcpy(inputData+4, "MessageKey", 10); inputData[14] = 0x00; memcpy(inputData+15, key->sessionId, 32); inputData[47] = (uint8_t)((key->sessionIndex>>24)&0x000000FF); inputData[48] = (uint8_t)((key->sessionIndex>>16)&0x000000FF); inputData[49] = (uint8_t)((key->sessionIndex>>8)&0x000000FF); inputData[50] = (uint8_t)(key->sessionIndex&0x000000FF); inputData[51] = 0x00; inputData[52] = 0x00; inputData[53] = 0x01; inputData[54] = 0x00; #if POLARSSL_VERSION_NUMBER >= 0x01030000 sha256_hmac(key->key, 32, inputData, 55, derivedKey, 0); #else sha2_hmac(key->key, 32, inputData, 55, derivedKey, 0); #endif memcpy(key->key, derivedKey, 32); key->sessionIndex += 1; return 0; }
[ "static", "int", "lime_deriveKey", "(", "limeKey_t", "*", "key", ")", "{", "uint8_t", "inputData", "[", "55", "]", ";", "uint8_t", "derivedKey", "[", "32", "]", ";", "if", "(", "key", "==", "NULL", ")", "{", "return", "LIME_UNABLE_TO_DERIVE_KEY", ";", "}", "#if", "0", "\n", "if", "(", "(", "key", "->", "key", "==", "NULL", ")", "||", "(", "key", "->", "sessionId", "==", "NULL", ")", ")", "{", "return", "LIME_UNABLE_TO_DERIVE_KEY", ";", "}", "#endif", "inputData", "[", "0", "]", "=", "0x00", ";", "inputData", "[", "1", "]", "=", "0x00", ";", "inputData", "[", "2", "]", "=", "0x00", ";", "inputData", "[", "3", "]", "=", "0x01", ";", "memcpy", "(", "inputData", "+", "4", ",", "\"", "\"", ",", "10", ")", ";", "inputData", "[", "14", "]", "=", "0x00", ";", "memcpy", "(", "inputData", "+", "15", ",", "key", "->", "sessionId", ",", "32", ")", ";", "inputData", "[", "47", "]", "=", "(", "uint8_t", ")", "(", "(", "key", "->", "sessionIndex", ">>", "24", ")", "&", "0x000000FF", ")", ";", "inputData", "[", "48", "]", "=", "(", "uint8_t", ")", "(", "(", "key", "->", "sessionIndex", ">>", "16", ")", "&", "0x000000FF", ")", ";", "inputData", "[", "49", "]", "=", "(", "uint8_t", ")", "(", "(", "key", "->", "sessionIndex", ">>", "8", ")", "&", "0x000000FF", ")", ";", "inputData", "[", "50", "]", "=", "(", "uint8_t", ")", "(", "key", "->", "sessionIndex", "&", "0x000000FF", ")", ";", "inputData", "[", "51", "]", "=", "0x00", ";", "inputData", "[", "52", "]", "=", "0x00", ";", "inputData", "[", "53", "]", "=", "0x01", ";", "inputData", "[", "54", "]", "=", "0x00", ";", "#if", "POLARSSL_VERSION_NUMBER", ">=", "0x01030000", "\n", "sha256_hmac", "(", "key", "->", "key", ",", "32", ",", "inputData", ",", "55", ",", "derivedKey", ",", "0", ")", ";", "#else", "sha2_hmac", "(", "key", "->", "key", ",", "32", ",", "inputData", ",", "55", ",", "derivedKey", ",", "0", ")", ";", "#endif", "memcpy", "(", "key", "->", "key", ",", "derivedKey", ",", "32", ")", ";", "key", "->", "sessionIndex", "+=", "1", ";", "return", "0", ";", "}" ]
@brief Derive in place the key given in parameter and increment session index Derivation is made derived Key = HMAC_SHA256(Key, 0x0000001||"MessageKey"||0x00||SessionId||SessionIndex||256)
[ "@brief", "Derive", "in", "place", "the", "key", "given", "in", "parameter", "and", "increment", "session", "index", "Derivation", "is", "made", "derived", "Key", "=", "HMAC_SHA256", "(", "Key", "0x0000001||", "\"", "MessageKey", "\"", "||0x00||SessionId||SessionIndex||256", ")" ]
[ "/*not doing anything yet since key and sessionId are array, not pointers*/", "/* Derivation is made derived Key = HMAC_SHA256(Key, 0x0000001||\"MessageKey\"||0x00||SessionId||SessionIndex||0x00000100)*/", "/* total data to be hashed is 55 bytes : 4 + 10 + 1 + 32 + 4 + 4 */", "/* derive the key in a temp buffer */", "/* for Polarssl version 1.3 */", "/* last param to zero to select SHA256 and not SHA224 */", "/* for Polarssl version 1.2 */", "/* last param to zero to select SHA256 and not SHA224 */", "/* POLARSSL_VERSION_NUMBER */", "/* overwrite the old key with the derived one */", "/* increment the session Index */" ]
[ { "param": "key", "type": "limeKey_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "key", "type": "limeKey_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2543638c3dbafb66df95f4534e42c596a9749e90
joelnb/duckyPad
resources/bdf2c-master/bdf2c.c
[ "MIT" ]
C
Header
void
void Header(FILE * out, const char *name) { char * headername; if(!SmartMatrix) headername = "font"; else headername = "MatrixFontCommon"; fprintf(out, "// Created from bdf2c Version %s, (c) 2009, 2010 by Lutz Sammer\n" "//\tLicense AGPLv3: GNU Affero General Public License version 3\n" "\n#include \"%s.h\"\n\n", VERSION, headername); fprintf(out, "\t/// character bitmap for each encoding\n" "static const unsigned char __%s_bitmap__[] = {\n", name); }
/// /// Print header for c file. /// /// @param out file stream for output /// @param name font variable name in C source file ///
Print header for c file.
[ "Print", "header", "for", "c", "file", "." ]
void Header(FILE * out, const char *name) { char * headername; if(!SmartMatrix) headername = "font"; else headername = "MatrixFontCommon"; fprintf(out, "// Created from bdf2c Version %s, (c) 2009, 2010 by Lutz Sammer\n" "//\tLicense AGPLv3: GNU Affero General Public License version 3\n" "\n#include \"%s.h\"\n\n", VERSION, headername); fprintf(out, "\t/// character bitmap for each encoding\n" "static const unsigned char __%s_bitmap__[] = {\n", name); }
[ "void", "Header", "(", "FILE", "*", "out", ",", "const", "char", "*", "name", ")", "{", "char", "*", "headername", ";", "if", "(", "!", "SmartMatrix", ")", "headername", "=", "\"", "\"", ";", "else", "headername", "=", "\"", "\"", ";", "fprintf", "(", "out", ",", "\"", "\\n", "\"", "\"", "\\t", "\\n", "\"", "\"", "\\n", "\\\"", "\\\"", "\\n", "\\n", "\"", ",", "VERSION", ",", "headername", ")", ";", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", "\"", "\\n", "\"", ",", "name", ")", ";", "}" ]
Print header for c file.
[ "Print", "header", "for", "c", "file", "." ]
[]
[ { "param": "out", "type": "FILE" }, { "param": "name", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "FILE", "docstring": "file stream for output", "docstring_tokens": [ "file", "stream", "for", "output" ], "default": null, "is_optional": null }, { "identifier": "name", "type": "char", "docstring": "font variable name in C source file", "docstring_tokens": [ "font", "variable", "name", "in", "C", "source", "file" ], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2543638c3dbafb66df95f4534e42c596a9749e90
joelnb/duckyPad
resources/bdf2c-master/bdf2c.c
[ "MIT" ]
C
WidthTable
void
void WidthTable(FILE * out, const char *name, const unsigned *width_table, int chars) { fprintf(out, "};\n\n"); fprintf(out, "\t/// character width for each encoding\n" "static const unsigned char __%s_widths__[] = {\n", name); while (chars--) { fprintf(out, "\t%u,\n", *width_table++); } }
/// /// Print width table for c file /// /// @param out file stream for output /// @param name font variable name in C source file /// @param width_table width table read from BDF file /// @param chars number of characters in width table ///
Print width table for c file
[ "Print", "width", "table", "for", "c", "file" ]
void WidthTable(FILE * out, const char *name, const unsigned *width_table, int chars) { fprintf(out, "};\n\n"); fprintf(out, "\t/// character width for each encoding\n" "static const unsigned char __%s_widths__[] = {\n", name); while (chars--) { fprintf(out, "\t%u,\n", *width_table++); } }
[ "void", "WidthTable", "(", "FILE", "*", "out", ",", "const", "char", "*", "name", ",", "const", "unsigned", "*", "width_table", ",", "int", "chars", ")", "{", "fprintf", "(", "out", ",", "\"", "\\n", "\\n", "\"", ")", ";", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", "\"", "\\n", "\"", ",", "name", ")", ";", "while", "(", "chars", "--", ")", "{", "fprintf", "(", "out", ",", "\"", "\\t", "\\n", "\"", ",", "*", "width_table", "++", ")", ";", "}", "}" ]
Print width table for c file
[ "Print", "width", "table", "for", "c", "file" ]
[]
[ { "param": "out", "type": "FILE" }, { "param": "name", "type": "char" }, { "param": "width_table", "type": "unsigned" }, { "param": "chars", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "out", "type": "FILE", "docstring": "file stream for output", "docstring_tokens": [ "file", "stream", "for", "output" ], "default": null, "is_optional": null }, { "identifier": "name", "type": "char", "docstring": "font variable name in C source file", "docstring_tokens": [ "font", "variable", "name", "in", "C", "source", "file" ], "default": null, "is_optional": null }, { "identifier": "width_table", "type": "unsigned", "docstring": "width table read from BDF file", "docstring_tokens": [ "width", "table", "read", "from", "BDF", "file" ], "default": null, "is_optional": null }, { "identifier": "chars", "type": "int", "docstring": "number of characters in width table", "docstring_tokens": [ "number", "of", "characters", "in", "width", "table" ], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }