hexsha
stringlengths
40
40
size
int64
5
2.72M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
976
max_stars_repo_name
stringlengths
5
113
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringdate
2015-01-01 00:01:43
2022-03-31 23:59:48
max_stars_repo_stars_event_max_datetime
stringdate
2015-01-01 00:06:24
2022-03-31 23:59:53
max_issues_repo_path
stringlengths
3
976
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
134k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
976
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringdate
2015-01-01 00:01:19
2022-03-31 23:59:49
max_forks_repo_forks_event_max_datetime
stringdate
2015-01-03 12:00:57
2022-03-31 23:59:49
content
stringlengths
5
2.72M
avg_line_length
float64
1.38
573k
max_line_length
int64
2
1.01M
alphanum_fraction
float64
0
1
d9370bf2648ffdb208fb2772991b27d63c5ae83d
903
c
C
Online Judges/Huxley/clones.c
NelsonGomesNeto/ProgramC
e743b1b869f58f7f3022d18bac00c5e0b078562e
[ "MIT" ]
3
2018-12-18T13:39:42.000Z
2021-06-23T18:05:18.000Z
Online Judges/Huxley/clones.c
NelsonGomesNeto/ProgramC
e743b1b869f58f7f3022d18bac00c5e0b078562e
[ "MIT" ]
1
2018-11-02T21:32:40.000Z
2018-11-02T22:47:12.000Z
Online Judges/Huxley/clones.c
NelsonGomesNeto/ProgramC
e743b1b869f58f7f3022d18bac00c5e0b078562e
[ "MIT" ]
6
2018-10-27T14:07:52.000Z
2019-11-14T13:49:29.000Z
#include <stdio.h> #include <string.h> int main() { int pessoas, DNA; while (scanf("%d %d", &pessoas, &DNA) && !(pessoas == 0 && DNA == 0)) { int ler, check, igual, clones[pessoas + 10]; char existencia[pessoas][DNA + 10]; for (ler = 0; ler < pessoas; ler ++) { getchar(); scanf("%[^\n]", existencia[ler]); clones[ler] = 0; } for (ler = 0; ler < pessoas; ler ++) { for (check = 0, igual = 0; check < pessoas; check ++) { if (strcmp(existencia[ler], existencia[check]) == 0 && check != ler && existencia[ler][0] != '.') { existencia[check][0] = '.'; igual ++; } } if (existencia[ler][0] != '.') { clones[igual] ++; } } for (ler = 0; ler < pessoas; ler ++) { printf("%d\n", clones[ler]); } } return(0); }
23.763158
106
0.439646
d938798aea102438052990c4d7de39d2ad4df20f
44,140
h
C
msp430fr2433_adc1.2/driverlib/MSP430FR2xx_4xx/adc.h
JuanSandu/MSP430FR2433_examples
5823220f283b33aaee8b44451beb1a5672b98715
[ "MIT" ]
2
2022-01-28T12:03:12.000Z
2022-02-02T08:50:56.000Z
ssm/src/driverlib/MSP430FR2xx_4xx/adc.h
charitywater/india-mark-ii-sensor
5485ef175ba6aab03897bb9d98c417bb8c702e16
[ "Apache-2.0" ]
null
null
null
ssm/src/driverlib/MSP430FR2xx_4xx/adc.h
charitywater/india-mark-ii-sensor
5485ef175ba6aab03897bb9d98c417bb8c702e16
[ "Apache-2.0" ]
null
null
null
/* --COPYRIGHT--,BSD * Copyright (c) 2017, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * --/COPYRIGHT--*/ //***************************************************************************** // // adc.h - Driver for the ADC Module. // //***************************************************************************** #ifndef __MSP430WARE_ADC_H__ #define __MSP430WARE_ADC_H__ #include "inc/hw_memmap.h" #ifdef __MSP430_HAS_ADC__ //***************************************************************************** // // If building with a C++ compiler, make all of the definitions in this header // have a C binding. // //***************************************************************************** #ifdef __cplusplus extern "C" { #endif //***************************************************************************** // // The following are values that can be passed to the clockSourceSelect // parameter for functions: ADC_init(). // //***************************************************************************** #define ADC_CLOCKSOURCE_ADCOSC (ADCSSEL_0) #define ADC_CLOCKSOURCE_ACLK (ADCSSEL_1) #define ADC_CLOCKSOURCE_SMCLK (ADCSSEL_2) //***************************************************************************** // // The following are values that can be passed to the clockSourceDivider // parameter for functions: ADC_init(). // //***************************************************************************** #define ADC_CLOCKDIVIDER_1 (ADCDIV_0 + ADCPDIV_0) #define ADC_CLOCKDIVIDER_2 (ADCDIV_1 + ADCPDIV_0) #define ADC_CLOCKDIVIDER_3 (ADCDIV_2 + ADCPDIV_0) #define ADC_CLOCKDIVIDER_4 (ADCDIV_3 + ADCPDIV_0) #define ADC_CLOCKDIVIDER_5 (ADCDIV_4 + ADCPDIV_0) #define ADC_CLOCKDIVIDER_6 (ADCDIV_5 + ADCPDIV_0) #define ADC_CLOCKDIVIDER_7 (ADCDIV_6 + ADCPDIV_0) #define ADC_CLOCKDIVIDER_8 (ADCDIV_7 + ADCPDIV_0) #define ADC_CLOCKDIVIDER_12 (ADCDIV_2 + ADCPDIV_1) #define ADC_CLOCKDIVIDER_16 (ADCDIV_3 + ADCPDIV_1) #define ADC_CLOCKDIVIDER_20 (ADCDIV_4 + ADCPDIV_1) #define ADC_CLOCKDIVIDER_24 (ADCDIV_5 + ADCPDIV_1) #define ADC_CLOCKDIVIDER_28 (ADCDIV_6 + ADCPDIV_1) #define ADC_CLOCKDIVIDER_32 (ADCDIV_7 + ADCPDIV_1) #define ADC_CLOCKDIVIDER_64 (ADCDIV_0 + ADCPDIV_2) #define ADC_CLOCKDIVIDER_128 (ADCDIV_1 + ADCPDIV_2) #define ADC_CLOCKDIVIDER_192 (ADCDIV_2 + ADCPDIV_2) #define ADC_CLOCKDIVIDER_256 (ADCDIV_3 + ADCPDIV_2) #define ADC_CLOCKDIVIDER_320 (ADCDIV_4 + ADCPDIV_2) #define ADC_CLOCKDIVIDER_384 (ADCDIV_5 + ADCPDIV_2) #define ADC_CLOCKDIVIDER_448 (ADCDIV_6 + ADCPDIV_2) #define ADC_CLOCKDIVIDER_512 (ADCDIV_7 + ADCPDIV_2) //***************************************************************************** // // The following are values that can be passed to the // sampleHoldSignalSourceSelect parameter for functions: ADC_init(). // //***************************************************************************** #define ADC_SAMPLEHOLDSOURCE_SC (ADCSHS_0) #define ADC_SAMPLEHOLDSOURCE_1 (ADCSHS_1) #define ADC_SAMPLEHOLDSOURCE_2 (ADCSHS_2) #define ADC_SAMPLEHOLDSOURCE_3 (ADCSHS_3) //***************************************************************************** // // The following are values that can be passed to the multipleSamplesEnabled // parameter for functions: ADC_setupSamplingTimer(). // //***************************************************************************** #define ADC_MULTIPLESAMPLESDISABLE (!(ADCMSC)) #define ADC_MULTIPLESAMPLESENABLE (ADCMSC) //***************************************************************************** // // The following are values that can be passed to the clockCycleHoldCount // parameter for functions: ADC_setupSamplingTimer(). // //***************************************************************************** #define ADC_CYCLEHOLD_4_CYCLES (ADCSHT_0) #define ADC_CYCLEHOLD_8_CYCLES (ADCSHT_1) #define ADC_CYCLEHOLD_16_CYCLES (ADCSHT_2) #define ADC_CYCLEHOLD_32_CYCLES (ADCSHT_3) #define ADC_CYCLEHOLD_64_CYCLES (ADCSHT_4) #define ADC_CYCLEHOLD_96_CYCLES (ADCSHT_5) #define ADC_CYCLEHOLD_128_CYCLES (ADCSHT_6) #define ADC_CYCLEHOLD_192_CYCLES (ADCSHT_7) #define ADC_CYCLEHOLD_256_CYCLES (ADCSHT_8) #define ADC_CYCLEHOLD_384_CYCLES (ADCSHT_9) #define ADC_CYCLEHOLD_512_CYCLES (ADCSHT_10) #define ADC_CYCLEHOLD_768_CYCLES (ADCSHT_11) #define ADC_CYCLEHOLD_1024_CYCLES (ADCSHT_12) //***************************************************************************** // // The following are values that can be passed to the inputSourceSelect // parameter for functions: ADC_configureMemory(). // //***************************************************************************** #define ADC_INPUT_A0 (ADCINCH_0) #define ADC_INPUT_A1 (ADCINCH_1) #define ADC_INPUT_A2 (ADCINCH_2) #define ADC_INPUT_A3 (ADCINCH_3) #define ADC_INPUT_A4 (ADCINCH_4) #define ADC_INPUT_A5 (ADCINCH_5) #define ADC_INPUT_A6 (ADCINCH_6) #define ADC_INPUT_A7 (ADCINCH_7) #define ADC_INPUT_A8 (ADCINCH_8) #define ADC_INPUT_A9 (ADCINCH_9) #define ADC_INPUT_TEMPSENSOR (ADCINCH_12) #define ADC_INPUT_REFVOLTAGE (ADCINCH_13) #define ADC_INPUT_DVSS (ADCINCH_14) #define ADC_INPUT_DVCC (ADCINCH_15) //***************************************************************************** // // The following are values that can be passed to the // positiveRefVoltageSourceSelect parameter for functions: // ADC_configureMemory(). // //***************************************************************************** #define ADC_VREFPOS_AVCC (!(ADCSREF0 + ADCSREF1)) #define ADC_VREFPOS_INT (ADCSREF0) #define ADC_VREFPOS_EXT_BUF (ADCSREF1) #define ADC_VREFPOS_EXT_NOBUF (ADCSREF1 + ADCSREF0) //***************************************************************************** // // The following are values that can be passed to the // negativeRefVoltageSourceSelect parameter for functions: // ADC_configureMemory(). // //***************************************************************************** #define ADC_VREFNEG_AVSS (!(ADCSREF2)) #define ADC_VREFNEG_EXT (ADCSREF2) //***************************************************************************** // // The following are values that can be passed to the interruptMask parameter // for functions: ADC_enableInterrupt(), and ADC_disableInterrupt(). // //***************************************************************************** #define ADC_OVERFLOW_INTERRUPT (ADCOVIE) #define ADC_TIMEOVERFLOW_INTERRUPT (ADCTOVIE) #define ADC_ABOVETHRESHOLD_INTERRUPT (ADCHIIE) #define ADC_BELOWTHRESHOLD_INTERRUPT (ADCLOIE) #define ADC_INSIDEWINDOW_INTERRUPT (ADCINIE) #define ADC_COMPLETED_INTERRUPT (ADCIE0) //***************************************************************************** // // The following are values that can be passed to the interruptFlagMask // parameter for functions: ADC_clearInterrupt(), and ADC_getInterruptStatus(). // //***************************************************************************** #define ADC_OVERFLOW_INTERRUPT_FLAG (ADCOVIFG) #define ADC_TIMEOVERFLOW_INTERRUPT_FLAG (ADCTOVIFG) #define ADC_ABOVETHRESHOLD_INTERRUPT_FLAG (ADCHIIFG) #define ADC_BELOWTHRESHOLD_INTERRUPT_FLAG (ADCLOIFG) #define ADC_INSIDEWINDOW_INTERRUPT_FLAG (ADCINIFG) #define ADC_COMPLETED_INTERRUPT_FLAG (ADCIFG0) //***************************************************************************** // // The following are values that can be passed to the // conversionSequenceModeSelect parameter for functions: ADC_startConversion(). // //***************************************************************************** #define ADC_SINGLECHANNEL (ADCCONSEQ_0) #define ADC_SEQOFCHANNELS (ADCCONSEQ_1) #define ADC_REPEATED_SINGLECHANNEL (ADCCONSEQ_2) #define ADC_REPEATED_SEQOFCHANNELS (ADCCONSEQ_3) //***************************************************************************** // // The following are values that can be passed to the preempt parameter for // functions: ADC_disableConversions(). // //***************************************************************************** #define ADC_COMPLETECONVERSION false #define ADC_PREEMPTCONVERSION true //***************************************************************************** // // The following are values that can be passed to the resolutionSelect // parameter for functions: ADC_setResolution(). // //***************************************************************************** #define ADC_RESOLUTION_8BIT (0x0) #define ADC_RESOLUTION_10BIT (0x10) #define ADC_RESOLUTION_12BIT (0x20) //***************************************************************************** // // The following are values that can be passed to the invertedSignal parameter // for functions: ADC_setSampleHoldSignalInversion(). // //***************************************************************************** #define ADC_NONINVERTEDSIGNAL (!(ADCISSH)) #define ADC_INVERTEDSIGNAL (ADCISSH) //***************************************************************************** // // The following are values that can be passed to the readBackFormat parameter // for functions: ADC_setDataReadBackFormat(). // //***************************************************************************** #define ADC_UNSIGNED_BINARY (!(ADCDF)) #define ADC_SIGNED_2SCOMPLEMENT (ADCDF) //***************************************************************************** // // The following are values that can be passed to the samplingRateSelect // parameter for functions: ADC_setReferenceBufferSamplingRate(). // //***************************************************************************** #define ADC_MAXSAMPLINGRATE_200KSPS (!(ADCSR)) #define ADC_MAXSAMPLINGRATE_50KSPS (ADCSR) //***************************************************************************** // // The following are values that can be passed toThe following are values that // can be returned by the ADC_isBusy() function. // //***************************************************************************** #define ADC_NOTBUSY (0x00) #define ADC_BUSY (ADCBUSY) //***************************************************************************** // // Prototypes for the APIs. // //***************************************************************************** //***************************************************************************** // //! \brief Initializes the ADC Module. //! //! This function initializes the ADC module to allow for analog-to-digital //! conversions. Specifically this function sets up the sample-and-hold signal //! and clock sources for the ADC core to use for conversions. Upon successful //! completion of the initialization all of the ADC control registers will be //! reset, excluding the memory controls and reference module bits, the given //! parameters will be set, and the ADC core will be turned on (Note, that the //! ADC core only draws power during conversions and remains off when not //! converting).Note that sample/hold signal sources are device dependent. Note //! that if re-initializing the ADC after starting a conversion with the //! startConversion() function, the disableConversion() must be called BEFORE //! this function can be called. //! //! \param baseAddress is the base address of the ADC module. //! \param sampleHoldSignalSourceSelect is the signal that will trigger a //! sample-and-hold for an input signal to be converted. This parameter //! is device specific and sources should be found in the device's //! datasheet. //! Valid values are: //! - \b ADC_SAMPLEHOLDSOURCE_SC [Default] //! - \b ADC_SAMPLEHOLDSOURCE_1 //! - \b ADC_SAMPLEHOLDSOURCE_2 //! - \b ADC_SAMPLEHOLDSOURCE_3 //! \n Modified bits are \b ADCSHSx of \b ADCCTL1 register. //! \param clockSourceSelect selects the clock that will be used by the ADC //! core and the sampling timer if a sampling pulse mode is enabled. //! Valid values are: //! - \b ADC_CLOCKSOURCE_ADCOSC [Default] - MODOSC 5 MHz oscillator from //! the clock system //! - \b ADC_CLOCKSOURCE_ACLK - The Auxilary Clock //! - \b ADC_CLOCKSOURCE_SMCLK - The Sub-Master Clock //! \n Modified bits are \b ADCSSELx of \b ADCCTL1 register. //! \param clockSourceDivider selects the amount that the clock will be //! divided. //! Valid values are: //! - \b ADC_CLOCKDIVIDER_1 [Default] //! - \b ADC_CLOCKDIVIDER_2 //! - \b ADC_CLOCKDIVIDER_3 //! - \b ADC_CLOCKDIVIDER_4 //! - \b ADC_CLOCKDIVIDER_5 //! - \b ADC_CLOCKDIVIDER_6 //! - \b ADC_CLOCKDIVIDER_7 //! - \b ADC_CLOCKDIVIDER_8 //! - \b ADC_CLOCKDIVIDER_12 //! - \b ADC_CLOCKDIVIDER_16 //! - \b ADC_CLOCKDIVIDER_20 //! - \b ADC_CLOCKDIVIDER_24 //! - \b ADC_CLOCKDIVIDER_28 //! - \b ADC_CLOCKDIVIDER_32 //! - \b ADC_CLOCKDIVIDER_64 //! - \b ADC_CLOCKDIVIDER_128 //! - \b ADC_CLOCKDIVIDER_192 //! - \b ADC_CLOCKDIVIDER_256 //! - \b ADC_CLOCKDIVIDER_320 //! - \b ADC_CLOCKDIVIDER_384 //! - \b ADC_CLOCKDIVIDER_448 //! - \b ADC_CLOCKDIVIDER_512 //! \n Modified bits are \b ADCDIVx of \b ADCCTL1 register; bits \b //! ADCPDIVx of \b ADCCTL2 register. //! //! \return None // //***************************************************************************** extern void ADC_init(uint16_t baseAddress, uint16_t sampleHoldSignalSourceSelect, uint8_t clockSourceSelect, uint16_t clockSourceDivider); //***************************************************************************** // //! \brief Enables the ADC block. //! //! This will enable operation of the ADC block. //! //! \param baseAddress is the base address of the ADC module. //! //! Modified bits are \b ADCON of \b ADCCTL0 register. //! //! \return None // //***************************************************************************** extern void ADC_enable(uint16_t baseAddress); //***************************************************************************** // //! \brief Disables the ADC block. //! //! This will disable operation of the ADC block. //! //! \param baseAddress is the base address of the ADC module. //! //! Modified bits are \b ADCON of \b ADCCTL0 register. //! //! \return None // //***************************************************************************** extern void ADC_disable(uint16_t baseAddress); //***************************************************************************** // //! \brief Sets up and enables the Sampling Timer Pulse Mode. //! //! This function sets up the sampling timer pulse mode which allows the //! sample/hold signal to trigger a sampling timer to sample-and-hold an input //! signal for a specified number of clock cycles without having to hold the //! sample/hold signal for the entire period of sampling. Note that if a //! conversion has been started with the startConversion() function, then a //! call to disableConversions() is required before this function may be //! called. //! //! \param baseAddress is the base address of the ADC module. //! \param clockCycleHoldCount sets the amount of clock cycles to sample-and- //! hold for the memory buffer. //! Valid values are: //! - \b ADC_CYCLEHOLD_4_CYCLES [Default] //! - \b ADC_CYCLEHOLD_8_CYCLES //! - \b ADC_CYCLEHOLD_16_CYCLES //! - \b ADC_CYCLEHOLD_32_CYCLES //! - \b ADC_CYCLEHOLD_64_CYCLES //! - \b ADC_CYCLEHOLD_96_CYCLES //! - \b ADC_CYCLEHOLD_128_CYCLES //! - \b ADC_CYCLEHOLD_192_CYCLES //! - \b ADC_CYCLEHOLD_256_CYCLES //! - \b ADC_CYCLEHOLD_384_CYCLES //! - \b ADC_CYCLEHOLD_512_CYCLES //! - \b ADC_CYCLEHOLD_768_CYCLES //! - \b ADC_CYCLEHOLD_1024_CYCLES //! \n Modified bits are \b ADCSHTx of \b ADCCTL0 register. //! \param multipleSamplesEnabled allows multiple conversions to start without //! a trigger signal from the sample/hold signal //! Valid values are: //! - \b ADC_MULTIPLESAMPLESDISABLE - a timer trigger will be needed to //! start every ADC conversion. //! - \b ADC_MULTIPLESAMPLESENABLE - during a sequenced and/or repeated //! conversion mode, after the first conversion, no sample/hold //! signal is necessary to start subsequent samples. //! \n Modified bits are \b ADCMSC of \b ADCCTL0 register. //! //! \return None // //***************************************************************************** extern void ADC_setupSamplingTimer(uint16_t baseAddress, uint16_t clockCycleHoldCount, uint16_t multipleSamplesEnabled); //***************************************************************************** // //! \brief Disables Sampling Timer Pulse Mode. //! //! Disables the Sampling Timer Pulse Mode. Note that if a conversion has been //! started with the startConversion() function, then a call to //! disableConversions() is required before this function may be called. //! //! \param baseAddress is the base address of the ADC module. //! //! Modified bits are \b ADCSHP of \b ADCCTL1 register. //! //! \return None // //***************************************************************************** extern void ADC_disableSamplingTimer(uint16_t baseAddress); //***************************************************************************** // //! \brief Configures the controls of the selected memory buffer. //! //! Maps an input signal conversion into the memory buffer, as well as the //! positive and negative reference voltages for each conversion being stored //! into the memory buffer. If the internal reference is used for the positive //! reference voltage, the internal REF module has to control the voltage //! level. Note that if a conversion has been started with the //! startConversion() function, then a call to disableConversions() is required //! before this function may be called. If conversion is not disabled, this //! function does nothing. //! //! \param baseAddress is the base address of the ADC module. //! \param inputSourceSelect is the input that will store the converted data //! into the specified memory buffer. //! Valid values are: //! - \b ADC_INPUT_A0 [Default] //! - \b ADC_INPUT_A1 //! - \b ADC_INPUT_A2 //! - \b ADC_INPUT_A3 //! - \b ADC_INPUT_A4 //! - \b ADC_INPUT_A5 //! - \b ADC_INPUT_A6 //! - \b ADC_INPUT_A7 //! - \b ADC_INPUT_A8 - [Valid for FR4xx devices] //! - \b ADC_INPUT_A9 - [Valid for FR4xx devices] //! - \b ADC_INPUT_TEMPSENSOR //! - \b ADC_INPUT_REFVOLTAGE //! - \b ADC_INPUT_DVSS //! - \b ADC_INPUT_DVCC //! \n Modified bits are \b ADCINCHx of \b ADCMCTL0 register. //! \param positiveRefVoltageSourceSelect is the reference voltage source to //! set as the upper limit for the conversion that is to be stored in //! the specified memory buffer. //! Valid values are: //! - \b ADC_VREFPOS_AVCC [Default] //! - \b ADC_VREFPOS_INT //! - \b ADC_VREFPOS_EXT_BUF //! - \b ADC_VREFPOS_EXT_NOBUF //! \n Modified bits are \b ADCSREF of \b ADCMCTL0 register. //! \param negativeRefVoltageSourceSelect is the reference voltage source to //! set as the lower limit for the conversion that is to be stored in //! the specified memory buffer. //! Valid values are: //! - \b ADC_VREFNEG_AVSS [Default] //! - \b ADC_VREFNEG_EXT //! \n Modified bits are \b ADCSREF of \b ADCMCTL0 register. //! //! \return None // //***************************************************************************** extern void ADC_configureMemory(uint16_t baseAddress, uint8_t inputSourceSelect, uint8_t positiveRefVoltageSourceSelect, uint8_t negativeRefVoltageSourceSelect); //***************************************************************************** // //! \brief Enables selected ADC interrupt sources. //! //! Enables the indicated ADC interrupt sources. Only the sources that are //! enabled can be reflected to the processor interrupt; disabled sources have //! no effect on the processor. <b>Does not clear interrupt flags. //! //! \param baseAddress is the base address of the ADC module. //! \param interruptMask is the bit mask of the memory buffer interrupt sources //! to be enabled. //! Mask value is the logical OR of any of the following: //! - \b ADC_OVERFLOW_INTERRUPT - Interrupts when a new conversion is //! about to overwrite the previous one //! - \b ADC_TIMEOVERFLOW_INTERRUPT - Interrupts when a new conversion //! is starting before the previous one has finished //! - \b ADC_ABOVETHRESHOLD_INTERRUPT - Interrups when the input signal //! has gone above the high threshold of the window comparator //! - \b ADC_BELOWTHRESHOLD_INTERRUPT - Interrupts when the input signal //! has gone below the low threshold of the low window comparator //! - \b ADC_INSIDEWINDOW_INTERRUPT - Interrupts when the input signal //! is in between the high and low thresholds of the window //! comparator //! - \b ADC_COMPLETED_INTERRUPT - Interrupt for new conversion data in //! the memory buffer //! //! Modified bits of \b ADCIE register. //! //! \return None // //***************************************************************************** extern void ADC_enableInterrupt(uint16_t baseAddress, uint8_t interruptMask); //***************************************************************************** // //! \brief Disables selected ADC interrupt sources. //! //! Disables the indicated ADC interrupt sources. Only the sources that are //! enabled can be reflected to the processor interrupt; disabled sources have //! no effect on the processor. //! //! \param baseAddress is the base address of the ADC module. //! \param interruptMask is the bit mask of the memory buffer interrupt sources //! to be disabled. //! Mask value is the logical OR of any of the following: //! - \b ADC_OVERFLOW_INTERRUPT - Interrupts when a new conversion is //! about to overwrite the previous one //! - \b ADC_TIMEOVERFLOW_INTERRUPT - Interrupts when a new conversion //! is starting before the previous one has finished //! - \b ADC_ABOVETHRESHOLD_INTERRUPT - Interrups when the input signal //! has gone above the high threshold of the window comparator //! - \b ADC_BELOWTHRESHOLD_INTERRUPT - Interrupts when the input signal //! has gone below the low threshold of the low window comparator //! - \b ADC_INSIDEWINDOW_INTERRUPT - Interrupts when the input signal //! is in between the high and low thresholds of the window //! comparator //! - \b ADC_COMPLETED_INTERRUPT - Interrupt for new conversion data in //! the memory buffer //! //! Modified bits of \b ADCIE register. //! //! \return None // //***************************************************************************** extern void ADC_disableInterrupt(uint16_t baseAddress, uint8_t interruptMask); //***************************************************************************** // //! \brief Clears ADC10B selected interrupt flags. //! //! The selected ADC interrupt flags are cleared, so that it no longer asserts. //! The memory buffer interrupt flags are only cleared when the memory buffer //! is accessed. //! //! \param baseAddress is the base address of the ADC module. //! \param interruptFlagMask is a bit mask of the interrupt flags to be //! cleared. //! Mask value is the logical OR of any of the following: //! - \b ADC_OVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new //! conversion is about to overwrite the previous one //! - \b ADC_TIMEOVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new //! conversion is starting before the previous one has finished //! - \b ADC_ABOVETHRESHOLD_INTERRUPT_FLAG - Interrup flag for when the //! input signal has gone above the high threshold of the window //! comparator //! - \b ADC_BELOWTHRESHOLD_INTERRUPT_FLAG - Interrupt flag for when the //! input signal has gone below the low threshold of the window //! comparator //! - \b ADC_INSIDEWINDOW_INTERRUPT_FLAG - Interrupt flag for when the //! input signal is in between the high and low thresholds of the //! window comparator //! - \b ADC_COMPLETED_INTERRUPT_FLAG - Interrupt flag for new //! conversion data in the memory buffer //! //! Modified bits of \b ADCIFG register. //! //! \return None // //***************************************************************************** extern void ADC_clearInterrupt(uint16_t baseAddress, uint8_t interruptFlagMask); //***************************************************************************** // //! \brief Returns the status of the selected memory interrupt flags. //! //! Returns the status of the selected interrupt flags. //! //! \param baseAddress is the base address of the ADC module. //! \param interruptFlagMask is a bit mask of the interrupt flags status to be //! returned. //! Mask value is the logical OR of any of the following: //! - \b ADC_OVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new //! conversion is about to overwrite the previous one //! - \b ADC_TIMEOVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new //! conversion is starting before the previous one has finished //! - \b ADC_ABOVETHRESHOLD_INTERRUPT_FLAG - Interrup flag for when the //! input signal has gone above the high threshold of the window //! comparator //! - \b ADC_BELOWTHRESHOLD_INTERRUPT_FLAG - Interrupt flag for when the //! input signal has gone below the low threshold of the window //! comparator //! - \b ADC_INSIDEWINDOW_INTERRUPT_FLAG - Interrupt flag for when the //! input signal is in between the high and low thresholds of the //! window comparator //! - \b ADC_COMPLETED_INTERRUPT_FLAG - Interrupt flag for new //! conversion data in the memory buffer //! //! Modified bits of \b ADC10IFG register. //! //! \return The current interrupt flag status for the corresponding mask. // //***************************************************************************** extern uint8_t ADC_getInterruptStatus(uint16_t baseAddress, uint8_t interruptFlagMask); //***************************************************************************** // //! \brief Enables/Starts an Analog-to-Digital Conversion. //! //! This function enables/starts the conversion process of the ADC. If the //! sample/hold signal source chosen during initialization was ADCOSC, then the //! conversion is started immediately, otherwise the chosen sample/hold signal //! source starts the conversion by a rising edge of the signal. Keep in mind //! when selecting conversion modes, that for sequenced and/or repeated modes, //! to keep the sample/hold-and-convert process continuing without a trigger //! from the sample/hold signal source, the multiple samples must be enabled //! using the ADC_setupSamplingTimer() function. Also note that when a sequence //! conversion mode is selected, the first input channel is the one mapped to //! the memory buffer, the next input channel selected for conversion is one //! less than the input channel just converted (i.e. A1 comes after A2), until //! A0 is reached, and if in repeating mode, then the next input channel will //! again be the one mapped to the memory buffer. Note that after this function //! is called, the ADC_stopConversions() has to be called to re-initialize the //! ADC, reconfigure a memory buffer control, enable/disable the sampling //! timer, or to change the internal reference voltage. //! //! \param baseAddress is the base address of the ADC module. //! \param conversionSequenceModeSelect determines the ADC operating mode. //! Valid values are: //! - \b ADC_SINGLECHANNEL [Default] - one-time conversion of a single //! channel into a single memory buffer //! - \b ADC_SEQOFCHANNELS - one time conversion of multiple channels //! into the specified starting memory buffer and each subsequent //! memory buffer up until the conversion is stored in a memory //! buffer dedicated as the end-of-sequence by the memory's control //! register //! - \b ADC_REPEATED_SINGLECHANNEL - repeated conversions of one //! channel into a single memory buffer //! - \b ADC_REPEATED_SEQOFCHANNELS - repeated conversions of multiple //! channels into the specified starting memory buffer and each //! subsequent memory buffer up until the conversion is stored in a //! memory buffer dedicated as the end-of-sequence by the memory's //! control register //! \n Modified bits are \b ADCCONSEQx of \b ADCCTL1 register. //! //! \return None // //***************************************************************************** extern void ADC_startConversion(uint16_t baseAddress, uint8_t conversionSequenceModeSelect); //***************************************************************************** // //! \brief Disables the ADC from converting any more signals. //! //! Disables the ADC from converting any more signals. If there is a conversion //! in progress, this function can stop it immediatly if the preempt parameter //! is set as ADC_PREEMPTCONVERSION, by changing the conversion mode to single- //! channel, single-conversion and disabling conversions. If the conversion //! mode is set as single-channel, single-conversion and this function is //! called without preemption, then the ADC core conversion status is polled //! until the conversion is complete before disabling conversions to prevent //! unpredictable data. If the ADC_startConversion() has been called, then this //! function has to be called to re-initialize the ADC, reconfigure a memory //! buffer control, enable/disable the sampling pulse mode, or change the //! internal reference voltage. //! //! \param baseAddress is the base address of the ADC module. //! \param preempt specifies if the current conversion should be preemptly //! stopped before the end of the conversion //! Valid values are: //! - \b ADC_COMPLETECONVERSION - Allows the ADC to end the current //! conversion before disabling conversions. //! - \b ADC_PREEMPTCONVERSION - Stops the ADC10B immediately, with //! unpredicatble results of the current conversion. Cannot be used //! with repeated conversion. //! //! Modified bits of \b ADCCTL0 register and bits of \b ADCCTL1 register. //! //! \return None // //***************************************************************************** extern void ADC_disableConversions(uint16_t baseAddress, bool preempt); //***************************************************************************** // //! \brief Returns the raw contents of the specified memory buffer. //! //! Returns the raw contents of the specified memory buffer. The format of the //! content depends on the read-back format of the data: if the data is in //! signed 2's complement format then the contents in the memory buffer will be //! left-justified with the least-siginificant bits as 0's, whereas if the data //! is in unsigned format then the contents in the memory buffer will be right- //! justified with the most-significant bits as 0's. //! //! \param baseAddress is the base address of the ADC module. //! //! \return A Signed Integer of the contents of the specified memory buffer. // //***************************************************************************** extern int16_t ADC_getResults(uint16_t baseAddress); //***************************************************************************** // //! \brief Use to change the resolution of the converted data. //! //! This function can be used to change the resolution of the converted data //! from the default of 10-bits. Refer to the device user's guide for available //! options. //! //! \param baseAddress is the base address of the ADC module. //! \param resolutionSelect determines the resolution of the converted data. //! Valid values are: //! - \b ADC_RESOLUTION_8BIT //! - \b ADC_RESOLUTION_10BIT [Default] //! - \b ADC_RESOLUTION_12BIT - [Only available in some devices] //! \n Modified bits are \b ADCRES of \b ADCCTL2 register. //! //! \return None // //***************************************************************************** extern void ADC_setResolution(uint16_t baseAddress, uint8_t resolutionSelect); //***************************************************************************** // //! \brief Use to invert or un-invert the sample/hold signal //! //! This function can be used to invert or un-invert the sample/hold signal. //! Note that if a conversion has been started with the startConversion() //! function, then a call to disableConversions() is required before this //! function may be called. //! //! \param baseAddress is the base address of the ADC module. //! \param invertedSignal set if the sample/hold signal should be inverted //! Valid values are: //! - \b ADC_NONINVERTEDSIGNAL [Default] - a sample-and-hold of an input //! signal for conversion will be started on a rising edge of the //! sample/hold signal. //! - \b ADC_INVERTEDSIGNAL - a sample-and-hold of an input signal for //! conversion will be started on a falling edge of the sample/hold //! signal. //! \n Modified bits are \b ADCISSH of \b ADCCTL1 register. //! //! \return None // //***************************************************************************** extern void ADC_setSampleHoldSignalInversion(uint16_t baseAddress, uint16_t invertedSignal); //***************************************************************************** // //! \brief Use to set the read-back format of the converted data //! //! Sets the format of the converted data: how it will be stored into the //! memory buffer, and how it should be read back. The format can be set as //! right-justified (default), which indicates that the number will be //! unsigned, or left-justified, which indicates that the number will be signed //! in 2's complement format. This change affects all memory buffers for //! subsequent conversions. //! //! \param baseAddress is the base address of the ADC module. //! \param readBackFormat is the specified format to store the conversions in //! the memory buffer. //! Valid values are: //! - \b ADC_UNSIGNED_BINARY [Default] //! - \b ADC_SIGNED_2SCOMPLEMENT //! \n Modified bits are \b ADCDF of \b ADCCTL2 register. //! //! \return None // //***************************************************************************** extern void ADC_setDataReadBackFormat(uint16_t baseAddress, uint16_t readBackFormat); //***************************************************************************** // //! \brief Use to set the reference buffer's sampling rate. //! //! Sets the reference buffer's sampling rate to the selected sampling rate. //! The default sampling rate is maximum of 200-ksps, and can be reduced to a //! maximum of 50-ksps to conserve power. //! //! \param baseAddress is the base address of the ADC module. //! \param samplingRateSelect is the specified maximum sampling rate. //! Valid values are: //! - \b ADC_MAXSAMPLINGRATE_200KSPS [Default] //! - \b ADC_MAXSAMPLINGRATE_50KSPS //! \n Modified bits are \b ADCSR of \b ADCCTL2 register. //! //! Modified bits of \b ADCCTL2 register. //! //! \return None // //***************************************************************************** extern void ADC_setReferenceBufferSamplingRate(uint16_t baseAddress, uint16_t samplingRateSelect); //***************************************************************************** // //! \brief Sets the high and low threshold for the window comparator feature. //! //! Sets the high and low threshold for the window comparator feature. Use the //! ADCHIIE, ADCINIE, ADCLOIE interrupts to utilize this feature. //! //! \param baseAddress is the base address of the ADC module. //! \param highThreshold is the upper bound that could trip an interrupt for //! the window comparator. //! \param lowThreshold is the lower bound that could trip on interrupt for the //! window comparator. //! //! Modified bits of \b ADCLO register and bits of \b ADCHI register. //! //! \return None // //***************************************************************************** extern void ADC_setWindowComp(uint16_t baseAddress, uint16_t highThreshold, uint16_t lowThreshold); //***************************************************************************** // //! \brief Returns the address of the memory buffer for the DMA module. //! //! \param baseAddress is the base address of the ADC module. //! //! \return the address of the memory buffer. This can be used in conjunction //! with the DMA to store the converted data directly to memory. // //***************************************************************************** extern uint32_t ADC_getMemoryAddressForDMA(uint16_t baseAddress); //***************************************************************************** // //! \brief Returns the busy status of the ADC core. //! //! Returns the status of the ADC core if there is a conversion currently //! taking place. //! //! \param baseAddress is the base address of the ADC module. //! //! \return ADC_BUSY or ADC_NOTBUSY dependent if there is a conversion //! currently taking place. //! Return one of the following: //! - \b ADC_NOTBUSY //! - \b ADC_BUSY // //***************************************************************************** extern uint8_t ADC_isBusy(uint16_t baseAddress); //***************************************************************************** // // The following are deprecated defines. // //***************************************************************************** #define ADC_INPUT_VEREF_N ADC_INPUT_A0 #define ADC_INPUT_VEREF_P ADC_INPUT_A1 //***************************************************************************** // // Mark the end of the C bindings section for C++ compilers. // //***************************************************************************** #ifdef __cplusplus } #endif #endif #endif // __MSP430WARE_ADC_H__
48.990011
79
0.542773
d9391f39177356ae9246bf181dca45ba90717ef3
9,176
h
C
cpp_utils/yas_flow_graph_private.h
objective-audio/cpp_utils
30f94df930351efba4823a32b0cf57f88de54da1
[ "MIT" ]
null
null
null
cpp_utils/yas_flow_graph_private.h
objective-audio/cpp_utils
30f94df930351efba4823a32b0cf57f88de54da1
[ "MIT" ]
null
null
null
cpp_utils/yas_flow_graph_private.h
objective-audio/cpp_utils
30f94df930351efba4823a32b0cf57f88de54da1
[ "MIT" ]
null
null
null
// // yas_flow_graph_private.h // #pragma once #include <unordered_map> namespace yas::flow { #pragma mark - state template <typename Waiting, typename Running> state<Waiting, Running>::state(Waiting waiting) : _waiting(std::move(waiting)) { } template <typename Waiting, typename Running> state<Waiting, Running>::state(Running running) : _running(std::move(running)) { } template <typename Waiting, typename Running> state_kind state<Waiting, Running>::kind() const { if (this->_waiting) { return state_kind::waiting; } else if (this->_running) { return state_kind::running; } else { throw std::runtime_error(""); } } template <typename Waiting, typename Running> Waiting const &state<Waiting, Running>::waiting() const { return *this->_waiting; } template <typename Waiting, typename Running> Running const &state<Waiting, Running>::running() const { return *this->_running; } #pragma mark - waiting_out template <typename Waiting, typename Running, typename Event> waiting_out<Waiting, Running, Event>::waiting_out(flow::wait<Waiting> value) : _wait_impl(std::make_shared<out_impl<flow::wait<Waiting>>>(std::move(value))) { } template <typename Waiting, typename Running, typename Event> waiting_out<Waiting, Running, Event>::waiting_out(flow::run<Running, Event> value) : _run_impl(std::make_shared<out_impl<flow::run<Running, Event>>>(std::move(value))) { } template <typename Waiting, typename Running, typename Event> waiting_out<Waiting, Running, Event>::waiting_out(flow::stay value) : _stay_impl(std::make_shared<out_impl<flow::stay>>(std::move(value))) { } template <typename Waiting, typename Running, typename Event> waiting_out<Waiting, Running, Event>::waiting_out(std::nullptr_t) { } template <typename Waiting, typename Running, typename Event> waiting_out_kind waiting_out<Waiting, Running, Event>::kind() const { if (this->_wait_impl) { return waiting_out_kind::wait; } else if (this->_run_impl) { return waiting_out_kind::run; } else if (this->_stay_impl) { return waiting_out_kind::stay; } else { throw std::runtime_error("flow_graph waiting_out kind() - kind not found"); } } template <typename Waiting, typename Running, typename Event> wait<Waiting> waiting_out<Waiting, Running, Event>::wait() const { return this->_wait_impl->value; } template <typename Waiting, typename Running, typename Event> run<Running, Event> waiting_out<Waiting, Running, Event>::run() const { return this->_run_impl->value; } #pragma mark - running_out template <typename Waiting, typename Running, typename Event> running_out<Waiting, Running, Event>::running_out(flow::wait<Waiting> value) : _wait_impl(std::make_shared<out_impl<flow::wait<Waiting>>>(std::move(value))) { } template <typename Waiting, typename Running, typename Event> running_out<Waiting, Running, Event>::running_out(flow::run<Running, Event> value) : _run_impl(std::make_shared<out_impl<flow::run<Running, Event>>>(std::move(value))) { } template <typename Waiting, typename Running, typename Event> running_out<Waiting, Running, Event>::running_out(std::nullptr_t) { } template <typename Waiting, typename Running, typename Event> running_out_kind running_out<Waiting, Running, Event>::kind() const { if (this->_wait_impl) { return running_out_kind::wait; } else if (this->_run_impl) { return running_out_kind::run; } else { throw std::runtime_error("flow_graph running_out kind() - kind not found"); } } template <typename Waiting, typename Running, typename Event> wait<Waiting> running_out<Waiting, Running, Event>::wait() const { return this->_wait_impl->value; } template <typename Waiting, typename Running, typename Event> run<Running, Event> running_out<Waiting, Running, Event>::run() const { return this->_run_impl->value; } #pragma mark - graph template <typename Waiting, typename Running, typename Event> struct graph<Waiting, Running, Event>::impl { state<Waiting, Running> _current; std::unordered_map<Waiting, waiting_handler_f> _waiting_handlers; std::unordered_map<Running, running_handler_f> _running_handlers; bool _performing = false; impl(Waiting &&waiting) : _current(std::move(waiting)) { } void addWaiting(Waiting &&waiting, waiting_handler_f &&handler) { if (this->_waiting_handlers.count(waiting) > 0) { throw std::invalid_argument("state exists."); } this->_waiting_handlers.emplace(std::move(waiting), std::move(handler)); } void addRunning(Running &&running, running_handler_f &&handler) { if (this->_running_handlers.count(running) > 0) { throw std::invalid_argument("state exists."); } this->_running_handlers.emplace(std::move(running), std::move(handler)); } void run(Event const &event) { if (this->_current.kind() != state_kind::waiting) { throw std::runtime_error("state is not waiting."); } this->_run(event); } bool contains(state<Waiting, Running> const &state) { switch (state.kind()) { case state_kind::waiting: return this->_waiting_handlers.count(state.waiting()) > 0; case state_kind::running: return this->_running_handlers.count(state.running()) > 0; } } private: void _run(Event const &event) { if (this->_performing) { throw std::runtime_error("performing."); } switch (this->_current.kind()) { case state_kind::waiting: { this->_run_waiting(this->_current.waiting(), event); } break; case state_kind::running: { this->_run_running(this->_current.running(), event); } break; } } void _run_waiting(Waiting const &state, Event const &event) { if (this->_waiting_handlers.count(state) == 0) { throw std::invalid_argument("waiting state not found."); } waiting_handler_f const &handler = this->_waiting_handlers.at(state); waiting_signal_t const signal{.event = event}; this->_performing = true; waiting_out const state_out = handler(signal); this->_performing = false; switch (state_out.kind()) { case waiting_out_kind::wait: { this->_current = state_out.wait().waiting; } break; case waiting_out_kind::run: { flow::run<Running, Event> run_out = state_out.run(); this->_current = run_out.running; this->_run(run_out.event); } break; case waiting_out_kind::stay: break; } } void _run_running(Running const &state, Event const &event) { if (this->_running_handlers.count(state) == 0) { throw std::invalid_argument("running state not found."); } running_handler_f const &handler = this->_running_handlers.at(state); running_signal_t const signal{.event = event}; this->_performing = true; running_out const state_out = handler(signal); this->_performing = false; switch (state_out.kind()) { case running_out_kind::wait: { this->_current = state_out.wait().waiting; } break; case running_out_kind::run: { flow::run<Running, Event> run_out = state_out.run(); this->_current = run_out.running; this->_run(run_out.event); } break; } } }; template <typename Waiting, typename Running, typename Event> graph<Waiting, Running, Event>::graph(Waiting &&waiting) : _impl(std::make_unique<impl>(std::move(waiting))) { } template <typename Waiting, typename Running, typename Event> void graph<Waiting, Running, Event>::add_waiting(Waiting waiting, waiting_handler_f handler) { this->_impl->addWaiting(std::move(waiting), std::move(handler)); } template <typename Waiting, typename Running, typename Event> void graph<Waiting, Running, Event>::add_running(Running running, running_handler_f handler) { this->_impl->addRunning(std::move(running), std::move(handler)); } template <typename Waiting, typename Running, typename Event> void graph<Waiting, Running, Event>::run(Event const &event) { this->_impl->run(event); } template <typename Waiting, typename Running, typename Event> state<Waiting, Running> const &graph<Waiting, Running, Event>::current() const { return this->_impl->_current; } template <typename Waiting, typename Running, typename Event> bool graph<Waiting, Running, Event>::contains(state<Waiting, Running> const &state) const { return this->_impl->contains(state); } template <typename Waiting, typename Running, typename Event> std::shared_ptr<graph<Waiting, Running, Event>> graph<Waiting, Running, Event>::make_shared(Waiting waiting) { return std::shared_ptr<graph<Waiting, Running, Event>>(new graph<Waiting, Running, Event>{std::move(waiting)}); } } // namespace yas::flow
33.126354
115
0.668374
d9392b13f830a6194f1c5f9cf6469302de240236
35,249
h
C
firehog/lynx/src/chrtrans/def7_uni.h
KipodAfterFree/KAF-2019-FireHog
5f6ee3c3c3329459bc9daeabc1a16ff4619508d9
[ "MIT" ]
null
null
null
firehog/lynx/src/chrtrans/def7_uni.h
KipodAfterFree/KAF-2019-FireHog
5f6ee3c3c3329459bc9daeabc1a16ff4619508d9
[ "MIT" ]
null
null
null
firehog/lynx/src/chrtrans/def7_uni.h
KipodAfterFree/KAF-2019-FireHog
5f6ee3c3c3329459bc9daeabc1a16ff4619508d9
[ "MIT" ]
1
2019-12-26T10:18:16.000Z
2019-12-26T10:18:16.000Z
/* * uni_hash.tbl * * Do not edit this file; it was automatically generated by * * ./makeuctb ./def7_uni.tbl * */ static u8 dfont_unicount[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 1, 5, 2, 1, 1, 1, 4, 1, 1, 2, 98, 2, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 3, 1, 1, 1, 2, 2, 10, 1, 6, 3, 12, 1, 9, 4, 14, 3, 5, 7, 2, 7, 10, 2, 3, 6, 6, 4, 12, 2, 2, 3, 4, 5, 2, 1, 1, 1, 1, 3, 10, 2, 6, 3, 11, 1, 9, 4, 12, 5, 4, 5, 2, 6, 12, 2, 2, 6, 6, 4, 12, 3, 3, 1, 5, 5, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static u16 dfont_unitable[464] = { 0x0020, 0x1360, 0x2000, 0x2002, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x3000, 0x0021, 0x0022, 0x201c, 0x201d, 0x201e, 0x201f, 0x0023, 0x05d0, 0x0024, 0x0025, 0x0026, 0x0027, 0x2019, 0x201a, 0x201b, 0x0028, 0x0029, 0x002a, 0x027e, 0x002b, 0x250c, 0x250d, 0x250e, 0x250f, 0x2510, 0x2511, 0x2512, 0x2513, 0x2514, 0x2515, 0x2516, 0x2517, 0x2518, 0x2519, 0x251a, 0x251b, 0x251c, 0x251d, 0x251e, 0x251f, 0x2520, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526, 0x2527, 0x2528, 0x2529, 0x252a, 0x252b, 0x252c, 0x252d, 0x252e, 0x252f, 0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536, 0x2537, 0x2538, 0x2539, 0x253a, 0x253b, 0x253c, 0x253d, 0x253e, 0x253f, 0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545, 0x2546, 0x2547, 0x2548, 0x2549, 0x254a, 0x254b, 0x254c, 0x254d, 0x254e, 0x254f, 0x2550, 0x2551, 0x2552, 0x2553, 0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, 0x255e, 0x255f, 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x002c, 0x1363, 0x002d, 0x0329, 0x2010, 0x2013, 0x2014, 0x2015, 0x2043, 0x002e, 0x0322, 0x0323, 0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x02d0, 0x05c2, 0x1361, 0x003b, 0x02b2, 0x0321, 0x003c, 0x003d, 0x003e, 0x003f, 0x0294, 0x0040, 0x0259, 0x0041, 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x0100, 0x0102, 0x0104, 0x01cd, 0x0251, 0x0042, 0x0043, 0x0106, 0x0108, 0x010a, 0x010c, 0x132d, 0x0044, 0x010e, 0x12fd, 0x0045, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x0112, 0x0114, 0x0116, 0x0118, 0x011a, 0x025b, 0x12a4, 0x0046, 0x0047, 0x011c, 0x011e, 0x0120, 0x0122, 0x01e6, 0x01f4, 0x0262, 0x131d, 0x0048, 0x0124, 0x0127, 0x1215, 0x0049, 0x00cc, 0x00cd, 0x00ce, 0x00cf, 0x0128, 0x012a, 0x012c, 0x012e, 0x0130, 0x01cf, 0x026a, 0x0269, 0x12a5, 0x004a, 0x0134, 0x025f, 0x004b, 0x0136, 0x01e8, 0x12bd, 0x212a, 0x004c, 0x0139, 0x013b, 0x013d, 0x026b, 0x026c, 0x029f, 0x004d, 0x0271, 0x004e, 0x00d1, 0x0143, 0x0145, 0x0147, 0x014b, 0x129d, 0x004f, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x014c, 0x014e, 0x01d1, 0x01ea, 0x0254, 0x0050, 0x1335, 0x0051, 0x0263, 0x1255, 0x0052, 0x0154, 0x0156, 0x0158, 0x025a, 0x0280, 0x0053, 0x015a, 0x015c, 0x015e, 0x0160, 0x0283, 0x0054, 0x0162, 0x0164, 0x1325, 0x0055, 0x00d9, 0x00da, 0x00db, 0x0168, 0x016a, 0x016c, 0x016e, 0x0172, 0x01d3, 0x0277, 0x028a, 0x0056, 0x028c, 0x0057, 0x0174, 0x0058, 0x2713, 0x2717, 0x0059, 0x00dd, 0x0176, 0x0178, 0x005a, 0x0179, 0x017b, 0x017d, 0x12e5, 0x005b, 0x032a, 0x005c, 0x005d, 0x005e, 0x005f, 0x0060, 0x02bc, 0x2018, 0x0061, 0x00e1, 0x00e2, 0x00e3, 0x0101, 0x0103, 0x0105, 0x01ce, 0x05b7, 0x12a3, 0x0062, 0x1265, 0x0063, 0x0107, 0x0109, 0x010b, 0x010d, 0x127d, 0x0064, 0x010f, 0x12f5, 0x0065, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x0113, 0x0115, 0x0117, 0x0119, 0x011b, 0x12a0, 0x0066, 0x0067, 0x011d, 0x011f, 0x0121, 0x0123, 0x01e7, 0x01f5, 0x0261, 0x130d, 0x0068, 0x0125, 0x05bf, 0x1205, 0x0069, 0x00ed, 0x00ee, 0x00ef, 0x0129, 0x012b, 0x012d, 0x012f, 0x0131, 0x01d0, 0x05b4, 0x12a2, 0x006a, 0x0135, 0x01f0, 0x029d, 0x1305, 0x006b, 0x0137, 0x01e9, 0x12ad, 0x006c, 0x013a, 0x013c, 0x013e, 0x120d, 0x006d, 0x121d, 0x006e, 0x00f1, 0x0144, 0x0146, 0x0148, 0x1295, 0x006f, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x014d, 0x014f, 0x01d2, 0x01eb, 0x05b8, 0x12a6, 0x134d, 0x0070, 0x1355, 0x0071, 0x1245, 0x0072, 0x0155, 0x0157, 0x0159, 0x0279, 0x122d, 0x0073, 0x015b, 0x015d, 0x015f, 0x0161, 0x1235, 0x0074, 0x0163, 0x0165, 0x1275, 0x0075, 0x00f9, 0x00fa, 0x00fb, 0x0169, 0x016b, 0x016d, 0x016f, 0x0173, 0x01d4, 0x05bc, 0x12a1, 0x0076, 0x05f0, 0x126d, 0x0077, 0x0175, 0x12cd, 0x0078, 0x0079, 0x00fd, 0x00ff, 0x0177, 0x12ed, 0x007a, 0x017a, 0x017c, 0x017e, 0x12dd, 0x007b, 0x007c, 0x007d, 0x007e, 0x0303, 0x0334 }; static struct unipair_str repl_map[1943] = { {0xa1,"!"}, {0xa2,"-c-"}, {0xa3,"-L-"}, {0xa4,"CUR"}, {0xa5,"YEN"}, {0xa6,"|"}, {0xa7,"S:"}, {0xa8,"\042"}, {0xa9,"(c)"}, {0xaa,"-a"}, {0xab,"<<"}, {0xac,"NOT"}, {0xae,"(R)"}, {0xaf,"-"}, {0xb0,"DEG"}, {0xb1,"+-"}, {0xb2,"^2"}, {0xb3,"^3"}, {0xb4,"'"}, {0xb5,"u"}, {0xb6,"P:"}, {0xb7,"."}, {0xb8,","}, {0xb9,"^1"}, {0xba,"-o"}, {0xbb,">>"}, {0xbc," 1/4"}, {0xbd," 1/2"}, {0xbe," 3/4"}, {0xbf,"?"}, {0xc4,"A:"}, {0xc5,"AA"}, {0xc6,"AE"}, {0xc7,"C,"}, {0xd0,"D-"}, {0xd6,"O:"}, {0xd7," *"}, {0xd8,"O/"}, {0xdc,"U:"}, {0xde,"TH"}, {0xdf,"ss"}, {0xe0,"`a"}, {0xe4,"a:"}, {0xe5,"aa"}, {0xe6,"ae"}, {0xe7,"c,"}, {0xec,"`i"}, {0xf0,"d-"}, {0xf6,"o:"}, {0xf7,"-:"}, {0xf8,"o/"}, {0xfc,"u:"}, {0xfe,"th"}, {0x110,"D/"}, {0x111,"d/"}, {0x126,"H/"}, {0x132,"IJ"}, {0x133,"ij"}, {0x138,"kk"}, {0x13f,"L."}, {0x140,"l."}, {0x141,"L/"}, {0x142,"l/"}, {0x149,"'n"}, {0x14a,"NG"}, {0x150,"O\042"}, {0x151,"o\042"}, {0x152,"OE"}, {0x153,"oe"}, {0x166,"T/"}, {0x167,"t/"}, {0x170,"U\042"}, {0x171,"u\042"}, {0x17f,"s1"}, {0x187,"C2"}, {0x188,"c2"}, {0x191,"F2"}, {0x192," f"}, {0x198,"K2"}, {0x199,"k2"}, {0x1a0,"O9"}, {0x1a1,"o9"}, {0x1a2,"OI"}, {0x1a3,"oi"}, {0x1a6,"yr"}, {0x1af,"U9"}, {0x1b0,"u9"}, {0x1b5,"Z/"}, {0x1b6,"z/"}, {0x1b7,"ED"}, {0x1d5,"U:-"}, {0x1d6,"u:-"}, {0x1d7,"U:'"}, {0x1d8,"u:'"}, {0x1d9,"U:<"}, {0x1da,"u:<"}, {0x1db,"U:!"}, {0x1dc,"u:!"}, {0x1de,"A1"}, {0x1df,"a1"}, {0x1e0,"A7"}, {0x1e1,"a7"}, {0x1e2,"A3"}, {0x1e3,"a3"}, {0x1e4,"G/"}, {0x1e5,"g/"}, {0x1ec,"O1"}, {0x1ed,"o1"}, {0x1ee,"EZ"}, {0x1ef,"ez"}, {0x1fa,"AA'"}, {0x1fb,"aa'"}, {0x1fc,"AE'"}, {0x1fd,"ae'"}, {0x1fe,"O/'"}, {0x1ff,"o/'"}, {0x200,"A!!"}, {0x201,"a!!"}, {0x202,"A)"}, {0x203,"a)"}, {0x204,"E!!"}, {0x205,"e!!"}, {0x206,"E)"}, {0x207,"e)"}, {0x208,"I!!"}, {0x209,"i!!"}, {0x20a,"I)"}, {0x20b,"i)"}, {0x20c,"O!!"}, {0x20d,"o!!"}, {0x20e,"O)"}, {0x20f,"o)"}, {0x210,"R!!"}, {0x211,"r!!"}, {0x212,"R)"}, {0x213,"r)"}, {0x214,"U!!"}, {0x215,"u!!"}, {0x216,"U)"}, {0x217,"u)"}, {0x252,"A."}, {0x253,"b`"}, {0x256,"d."}, {0x257,"d`"}, {0x258,"@<umd>"}, {0x25c,"V\042"}, {0x25d,"R<umd>"}, {0x25e,"O\042"}, {0x260,"g`"}, {0x264,"o-"}, {0x265,"j<rnd>"}, {0x266,"h<?>"}, {0x268,"i\042"}, {0x26d,"l."}, {0x26e,"z<lat>"}, {0x26f,"u-"}, {0x270,"j<vel>"}, {0x273,"n."}, {0x274,"n\042"}, {0x275,"@."}, {0x276,"&."}, {0x27a,"*<lat>"}, {0x27b,"r."}, {0x27d,"*."}, {0x280,"r\042"}, {0x281,"g\042"}, {0x282,"s."}, {0x284,"J`"}, {0x287,"t!"}, {0x288,"t."}, {0x289,"u\042"}, {0x28b,"r<lbd>"}, {0x28d,"w<vls>"}, {0x28e,"l^"}, {0x28f,"I."}, {0x290,"z."}, {0x292,"ed"}, {0x295,"H<vcd>"}, {0x296,"l!"}, {0x297,"c!"}, {0x298,"p!"}, {0x299,"b<trl>"}, {0x29b,"G`"}, {0x29e,"k!"}, {0x2a0,"q`"}, {0x2b0,"<h>"}, {0x2b1,"<?>"}, {0x2b3,"<r>"}, {0x2b7,"<w>"}, {0x2bb,";S"}, {0x2c6,"^"}, {0x2c7,"'<"}, {0x2c9,"1-"}, {0x2cb,"1!"}, {0x2d8,"'("}, {0x2d9,"'."}, {0x2da,"'0"}, {0x2db,"';"}, {0x2dc,"~"}, {0x2dd,"'\042"}, {0x324,"<?>"}, {0x325,"<o>"}, {0x32b,"<w>"}, {0x334,"<H>"}, {0x374,"'"}, {0x375,","}, {0x37a,"j3"}, {0x37e,"?%"}, {0x384,"'*"}, {0x385,"'%"}, {0x386,"A%"}, {0x387,".*"}, {0x388,"E%"}, {0x389,"Y%"}, {0x38a,"I%"}, {0x38c,"O%"}, {0x38e,"U%"}, {0x38f,"W%"}, {0x390,"i3"}, {0x391,"A"}, {0x392,"B"}, {0x393,"G"}, {0x394,"D"}, {0x395,"E"}, {0x396,"Z"}, {0x397,"Y"}, {0x398,"TH"}, {0x399,"I"}, {0x39a,"K"}, {0x39b,"L"}, {0x39c,"M"}, {0x39d,"N"}, {0x39e,"C"}, {0x39f,"O"}, {0x3a0,"P"}, {0x3a1,"R"}, {0x3a3,"S"}, {0x3a4,"T"}, {0x3a5,"U"}, {0x3a6,"F"}, {0x3a7,"X"}, {0x3a8,"Q"}, {0x3a9,"W"}, {0x3aa,"J"}, {0x3ab,"V*"}, {0x3ac,"a%"}, {0x3ad,"e%"}, {0x3ae,"y%"}, {0x3af,"i%"}, {0x3b0,"u3"}, {0x3b1,"a"}, {0x3b2,"b"}, {0x3b3,"g"}, {0x3b4,"d"}, {0x3b5,"e"}, {0x3b6,"z"}, {0x3b7,"y"}, {0x3b8,"th"}, {0x3b9,"i"}, {0x3ba,"k"}, {0x3bb,"l"}, {0x3bc,"m"}, {0x3bd,"n"}, {0x3be,"c"}, {0x3bf,"o"}, {0x3c0,"p"}, {0x3c1,"r"}, {0x3c2,"*s"}, {0x3c3,"s"}, {0x3c4,"t"}, {0x3c5,"u"}, {0x3c6,"f"}, {0x3c7,"x"}, {0x3c8,"q"}, {0x3c9,"w"}, {0x3ca,"j"}, {0x3cb,"v*"}, {0x3cc,"o%"}, {0x3cd,"u%"}, {0x3ce,"w%"}, {0x3d0,"beta "}, {0x3d1,"theta "}, {0x3d2,"upsi "}, {0x3d5,"phi "}, {0x3d6,"pi "}, {0x3da,"T3"}, {0x3db,"t3"}, {0x3dc,"M3"}, {0x3dd,"m3"}, {0x3de,"K3"}, {0x3df,"k3"}, {0x3e0,"P3"}, {0x3e1,"p3"}, {0x3f0,"kappa "}, {0x3f1,"rho "}, {0x3f4,"'%"}, {0x3f5,"j3"}, {0x402,"D%"}, {0x403,"G%"}, {0x404,"IE"}, {0x405,"DS"}, {0x406,"II"}, {0x407,"YI"}, {0x408,"J%"}, {0x409,"LJ"}, {0x40a,"NJ"}, {0x40b,"Ts"}, {0x40c,"KJ"}, {0x40e,"V%"}, {0x40f,"DZ"}, {0x401,"IO"}, {0x410,"A"}, {0x411,"B"}, {0x412,"V"}, {0x413,"G"}, {0x414,"D"}, {0x415,"E"}, {0x416,"ZH"}, {0x417,"Z"}, {0x418,"I"}, {0x419,"J"}, {0x41a,"K"}, {0x41b,"L"}, {0x41c,"M"}, {0x41d,"N"}, {0x41e,"O"}, {0x41f,"P"}, {0x420,"R"}, {0x421,"S"}, {0x422,"T"}, {0x423,"U"}, {0x424,"F"}, {0x425,"H"}, {0x426,"C"}, {0x427,"CH"}, {0x428,"SH"}, {0x429,"SCH"}, {0x42a,"\042"}, {0x42b,"Y"}, {0x42c,"'"}, {0x42d,"`E"}, {0x42e,"YU"}, {0x42f,"YA"}, {0x430,"a"}, {0x431,"b"}, {0x432,"v"}, {0x433,"g"}, {0x434,"d"}, {0x435,"e"}, {0x436,"zh"}, {0x437,"z"}, {0x438,"i"}, {0x439,"j"}, {0x43a,"k"}, {0x43b,"l"}, {0x43c,"m"}, {0x43d,"n"}, {0x43e,"o"}, {0x43f,"p"}, {0x440,"r"}, {0x441,"s"}, {0x442,"t"}, {0x443,"u"}, {0x444,"f"}, {0x445,"h"}, {0x446,"c"}, {0x447,"ch"}, {0x448,"sh"}, {0x449,"sch"}, {0x44a,"\042"}, {0x44b,"y"}, {0x44c,"'"}, {0x44d,"`e"}, {0x44e,"yu"}, {0x44f,"ya"}, {0x451,"io"}, {0x452,"d%"}, {0x453,"g%"}, {0x454,"ie"}, {0x455,"ds"}, {0x456,"ii"}, {0x457,"yi"}, {0x458,"j%"}, {0x459,"lj"}, {0x45a,"nj"}, {0x45b,"ts"}, {0x45c,"kj"}, {0x45e,"v%"}, {0x45f,"dz"}, {0x462,"Y3"}, {0x463,"y3"}, {0x46a,"O3"}, {0x46b,"o3"}, {0x472,"F3"}, {0x473,"f3"}, {0x474,"V3"}, {0x475,"v3"}, {0x480,"C3"}, {0x481,"c3"}, {0x490,"G3"}, {0x491,"g3"}, {0x5f1,"oy"}, {0x5f2,"ey"}, {0x5d1,"B+"}, {0x5d2,"G+"}, {0x5d3,"D+"}, {0x5d4,"H+"}, {0x5d5,"W+"}, {0x5d6,"Z+"}, {0x5d7,"X+"}, {0x5d8,"Tj"}, {0x5d9,"J+"}, {0x5da,"K%"}, {0x5db,"K+"}, {0x5dc,"L+"}, {0x5dd,"M%"}, {0x5de,"M+"}, {0x5df,"N%"}, {0x5e0,"N+"}, {0x5e1,"S+"}, {0x5e2,"E+"}, {0x5e3,"P%"}, {0x5e4,"P+"}, {0x5e5,"Zj"}, {0x5e6,"ZJ"}, {0x5e7,"Q+"}, {0x5e8,"R+"}, {0x5e9,"Sh"}, {0x5ea,"T+"}, {0x60c,",+"}, {0x61b,";+"}, {0x61f,"?+"}, {0x621,"H'"}, {0x622,"aM"}, {0x623,"aH"}, {0x624,"wH"}, {0x625,"ah"}, {0x626,"yH"}, {0x627,"a+"}, {0x628,"b+"}, {0x629,"tm"}, {0x62a,"t+"}, {0x62b,"tk"}, {0x62c,"g+"}, {0x62d,"hk"}, {0x62e,"x+"}, {0x62f,"d+"}, {0x630,"dk"}, {0x631,"r+"}, {0x632,"z+"}, {0x633,"s+"}, {0x634,"sn"}, {0x635,"c+"}, {0x636,"dd"}, {0x637,"tj"}, {0x638,"zH"}, {0x639,"e+"}, {0x63a,"i+"}, {0x640,"++"}, {0x641,"f+"}, {0x642,"q+"}, {0x643,"k+"}, {0x644,"l+"}, {0x645,"m+"}, {0x646,"n+"}, {0x647,"h+"}, {0x648,"w+"}, {0x649,"j+"}, {0x64a,"y+"}, {0x64b,":+"}, {0x64c,"\042+"}, {0x64d,"=+"}, {0x64e,"/+"}, {0x64f,"'+"}, {0x650,"1+"}, {0x651,"3+"}, {0x652,"0+"}, {0x660,"0a"}, {0x661,"1a"}, {0x662,"2a"}, {0x663,"3a"}, {0x664,"4a"}, {0x665,"5a"}, {0x666,"6a"}, {0x667,"7a"}, {0x668,"8a"}, {0x669,"9a"}, {0x670,"aS"}, {0x67e,"p+"}, {0x681,"hH"}, {0x686,"tc"}, {0x698,"zj"}, {0x6a4,"v+"}, {0x6af,"gf"}, {0x6f0,"0a"}, {0x6f1,"1a"}, {0x6f2,"2a"}, {0x6f3,"3a"}, {0x6f4,"4a"}, {0x6f5,"5a"}, {0x6f6,"6a"}, {0x6f7,"7a"}, {0x6f8,"8a"}, {0x6f9,"9a"}, {0x1200,"he"}, {0x1201,"hu"}, {0x1202,"hi"}, {0x1203,"ha"}, {0x1204,"hE"}, {0x1206,"ho"}, {0x1208,"le"}, {0x1209,"lu"}, {0x120a,"li"}, {0x120b,"la"}, {0x120c,"lE"}, {0x120e,"lo"}, {0x120f,"lWa"}, {0x1210,"He"}, {0x1211,"Hu"}, {0x1212,"Hi"}, {0x1213,"Ha"}, {0x1214,"HE"}, {0x1216,"Ho"}, {0x1217,"HWa"}, {0x1218,"me"}, {0x1219,"mu"}, {0x121a,"mi"}, {0x121b,"ma"}, {0x121c,"mE"}, {0x121e,"mo"}, {0x121f,"mWa"}, {0x1220,"`se"}, {0x1221,"`su"}, {0x1222,"`si"}, {0x1223,"`sa"}, {0x1224,"`sE"}, {0x1225,"`s"}, {0x1226,"`so"}, {0x1227,"`sWa"}, {0x1228,"re"}, {0x1229,"ru"}, {0x122a,"ri"}, {0x122b,"ra"}, {0x122c,"rE"}, {0x122e,"ro"}, {0x122f,"rWa"}, {0x1230,"se"}, {0x1231,"su"}, {0x1232,"si"}, {0x1233,"sa"}, {0x1234,"sE"}, {0x1236,"so"}, {0x1237,"sWa"}, {0x1238,"xe"}, {0x1239,"xu"}, {0x123a,"xi"}, {0x123b,"xa"}, {0x123c,"xE"}, {0x123d,"xa"}, {0x123e,"xo"}, {0x123f,"xWa"}, {0x1240,"qe"}, {0x1241,"qu"}, {0x1242,"qi"}, {0x1243,"qa"}, {0x1244,"qE"}, {0x1246,"qo"}, {0x1248,"qWe"}, {0x124a,"qWi"}, {0x124b,"qWa"}, {0x124c,"qWE"}, {0x124d,"qW"}, {0x1250,"Qe"}, {0x1251,"Qu"}, {0x1252,"Qi"}, {0x1253,"Qa"}, {0x1254,"QE"}, {0x1256,"Qo"}, {0x1258,"QWe"}, {0x125a,"QWi"}, {0x125b,"QWa"}, {0x125c,"QWE"}, {0x125d,"QW"}, {0x1260,"be"}, {0x1261,"bu"}, {0x1262,"bi"}, {0x1263,"ba"}, {0x1264,"bE"}, {0x1266,"bo"}, {0x1267,"bWa"}, {0x1268,"ve"}, {0x1269,"vu"}, {0x126a,"vi"}, {0x126b,"va"}, {0x126c,"vE"}, {0x126e,"vo"}, {0x126f,"vWa"}, {0x1270,"te"}, {0x1271,"tu"}, {0x1272,"ti"}, {0x1273,"ta"}, {0x1274,"tE"}, {0x1276,"to"}, {0x1277,"tWa"}, {0x1278,"ce"}, {0x1279,"cu"}, {0x127a,"ci"}, {0x127b,"ca"}, {0x127c,"cE"}, {0x127e,"co"}, {0x127f,"cWa"}, {0x1280,"`he"}, {0x1281,"`hu"}, {0x1282,"`hi"}, {0x1283,"`ha"}, {0x1284,"`hE"}, {0x1285,"`h"}, {0x1286,"`ho"}, {0x1288,"hWe"}, {0x128a,"hWi"}, {0x128b,"hWa"}, {0x128c,"hWE"}, {0x128d,"hW"}, {0x1290,"na"}, {0x1291,"nu"}, {0x1292,"ni"}, {0x1293,"na"}, {0x1294,"nE"}, {0x1296,"no"}, {0x1297,"nWa"}, {0x1298,"Ne"}, {0x1299,"Nu"}, {0x129a,"Ni"}, {0x129b,"Na"}, {0x129c,"NE"}, {0x129e,"No"}, {0x129f,"NWa"}, {0x12a7,"e3"}, {0x12a8,"ke"}, {0x12a9,"ku"}, {0x12aa,"ki"}, {0x12ab,"ka"}, {0x12ac,"kE"}, {0x12ae,"ko"}, {0x12b0,"kWe"}, {0x12b2,"kWi"}, {0x12b3,"kWa"}, {0x12b4,"kWE"}, {0x12b5,"kW"}, {0x12b8,"Ke"}, {0x12b9,"Ku"}, {0x12ba,"Ki"}, {0x12bb,"Ka"}, {0x12bc,"KE"}, {0x12be,"Ko"}, {0x12c0,"KWe"}, {0x12c2,"KWi"}, {0x12c3,"KWa"}, {0x12c4,"KWE"}, {0x12c5,"KW"}, {0x12c8,"we"}, {0x12c9,"wu"}, {0x12ca,"wi"}, {0x12cb,"wa"}, {0x12cc,"wE"}, {0x12ce,"wo"}, {0x12d0,"`e"}, {0x12d1,"`u"}, {0x12d2,"`i"}, {0x12d3,"`a"}, {0x12d4,"`E"}, {0x12d5,"`I"}, {0x12d6,"`o"}, {0x12d8,"ze"}, {0x12d9,"zu"}, {0x12da,"zi"}, {0x12db,"za"}, {0x12dc,"zE"}, {0x12de,"zo"}, {0x12df,"zWa"}, {0x12e0,"Ze"}, {0x12e1,"Zu"}, {0x12e2,"Zi"}, {0x12e3,"Za"}, {0x12e4,"ZE"}, {0x12e6,"Zo"}, {0x12e7,"ZWa"}, {0x12e8,"ye"}, {0x12e9,"yu"}, {0x12ea,"yi"}, {0x12eb,"ya"}, {0x12ec,"yE"}, {0x12ee,"yo"}, {0x12ef,"yWa"}, {0x12f0,"de"}, {0x12f1,"du"}, {0x12f2,"di"}, {0x12f3,"da"}, {0x12f4,"dE"}, {0x12f6,"do"}, {0x12f7,"dWa"}, {0x12f8,"De"}, {0x12f9,"Du"}, {0x12fa,"Di"}, {0x12fb,"Da"}, {0x12fc,"DE"}, {0x12fe,"Do"}, {0x12ff,"DWa"}, {0x1300,"je"}, {0x1301,"ju"}, {0x1302,"ji"}, {0x1303,"ja"}, {0x1304,"jE"}, {0x1306,"jo"}, {0x1307,"jWa"}, {0x1308,"ga"}, {0x1309,"gu"}, {0x130a,"gi"}, {0x130b,"ga"}, {0x130c,"gE"}, {0x130e,"go"}, {0x1310,"gWu"}, {0x1312,"gWi"}, {0x1313,"gWa"}, {0x1314,"gWE"}, {0x1315,"gW"}, {0x1318,"Ge"}, {0x1319,"Gu"}, {0x131a,"Gi"}, {0x131b,"Ga"}, {0x131c,"GE"}, {0x131e,"Go"}, {0x131f,"GWa"}, {0x1320,"Te"}, {0x1321,"Tu"}, {0x1322,"Ti"}, {0x1323,"Ta"}, {0x1324,"TE"}, {0x1326,"To"}, {0x1327,"TWa"}, {0x1328,"Ce"}, {0x1329,"Ca"}, {0x132a,"Cu"}, {0x132b,"Ca"}, {0x132c,"CE"}, {0x132e,"Co"}, {0x132f,"CWa"}, {0x1330,"Pe"}, {0x1331,"Pu"}, {0x1332,"Pi"}, {0x1333,"Pa"}, {0x1334,"PE"}, {0x1336,"Po"}, {0x1337,"PWa"}, {0x1338,"SWe"}, {0x1339,"SWu"}, {0x133a,"SWi"}, {0x133b,"SWa"}, {0x133c,"SWE"}, {0x133d,"SW"}, {0x133e,"SWo"}, {0x133f,"SWa"}, {0x1340,"`Sa"}, {0x1341,"`Su"}, {0x1342,"`Si"}, {0x1343,"`Sa"}, {0x1344,"`SE"}, {0x1345,"`S"}, {0x1346,"`So"}, {0x1348,"fa"}, {0x1349,"fu"}, {0x134a,"fi"}, {0x134b,"fa"}, {0x134c,"fE"}, {0x134e,"fo"}, {0x134f,"fWa"}, {0x1350,"pe"}, {0x1351,"pu"}, {0x1352,"pi"}, {0x1353,"pa"}, {0x1354,"pE"}, {0x1356,"po"}, {0x1357,"pWa"}, {0x1358,"mYa"}, {0x1359,"rYa"}, {0x135a,"fYa"}, {0x1362,"::"}, {0x1364,";"}, {0x1365,"-:"}, {0x1366,":-"}, {0x1367,"`?"}, {0x1368,":|:"}, {0x1369,"`1"}, {0x136a,"`2"}, {0x136b,"`3"}, {0x136c,"`4"}, {0x136d,"`5"}, {0x136e,"`6"}, {0x136f,"`7"}, {0x1370,"`8"}, {0x1371,"`9"}, {0x1372,"`10"}, {0x1373,"`20"}, {0x1374,"`30"}, {0x1375,"`40"}, {0x1376,"`50"}, {0x1377,"`60"}, {0x1378,"`70"}, {0x1379,"`80"}, {0x137a,"`90"}, {0x137b,"`100"}, {0x137c,"`10000"}, {0x1e00,"A-0"}, {0x1e01,"a-0"}, {0x1e02,"B."}, {0x1e03,"b."}, {0x1e04,"B-."}, {0x1e05,"b-."}, {0x1e06,"B_"}, {0x1e07,"b_"}, {0x1e08,"C,'"}, {0x1e09,"c,'"}, {0x1e0a,"D."}, {0x1e0b,"d."}, {0x1e0c,"D-."}, {0x1e0d,"d-."}, {0x1e0e,"D_"}, {0x1e0f,"d_"}, {0x1e10,"D,"}, {0x1e11,"d,"}, {0x1e12,"D->"}, {0x1e13,"d->"}, {0x1e14,"E-!"}, {0x1e15,"e-!"}, {0x1e16,"E-'"}, {0x1e17,"e-'"}, {0x1e18,"E->"}, {0x1e19,"e->"}, {0x1e1a,"E-?"}, {0x1e1b,"e-?"}, {0x1e1c,"E,("}, {0x1e1d,"e,("}, {0x1e1e,"F."}, {0x1e1f,"f."}, {0x1e20,"G-"}, {0x1e21,"g-"}, {0x1e22,"H."}, {0x1e23,"h."}, {0x1e24,"H-."}, {0x1e25,"h-."}, {0x1e26,"H:"}, {0x1e27,"h:"}, {0x1e28,"H,"}, {0x1e29,"h,"}, {0x1e2a,"H-("}, {0x1e2b,"h-("}, {0x1e2c,"I-?"}, {0x1e2d,"i-?"}, {0x1e2e,"I:'"}, {0x1e2f,"i:'"}, {0x1e30,"K'"}, {0x1e31,"k'"}, {0x1e32,"K-."}, {0x1e33,"k-."}, {0x1e34,"K_"}, {0x1e35,"k_"}, {0x1e36,"L-."}, {0x1e37,"l-."}, {0x1e38,"L--."}, {0x1e39,"l--."}, {0x1e3a,"L_"}, {0x1e3b,"l_"}, {0x1e3c,"L->"}, {0x1e3d,"l->"}, {0x1e3e,"M'"}, {0x1e3f,"m'"}, {0x1e40,"M."}, {0x1e41,"m."}, {0x1e42,"M-."}, {0x1e43,"m-."}, {0x1e44,"N."}, {0x1e45,"n."}, {0x1e46,"N-."}, {0x1e47,"n-."}, {0x1e48,"N_"}, {0x1e49,"n_"}, {0x1e4a,"N->"}, {0x1e4b,"n->"}, {0x1e4c,"O?'"}, {0x1e4d,"o?'"}, {0x1e4e,"O?:"}, {0x1e4f,"o?:"}, {0x1e50,"O-!"}, {0x1e51,"o-!"}, {0x1e52,"O-'"}, {0x1e53,"o-'"}, {0x1e54,"P'"}, {0x1e55,"p'"}, {0x1e56,"P."}, {0x1e57,"p."}, {0x1e58,"R."}, {0x1e59,"r."}, {0x1e5a,"R-."}, {0x1e5b,"r-."}, {0x1e5c,"R--."}, {0x1e5d,"r--."}, {0x1e5e,"R_"}, {0x1e5f,"r_"}, {0x1e60,"S."}, {0x1e61,"s."}, {0x1e62,"S-."}, {0x1e63,"s-."}, {0x1e64,"S'."}, {0x1e65,"s'."}, {0x1e66,"S<."}, {0x1e67,"s<."}, {0x1e68,"S.-."}, {0x1e69,"s.-."}, {0x1e6a,"T."}, {0x1e6b,"t."}, {0x1e6c,"T-."}, {0x1e6d,"t-."}, {0x1e6e,"T_"}, {0x1e6f,"t_"}, {0x1e70,"T->"}, {0x1e71,"t->"}, {0x1e72,"U--:"}, {0x1e73,"u--:"}, {0x1e74,"U-?"}, {0x1e75,"u-?"}, {0x1e76,"U->"}, {0x1e77,"u->"}, {0x1e78,"U?'"}, {0x1e79,"u?'"}, {0x1e7a,"U-:"}, {0x1e7b,"u-:"}, {0x1e7c,"V?"}, {0x1e7d,"v?"}, {0x1e7e,"V-."}, {0x1e7f,"v-."}, {0x1e80,"W!"}, {0x1e81,"w!"}, {0x1e82,"W'"}, {0x1e83,"w'"}, {0x1e84,"W:"}, {0x1e85,"w:"}, {0x1e86,"W."}, {0x1e87,"w."}, {0x1e88,"W-."}, {0x1e89,"w-."}, {0x1e8a,"X."}, {0x1e8b,"x."}, {0x1e8c,"X:"}, {0x1e8d,"x:"}, {0x1e8e,"Y."}, {0x1e8f,"y."}, {0x1e90,"Z>"}, {0x1e91,"z>"}, {0x1e92,"Z-."}, {0x1e93,"z-."}, {0x1e94,"Z_"}, {0x1e95,"z_"}, {0x1e96,"h_"}, {0x1e97,"t:"}, {0x1e98,"w0"}, {0x1e99,"y0"}, {0x1ea0,"A-."}, {0x1ea1,"a-."}, {0x1ea2,"A2"}, {0x1ea3,"a2"}, {0x1ea4,"A>'"}, {0x1ea5,"a>'"}, {0x1ea6,"A>!"}, {0x1ea7,"a>!"}, {0x1ea8,"A>2"}, {0x1ea9,"a>2"}, {0x1eaa,"A>?"}, {0x1eab,"a>?"}, {0x1eac,"A>-."}, {0x1ead,"a>-."}, {0x1eae,"A('"}, {0x1eaf,"a('"}, {0x1eb0,"A(!"}, {0x1eb1,"a(!"}, {0x1eb2,"A(2"}, {0x1eb3,"a(2"}, {0x1eb4,"A(?"}, {0x1eb5,"a(?"}, {0x1eb6,"A(-."}, {0x1eb7,"a(-."}, {0x1eb8,"E-."}, {0x1eb9,"e-."}, {0x1eba,"E2"}, {0x1ebb,"e2"}, {0x1ebc,"E?"}, {0x1ebd,"e?"}, {0x1ebe,"E>'"}, {0x1ebf,"e>'"}, {0x1ec0,"E>!"}, {0x1ec1,"e>!"}, {0x1ec2,"E>2"}, {0x1ec3,"e>2"}, {0x1ec4,"E>?"}, {0x1ec5,"e>?"}, {0x1ec6,"E>-."}, {0x1ec7,"e>-."}, {0x1ec8,"I2"}, {0x1ec9,"i2"}, {0x1eca,"I-."}, {0x1ecb,"i-."}, {0x1ecc,"O-."}, {0x1ecd,"o-."}, {0x1ece,"O2"}, {0x1ecf,"o2"}, {0x1ed0,"O>'"}, {0x1ed1,"o>'"}, {0x1ed2,"O>!"}, {0x1ed3,"o>!"}, {0x1ed4,"O>2"}, {0x1ed5,"o>2"}, {0x1ed6,"O>?"}, {0x1ed7,"o>?"}, {0x1ed8,"O>-."}, {0x1ed9,"o>-."}, {0x1eda,"O9'"}, {0x1edb,"o9'"}, {0x1edc,"O9!"}, {0x1edd,"o9!"}, {0x1ede,"O92"}, {0x1edf,"o92"}, {0x1ee0,"O9?"}, {0x1ee1,"o9?"}, {0x1ee2,"O9-."}, {0x1ee3,"o9-."}, {0x1ee4,"U-."}, {0x1ee5,"u-."}, {0x1ee6,"U2"}, {0x1ee7,"u2"}, {0x1ee8,"U9'"}, {0x1ee9,"u9'"}, {0x1eea,"U9!"}, {0x1eeb,"u9!"}, {0x1eec,"U92"}, {0x1eed,"u92"}, {0x1eee,"U9?"}, {0x1eef,"u9?"}, {0x1ef0,"U9-."}, {0x1ef1,"u9-."}, {0x1ef2,"Y!"}, {0x1ef3,"y!"}, {0x1ef4,"Y-."}, {0x1ef5,"y-."}, {0x1ef6,"Y2"}, {0x1ef7,"y2"}, {0x1ef8,"Y?"}, {0x1ef9,"y?"}, {0x1f00,";'"}, {0x1f01,",'"}, {0x1f02,";!"}, {0x1f03,",!"}, {0x1f04,"?;"}, {0x1f05,"?,"}, {0x1f06,"!:"}, {0x1f07,"?:"}, {0x1fbf,",,"}, {0x1fc0,"?*"}, {0x1fc1,"?:"}, {0x1fcd,",!"}, {0x1fce,",'"}, {0x1fcf,"?,"}, {0x1fdd,";!"}, {0x1fde,";'"}, {0x1fdf,"?;"}, {0x1fed,"!:"}, {0x1fef,"!*"}, {0x1ffe,";;"}, {0x2001," "}, {0x2003," "}, {0x200e,"(->)"}, {0x200f,"(<-)"}, {0x200a,""}, {0x2016,"||"}, {0x2017,"=2"}, {0x2020,"/-"}, {0x2021,"/="}, {0x2022," o "}, {0x2025,".."}, {0x2026,"..."}, {0x202c,""}, {0x202d,""}, {0x2030," 0/00"}, {0x2032,"'"}, {0x2033,"''"}, {0x2034,"'''"}, {0x2035,"`"}, {0x2036,"``"}, {0x2037,"```"}, {0x2038,"Ca"}, {0x2039,"<"}, {0x203a,">"}, {0x203b,":X"}, {0x203c,"!!"}, {0x203e,"'-"}, {0x2044,"/"}, {0x2070,"^0"}, {0x2074,"^4"}, {0x2075,"^5"}, {0x2076,"^6"}, {0x2077,"^7"}, {0x2078,"^8"}, {0x2079,"^9"}, {0x207a,"^+"}, {0x207b,"^-"}, {0x207c,"^="}, {0x207d,"^("}, {0x207e,"^)"}, {0x207f,"^n"}, {0x2080,"_0"}, {0x2081,"_1"}, {0x2082,"_2"}, {0x2083,"_3"}, {0x2084,"_4"}, {0x2085,"_5"}, {0x2086,"_6"}, {0x2087,"_7"}, {0x2088,"_8"}, {0x2089,"_9"}, {0x208a,"_+"}, {0x208b,"_-"}, {0x208c,"_="}, {0x208d,"("}, {0x208e,")"}, {0x20a3,"Ff"}, {0x20a4,"Li"}, {0x20a7,"Pt"}, {0x20a9,"W="}, {0x20ac,"EUR"}, {0x2103,"oC"}, {0x2105,"c/o"}, {0x2109,"oF"}, {0x2111,"Im"}, {0x2116,"No."}, {0x2117,"PO"}, {0x2118,"P"}, {0x211c,"Re"}, {0x211e,"Rx"}, {0x2120,"(SM)"}, {0x2122,"(TM)"}, {0x2126,"Ohm"}, {0x212b,"Ang."}, {0x212e,"est."}, {0x2135,"Aleph "}, {0x2136,"Bet "}, {0x2137,"Gimel "}, {0x2138,"Dalet "}, {0x2153," 1/3"}, {0x2154," 2/3"}, {0x2155," 1/5"}, {0x2156," 2/5"}, {0x2157," 3/5"}, {0x2158," 4/5"}, {0x2159," 1/6"}, {0x215a," 5/6"}, {0x215b," 1/8"}, {0x215c," 3/8"}, {0x215d," 5/8"}, {0x215e," 7/8"}, {0x2160,"I"}, {0x2161,"II"}, {0x2162,"III"}, {0x2163,"IV"}, {0x2164,"V"}, {0x2165,"VI"}, {0x2166,"VII"}, {0x2167,"VIII"}, {0x2168,"IX"}, {0x2169,"X"}, {0x216a,"XI"}, {0x216b,"XII"}, {0x216c,"L"}, {0x216d,"C"}, {0x216e,"D"}, {0x216f,"M"}, {0x2170,"i"}, {0x2171,"ii"}, {0x2172,"iii"}, {0x2173,"iv"}, {0x2174,"v"}, {0x2175,"vi"}, {0x2176,"vii"}, {0x2177,"viii"}, {0x2178,"ix"}, {0x2179,"x"}, {0x217a,"xi"}, {0x217b,"xii"}, {0x217c,"l"}, {0x217d,"c"}, {0x217e,"d"}, {0x217f,"m"}, {0x2180,"1000RCD"}, {0x2181,"5000R"}, {0x2182,"10000R"}, {0x2190,"<-"}, {0x2191,"-^"}, {0x2192,"->"}, {0x2193,"-v"}, {0x2194,"<->"}, {0x2195,"UD"}, {0x2196,"<!!"}, {0x2197,"//>"}, {0x2198,"!!>"}, {0x2199,"<//"}, {0x21a8,"UD-"}, {0x21b5,"RET"}, {0x21c0,">V"}, {0x21d0,"<="}, {0x21d1,"^^"}, {0x21d2,"=>"}, {0x21d3,"vv"}, {0x21d4,"<=>"}, {0x2200,"FA"}, {0x2202,"\134partial"}, {0x2203,"TE"}, {0x2205,"{}"}, {0x2206,"decr."}, {0x2207,"Nabla"}, {0x2208,"(-"}, {0x2209,"!(-"}, {0x220b,"-)"}, {0x220f,"\134prod"}, {0x2211,"\134sum"}, {0x2212," -"}, {0x2213,"-/+"}, {0x2214,".+"}, {0x2217,"*"}, {0x2218,"Ob"}, {0x2219,"sb"}, {0x221a," SQRT "}, {0x221d,"0("}, {0x221e,"infty"}, {0x221f,"-L"}, {0x2220,"-V"}, {0x2225,"PP"}, {0x2227,"AND"}, {0x2228,"OR"}, {0x2229,"(U"}, {0x222a,")U"}, {0x222b,"\134int "}, {0x222c,"DI"}, {0x222e,"Io"}, {0x2234,".:"}, {0x2235,":."}, {0x2236,":R"}, {0x2237,"::"}, {0x223c,"?1"}, {0x223e,"CG"}, {0x2243,"?-"}, {0x2245,"?="}, {0x2248,"~="}, {0x224c,"=?"}, {0x2253,"HI"}, {0x2260,"!="}, {0x2261,"=3"}, {0x2264,"=<"}, {0x2265,">="}, {0x226a,"<<"}, {0x226b,">>"}, {0x226e,"!<"}, {0x226f,"!>"}, {0x2282,"!(C"}, {0x2283,")C"}, {0x2286,"(_"}, {0x2287,")_"}, {0x2295,"(+)"}, {0x2297,"(x)"}, {0x2299,"0."}, {0x229a,"02"}, {0x22a5,"-T"}, {0x22c5,".P"}, {0x22ee,":3"}, {0x22ef,".3"}, {0x2302,"Eh"}, {0x2308,"<7"}, {0x2309,">7"}, {0x230a,"7<"}, {0x230b,"7>"}, {0x2310,"NI"}, {0x2312,"(A"}, {0x2315,"TR"}, {0x2318,"88"}, {0x2320,"Iu"}, {0x2321,"Il"}, {0x2323,":)"}, {0x2329,"</"}, {0x232a,"/>"}, {0x2423,"Vs"}, {0x2440,"1h"}, {0x2441,"3h"}, {0x2442,"2h"}, {0x2443,"4h"}, {0x2446,"1j"}, {0x2447,"2j"}, {0x2448,"3j"}, {0x2449,"4j"}, {0x2460,"1-o"}, {0x2461,"2-o"}, {0x2462,"3-o"}, {0x2463,"4-o"}, {0x2464,"5-o"}, {0x2465,"6-o"}, {0x2466,"7-o"}, {0x2467,"8-o"}, {0x2468,"9-o"}, {0x2469,"10-o"}, {0x246a,"11-o"}, {0x246b,"12-o"}, {0x246c,"13-o"}, {0x246d,"14-o"}, {0x246e,"15-o"}, {0x246f,"16-o"}, {0x2470,"17-o"}, {0x2471,"18-o"}, {0x2472,"19-o"}, {0x2473,"20-o"}, {0x2474,"(1)"}, {0x2475,"(2)"}, {0x2476,"(3)"}, {0x2477,"(4)"}, {0x2478,"(5)"}, {0x2479,"(6)"}, {0x247a,"(7)"}, {0x247b,"(8)"}, {0x247c,"(9)"}, {0x247d,"(10)"}, {0x247e,"(11)"}, {0x247f,"(12)"}, {0x2480,"(13)"}, {0x2481,"(14)"}, {0x2482,"(15)"}, {0x2483,"(16)"}, {0x2484,"(17)"}, {0x2485,"(18)"}, {0x2486,"(19)"}, {0x2487,"(20)"}, {0x2488,"1."}, {0x2489,"2."}, {0x248a,"3."}, {0x248b,"4."}, {0x248c,"5."}, {0x248d,"6."}, {0x248e,"7."}, {0x248f,"8."}, {0x2490,"9."}, {0x2491,"10."}, {0x2492,"11."}, {0x2493,"12."}, {0x2494,"13."}, {0x2495,"14."}, {0x2496,"15."}, {0x2497,"16."}, {0x2498,"17."}, {0x2499,"18."}, {0x249a,"19."}, {0x249b,"20."}, {0x249c,"(a)"}, {0x249d,"(b)"}, {0x249e,"(c)"}, {0x249f,"(d)"}, {0x24a0,"(e)"}, {0x24a1,"(f)"}, {0x24a2,"(g)"}, {0x24a3,"(h)"}, {0x24a4,"(i)"}, {0x24a5,"(j)"}, {0x24a6,"(k)"}, {0x24a7,"(l)"}, {0x24a8,"(m)"}, {0x24a9,"(n)"}, {0x24aa,"(o)"}, {0x24ab,"(p)"}, {0x24ac,"(q)"}, {0x24ad,"(r)"}, {0x24ae,"(s)"}, {0x24af,"(t)"}, {0x24b0,"(u)"}, {0x24b1,"(v)"}, {0x24b2,"(w)"}, {0x24b3,"(x)"}, {0x24b4,"(y)"}, {0x24b5,"(z)"}, {0x24b6,"A-o"}, {0x24b7,"B-o"}, {0x24b8,"C-o"}, {0x24b9,"D-o"}, {0x24ba,"E-o"}, {0x24bb,"F-o"}, {0x24bc,"G-o"}, {0x24bd,"H-o"}, {0x24be,"I-o"}, {0x24bf,"J-o"}, {0x24c0,"K-o"}, {0x24c1,"L-o"}, {0x24c2,"M-o"}, {0x24c3,"N-o"}, {0x24c4,"O-o"}, {0x24c5,"P-o"}, {0x24c6,"Q-o"}, {0x24c7,"R-o"}, {0x24c8,"S-o"}, {0x24c9,"T-o"}, {0x24ca,"U-o"}, {0x24cb,"V-o"}, {0x24cc,"W-o"}, {0x24cd,"X-o"}, {0x24ce,"Y-o"}, {0x24cf,"Z-o"}, {0x24d0,"a-o"}, {0x24d1,"b-o"}, {0x24d2,"c-o"}, {0x24d3,"d-o"}, {0x24d4,"e-o"}, {0x24d5,"f-o"}, {0x24d6,"g-o"}, {0x24d7,"h-o"}, {0x24d8,"i-o"}, {0x24d9,"j-o"}, {0x24da,"k-o"}, {0x24db,"l-o"}, {0x24dc,"m-o"}, {0x24dd,"n-o"}, {0x24de,"o-o"}, {0x24df,"p-o"}, {0x24e0,"q-o"}, {0x24e1,"r-o"}, {0x24e2,"s-o"}, {0x24e3,"t-o"}, {0x24e4,"u-o"}, {0x24e5,"v-o"}, {0x24e6,"w-o"}, {0x24e7,"x-o"}, {0x24e8,"y-o"}, {0x24e9,"z-o"}, {0x24ea,"0-o"}, {0x2500,"-"}, {0x2501,"="}, {0x2502,"|"}, {0x2503,"|"}, {0x2504,"-"}, {0x2505,"="}, {0x2506,"|"}, {0x2507,"|"}, {0x2508,"-"}, {0x2509,"="}, {0x250a,"|"}, {0x250b,"|"}, {0x2571,"/"}, {0x2572,"\134"}, {0x2580,"TB"}, {0x2584,"LB"}, {0x2588,"FB"}, {0x258c,"lB"}, {0x2590,"RB"}, {0x2591,".S"}, {0x2592,":S"}, {0x2593,"?S"}, {0x25a0,"fS"}, {0x25a1,"OS"}, {0x25a2,"RO"}, {0x25a3,"Rr"}, {0x25a4,"RF"}, {0x25a5,"RY"}, {0x25a6,"RH"}, {0x25a7,"RZ"}, {0x25a8,"RK"}, {0x25a9,"RX"}, {0x25aa,"sB"}, {0x25ac,"SR"}, {0x25ad,"Or"}, {0x25b2,"UT"}, {0x25b3,"uT"}, {0x25b6,"PR"}, {0x25b7,"Tr"}, {0x25ba,"PR"}, {0x25bc,"Dt"}, {0x25bd,"dT"}, {0x25c0,"PL"}, {0x25c1,"Tl"}, {0x25c4,"PL"}, {0x25c6,"Db"}, {0x25c7,"Dw"}, {0x25ca,"LZ"}, {0x25cb,"0m"}, {0x25ce,"0o"}, {0x25cf,"0M"}, {0x25d0,"0L"}, {0x25d1,"0R"}, {0x25d8,"Sn"}, {0x25d9,"Ic"}, {0x25e2,"Fd"}, {0x25e3,"Bd"}, {0x25ef,"Ci"}, {0x2605,"*2"}, {0x2606,"*1"}, {0x260e,"TEL"}, {0x260f,"tel"}, {0x261c,"<--"}, {0x261e,"-->"}, {0x263a,":-)"}, {0x263b,"(-:"}, {0x263c,"SU"}, {0x2640,"f."}, {0x2642,"m."}, {0x2660,"cS"}, {0x2661,"cH"}, {0x2662,"cD"}, {0x2663,"cC"}, {0x2664,"cS-"}, {0x2665,"cH-"}, {0x2666,"cD-"}, {0x2667,"cC-"}, {0x2669,"Md"}, {0x266a,"M8"}, {0x266b,"M2"}, {0x266c,"M16"}, {0x266d,"b"}, {0x266e,"Mx"}, {0x266f,"#"}, {0x2720,"-X"}, {0x3001,",_"}, {0x3002,"._"}, {0x3003,"+\042"}, {0x3004,"JIS"}, {0x3005,"*_"}, {0x3006,";_"}, {0x3007,"0_"}, {0x300a,"<+"}, {0x300b,">+"}, {0x300c,"<'"}, {0x300d,">'"}, {0x300e,"<\042"}, {0x300f,">\042"}, {0x3010,"(\042"}, {0x3011,")\042"}, {0x3012,"=T"}, {0x3013,"=_"}, {0x3014,"('"}, {0x3015,")'"}, {0x3016,"(I"}, {0x3017,")I"}, {0x301c,"-?"}, {0x3020,"=T:)"}, {0x3041,"A5"}, {0x3042,"a5"}, {0x3043,"I5"}, {0x3044,"i5"}, {0x3045,"U5"}, {0x3046,"u5"}, {0x3047,"E5"}, {0x3048,"e5"}, {0x3049,"O5"}, {0x304a,"o5"}, {0x304b,"ka"}, {0x304c,"ga"}, {0x304d,"ki"}, {0x304e,"gi"}, {0x304f,"ku"}, {0x3050,"gu"}, {0x3051,"ke"}, {0x3052,"ge"}, {0x3053,"ko"}, {0x3054,"go"}, {0x3055,"sa"}, {0x3056,"za"}, {0x3057,"si"}, {0x3058,"zi"}, {0x3059,"su"}, {0x305a,"zu"}, {0x305b,"se"}, {0x305c,"ze"}, {0x305d,"so"}, {0x305e,"zo"}, {0x305f,"ta"}, {0x3060,"da"}, {0x3061,"ti"}, {0x3062,"di"}, {0x3063,"tU"}, {0x3064,"tu"}, {0x3065,"du"}, {0x3066,"te"}, {0x3067,"de"}, {0x3068,"to"}, {0x3069,"do"}, {0x306a,"na"}, {0x306b,"ni"}, {0x306c,"nu"}, {0x306d,"ne"}, {0x306e,"no"}, {0x306f,"ha"}, {0x3070,"ba"}, {0x3071,"pa"}, {0x3072,"hi"}, {0x3073,"bi"}, {0x3074,"pi"}, {0x3075,"hu"}, {0x3076,"bu"}, {0x3077,"pu"}, {0x3078,"he"}, {0x3079,"be"}, {0x307a,"pe"}, {0x307b,"ho"}, {0x307c,"bo"}, {0x307d,"po"}, {0x307e,"ma"}, {0x307f,"mi"}, {0x3080,"mu"}, {0x3081,"me"}, {0x3082,"mo"}, {0x3083,"yA"}, {0x3084,"ya"}, {0x3085,"yU"}, {0x3086,"yu"}, {0x3087,"yO"}, {0x3088,"yo"}, {0x3089,"ra"}, {0x308a,"ri"}, {0x308b,"ru"}, {0x308c,"re"}, {0x308d,"ro"}, {0x308e,"wA"}, {0x308f,"wa"}, {0x3090,"wi"}, {0x3091,"we"}, {0x3092,"wo"}, {0x3093,"n5"}, {0x3094,"vu"}, {0x309b,"\0425"}, {0x309c,"05"}, {0x309d,"*5"}, {0x309e,"+5"}, {0x30a1,"a6"}, {0x30a2,"A6"}, {0x30a3,"i6"}, {0x30a4,"I6"}, {0x30a5,"u6"}, {0x30a6,"U6"}, {0x30a7,"e6"}, {0x30a8,"E6"}, {0x30a9,"o6"}, {0x30aa,"O6"}, {0x30ab,"Ka"}, {0x30ac,"Ga"}, {0x30ad,"Ki"}, {0x30ae,"Gi"}, {0x30af,"Ku"}, {0x30b0,"Gu"}, {0x30b1,"Ke"}, {0x30b2,"Ge"}, {0x30b3,"Ko"}, {0x30b4,"Go"}, {0x30b5,"Sa"}, {0x30b6,"Za"}, {0x30b7,"Si"}, {0x30b8,"Zi"}, {0x30b9,"Su"}, {0x30ba,"Zu"}, {0x30bb,"Se"}, {0x30bc,"Ze"}, {0x30bd,"So"}, {0x30be,"Zo"}, {0x30bf,"Ta"}, {0x30c0,"Da"}, {0x30c1,"Ti"}, {0x30c2,"Di"}, {0x30c3,"TU"}, {0x30c4,"Tu"}, {0x30c5,"Du"}, {0x30c6,"Te"}, {0x30c7,"De"}, {0x30c8,"To"}, {0x30c9,"Do"}, {0x30ca,"Na"}, {0x30cb,"Ni"}, {0x30cc,"Nu"}, {0x30cd,"Ne"}, {0x30ce,"No"}, {0x30cf,"Ha"}, {0x30d0,"Ba"}, {0x30d1,"Pa"}, {0x30d2,"Hi"}, {0x30d3,"Bi"}, {0x30d4,"Pi"}, {0x30d5,"Hu"}, {0x30d6,"Bu"}, {0x30d7,"Pu"}, {0x30d8,"He"}, {0x30d9,"Be"}, {0x30da,"Pe"}, {0x30db,"Ho"}, {0x30dc,"Bo"}, {0x30dd,"Po"}, {0x30de,"Ma"}, {0x30df,"Mi"}, {0x30e0,"Mu"}, {0x30e1,"Me"}, {0x30e2,"Mo"}, {0x30e3,"YA"}, {0x30e4,"Ya"}, {0x30e5,"YU"}, {0x30e6,"Yu"}, {0x30e7,"YO"}, {0x30e8,"Yo"}, {0x30e9,"Ra"}, {0x30ea,"Ri"}, {0x30eb,"Ru"}, {0x30ec,"Re"}, {0x30ed,"Ro"}, {0x30ee,"WA"}, {0x30ef,"Wa"}, {0x30f0,"Wi"}, {0x30f1,"We"}, {0x30f2,"Wo"}, {0x30f3,"N6"}, {0x30f4,"Vu"}, {0x30f5,"KA"}, {0x30f6,"KE"}, {0x30f7,"Va"}, {0x30f8,"Vi"}, {0x30f9,"Ve"}, {0x30fa,"Vo"}, {0x30fb,".6"}, {0x30fc,"-6"}, {0x30fd,"*6"}, {0x30fe,"+6"}, {0x3105,"b4"}, {0x3106,"p4"}, {0x3107,"m4"}, {0x3108,"f4"}, {0x3109,"d4"}, {0x310a,"t4"}, {0x310b,"n4"}, {0x310c,"l4"}, {0x310d,"g4"}, {0x310e,"k4"}, {0x310f,"h4"}, {0x3110,"j4"}, {0x3111,"q4"}, {0x3112,"x4"}, {0x3113,"zh"}, {0x3114,"ch"}, {0x3115,"sh"}, {0x3116,"r4"}, {0x3117,"z4"}, {0x3118,"c4"}, {0x3119,"s4"}, {0x311a,"a4"}, {0x311b,"o4"}, {0x311c,"e4"}, {0x311d,"eh4"}, {0x311e,"ai"}, {0x311f,"ei"}, {0x3120,"au"}, {0x3121,"ou"}, {0x3122,"an"}, {0x3123,"en"}, {0x3124,"aN"}, {0x3125,"eN"}, {0x3126,"er"}, {0x3127,"i4"}, {0x3128,"u4"}, {0x3129,"iu"}, {0x312a,"v4"}, {0x312b,"nG"}, {0x312c,"gn"}, {0x321c,"(JU)"}, {0x3220,"1c"}, {0x3221,"2c"}, {0x3222,"3c"}, {0x3223,"4c"}, {0x3224,"5c"}, {0x3225,"6c"}, {0x3226,"7c"}, {0x3227,"8c"}, {0x3228,"9c"}, {0x3229,"10c"}, {0x327f,"KSC"}, {0x33c2,"am"}, {0x33d8,"pm"}, {0xfb00,"ff"}, {0xfb01,"fi"}, {0xfb02,"fl"}, {0xfb03,"ffi"}, {0xfb04,"ffl"}, {0xfb05,"St"}, {0xfb06,"st"}, {0xfe7d,"3+;"}, {0xfe82,"aM."}, {0xfe84,"aH."}, {0xfe88,"ah."}, {0xfe8d,"a+-"}, {0xfe8e,"a+."}, {0xfe8f,"b+-"}, {0xfe90,"b+."}, {0xfe91,"b+,"}, {0xfe92,"b+;"}, {0xfe93,"tm-"}, {0xfe94,"tm."}, {0xfe95,"t+-"}, {0xfe96,"t+."}, {0xfe97,"t+,"}, {0xfe98,"t+;"}, {0xfe99,"tk-"}, {0xfe9a,"tk."}, {0xfe9b,"tk,"}, {0xfe9c,"tk;"}, {0xfe9d,"g+-"}, {0xfe9e,"g+."}, {0xfe9f,"g+,"}, {0xfea0,"g+;"}, {0xfea1,"hk-"}, {0xfea2,"hk."}, {0xfea3,"hk,"}, {0xfea4,"hk;"}, {0xfea5,"x+-"}, {0xfea6,"x+."}, {0xfea7,"x+,"}, {0xfea8,"x+;"}, {0xfea9,"d+-"}, {0xfeaa,"d+."}, {0xfeab,"dk-"}, {0xfeac,"dk."}, {0xfead,"r+-"}, {0xfeae,"r+."}, {0xfeaf,"z+-"}, {0xfeb0,"z+."}, {0xfeb1,"s+-"}, {0xfeb2,"s+."}, {0xfeb3,"s+,"}, {0xfeb4,"s+;"}, {0xfeb5,"sn-"}, {0xfeb6,"sn."}, {0xfeb7,"sn,"}, {0xfeb8,"sn;"}, {0xfeb9,"c+-"}, {0xfeba,"c+."}, {0xfebb,"c+,"}, {0xfebc,"c+;"}, {0xfebd,"dd-"}, {0xfebe,"dd."}, {0xfebf,"dd,"}, {0xfec0,"dd;"}, {0xfec1,"tj-"}, {0xfec2,"tj."}, {0xfec3,"tj,"}, {0xfec4,"tj;"}, {0xfec5,"zH-"}, {0xfec6,"zH."}, {0xfec7,"zH,"}, {0xfec8,"zH;"}, {0xfec9,"e+-"}, {0xfeca,"e+."}, {0xfecb,"e+,"}, {0xfecc,"e+;"}, {0xfecd,"i+-"}, {0xfece,"i+."}, {0xfecf,"i+,"}, {0xfed0,"i+;"}, {0xfed1,"f+-"}, {0xfed2,"f+."}, {0xfed3,"f+,"}, {0xfed4,"f+;"}, {0xfed5,"q+-"}, {0xfed6,"q+."}, {0xfed7,"q+,"}, {0xfed8,"q+;"}, {0xfed9,"k+-"}, {0xfeda,"k+."}, {0xfedb,"k+,"}, {0xfedc,"k+;"}, {0xfedd,"l+-"}, {0xfede,"l+."}, {0xfedf,"l+,"}, {0xfee0,"l+;"}, {0xfee1,"m+-"}, {0xfee2,"m+."}, {0xfee3,"m+,"}, {0xfee4,"m+;"}, {0xfee5,"n+-"}, {0xfee6,"n+."}, {0xfee7,"n+,"}, {0xfee8,"n+;"}, {0xfee9,"h+-"}, {0xfeea,"h+."}, {0xfeeb,"h+,"}, {0xfeec,"h+;"}, {0xfeed,"w+-"}, {0xfeee,"w+."}, {0xfeef,"j+-"}, {0xfef0,"j+."}, {0xfef1,"y+-"}, {0xfef2,"y+."}, {0xfef3,"y+,"}, {0xfef4,"y+;"}, {0xfef5,"lM-"}, {0xfef6,"lM."}, {0xfef7,"lH-"}, {0xfef8,"lH."}, {0xfef9,"lh-"}, {0xfefa,"lh."}, {0xfefb,"la-"}, {0xfefc,"la."}, {0x0,"NUL"}, {0x1,"SH"}, {0x2,"SX"}, {0x3,"EX"}, {0x4,"ET"}, {0x5,"ENQ"}, {0x6,"AK"}, {0x7,"BL"}, {0x8,"BS"}, {0x9,"HT"}, {0xa,"LF"}, {0xb,"VT"}, {0xc,"FF"}, {0xd,"CR"}, {0xe,"SO"}, {0xf,"SI"}, {0x10,"DL"}, {0x11,"DC1"}, {0x12,"DC2"}, {0x13,"DC3"}, {0x14,"DC4"}, {0x15,"NAK"}, {0x16,"SYN"}, {0x17,"EB"}, {0x18,"CN"}, {0x19,"EM"}, {0x1a,"SB"}, {0x1b,"ESC"}, {0x1c,"FS"}, {0x1d,"GS"}, {0x1e,"RS"}, {0x1f,"US"}, {0x7f,"DT"} }; static struct unimapdesc_str dfont_replacedesc = {1943,repl_map,1,0}; #define UC_CHARSET_SETUP UC_Charset_Setup("us-ascii",\ "us-ascii",\ dfont_unicount,dfont_unitable,464,\ dfont_replacedesc,999,0)
58.456053
72
0.49695
d93a4569d6adbad2f034cb744fee748423128010
3,104
h
C
Qtc/include/core/qtc_hs_QCoreApplication.h
keera-studios/hsQt
8aa71a585cbec40005354d0ee43bce9794a55a9a
[ "BSD-2-Clause" ]
42
2015-02-16T19:29:16.000Z
2021-07-25T11:09:03.000Z
Qtc/include/core/qtc_hs_QCoreApplication.h
keera-studios/hsQt
8aa71a585cbec40005354d0ee43bce9794a55a9a
[ "BSD-2-Clause" ]
1
2017-11-23T12:49:25.000Z
2017-11-23T12:49:25.000Z
Qtc/include/core/qtc_hs_QCoreApplication.h
keera-studios/hsQt
8aa71a585cbec40005354d0ee43bce9794a55a9a
[ "BSD-2-Clause" ]
5
2015-10-15T21:25:30.000Z
2017-11-22T13:18:24.000Z
///////////////////////////////////////////////////////////////////////////// // // File : qtc_hs_QCoreApplication.h // Copyright : (c) David Harley 2010 // Project : qtHaskell // Version : 1.1.4 // Modified : 2010-09-02 17:02:37 // // Warning : this file is machine generated - do not modify. // ///////////////////////////////////////////////////////////////////////////// void qtc_QCoreApplication_addLibraryPath(void*); void* qtc_QCoreApplication_applicationDirPath(); void* qtc_QCoreApplication_applicationFilePath(); void* qtc_QCoreApplication_applicationName(); void* qtc_QCoreApplication_argc(); int qtc_QCoreApplication_arguments(void*); int qtc_QCoreApplication_closingDown(); int qtc_QCoreApplication_event(void*,void*); int qtc_QCoreApplication_exec(); void qtc_QCoreApplication_exit(); void qtc_QCoreApplication_exit1(int); void qtc_QCoreApplication_flush(); int qtc_QCoreApplication_hasPendingEvents(); void qtc_QCoreApplication_installTranslator(void*); void* qtc_QCoreApplication_instance(); int qtc_QCoreApplication_libraryPaths(void*); int qtc_QCoreApplication_notify(void*,void*,void*); void* qtc_QCoreApplication_organizationDomain(); void* qtc_QCoreApplication_organizationName(); void qtc_QCoreApplication_postEvent(void*,void*); void qtc_QCoreApplication_postEvent1(void*,void*,int); void qtc_QCoreApplication_processEvents(); void qtc_QCoreApplication_processEvents1(long); void qtc_QCoreApplication_processEvents2(long,int); void qtc_QCoreApplication_quit(); void qtc_QCoreApplication_removeLibraryPath(void*); void qtc_QCoreApplication_removePostedEvents(void*); void qtc_QCoreApplication_removePostedEvents1(void*,int); void qtc_QCoreApplication_removeTranslator(void*); int qtc_QCoreApplication_sendEvent(void*,void*); void qtc_QCoreApplication_sendPostedEvents(); void qtc_QCoreApplication_sendPostedEvents1(void*,int); void qtc_QCoreApplication_setApplicationName(void*); void qtc_QCoreApplication_setAttribute(long); void qtc_QCoreApplication_setAttribute1(long,int); void* qtc_QCoreApplication_setEventFilter(void*,void*); void qtc_QCoreApplication_setLibraryPaths(int,void*); void qtc_QCoreApplication_setOrganizationDomain(void*); void qtc_QCoreApplication_setOrganizationName(void*); int qtc_QCoreApplication_startingUp(); int qtc_QCoreApplication_testAttribute(long); void* qtc_QCoreApplication_translate(void*,void*); void* qtc_QCoreApplication_translate1(void*,void*,void*); void* qtc_QCoreApplication_translate2(void*,void*,void*,long); void* qtc_QCoreApplication_translate3(void*,void*,void*,long,int); void qtc_QCoreApplication_finalizer(void*); void* qtc_QCoreApplication_getFinalizer(); void qtc_QCoreApplication_childEvent(void*,void*); void qtc_QCoreApplication_connectNotify(void*,void*); void qtc_QCoreApplication_customEvent(void*,void*); void qtc_QCoreApplication_disconnectNotify(void*,void*); int qtc_QCoreApplication_eventFilter(void*,void*,void*); int qtc_QCoreApplication_receivers(void*,void*); void* qtc_QCoreApplication_sender(void*); void qtc_QCoreApplication_timerEvent(void*,void*);
45.647059
77
0.78576
d93aee18100ffaeefc9da77c503c323064296f8b
3,287
c
C
binutils/libiberty/pexecute.c
Hwangwoosam/AFLplusplus
666ba142e90588dea5f620e4821e575922d7fdd0
[ "Apache-2.0" ]
null
null
null
binutils/libiberty/pexecute.c
Hwangwoosam/AFLplusplus
666ba142e90588dea5f620e4821e575922d7fdd0
[ "Apache-2.0" ]
null
null
null
binutils/libiberty/pexecute.c
Hwangwoosam/AFLplusplus
666ba142e90588dea5f620e4821e575922d7fdd0
[ "Apache-2.0" ]
null
null
null
/* Utilities to execute a program in a subprocess (possibly linked by pipes with other subprocesses), and wait for it. Copyright (C) 2004-2022 Free Software Foundation, Inc. This file is part of the libiberty library. Libiberty is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Libiberty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with libiberty; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /* pexecute is an old routine. This implementation uses the newer pex_init/pex_run/pex_get_status/pex_free routines. Don't use pexecute in new code. Use the newer routines instead. */ #include "config.h" #include "libiberty.h" #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif /* We only permit a single pexecute chain to execute at a time. This was always true anyhow, though it wasn't documented. */ static struct pex_obj *pex; static int idx; int pexecute (const char *program, char * const *argv, const char *pname, const char *temp_base, char **errmsg_fmt, char **errmsg_arg, int flags) { const char *errmsg; int err; if ((flags & PEXECUTE_FIRST) != 0) { if (pex != NULL) { *errmsg_fmt = (char *) "pexecute already in progress"; *errmsg_arg = NULL; return -1; } pex = pex_init (PEX_USE_PIPES, pname, temp_base); idx = 0; } else { if (pex == NULL) { *errmsg_fmt = (char *) "pexecute not in progress"; *errmsg_arg = NULL; return -1; } } errmsg = pex_run (pex, (((flags & PEXECUTE_LAST) != 0 ? PEX_LAST : 0) | ((flags & PEXECUTE_SEARCH) != 0 ? PEX_SEARCH : 0)), program, argv, NULL, NULL, &err); if (errmsg != NULL) { *errmsg_fmt = (char *) errmsg; *errmsg_arg = NULL; return -1; } /* Instead of a PID, we just return a one-based index into the status values. We avoid zero just because the old pexecute would never return it. */ return ++idx; } int pwait (int pid, int *status, int flags ATTRIBUTE_UNUSED) { /* The PID returned by pexecute is one-based. */ --pid; if (pex == NULL || pid < 0 || pid >= idx) return -1; if (pid == 0 && idx == 1) { if (!pex_get_status (pex, 1, status)) return -1; } else { int *vector; vector = XNEWVEC (int, idx); if (!pex_get_status (pex, idx, vector)) { free (vector); return -1; } *status = vector[pid]; free (vector); } /* Assume that we are done after the caller has retrieved the last exit status. The original implementation did not require that the exit statuses be retrieved in order, but this implementation does. */ if (pid + 1 == idx) { pex_free (pex); pex = NULL; idx = 0; } return pid + 1; }
26.296
78
0.655005
d93c508db37d9c73f28151a766440e3f2ea148f5
631
h
C
include/processor.h
gassysoil/System-Monitor-Project
2a150b947d113a0a270bc26cdf7528f879be9c96
[ "MIT" ]
null
null
null
include/processor.h
gassysoil/System-Monitor-Project
2a150b947d113a0a270bc26cdf7528f879be9c96
[ "MIT" ]
null
null
null
include/processor.h
gassysoil/System-Monitor-Project
2a150b947d113a0a270bc26cdf7528f879be9c96
[ "MIT" ]
null
null
null
#ifndef PROCESSOR_H #define PROCESSOR_H #include <array> #include <vector> using std::vector; using std::array; // this class has been updated class Processor { public: // done: See src/processor.cpp float Utilization(); long getTotalJiffies(); Processor(); // done: Declare any necessary private members private: void CalculateDeltaTime(array<long, 3>&, array<long, 3>&); virtual void GetLinuxParsesForJiffies(array<long, 3>&); float CalculateUtilization(); void UpdatePrevJiffies(); array<long, 3> current_cpu_jiffies_; array<long, 3> prev_cpu_jiffies_; array<float, 3> delta_jiffies_; }; #endif
21.033333
60
0.727417
d93e0bc3a3d3ec520180ebabba004624a7b33cc0
2,347
h
C
tests/smoke/CmdLineParser.gr/Snapshot/TermEnumClsStr.h
mike7ant/SGParser
b38a74565b6295bafd5b427833e264e2cc9a770c
[ "MIT" ]
null
null
null
tests/smoke/CmdLineParser.gr/Snapshot/TermEnumClsStr.h
mike7ant/SGParser
b38a74565b6295bafd5b427833e264e2cc9a770c
[ "MIT" ]
null
null
null
tests/smoke/CmdLineParser.gr/Snapshot/TermEnumClsStr.h
mike7ant/SGParser
b38a74565b6295bafd5b427833e264e2cc9a770c
[ "MIT" ]
null
null
null
//////////////////////////// TermEnum //////////////////////////// enum class TermEnum { /*0*/ TokenError, /*1*/ TokenEOF, /*2*/ option, /*3*/ parameter, /*4*/ integer, /*5*/ fileName, /*6*/ className, /*7*/ msgCode, /*8*/ colon, /*9*/ opConfigFile, /*10*/ opTableTypeLR, /*11*/ opTableTypeLALR, /*12*/ opTableTypeCLR, /*13*/ opParseData, /*14*/ opEnumFile, /*15*/ opEnumClasses, /*16*/ opEnumStrings, /*17*/ opTermEnum, /*18*/ opNonTermEnum, /*19*/ opProdEnum, /*20*/ opReduceFunc, /*21*/ opStaticDFA, /*22*/ opStaticParseTable, /*23*/ opCanonical, /*24*/ opConflictReport, /*25*/ opNoWarnings, /*26*/ opNotes, /*27*/ opStats, /*28*/ opHelp, /*29*/ opQuietMode, /*30*/ opVersion, /*31*/ opCLGrammar, /*32*/ fileNameParam, /*33*/ classNameParam, /*34*/ stackNameParam, /*35*/ prefixParam, /*36*/ stringParam, /*37*/ optionParam, /*38*/ messageParam, /*39*/ dfaParam, /*40*/ linesParam, /*41*/ labelsParam, /*42*/ pointsParam, /*43*/ displayParam, /*44*/ string }; constexpr char const* const StringifyEnumTermEnum[] = { /*0*/ "TokenError", /*1*/ "TokenEOF", /*2*/ "option", /*3*/ "parameter", /*4*/ "integer", /*5*/ "fileName", /*6*/ "className", /*7*/ "msgCode", /*8*/ "colon", /*9*/ "opConfigFile", /*10*/ "opTableTypeLR", /*11*/ "opTableTypeLALR", /*12*/ "opTableTypeCLR", /*13*/ "opParseData", /*14*/ "opEnumFile", /*15*/ "opEnumClasses", /*16*/ "opEnumStrings", /*17*/ "opTermEnum", /*18*/ "opNonTermEnum", /*19*/ "opProdEnum", /*20*/ "opReduceFunc", /*21*/ "opStaticDFA", /*22*/ "opStaticParseTable", /*23*/ "opCanonical", /*24*/ "opConflictReport", /*25*/ "opNoWarnings", /*26*/ "opNotes", /*27*/ "opStats", /*28*/ "opHelp", /*29*/ "opQuietMode", /*30*/ "opVersion", /*31*/ "opCLGrammar", /*32*/ "fileNameParam", /*33*/ "classNameParam", /*34*/ "stackNameParam", /*35*/ "prefixParam", /*36*/ "stringParam", /*37*/ "optionParam", /*38*/ "messageParam", /*39*/ "dfaParam", /*40*/ "linesParam", /*41*/ "labelsParam", /*42*/ "pointsParam", /*43*/ "displayParam", /*44*/ "string" };
23.47
66
0.5049
d94070ce30e1f121daed4a707a6386f55e63f0e2
1,368
h
C
Airship/AirshipMessageCenter/Source/Public/UAUser.h
andreinagy/ios-library
77770031f0a5d83539ea5468780126eda8d167a9
[ "Apache-2.0" ]
null
null
null
Airship/AirshipMessageCenter/Source/Public/UAUser.h
andreinagy/ios-library
77770031f0a5d83539ea5468780126eda8d167a9
[ "Apache-2.0" ]
null
null
null
Airship/AirshipMessageCenter/Source/Public/UAUser.h
andreinagy/ios-library
77770031f0a5d83539ea5468780126eda8d167a9
[ "Apache-2.0" ]
null
null
null
/* Copyright Airship and Contributors */ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "UAUserData.h" NS_ASSUME_NONNULL_BEGIN extern NSString * const UAUserCreatedNotification; /** * Primary interface for working with the application's associated Airship user. */ @interface UAUser : NSObject ///--------------------------------------------------------------------------------------- /// @name User Properties ///--------------------------------------------------------------------------------------- /** * Gets the data associated with the user. * * @param completionHandler A completion handler which will be called with the user data. * @param queue The queue on which to invoke the completion handler. */ - (void)getUserData:(void (^)(UAUserData *))completionHandler queue:(nullable dispatch_queue_t)queue; /** * Gets the data associated with the user. * * @param completionHandler A completion handler which will be called with the user data. */ - (void)getUserData:(void (^)(UAUserData *))completionHandler; /** * Gets the data associated with the user, synchronously. * * Note: This method may block the calling thread, and thus should be avoided while working on the main queue. * * @return The user data, or `nil` if no data is available. */ - (nullable UAUserData *)getUserDataSync; @end NS_ASSUME_NONNULL_END
28.5
110
0.644737
d940c35d80e3ca3b83209153f13619e76c725b08
2,388
h
C
tests/framework/layer/layer_util.h
rhabacker/Vulkan-Loader
371000152173a9ef199d50103ec35b9e8d160578
[ "Apache-2.0" ]
338
2018-05-11T19:14:27.000Z
2022-03-29T12:16:16.000Z
tests/framework/layer/layer_util.h
BtbN/Vulkan-Loader
73d8fb89c6897648ef9e0340793cb2487695488f
[ "Apache-2.0" ]
726
2018-05-14T01:18:26.000Z
2022-03-31T19:45:57.000Z
tests/framework/layer/layer_util.h
BtbN/Vulkan-Loader
73d8fb89c6897648ef9e0340793cb2487695488f
[ "Apache-2.0" ]
231
2018-05-13T18:27:38.000Z
2022-03-26T10:38:32.000Z
/* * Copyright (c) 2021 The Khronos Group Inc. * Copyright (c) 2021 Valve Corporation * Copyright (c) 2021 LunarG, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and/or associated documentation files (the "Materials"), to * deal in the Materials without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Materials, and to permit persons to whom the Materials are * furnished to do so, subject to the following conditions: * * The above copyright notice(s) and this permission notice shall be included in * all copies or substantial portions of the Materials. * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE * USE OR OTHER DEALINGS IN THE MATERIALS. * * Author: Charles Giessen <charles@lunarg.com> */ #pragma once #include "test_util.h" struct LayerDefinition { std::string layerName; uint32_t specVersion = VK_MAKE_VERSION(1, 0, 0); uint32_t implementationVersion = VK_MAKE_VERSION(1, 0, 0); std::string description; std::vector<Extension> extensions; LayerDefinition(std::string layerName, uint32_t specVersion = VK_MAKE_VERSION(1, 0, 0), uint32_t implementationVersion = VK_MAKE_VERSION(1, 0, 0), std::string description = "", std::vector<Extension> extensions = {}) : layerName(layerName), specVersion(specVersion), implementationVersion(implementationVersion), description(description), extensions(extensions) {} VkLayerProperties get() const noexcept { VkLayerProperties props{}; std::strncpy(props.layerName, layerName.data(), VK_MAX_EXTENSION_NAME_SIZE); props.specVersion = specVersion; props.implementationVersion = implementationVersion; std::strncpy(props.description, layerName.data(), VK_MAX_DESCRIPTION_SIZE); return props; } };
41.894737
108
0.716918
d942e05b0823ecdcac2321172b06b0624337fed7
1,564
h
C
usr/libexec/assistantd/ADSyncSnapshot.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
2
2021-11-02T09:23:27.000Z
2022-03-28T08:21:57.000Z
usr/libexec/assistantd/ADSyncSnapshot.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
null
null
null
usr/libexec/assistantd/ADSyncSnapshot.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
1
2022-03-28T08:21:59.000Z
2022-03-28T08:21:59.000Z
// // Generated by classdumpios 1.0.1 (64 bit) (iOS port by DreamDevLost)(Debug version compiled Sep 26 2020 13:48:20). // // Copyright (C) 1997-2019 Steve Nygard. // #import <objc/NSObject.h> @class NSMutableDictionary; @protocol OS_dispatch_queue, OS_dispatch_source; @interface ADSyncSnapshot : NSObject { NSMutableDictionary *_pluginCache; // 8 = 0x8 NSMutableDictionary *_appsCache; // 16 = 0x10 NSObject<OS_dispatch_queue> *_queue; // 24 = 0x18 NSObject<OS_dispatch_source> *_saveTimer; // 32 = 0x20 } + (id)sharedInstance; // IMP=0x00000001000c5138 - (void).cxx_destruct; // IMP=0x00000001000c7430 - (void)_save; // IMP=0x00000001000c6e20 - (void)pruneCacheWithCurrentSynapseInfo:(id)arg1; // IMP=0x00000001000c6d50 - (_Bool)_pruneAppsCacheWithTruth:(id)arg1; // IMP=0x00000001000c68e8 - (void)_readFromDisk; // IMP=0x00000001000c60a0 - (_Bool)shouldIgnoreSyncKey:(id)arg1; // IMP=0x00000001000c602c - (void)deleteSavedSnapshots; // IMP=0x00000001000c5f58 - (void)noteSendingChunk:(id)arg1; // IMP=0x00000001000c5cbc - (void)_noteSendingPostGen:(id)arg1 validity:(id)arg2 key:(id)arg3 appMetaData:(id)arg4; // IMP=0x00000001000c59a0 - (void)_scheduleSave; // IMP=0x00000001000c5838 - (void)_cancelSaveTimer; // IMP=0x00000001000c57fc - (void)fetchSentAnchorsOnQueue:(id)arg1 completion:(CDUnknownBlockType)arg2; // IMP=0x00000001000c56d0 - (void)_fetchSentAnchorsOnQueue:(id)arg1 completion:(CDUnknownBlockType)arg2; // IMP=0x00000001000c537c - (id)_storePath; // IMP=0x00000001000c5328 - (id)init; // IMP=0x00000001000c51d4 @end
40.102564
120
0.761509
d9431cf165e83a98a904f7e8ab198a1112a5360f
4,002
c
C
sched/sched/sched_reprioritize.c
liuweisword/Nuttx
63775322bf25adb406594f8e610122fe0cef2f7a
[ "Zlib" ]
15
2017-07-21T07:26:56.000Z
2022-01-11T17:51:02.000Z
sched/sched/sched_reprioritize.c
liuweisword/Nuttx
63775322bf25adb406594f8e610122fe0cef2f7a
[ "Zlib" ]
1
2019-12-07T22:04:13.000Z
2020-03-15T04:01:44.000Z
sched/sched/sched_reprioritize.c
liuweisword/Nuttx
63775322bf25adb406594f8e610122fe0cef2f7a
[ "Zlib" ]
14
2017-02-20T07:36:52.000Z
2021-12-28T03:07:04.000Z
/**************************************************************************** * sched/sched/sched_reprioritize.c * * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <stdint.h> #include <sched.h> #include <errno.h> #include "sched/sched.h" #ifdef CONFIG_PRIORITY_INHERITANCE /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: sched_reprioritize * * Description: * This function sets the priority of a specified task. * * NOTE: Setting a task's priority to the same value has a similar effect * to sched_yield() -- The task will be moved to after all other tasks * with the same priority. * * Inputs: * tcb - the TCB of task to reprioritize. * sched_priority - The new task priority * * Return Value: * On success, sched_setparam() returns 0 (OK). On error, -1 * (ERROR) is returned, and errno is set appropriately. * * EINVAL The parameter 'param' is invalid or does not make sense for the * current scheduling policy. * EPERM The calling task does not have appropriate privileges. * ESRCH The task whose ID is pid could not be found. * * Assumptions: * ****************************************************************************/ int sched_reprioritize(FAR struct tcb_s *tcb, int sched_priority) { /* This function is equivalent to sched_setpriority() BUT it also has the * side effect of discarding all priority inheritance history. This is * done only on explicit, user-initiated reprioritization. */ int ret = sched_setpriority(tcb, sched_priority); if (ret == 0) { /* Reset the base_priority -- the priority that the thread would return * to once it posts the semaphore. */ tcb->base_priority = (uint8_t)sched_priority; /* Discard any pending reprioritizations as well */ #if CONFIG_SEM_NNESTPRIO > 0 tcb->npend_reprio = 0; #endif } return ret; } #endif /* CONFIG_PRIORITY_INHERITANCE */
37.401869
78
0.610695
d94504e5eb9a6080927e3ff966a50747d2e0a00f
889
h
C
client/ProjectMonitor/DetailViewController.h
baophucct/iOS.ProjectMonitor
265a485dc2dfb3cb17ae54e05f54b3b32113ea5f
[ "MIT" ]
9
2015-03-17T19:53:58.000Z
2021-01-09T17:45:11.000Z
client/ProjectMonitor/DetailViewController.h
baophucct/iOS.ProjectMonitor
265a485dc2dfb3cb17ae54e05f54b3b32113ea5f
[ "MIT" ]
null
null
null
client/ProjectMonitor/DetailViewController.h
baophucct/iOS.ProjectMonitor
265a485dc2dfb3cb17ae54e05f54b3b32113ea5f
[ "MIT" ]
3
2015-02-25T18:24:16.000Z
2019-04-07T16:22:28.000Z
// // DetailViewController.h // ProjectMonitor // // Created by Dimitri Roche on 1/29/14. // Copyright (c) 2014 Dimitri Roche. All rights reserved. // #import <UIKit/UIKit.h> @interface DetailViewController : UITableViewController @property (strong, nonatomic) id build; @property (weak, nonatomic) IBOutlet UINavigationItem *nagivationItem; @property (weak, nonatomic) IBOutlet UILabel *branchLabel; @property (weak, nonatomic) IBOutlet UILabel *finishedAtLabel; @property (weak, nonatomic) IBOutlet UILabel *statusLabel; @property (weak, nonatomic) IBOutlet UILabel *typeLabel; @property (weak, nonatomic) IBOutlet UILabel *lastPollLabel; @property (weak, nonatomic) IBOutlet UILabel *authorLabel; @property (weak, nonatomic) IBOutlet UILabel *emailLabel; @property (weak, nonatomic) IBOutlet UILabel *shaLabel; @property (weak, nonatomic) IBOutlet UILabel *messageLabel; @end
31.75
70
0.775028
d945b89789078ff175d9fe42bb55bee16849acfb
31,069
c
C
FreeBSD/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
TigerBSD/FreeBSD-Custom-ThinkPad
3d092f261b362f73170871403397fc5d6b89d1dc
[ "0BSD" ]
4
2016-08-22T22:02:55.000Z
2017-03-04T22:56:44.000Z
FreeBSD/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
TigerBSD/FreeBSD-Custom-ThinkPad
3d092f261b362f73170871403397fc5d6b89d1dc
[ "0BSD" ]
21
2016-08-11T09:43:43.000Z
2017-01-29T12:52:56.000Z
FreeBSD/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
TigerBSD/TigerBSD
3d092f261b362f73170871403397fc5d6b89d1dc
[ "0BSD" ]
null
null
null
/*- * Copyright (c) 2006 The FreeBSD Project * All rights reserved. * * Author: Shteryana Shopova <syrinx@FreeBSD.org> * * Redistribution of this software and documentation and use in source and * binary forms, with or without modification, are permitted provided that * the following conditions are met: * * 1. Redistributions of source code or documentation must retain the above * copyright notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Textual conventions for OctetStrings * * $FreeBSD$ */ #include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/uio.h> #include <ctype.h> #include <err.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <syslog.h> #include <unistd.h> #include <arpa/inet.h> #include <netinet/in.h> #include <bsnmp/asn1.h> #include <bsnmp/snmp.h> #include "bsnmptc.h" #include "bsnmptools.h" /* OctetString, DisplayString */ static char *snmp_oct2str(uint32_t, char *, char *); static char *snmp_str2asn_oid(char *, struct asn_oid *); static int parse_octetstring(struct snmp_value *, char *); /* DateAndTime */ static char *snmp_octstr2date(uint32_t, char *, char *); static char *snmp_date2asn_oid(char * , struct asn_oid *); static int parse_dateandtime(struct snmp_value *, char *); /* PhysAddress */ static char *snmp_oct2physAddr(uint32_t, char *, char *); static char *snmp_addr2asn_oid(char *, struct asn_oid *); static int parse_physaddress(struct snmp_value *, char *); /* NTPTimeStamp */ static char *snmp_oct2ntp_ts(uint32_t, char *, char *); static char *snmp_ntp_ts2asn_oid(char *, struct asn_oid *); static int parse_ntp_ts(struct snmp_value *, char *); /* BridgeId */ static char *snmp_oct2bridgeid(uint32_t, char *, char *); static char *snmp_bridgeid2oct(char *, struct asn_oid *); static int parse_bridge_id(struct snmp_value *, char *); /* BridgePortId */ static char *snmp_oct2bport_id(uint32_t, char *, char *); static char *snmp_bport_id2oct(char *, struct asn_oid *); static int parse_bport_id(struct snmp_value *, char *); /* InetAddress */ static char *snmp_oct2inetaddr(uint32_t len, char *octets, char *buf); static char *snmp_inetaddr2oct(char *str, struct asn_oid *oid); static int32_t parse_inetaddr(struct snmp_value *value, char *string); static char *snmp_oct2bits(uint32_t len, char *octets, char *buf); static char *snmp_bits2oct(char *str, struct asn_oid *oid); static int32_t parse_bits(struct snmp_value *value, char *string); static struct snmp_text_conv { enum snmp_tc tc; const char *tc_str; int32_t len; snmp_oct2tc_f oct2tc; snmp_tc2oid_f tc2oid; snmp_tc2oct_f tc2oct; } text_convs[] = { { SNMP_STRING, "OctetString", SNMP_VAR_STRSZ, snmp_oct2str, snmp_str2asn_oid, parse_octetstring }, { SNMP_DISPLAYSTRING, "DisplayString" , SNMP_VAR_STRSZ, snmp_oct2str, snmp_str2asn_oid, parse_octetstring }, { SNMP_DATEANDTIME, "DateAndTime", SNMP_DATETIME_STRSZ, snmp_octstr2date, snmp_date2asn_oid, parse_dateandtime }, { SNMP_PHYSADDR, "PhysAddress", SNMP_PHYSADDR_STRSZ, snmp_oct2physAddr, snmp_addr2asn_oid, parse_physaddress }, { SNMP_ATMESI, "AtmESI", SNMP_PHYSADDR_STRSZ, snmp_oct2physAddr, snmp_addr2asn_oid, parse_physaddress }, { SNMP_NTP_TIMESTAMP, "NTPTimeStamp", SNMP_NTP_TS_STRSZ, snmp_oct2ntp_ts, snmp_ntp_ts2asn_oid, parse_ntp_ts }, { SNMP_MACADDRESS, "MacAddress", SNMP_PHYSADDR_STRSZ, snmp_oct2physAddr, snmp_addr2asn_oid, parse_physaddress }, { SNMP_BRIDGE_ID, "BridgeId", SNMP_BRIDGEID_STRSZ, snmp_oct2bridgeid, snmp_bridgeid2oct, parse_bridge_id }, { SNMP_BPORT_ID, "BridgePortId", SNMP_BPORT_STRSZ, snmp_oct2bport_id, snmp_bport_id2oct, parse_bport_id }, { SNMP_INETADDRESS, "InetAddress", SNMP_INADDRS_STRSZ, snmp_oct2inetaddr, snmp_inetaddr2oct, parse_inetaddr }, { SNMP_TC_OWN, "BITS", SNMP_VAR_STRSZ, snmp_oct2bits, snmp_bits2oct, parse_bits }, { SNMP_UNKNOWN, "Unknown", SNMP_VAR_STRSZ, snmp_oct2str, snmp_str2asn_oid, parse_octetstring } /* keep last */ }; /* Common API */ enum snmp_tc snmp_get_tc(char *str) { int i; for (i = 0; i < SNMP_UNKNOWN; i++) { if (!strncmp(text_convs[i].tc_str, str, strlen(text_convs[i].tc_str))) return (text_convs[i].tc); } return (SNMP_STRING); } char * snmp_oct2tc(enum snmp_tc tc, uint32_t len, char *octets) { uint32_t tc_len; char * buf; if (tc > SNMP_UNKNOWN) tc = SNMP_UNKNOWN; if (text_convs[tc].len > 0) tc_len = text_convs[tc].len; else tc_len = 2 * len + 3; if ((buf = malloc(tc_len)) == NULL ) { syslog(LOG_ERR, "malloc failed - %s", strerror(errno)); return (NULL); } memset(buf, 0, tc_len); if (text_convs[tc].oct2tc(len, octets, buf) == NULL) { free(buf); return (NULL); } return (buf); } char * snmp_tc2oid(enum snmp_tc tc, char *str, struct asn_oid *oid) { if (tc > SNMP_UNKNOWN) tc = SNMP_UNKNOWN; return (text_convs[tc].tc2oid(str, oid)); } int32_t snmp_tc2oct(enum snmp_tc tc, struct snmp_value *value, char *string) { if (tc > SNMP_UNKNOWN) tc = SNMP_UNKNOWN; return (text_convs[tc].tc2oct(value, string)); } /***************************************************** * Basic OctetString type. */ static char * snmp_oct2str(uint32_t len, char *octets, char *buf) { uint8_t binary = 0; uint32_t i; char *ptr; if (len > MAX_OCTSTRING_LEN || octets == NULL || buf == NULL) return (NULL); for (ptr = buf, i = 0; i < len; i++) if (!isprint(octets[i])) { binary = 1; buf += sprintf(buf, "0x"); break; } for (ptr = buf, i = 0; i < len; i++) if (!binary) ptr += sprintf(ptr, "%c", octets[i]); else ptr += sprintf(ptr, "%2.2x", (u_char)octets[i]); return (buf); } static char * snmp_str2asn_oid(char *str, struct asn_oid *oid) { uint32_t i, len = 0; /* * OctetStrings are allowed max length of ASN_MAXOCTETSTRING, * but trying to index an entry with such a long OctetString * will fail anyway. */ for (len = 0; len < ASN_MAXOIDLEN; len++) { if (strchr(",]", *(str + len)) != NULL) break; } if (len >= ASN_MAXOIDLEN) return (NULL); if (snmp_suboid_append(oid, (asn_subid_t) len) < 0) return (NULL); for (i = 0; i < len; i++) if (snmp_suboid_append(oid, (asn_subid_t) *(str + i)) < 0) return (NULL); return (str + len); } static int32_t parse_octetstring(struct snmp_value *value, char *val) { size_t len; if ((len = strlen(val)) >= MAX_OCTSTRING_LEN) { warnx("Octetstring too long - %d is max allowed", MAX_OCTSTRING_LEN - 1); return (-1); } value->v.octetstring.len = len; if((value->v.octetstring.octets = malloc(len)) == NULL) { syslog(LOG_ERR,"malloc failed: %s", strerror(errno)); return (-1); } memcpy(value->v.octetstring.octets, val, len); value->syntax = SNMP_SYNTAX_OCTETSTRING; return (0); } /************************************************************* * DateAndTime ************************************************************* * rfc 2579 specification: * DateAndTime ::= TEXTUAL-CONVENTION * DISPLAY-HINT "2d-1d-1d,1d:1d:1d.1d,1a1d:1d" * STATUS current * DESCRIPTION * "A date-time specification. * * field octets contents range * ----- ------ -------- ----- * 1 1-2 year* 0..65536 * 2 3 month 1..12 * 3 4 day 1..31 * 4 5 hour 0..23 * 5 6 minutes 0..59 * 6 7 seconds 0..60 * (use 60 for leap-second) * 7 8 deci-seconds 0..9 * 8 9 direction from UTC '+' / '-' * 9 10 hours from UTC* 0..13 * 10 11 minutes from UTC 0..59 * * * Notes: * - the value of year is in network-byte order * - daylight saving time in New Zealand is +13 * * For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be * displayed as: * * 1992-5-26,13:30:15.0,-4:0 */ static char * snmp_octstr2date(uint32_t len, char *octets, char *buf) { int year; char *ptr; if (len != SNMP_DATETIME_OCTETS || octets == NULL || buf == NULL) return (NULL); buf[0]= '\0'; year = (octets[0] << 8); year += (octets[1]); ptr = buf; ptr += sprintf(ptr, "%4.4d-%.2d-%.2d, ", year, octets[2],octets[3]); ptr += sprintf(ptr, "%2.2d:%2.2d:%2.2d.%.2d, ", octets[4],octets[5], octets[6],octets[7]); ptr += sprintf(ptr, "%c%.2d:%.2d", octets[8],octets[9],octets[10]); return (buf); } static char * snmp_date2asn_oid(char *str, struct asn_oid *oid) { char *endptr, *ptr; static const char UTC[3] = "UTC"; int32_t saved_errno; uint32_t v; if (snmp_suboid_append(oid, (asn_subid_t) SNMP_DATETIME_OCTETS) < 0) return (NULL); /* Read 'YYYY-' and write it in two subs. */ ptr = str; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (v > 0xffff) goto error; else errno = saved_errno; if (*endptr != '-') goto error1; if (snmp_suboid_append(oid, (asn_subid_t) ((v & 0xff00) >> 8)) < 0) return (NULL); if (snmp_suboid_append(oid, (asn_subid_t) (v & 0xff)) < 0) return (NULL); /* 'MM-' */ ptr = endptr + 1; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (errno != 0) goto error; else errno = saved_errno; if (*endptr != '-') goto error1; if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); /* 'DD,' */ ptr = endptr + 1; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (errno != 0) goto error; else errno = saved_errno; if (*endptr != '-') goto error1; if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); /* 'HH:' */ ptr = endptr + 1; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (errno != 0) goto error; else errno = saved_errno; if (*endptr != ':') goto error1; if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); /* 'MM:' */ ptr = endptr + 1; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (errno != 0) goto error; else errno = saved_errno; if (*endptr != ':') goto error1; if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); /* 'SS.' */ ptr = endptr + 1; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (errno != 0) goto error; else errno = saved_errno; if (*endptr != '.') goto error1; if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); /* 'M(mseconds),' */ ptr = endptr + 1; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (errno != 0) goto error; else errno = saved_errno; if (*endptr != ',') goto error1; if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); /* 'UTC' - optional */ ptr = endptr + 1; if (strncmp(ptr, UTC, sizeof(UTC)) == 0) ptr += sizeof(UTC); /* '+/-' */ if (*ptr == '-' || *ptr == '+') { if (snmp_suboid_append(oid, (asn_subid_t) (*ptr)) < 0) return (NULL); } else goto error1; /* 'HH:' */ ptr = endptr + 1; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (errno != 0) goto error; else errno = saved_errno; if (*endptr != ':') goto error1; if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); /* 'MM' - last one - ignore endptr here. */ ptr = endptr + 1; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (errno != 0) goto error; else errno = saved_errno; if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); return (endptr); error: errno = saved_errno; error1: warnx("Date value %s not supported", str); return (NULL); } /* Read a DateAndTime string eg. 1992-5-26,13:30:15.0,-4:0. */ static int32_t parse_dateandtime(struct snmp_value *sv, char *val) { char *endptr; uint32_t v; uint8_t date[SNMP_DATETIME_OCTETS]; /* 'YYYY-' */ v = strtoul(val, &endptr, 10); if (v > 0xffff || *endptr != '-') goto error; date[0] = ((v & 0xff00) >> 8); date[1] = (v & 0xff); val = endptr + 1; /* 'MM-' */ v = strtoul(val, &endptr, 10); if (v == 0 || v > 12 || *endptr != '-') goto error; date[2] = v; val = endptr + 1; /* 'DD,' */ v = strtoul(val, &endptr, 10); if (v == 0 || v > 31 || *endptr != ',') goto error; date[3] = v; val = endptr + 1; /* 'HH:' */ v = strtoul(val, &endptr, 10); if (v > 23 || *endptr != ':') goto error; date[4] = v; val = endptr + 1; /* 'MM:' */ v = strtoul(val, &endptr, 10); if (v > 59 || *endptr != ':') goto error; date[5] = v; val = endptr + 1; /* 'SS.' */ v = strtoul(val, &endptr, 10); if (v > 60 || *endptr != '.') goto error; date[6] = v; val = endptr + 1; /* '(deci-)s,' */ v = strtoul(val, &endptr, 10); if (v > 9 || *endptr != ',') goto error; date[7] = v; val = endptr + 1; /* offset - '+/-' */ if (*val != '-' && *val != '+') goto error; date[8] = (uint8_t) *val; val = endptr + 1; /* 'HH:' - offset from UTC */ v = strtoul(val, &endptr, 10); if (v > 13 || *endptr != ':') goto error; date[9] = v; val = endptr + 1; /* 'MM'\0'' offset from UTC */ v = strtoul(val, &endptr, 10); if (v > 59 || *endptr != '\0') goto error; date[10] = v; if ((sv->v.octetstring.octets = malloc(SNMP_DATETIME_OCTETS)) == NULL) { warnx("malloc() failed - %s", strerror(errno)); return (-1); } sv->v.octetstring.len = SNMP_DATETIME_OCTETS; memcpy(sv->v.octetstring.octets, date, SNMP_DATETIME_OCTETS); sv->syntax = SNMP_SYNTAX_OCTETSTRING; return (1); error: warnx("Date value %s not supported", val); return (-1); } /************************************************************** * PhysAddress */ static char * snmp_oct2physAddr(uint32_t len, char *octets, char *buf) { char *ptr; uint32_t i; if (len != SNMP_PHYSADDR_OCTETS || octets == NULL || buf == NULL) return (NULL); buf[0]= '\0'; ptr = buf; ptr += sprintf(ptr, "%2.2x", octets[0]); for (i = 1; i < 6; i++) ptr += sprintf(ptr, ":%2.2x", octets[i]); return (buf); } static char * snmp_addr2asn_oid(char *str, struct asn_oid *oid) { char *endptr, *ptr; uint32_t v, i; int saved_errno; if (snmp_suboid_append(oid, (asn_subid_t) SNMP_PHYSADDR_OCTETS) < 0) return (NULL); ptr = str; for (i = 0; i < 5; i++) { saved_errno = errno; v = strtoul(ptr, &endptr, 16); errno = saved_errno; if (v > 0xff) { warnx("Integer value %s not supported", str); return (NULL); } if (*endptr != ':') { warnx("Failed adding oid - %s",str); return (NULL); } if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); ptr = endptr + 1; } /* The last one - don't check the ending char here. */ saved_errno = errno; v = strtoul(ptr, &endptr, 16); errno = saved_errno; if (v > 0xff) { warnx("Integer value %s not supported", str); return (NULL); } if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); return (endptr); } static int32_t parse_physaddress(struct snmp_value *sv, char *val) { char *endptr; int32_t i; uint32_t v; uint8_t phys_addr[SNMP_PHYSADDR_OCTETS]; for (i = 0; i < 5; i++) { v = strtoul(val, &endptr, 16); if (v > 0xff) { warnx("Integer value %s not supported", val); return (-1); } if(*endptr != ':') { warnx("Failed reading octet - %s", val); return (-1); } phys_addr[i] = v; val = endptr + 1; } /* The last one - don't check the ending char here. */ v = strtoul(val, &endptr, 16); if (v > 0xff) { warnx("Integer value %s not supported", val); return (-1); } phys_addr[5] = v; if ((sv->v.octetstring.octets = malloc(SNMP_PHYSADDR_OCTETS)) == NULL) { syslog(LOG_ERR,"malloc failed: %s", strerror(errno)); return (-1); } sv->v.octetstring.len = SNMP_PHYSADDR_OCTETS; memcpy(sv->v.octetstring.octets, phys_addr, SNMP_PHYSADDR_OCTETS); sv->syntax = SNMP_SYNTAX_OCTETSTRING; return (1); } /************************************************************** * NTPTimeStamp ************************************************************** * NTP MIB, Revision 0.2, 7/25/97: * NTPTimeStamp ::= TEXTUAL-CONVENTION * DISPLAY-HINT "4x.4x" * STATUS current * DESCRIPTION * "" * SYNTAX OCTET STRING (SIZE(8)) */ static char * snmp_oct2ntp_ts(uint32_t len, char *octets, char *buf) { char *ptr; uint32_t i; if (len != SNMP_NTP_TS_OCTETS || octets == NULL || buf == NULL) return (NULL); buf[0]= '\0'; ptr = buf; i = octets[0] * 1000 + octets[1] * 100 + octets[2] * 10 + octets[3]; ptr += sprintf(ptr, "%4.4d", i); i = octets[4] * 1000 + octets[5] * 100 + octets[6] * 10 + octets[7]; ptr += sprintf(ptr, ".%4.4d", i); return (buf); } static char * snmp_ntp_ts2asn_oid(char *str, struct asn_oid *oid) { char *endptr, *ptr; uint32_t v, i, d; struct asn_oid suboid; int saved_errno; if (snmp_suboid_append(oid, (asn_subid_t) SNMP_NTP_TS_OCTETS) < 0) return (NULL); ptr = str; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (errno != 0 || (v / 1000) > 9) { warnx("Integer value %s not supported", str); errno = saved_errno; return (NULL); } else errno = saved_errno; if (*endptr != '.') { warnx("Failed adding oid - %s",str); return (NULL); } memset(&suboid, 0, sizeof(struct asn_oid)); suboid.len = SNMP_NTP_TS_OCTETS; for (i = 0, d = 1000; i < 4; i++) { suboid.subs[i] = v / d; v = v % d; d = d / 10; } ptr = endptr + 1; saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (errno != 0 || (v / 1000) > 9) { warnx("Integer value %s not supported", str); errno = saved_errno; return (NULL); } else errno = saved_errno; for (i = 0, d = 1000; i < 4; i++) { suboid.subs[i + 4] = v / d; v = v % d; d = d / 10; } asn_append_oid(oid, &suboid); return (endptr); } static int32_t parse_ntp_ts(struct snmp_value *sv, char *val) { char *endptr; int32_t i, d, saved_errno; uint32_t v; uint8_t ntp_ts[SNMP_NTP_TS_OCTETS]; saved_errno = errno; errno = 0; v = strtoul(val, &endptr, 10); if (errno != 0 || (v / 1000) > 9) { errno = saved_errno; warnx("Integer value %s not supported", val); return (-1); } else errno = saved_errno; if (*endptr != '.') { warnx("Failed reading octet - %s", val); return (-1); } for (i = 0, d = 1000; i < 4; i++) { ntp_ts[i] = v / d; v = v % d; d = d / 10; } val = endptr + 1; saved_errno = errno; errno = 0; v = strtoul(val, &endptr, 10); if (errno != 0 || (v / 1000) > 9) { errno = saved_errno; warnx("Integer value %s not supported", val); return (-1); } else errno = saved_errno; for (i = 0, d = 1000; i < 4; i++) { ntp_ts[i + 4] = v / d; v = v % d; d = d / 10; } if ((sv->v.octetstring.octets = malloc(SNMP_NTP_TS_OCTETS)) == NULL) { syslog(LOG_ERR,"malloc failed: %s", strerror(errno)); return (-1); } sv->v.octetstring.len = SNMP_NTP_TS_OCTETS; memcpy(sv->v.octetstring.octets, ntp_ts, SNMP_NTP_TS_OCTETS); sv->syntax = SNMP_SYNTAX_OCTETSTRING; return (1); } /************************************************************** * BridgeId ************************************************************** * BRIDGE-MIB, REVISION "200509190000Z" * BridgeId ::= TEXTUAL-CONVENTION * STATUS current * DESCRIPTION * "The Bridge-Identifier, as used in the Spanning Tree * Protocol, to uniquely identify a bridge. Its first two * octets (in network byte order) contain a priority value, * and its last 6 octets contain the MAC address used to * refer to a bridge in a unique fashion (typically, the * numerically smallest MAC address of all ports on the * bridge)." * SYNTAX OCTET STRING (SIZE (8)) */ static char * snmp_oct2bridgeid(uint32_t len, char *octets, char *buf) { char *ptr; uint32_t i, priority; if (len != SNMP_BRIDGEID_OCTETS || octets == NULL || buf == NULL) return (NULL); buf[0]= '\0'; ptr = buf; priority = octets[0] << 8; priority += octets[1]; if (priority > SNMP_MAX_BRIDGE_PRIORITY) { warnx("Invalid bridge priority %d", priority); return (NULL); } else ptr += sprintf(ptr, "%d.", octets[0]); ptr += sprintf(ptr, "%2.2x", octets[2]); for (i = 1; i < 6; i++) ptr += sprintf(ptr, ":%2.2x", octets[i + 2]); return (buf); } static char * snmp_bridgeid2oct(char *str, struct asn_oid *oid) { char *endptr, *ptr; uint32_t v, i; int32_t saved_errno; if (snmp_suboid_append(oid, (asn_subid_t) SNMP_BRIDGEID_OCTETS) < 0) return (NULL); ptr = str; /* Read the priority. */ saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (v > SNMP_MAX_BRIDGE_PRIORITY || errno != 0 || *endptr != '.') { errno = saved_errno; warnx("Bad bridge priority value %d", v); return (NULL); } if (snmp_suboid_append(oid, (asn_subid_t) (v & 0xff00)) < 0) return (NULL); if (snmp_suboid_append(oid, (asn_subid_t) (v & 0xff)) < 0) return (NULL); ptr = endptr + 1; for (i = 0; i < 5; i++) { saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 16); errno = saved_errno; if (v > 0xff) { warnx("Integer value %s not supported", str); return (NULL); } if (*endptr != ':') { warnx("Failed adding oid - %s",str); return (NULL); } if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); ptr = endptr + 1; } /* The last one - don't check the ending char here. */ saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 16); errno = saved_errno; if (v > 0xff) { warnx("Integer value %s not supported", str); return (NULL); } if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); return (endptr); } static int32_t parse_bridge_id(struct snmp_value *sv, char *string) { char *endptr; int32_t i, saved_errno; uint32_t v; uint8_t bridge_id[SNMP_BRIDGEID_OCTETS]; /* Read the priority. */ saved_errno = errno; errno = 0; v = strtoul(string, &endptr, 10); if (v > SNMP_MAX_BRIDGE_PRIORITY || errno != 0 || *endptr != '.') { errno = saved_errno; warnx("Bad bridge priority value %d", v); return (-1); } bridge_id[0] = (v & 0xff00); bridge_id[1] = (v & 0xff); string = endptr + 1; for (i = 0; i < 5; i++) { v = strtoul(string, &endptr, 16); if (v > 0xff) { warnx("Integer value %s not supported", string); return (-1); } if(*endptr != ':') { warnx("Failed reading octet - %s", string); return (-1); } bridge_id[i + 2] = v; string = endptr + 1; } /* The last one - don't check the ending char here. */ v = strtoul(string, &endptr, 16); if (v > 0xff) { warnx("Integer value %s not supported", string); return (-1); } bridge_id[7] = v; if ((sv->v.octetstring.octets = malloc(SNMP_BRIDGEID_OCTETS)) == NULL) { syslog(LOG_ERR,"malloc failed: %s", strerror(errno)); return (-1); } sv->v.octetstring.len = SNMP_BRIDGEID_OCTETS; memcpy(sv->v.octetstring.octets, bridge_id, SNMP_BRIDGEID_OCTETS); sv->syntax = SNMP_SYNTAX_OCTETSTRING; return (1); } /************************************************************** * BridgePortId ************************************************************** * BEGEMOT-BRIDGE-MIB, LAST-UPDATED "200608100000Z" * BridgePortId ::= TEXTUAL-CONVENTION * DISPLAY-HINT "1x.1x" * STATUS current * DESCRIPTION * "A port identifier that contains a bridge port's STP priority * in the first octet and the port number in the second octet." * SYNTAX OCTET STRING (SIZE(2)) */ static char * snmp_oct2bport_id(uint32_t len, char *octets, char *buf) { char *ptr; if (len != SNMP_BPORT_OCTETS || octets == NULL || buf == NULL) return (NULL); buf[0]= '\0'; ptr = buf; ptr += sprintf(ptr, "%d.", octets[0]); ptr += sprintf(ptr, "%d", octets[1]); return (buf); } static char * snmp_bport_id2oct(char *str, struct asn_oid *oid) { char *endptr, *ptr; uint32_t v; int saved_errno; if (snmp_suboid_append(oid, (asn_subid_t) SNMP_BPORT_OCTETS) < 0) return (NULL); ptr = str; /* Read the priority. */ saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 10); if (v > SNMP_MAX_BPORT_PRIORITY || errno != 0 || *endptr != '.') { errno = saved_errno; warnx("Bad bridge port priority value %d", v); return (NULL); } if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); saved_errno = errno; errno = 0; v = strtoul(ptr, &endptr, 16); errno = saved_errno; if (v > 0xff) { warnx("Bad port number - %d", v); return (NULL); } if (snmp_suboid_append(oid, (asn_subid_t) v) < 0) return (NULL); return (endptr); } static int32_t parse_bport_id(struct snmp_value *value, char *string) { char *endptr; int saved_errno; uint32_t v; uint8_t bport_id[SNMP_BPORT_OCTETS]; /* Read the priority. */ saved_errno = errno; errno = 0; v = strtoul(string, &endptr, 10); if (v > SNMP_MAX_BPORT_PRIORITY || errno != 0 || *endptr != '.') { errno = saved_errno; warnx("Bad bridge port priority value %d", v); return (-1); } bport_id[0] = v; string = endptr + 1; v = strtoul(string, &endptr, 16); if (v > 0xff) { warnx("Bad port number - %d", v); return (-1); } bport_id[1] = v; if ((value->v.octetstring.octets = malloc(SNMP_BPORT_OCTETS)) == NULL) { syslog(LOG_ERR,"malloc failed: %s", strerror(errno)); return (-1); } value->v.octetstring.len = SNMP_BPORT_OCTETS; memcpy(value->v.octetstring.octets, bport_id, SNMP_BPORT_OCTETS); value->syntax = SNMP_SYNTAX_OCTETSTRING; return (1); } /************************************************************** * InetAddress ************************************************************** * INET-ADDRESS-MIB, REVISION "200502040000Z" * InetAddress ::= TEXTUAL-CONVENTION * STATUS current * DESCRIPTION * "Denotes a generic Internet address. * * An InetAddress value is always interpreted within the context * of an InetAddressType value. Every usage of the InetAddress * textual convention is required to specify the InetAddressType * object that provides the context. It is suggested that the * InetAddressType object be logically registered before the * object(s) that use the InetAddress textual convention, if * they appear in the same logical row. * * The value of an InetAddress object must always be * consistent with the value of the associated InetAddressType * object. Attempts to set an InetAddress object to a value * inconsistent with the associated InetAddressType * must fail with an inconsistentValue error. * * When this textual convention is used as the syntax of an * index object, there may be issues with the limit of 128 * sub-identifiers specified in SMIv2, STD 58. In this case, * the object definition MUST include a 'SIZE' clause to * limit the number of potential instance sub-identifiers; * otherwise the applicable constraints MUST be stated in * the appropriate conceptual row DESCRIPTION clauses, or * in the surrounding documentation if there is no single * DESCRIPTION clause that is appropriate." * SYNTAX OCTET STRING (SIZE (0..255)) ************************************************************** * TODO: FIXME!!! syrinx: Since we do not support checking the * consistency of a varbinding based on the value of a previous * one, try to guess the type of address based on the * OctetString SIZE - 4 for IPv4, 16 for IPv6, others currently * not supported. */ static char * snmp_oct2inetaddr(uint32_t len, char *octets, char *buf) { int af; void *ip; struct in_addr ipv4; struct in6_addr ipv6; if (len > MAX_OCTSTRING_LEN || octets == NULL || buf == NULL) return (NULL); switch (len) { /* XXX: FIXME - IPv4*/ case 4: memcpy(&ipv4.s_addr, octets, sizeof(ipv4.s_addr)); af = AF_INET; ip = &ipv4; break; /* XXX: FIXME - IPv4*/ case 16: memcpy(ipv6.s6_addr, octets, sizeof(ipv6.s6_addr)); af = AF_INET6; ip = &ipv6; break; default: return (NULL); } if (inet_ntop(af, ip, buf, SNMP_INADDRS_STRSZ) == NULL) { warnx("inet_ntop failed - %s", strerror(errno)); return (NULL); } return (buf); } static char * snmp_inetaddr2oct(char *str __unused, struct asn_oid *oid __unused) { return (NULL); } static int32_t parse_inetaddr(struct snmp_value *value __unused, char *string __unused) { return (-1); } /************************************************************** * SNMP BITS type - XXX: FIXME **************************************************************/ static char * snmp_oct2bits(uint32_t len, char *octets, char *buf) { int i, bits; uint64_t value; if (len > sizeof(value) || octets == NULL || buf == NULL) return (NULL); for (i = len, value = 0, bits = 0; i > 0; i--, bits += 8) value += octets[i] << bits; buf[0]= '\0'; sprintf(buf, "0x%llx.",(long long unsigned) value); return (buf); } static char * snmp_bits2oct(char *str, struct asn_oid *oid) { char *endptr; int i, size, bits, saved_errno; uint64_t v, mask = 0xFF00000000000000; saved_errno = errno; errno = 0; v = strtoull(str, &endptr, 16); if (errno != 0) { warnx("Bad BITS value %s - %s", str, strerror(errno)); errno = saved_errno; return (NULL); } bits = 8; /* Determine length - up to 8 octets supported so far. */ for (size = sizeof(v); size > 0; size--) { if ((v & mask) != 0) break; mask = mask >> bits; } if (size == 0) size = 1; if (snmp_suboid_append(oid, (asn_subid_t) size) < 0) return (NULL); for (i = 0, bits = 0; i < size; i++, bits += 8) if (snmp_suboid_append(oid, (asn_subid_t)((v & mask) >> bits)) < 0) return (NULL); return (endptr); } static int32_t parse_bits(struct snmp_value *value, char *string) { char *endptr; int i, size, bits, saved_errno; uint64_t v, mask = 0xFF00000000000000; saved_errno = errno; errno = 0; v = strtoull(string, &endptr, 16); if (errno != 0) { warnx("Bad BITS value %s - %s", string, strerror(errno)); errno = saved_errno; return (-1); } bits = 8; /* Determine length - up to 8 octets supported so far. */ for (size = sizeof(v); size > 0; size--) { if ((v & mask) != 0) break; mask = mask >> bits; } if (size == 0) size = 1; if ((value->v.octetstring.octets = malloc(size)) == NULL) { syslog(LOG_ERR, "malloc failed: %s", strerror(errno)); return (-1); } value->v.octetstring.len = size; for (i = 0, bits = 0; i < size; i++, bits += 8) value->v.octetstring.octets[i] = (v & mask) >> bits; value->syntax = SNMP_SYNTAX_OCTETSTRING; return (1); }
23.899231
77
0.619299
d946660d47f8325e7fd76bf0a88b50eeebd8b95f
3,891
c
C
drivers/gpu/host1x/hw/syncpt_hw.c
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
null
null
null
drivers/gpu/host1x/hw/syncpt_hw.c
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
null
null
null
drivers/gpu/host1x/hw/syncpt_hw.c
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
null
null
null
/* * Tegra host1x Syncpoints * * Copyright (c) 2010-2013, NVIDIA Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <linux/io.h> #include "../dev.h" #include "../syncpt.h" /* * Write the current syncpoint value back to hw. */ static void syncpt_restore(struct host1x_syncpt *sp) { u32 min = host1x_syncpt_read_min(sp); struct host1x *host = sp->host; host1x_sync_writel(host, min, HOST1X_SYNC_SYNCPT(sp->id)); } /* * Write the current waitbase value back to hw. */ static void syncpt_restore_wait_base(struct host1x_syncpt *sp) { #if HOST1X_HW < 7 struct host1x *host = sp->host; host1x_sync_writel(host, sp->base_val, HOST1X_SYNC_SYNCPT_BASE(sp->id)); #endif } /* * Read waitbase value from hw. */ static void syncpt_read_wait_base(struct host1x_syncpt *sp) { #if HOST1X_HW < 7 struct host1x *host = sp->host; sp->base_val = host1x_sync_readl(host, HOST1X_SYNC_SYNCPT_BASE(sp->id)); #endif } /* * Updates the last value read from hardware. */ static u32 syncpt_load(struct host1x_syncpt *sp) { struct host1x *host = sp->host; u32 old, live; /* Loop in case there's a race writing to min_val */ do { old = host1x_syncpt_read_min(sp); live = host1x_sync_readl(host, HOST1X_SYNC_SYNCPT(sp->id)); } while ((u32)atomic_cmpxchg(&sp->min_val, old, live) != old); if (!host1x_syncpt_check_max(sp, live)) dev_err(host->dev, "%s failed: id=%u, min=%d, max=%d\n", __func__, sp->id, host1x_syncpt_read_min(sp), host1x_syncpt_read_max(sp)); return live; } /* * Write a cpu syncpoint increment to the hardware, without touching * the cache. */ static int syncpt_cpu_incr(struct host1x_syncpt *sp) { struct host1x *host = sp->host; u32 reg_offset = sp->id / 32; if (!host1x_syncpt_client_managed(sp) && host1x_syncpt_idle(sp)) return -EINVAL; host1x_sync_writel(host, BIT(sp->id % 32), HOST1X_SYNC_SYNCPT_CPU_INCR(reg_offset)); wmb(); return 0; } /** * syncpt_assign_to_channel() - Assign syncpoint to channel * @sp: syncpoint * @ch: channel * * On chips with the syncpoint protection feature (Tegra186+), assign @sp to * @ch, preventing other channels from incrementing the syncpoints. If @ch is * NULL, unassigns the syncpoint. * * On older chips, do nothing. */ static void syncpt_assign_to_channel(struct host1x_syncpt *sp, struct host1x_channel *ch) { #if HOST1X_HW >= 6 struct host1x *host = sp->host; if (!host->hv_regs) return; host1x_sync_writel(host, HOST1X_SYNC_SYNCPT_CH_APP_CH(ch ? ch->id : 0xff), HOST1X_SYNC_SYNCPT_CH_APP(sp->id)); #endif } /** * syncpt_enable_protection() - Enable syncpoint protection * @host: host1x instance * * On chips with the syncpoint protection feature (Tegra186+), enable this * feature. On older chips, do nothing. */ static void syncpt_enable_protection(struct host1x *host) { #if HOST1X_HW >= 6 if (!host->hv_regs) return; host1x_hypervisor_writel(host, HOST1X_HV_SYNCPT_PROT_EN_CH_EN, HOST1X_HV_SYNCPT_PROT_EN); #endif } static const struct host1x_syncpt_ops host1x_syncpt_ops = { .restore = syncpt_restore, .restore_wait_base = syncpt_restore_wait_base, .load_wait_base = syncpt_read_wait_base, .load = syncpt_load, .cpu_incr = syncpt_cpu_incr, .assign_to_channel = syncpt_assign_to_channel, .enable_protection = syncpt_enable_protection, };
24.942308
77
0.724235
d94848a3d2c3da3bd990b3b3cb55fa3791976c62
10,663
h
C
include/nmg/ray.h
dservin/brlcad
34b72d3efd24ac2c84abbccf9452323231751cd1
[ "BSD-4-Clause", "BSD-3-Clause" ]
null
null
null
include/nmg/ray.h
dservin/brlcad
34b72d3efd24ac2c84abbccf9452323231751cd1
[ "BSD-4-Clause", "BSD-3-Clause" ]
null
null
null
include/nmg/ray.h
dservin/brlcad
34b72d3efd24ac2c84abbccf9452323231751cd1
[ "BSD-4-Clause", "BSD-3-Clause" ]
null
null
null
/* R A Y . H * BRL-CAD * * Copyright (c) 2004-2022 United States Government as represented by * the U.S. Army Research Laboratory. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this file; see the file named COPYING for more * information. */ /*----------------------------------------------------------------------*/ /** @addtogroup nmg_ray * * TODO - these structs and ray_in_rpp are versions of librt functionality, * and we need to think about how/where to merge them into a common function * and struct that are available to both libraries without introducing a * coupling dependency. */ /** @{ */ /** @file nmg/ray.h */ #ifndef NMG_RAY_H #define NMG_RAY_H #include "common.h" #include "vmath.h" #include "bu/list.h" #include "nmg/defines.h" //#include "nmg/model.h" __BEGIN_DECLS struct model; NMG_EXPORT extern struct bu_list re_nmgfree; /**< @brief head of NMG hitmiss freelist */ #define NMG_HIT_LIST 0 #define NMG_MISS_LIST 1 /* These values are for the hitmiss "in_out" variable and indicate the * nature of the hit when known */ #define HMG_INBOUND_STATE(_hm) (((_hm)->in_out & 0x0f0) >> 4) #define HMG_OUTBOUND_STATE(_hm) ((_hm)->in_out & 0x0f) #define NMG_RAY_STATE_INSIDE 1 #define NMG_RAY_STATE_ON 2 #define NMG_RAY_STATE_OUTSIDE 4 #define NMG_RAY_STATE_ANY 8 #define HMG_HIT_IN_IN 0x11 /**< @brief hit internal structure */ #define HMG_HIT_IN_OUT 0x14 /**< @brief breaking out */ #define HMG_HIT_OUT_IN 0x41 /**< @brief breaking in */ #define HMG_HIT_OUT_OUT 0x44 /**< @brief edge/vertex graze */ #define HMG_HIT_IN_ON 0x12 #define HMG_HIT_ON_IN 0x21 #define HMG_HIT_ON_ON 0x22 #define HMG_HIT_OUT_ON 0x42 #define HMG_HIT_ON_OUT 0x24 #define HMG_HIT_ANY_ANY 0x88 /**< @brief hit on non-3-manifold */ #define NMG_VERT_ENTER 1 #define NMG_VERT_ENTER_LEAVE 0 #define NMG_VERT_LEAVE -1 #define NMG_VERT_UNKNOWN -2 #define NMG_HITMISS_SEG_IN 0x696e00 /**< @brief "in" */ #define NMG_HITMISS_SEG_OUT 0x6f757400 /**< @brief "out" */ #define NMG_CK_RD(_rd) NMG_CKMAG(_rd, NMG_RAY_DATA_MAGIC, "ray data"); #ifdef NO_BOMBING_MACROS # define NMG_CK_HITMISS(hm) (void)(hm) #else # define NMG_CK_HITMISS(hm) \ {\ switch (hm->l.magic) { \ case NMG_RT_HIT_MAGIC: \ case NMG_RT_HIT_SUB_MAGIC: \ case NMG_RT_MISS_MAGIC: \ break; \ case NMG_MISS_LIST: \ bu_log(CPP_FILELINE ": struct hitmiss has NMG_MISS_LIST magic #\n"); \ bu_bomb("NMG_CK_HITMISS: going down in flames\n"); \ break; \ case NMG_HIT_LIST: \ bu_log(CPP_FILELINE ": struct hitmiss has NMG_MISS_LIST magic #\n"); \ bu_bomb("NMG_CK_HITMISS: going down in flames\n"); \ break; \ default: \ bu_log(CPP_FILELINE ": bad struct hitmiss magic: %u:(0x%08x)\n", \ hm->l.magic, hm->l.magic); \ bu_bomb("NMG_CK_HITMISS: going down in flames\n"); \ }\ if (!hm->hit.hit_private) { \ bu_log(CPP_FILELINE ": NULL hit_private in hitmiss struct\n"); \ bu_bomb("NMG_CK_HITMISS: going down in flames\n"); \ } \ } #endif #ifdef NO_BOMBING_MACROS # define NMG_CK_HITMISS_LISTS(rd) (void)(rd) #else # define NMG_CK_HITMISS_LISTS(rd) \ { \ struct nmg_hitmiss *_a_hit; \ for (BU_LIST_FOR(_a_hit, nmg_hitmiss, &rd->rd_hit)) {NMG_CK_HITMISS(_a_hit);} \ for (BU_LIST_FOR(_a_hit, nmg_hitmiss, &rd->rd_miss)) {NMG_CK_HITMISS(_a_hit);} \ } #endif #define NMG_GET_HITMISS(_p) { \ (_p) = BU_LIST_FIRST(nmg_hitmiss, &(re_nmgfree)); \ if (BU_LIST_IS_HEAD((_p), &(re_nmgfree))) \ BU_ALLOC((_p), struct nmg_hitmiss); \ else \ BU_LIST_DEQUEUE(&((_p)->l)); \ } #define NMG_FREE_HITLIST(_p) { \ BU_CK_LIST_HEAD((_p)); \ BU_LIST_APPEND_LIST(&(re_nmgfree), (_p)); \ } #ifdef NO_BOMBING_MACROS # define nmg_bu_bomb(rd, vlfree, str) (void)(rd) #else # define nmg_bu_bomb(rd, vlfree, str) { \ bu_log("%s", str); \ if (nmg_debug & NMG_DEBUG_NMGRT) bu_bomb("End of diagnostics"); \ BU_LIST_INIT(&rd->rd_hit); \ BU_LIST_INIT(&rd->rd_miss); \ nmg_debug |= NMG_DEBUG_NMGRT; \ nmg_isect_ray_model(rd,vlfree); \ bu_bomb("Should have bombed before this\n"); \ } #endif #define HIT 1 /**< @brief a hit on a face */ #define MISS 0 /**< @brief a miss on the face */ struct nmg_ray { uint32_t magic; point_t r_pt; /**< @brief Point at which ray starts */ vect_t r_dir; /**< @brief Direction of ray (UNIT Length) */ fastf_t r_min; /**< @brief entry dist to bounding sphere */ fastf_t r_max; /**< @brief exit dist from bounding sphere */ }; struct nmg_hit { uint32_t hit_magic; fastf_t hit_dist; /**< @brief dist from r_pt to hit_point */ point_t hit_point; /**< @brief DEPRECATED: Intersection point, use VJOIN1 hit_dist */ vect_t hit_normal; /**< @brief DEPRECATED: Surface Normal at hit_point, use RT_HIT_NORMAL */ vect_t hit_vpriv; /**< @brief PRIVATE vector for xxx_*() */ void * hit_private; /**< @brief PRIVATE handle for xxx_shot() */ int hit_surfno; /**< @brief solid-specific surface indicator */ struct nmg_ray * hit_rayp; /**< @brief pointer to defining ray */ }; struct nmg_seg { struct bu_list l; struct nmg_hit seg_in; /**< @brief IN information */ struct nmg_hit seg_out; /**< @brief OUT information */ void * seg_stp; /**< @brief pointer back to soltab */ }; struct nmg_hitmiss { struct bu_list l; struct nmg_hit hit; fastf_t dist_in_plane; /**< @brief distance from plane intersect */ int in_out; /**< @brief status of ray as it transitions * this hit point. */ long *inbound_use; vect_t inbound_norm; long *outbound_use; vect_t outbound_norm; int start_stop; /**< @brief is this a seg_in or seg_out */ struct nmg_hitmiss *other; /**< @brief for keeping track of the other * end of the segment when we know * it */ }; /** * Ray Data structure * * A) the hitmiss table has one element for each nmg structure in the * nmgmodel. The table keeps track of which elements have been * processed before and which haven't. Elements in this table will * either be: (NULL) item not previously processed hitmiss ptr item * previously processed * * the 0th item in the array is a pointer to the head of the "hit" * list. The 1th item in the array is a pointer to the head of the * "miss" list. * * B) If plane_pt is non-null then we are currently processing a face * intersection. The plane_dist and ray_dist_to_plane are valid. The * ray/edge intersector should check the distance from the plane * intercept to the edge and update "plane_closest" if the current * edge is closer to the intercept than the previous closest object. */ struct nmg_ray_data { uint32_t magic; struct model *rd_m; char *manifolds; /**< @brief structure 1-3manifold table */ vect_t rd_invdir; struct nmg_ray *rp; void * *ap; struct nmg_seg *seghead; void * *stp; const struct bn_tol *tol; struct nmg_hitmiss **hitmiss; /**< @brief 1 struct hitmiss ptr per elem. */ struct bu_list rd_hit; /**< @brief list of hit elements */ struct bu_list rd_miss; /**< @brief list of missed/sub-hit elements */ /* The following are to support isect_ray_face() */ /** * plane_pt is the intercept point of the ray with the plane of * the face. */ point_t plane_pt; /**< @brief ray/plane(face) intercept point */ /** * ray_dist_to_plane is the parametric distance along the ray from * the ray origin (rd->rp->r_pt) to the ray/plane intercept point */ fastf_t ray_dist_to_plane; /**< @brief ray parametric dist to plane */ /** * the "face_subhit" element is a boolean used by isect_ray_face * and [e|v]u_touch_func to record the fact that the * ray/(plane/face) intercept point was within tolerance of an * edge/vertex of the face. In such instances, isect_ray_face * does NOT need to generate a hit point for the face, as the hit * point for the edge/vertex will suffice. */ int face_subhit; /** * the "classifying_ray" flag indicates that this ray is being * used to classify a point, so that the "eu_touch" and "vu_touch" * functions should not be called. */ int classifying_ray; }; int ray_in_rpp(struct nmg_ray *rp, const fastf_t *invdir, /* inverses of rp->r_dir[] */ const fastf_t *min, const fastf_t *max); NMG_EXPORT extern int nmg_class_ray_vs_shell(struct nmg_ray *rp, const struct shell *s, const int in_or_out_only, struct bu_list *vlfree, const struct bn_tol *tol); NMG_EXPORT extern void nmg_isect_ray_model(struct nmg_ray_data *rd, struct bu_list *vlfree); __END_DECLS #endif /* NMG_RAY_H */ /** @} */ /* * Local Variables: * mode: C * tab-width: 8 * indent-tabs-mode: t * c-file-style: "stroustrup" * End: * ex: shiftwidth=4 tabstop=8 */
36.392491
113
0.594298
d94a19b7bd6c5fc3d57b632f5c736a5cc9d31040
746
h
C
src/graphics/MeshShader.h
jarllarsson/loppan
64676c950facfedd88b4b5fbc589610251fb0c2b
[ "BSD-3-Clause" ]
null
null
null
src/graphics/MeshShader.h
jarllarsson/loppan
64676c950facfedd88b4b5fbc589610251fb0c2b
[ "BSD-3-Clause" ]
9
2015-04-25T13:50:29.000Z
2015-05-03T14:17:37.000Z
src/graphics/MeshShader.h
jarllarsson/loppan
64676c950facfedd88b4b5fbc589610251fb0c2b
[ "BSD-3-Clause" ]
null
null
null
#pragma once #include "ShaderVariableContainer.h" #include "ShaderBase.h" #include "Buffer.h" // ======================================================================================= // MeshShader // ======================================================================================= ///--------------------------------------------------------------------------------------- /// \brief Shader for rendering mesh pixel /// /// # MeshShader /// /// 2-3-2014 Jarl Larsson ///--------------------------------------------------------------------------------------- class MeshShader : public ShaderBase { public: MeshShader(ShaderVariableContainer p_initData); virtual ~MeshShader(); void apply(); protected: private: };
26.642857
90
0.353887
d94c2c7240b8160f215900c1938949c9a3cbb179
1,775
c
C
deps/xxHash/tests/ppc_define.c
Masha/hashcat
178003d692ab72abfd9588fdce9e4f569d2b1aa7
[ "MIT" ]
13,663
2015-12-04T16:08:29.000Z
2022-03-31T23:43:17.000Z
deps/xxHash/tests/ppc_define.c
Masha/hashcat
178003d692ab72abfd9588fdce9e4f569d2b1aa7
[ "MIT" ]
2,014
2015-12-04T16:45:36.000Z
2022-03-31T21:02:58.000Z
deps/xxHash/tests/ppc_define.c
Masha/hashcat
178003d692ab72abfd9588fdce9e4f569d2b1aa7
[ "MIT" ]
2,555
2015-12-04T16:09:31.000Z
2022-03-31T11:34:38.000Z
/* * Multi-include test program * ensure that pixel, bool and vector are not redefined * * Copyright (C) 2020 Yann Collet * * GPL v2 License * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * You can contact the author at: * - xxHash homepage: https://www.xxhash.com * - xxHash source repository: https://github.com/Cyan4973/xxHash */ /* gcc's altivec.h, included for the VSX code path, * may, in some circumstances, redefine * bool, vector and pixel keywords. * * This unit checks if it happens. * It's a compile test. * The test is mostly meaningful for PPC target using altivec.h * hence XXH_VECTOR == XXH_VSX */ #define BOOL_VALUE 32123456 #define bool BOOL_VALUE #define VECTOR_VALUE 374464784 #define vector VECTOR_VALUE #define PIXEL_VALUE 5846841 #define pixel PIXEL_VALUE #define XXH_INLINE_ALL #include "../xxhash.h" #if (bool != BOOL_VALUE) # error "bool macro was redefined !" #endif #if (vector != VECTOR_VALUE) # error "vector macro was redefined !" #endif #if (pixel != PIXEL_VALUE) # error "pixel macro was redefined !" #endif int g_nonEmptyUnit = 0;
28.174603
74
0.731268
d94c7de816ffd7b5debdcdae65afbfd670264509
55,427
h
C
Source Code/algo/linux/alg1_psyho.h
JUJUME1960/Orbita
74b80a1267566ab609d94ac776bf5585e626d64f
[ "Apache-2.0" ]
64
2015-03-10T15:35:01.000Z
2015-04-19T15:26:39.000Z
Source Code/algo/linux/alg1_psyho.h
nasa/NTL-Asteroid-Data-Hunter
74b80a1267566ab609d94ac776bf5585e626d64f
[ "Apache-2.0" ]
19
2015-03-16T03:07:47.000Z
2015-04-26T19:29:43.000Z
Source Code/algo/linux/alg1_psyho.h
JUJUME1960/Orbita
74b80a1267566ab609d94ac776bf5585e626d64f
[ "Apache-2.0" ]
17
2015-03-16T01:45:39.000Z
2015-04-17T11:25:06.000Z
bool CFG_FEATURES_USE_POSITION = false; //use position (RA/DEC) bool CFG_FEATURES_USE_SPEED = true; //use absolute speed bool CFG_FEATURES_USE_DIRECTION = true; //use direction of the speed (angle + speed in each direction) #include <bits/stdc++.h> #include <sys/time.h> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/serialization/vector.hpp> using namespace std; /** Psyho Code **/ #define INLINE inline __attribute__ ((always_inline)) #define NOINLINE __attribute__ ((noinline)) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,a) FOR(i,0,a) #define ZERO(m) memset(m,0,sizeof(m)) #define ALL(x) x.begin(),x.end() #define PB push_back #define SZ size() #define LL long long #define ULL unsigned long long #define LD long double #define MP make_pair #define X first #define Y second #define VC vector #define PII pair <int, int> #define PDD pair <double, double> #define PFF pair <float, float> #define VI VC < int > #define VVI VC < VI > #define VVVI VC < VVI > #define VVVVI VC < VVVI > #define VPII VC < PII > #define VD VC < double > #define VVD VC < VD > #define VVVD VC < VVD > #define VF VC < float > #define VVF VC < VF > #define VVVF VC < VVF > #define VS VC < string > #define VVS VC < VS > #define DB(a) cerr << #a << ": " << (a) << endl; #define DBM(a) cerr << (a) << endl; static double t0 = 0; double getTime() { timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec + 1e-6 * tv.tv_usec; } VS splt(string s, char c = ' ') {VS all; int p = 0, np; while (np = s.find(c, p), np >= 0) {if (np != p) all.PB(s.substr(p, np - p)); p = np + 1;} if (p < s.SZ) all.PB(s.substr(p)); return all;} struct RNG { unsigned int MT[624]; int index; RNG(int seed = 1) { init(seed); } void init(int seed = 1) { MT[0] = seed; FOR(i, 1, 624) MT[i] = (1812433253UL * (MT[i-1] ^ (MT[i-1] >> 30)) + i); index = 0; } void generate() { const unsigned int MULT[] = {0, 2567483615UL}; REP(i, 227) { unsigned int y = (MT[i] & 0x8000000UL) + (MT[i+1] & 0x7FFFFFFFUL); MT[i] = MT[i+397] ^ (y >> 1); MT[i] ^= MULT[y&1]; } FOR(i, 227, 623) { unsigned int y = (MT[i] & 0x8000000UL) + (MT[i+1] & 0x7FFFFFFFUL); MT[i] = MT[i-227] ^ (y >> 1); MT[i] ^= MULT[y&1]; } unsigned int y = (MT[623] & 0x8000000UL) + (MT[0] & 0x7FFFFFFFUL); MT[623] = MT[623-227] ^ (y >> 1); MT[623] ^= MULT[y&1]; } unsigned int rand() { if (index == 0) { generate(); } unsigned int y = MT[index]; y ^= y >> 11; y ^= y << 7 & 2636928640UL; y ^= y << 15 & 4022730752UL; y ^= y >> 18; index = index == 623 ? 0 : index + 1; return y; } INLINE int next() { return rand(); } INLINE int next(int x) { return rand() % x; } INLINE int next(int a, int b) { return a + (rand() % (b - a)); } INLINE double nextDouble() { return (rand() + 0.5) * (1.0 / 4294967296.0); } }; static RNG rng; struct TreeNode { friend class boost::serialization::access; // Serialize the class template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & level; ar & feature; ar & value; ar & result; ar & left; ar & right; } int level; int feature; float value; float result; int left; int right; TreeNode() { level = -1; feature = -1; value = 0; result = 0; left = -1; right = -1; } }; struct RandomForestConfig { friend class boost::serialization::access; // Serialize the class template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & randomFeatures; ar & randomPositions; ar & featuresIgnored; ar & groupFeature; ar & maxLevel; ar & maxNodeSize; ar & threadsNo; ar & bagSize; ar & timeLimit; ar & useBootstrapping; ar & computeImportances; ar & computeOOB; } VI randomFeatures = {5}; VI randomPositions = {2}; int featuresIgnored = 0; int groupFeature = -1; //NOT IMPLEMENTED int maxLevel = 100; int maxNodeSize = 1; int threadsNo = 1; double bagSize = 1.0; double timeLimit = 0; bool useBootstrapping = true; bool computeImportances = false; bool computeOOB = false; //NOT IMPLEMENTED }; class DecisionTree { private: friend class boost::serialization::access; // Serialize the class template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & nodes; ar & importances; } public: VC < TreeNode > nodes; VD importances; DecisionTree() { } template < class T > DecisionTree(VC < VC < T > > &features, VC < T > &results, RandomForestConfig &config, int seed) { RNG r(seed); if (config.computeImportances) { importances = VD(features[0].SZ); } VI chosenGroups(features.SZ); REP(i, (int)(features.SZ * config.bagSize)) chosenGroups[r.next(features.SZ)]++; int bagSize = 0; REP(i, features.SZ) if (chosenGroups[i]) bagSize++; VI bag(bagSize); VI weight(features.SZ); int pos = 0; REP(i, features.SZ) { weight[i] = config.useBootstrapping ? chosenGroups[i] : min(1, chosenGroups[i]); if (chosenGroups[i]) bag[pos++] = i; } TreeNode root; root.level = 0; root.left = 0; root.right = pos; nodes.PB(root); VI stack; stack.PB(0); while (stack.SZ) { bool equal = true; int curNode = stack[stack.SZ - 1]; stack.pop_back(); int bLeft = nodes[curNode].left; int bRight = nodes[curNode].right; int bSize = bRight - bLeft; int totalWeight = 0; T totalSum = 0; FOR(i, bLeft, bRight) { totalSum += results[bag[i]] * weight[bag[i]]; totalWeight += weight[bag[i]]; } assert(bSize > 0); FOR(i, bLeft + 1, bRight) if (results[bag[i]] != results[bag[i - 1]]) { equal = false; break; } if (equal || bSize <= config.maxNodeSize || nodes[curNode].level >= config.maxLevel) { if (totalWeight < 10) { nodes[curNode].result = totalSum / totalWeight; } else { T mn = +1e10; T mx = -1e10; FOR(i, bLeft + 1, bRight) { mn = min(mn, results[bag[i]]); mx = max(mx, results[bag[i]]); } nodes[curNode].result = (totalSum - mn - mx) / (totalWeight - 2); } continue; } int bestFeature = -1; int bestLeft = 0; int bestRight = 0; T bestValue = 0; T bestMSE = 1e99; const int randomFeatures = config.randomFeatures[min(nodes[curNode].level, (int)config.randomFeatures.SZ - 1)]; REP(i, randomFeatures) { int featureID = config.featuresIgnored + r.next(features[0].SZ - config.featuresIgnored); T vlo, vhi; vlo = vhi = features[bag[bLeft]][featureID]; FOR(j, bLeft + 1, bRight) { vlo = min(vlo, features[bag[j]][featureID]); vhi = max(vhi, features[bag[j]][featureID]); } if (vlo == vhi) continue; const int randomPositions = config.randomPositions[min(nodes[curNode].level, (int)config.randomPositions.SZ - 1)]; REP(j, randomPositions) { T splitValue = features[bag[bLeft + r.next(bSize)]][featureID]; if (splitValue == vlo) { j--; continue; } T sumLeft = 0; int totalLeft = 0; int weightLeft = 0; FOR(k, bLeft, bRight) { int p = bag[k]; if (features[p][featureID] < splitValue) { sumLeft += results[p] * weight[p]; weightLeft += weight[p]; totalLeft++; } } T sumRight = totalSum - sumLeft; int weightRight = totalWeight - weightLeft; int totalRight = bSize - totalLeft; if (totalLeft == 0 || totalRight == 0) continue; T meanLeft = sumLeft / weightLeft; T meanRight = sumRight / weightRight; T mse = 0; mse = (1 - meanLeft) * (1 - meanLeft) * (1 - meanLeft) * sumLeft + meanLeft * meanLeft * meanLeft * (weightLeft - sumLeft) + (1 - meanRight) * (1 - meanRight) * (1 - meanRight) * sumRight + meanRight * meanRight * meanRight * (weightRight - sumRight); if (mse < bestMSE) { bestMSE = mse; bestValue = splitValue; bestFeature = featureID; bestLeft = totalLeft; bestRight = totalRight; if (mse == 0) goto outer; } } } outer: if (bestLeft == 0 || bestRight == 0) { if (totalWeight < 10) { nodes[curNode].result = totalSum / totalWeight; } else { T mn = +1e10; T mx = -1e10; FOR(i, bLeft + 1, bRight) { mn = min(mn, results[bag[i]]); mx = max(mx, results[bag[i]]); } nodes[curNode].result = (totalSum - mn - mx) / (totalWeight - 2); } continue; } if (config.computeImportances) { importances[bestFeature] += 1. * (bRight - bLeft) / features.SZ; } T mean = totalSum / totalWeight; T nextValue = -1e99; FOR(i, bLeft, bRight) if (features[bag[i]][bestFeature] < bestValue) nextValue = max(nextValue, features[bag[i]][bestFeature]); TreeNode left; TreeNode right; left.level = right.level = nodes[curNode].level + 1; nodes[curNode].feature = bestFeature; nodes[curNode].value = (bestValue + nextValue) / 2.0; if (!(nodes[curNode].value > nextValue)) nodes[curNode].value = bestValue; nodes[curNode].left = nodes.SZ; nodes[curNode].right = nodes.SZ + 1; int bMiddle = bRight; FOR(i, bLeft, bMiddle) { if (features[bag[i]][nodes[curNode].feature] >= nodes[curNode].value) { swap(bag[i], bag[--bMiddle]); i--; continue; } } assert(bestLeft == bMiddle - bLeft); assert(bestRight == bRight - bMiddle); left.left = bLeft; left.right = bMiddle; right.left = bMiddle; right.right = bRight; stack.PB(nodes.SZ); stack.PB(nodes.SZ + 1); nodes.PB(left); nodes.PB(right); } nodes.shrink_to_fit(); } template < class T > double estimate(VC < T > &features) { TreeNode *pNode = &nodes[0]; while (true) { if (pNode->feature < 0) return pNode->result; pNode = &nodes[features[pNode->feature] < pNode->value ? pNode->left : pNode->right]; } } }; RNG gRNG(1); class RandomForest { private: friend class boost::serialization::access; // Serialize the class template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & trees; ar & importances; ar & config; } public: VC < DecisionTree > trees; VD importances; RandomForestConfig config; void clear() { trees.clear(); trees.shrink_to_fit(); } template < class T > void train(VC < VC < T > > &features, VC < T > &results, RandomForestConfig &_config, int treesNo) { double startTime = getTime(); config = _config; if (config.threadsNo == 1) { REP(i, treesNo) { if (config.timeLimit && getTime() - startTime > config.timeLimit) break; trees.PB(DecisionTree(features, results, config, gRNG.next())); } } else { thread *threads = new thread[config.threadsNo]; mutex mutex; REP(i, config.threadsNo) threads[i] = thread([&] { while (true) { auto tree = DecisionTree(features, results, config, gRNG.next()); mutex.lock(); if (trees.SZ < treesNo) trees.PB(tree); bool done = trees.SZ >= treesNo || config.timeLimit && getTime() - startTime > config.timeLimit; mutex.unlock(); if (done) break; } }); REP(i, config.threadsNo) threads[i].join(); delete[] threads; } if (config.computeImportances) { importances = VD(features[0].SZ); for (DecisionTree tree : trees) REP(i, importances.SZ) importances[i] += tree.importances[i]; double sum = 0; REP(i, importances.SZ) sum += importances[i]; REP(i, importances.SZ) importances[i] /= sum; } } template <class T> double estimate(VC<T> &features) { assert(trees.SZ); double sum = 0; REP(i, trees.SZ) sum += trees[i].estimate(features); return sum / trees.SZ; } template <class T> VD estimate(VC<VC<T>> &features) { assert(trees.SZ); int samplesNo = features.SZ; VD rv(samplesNo); if (config.threadsNo == 1) { REP(j, samplesNo) { REP(i, trees.SZ) rv[j] += trees[i].estimate(features[j]); rv[j] /= trees.SZ; } } else { thread *threads = new thread[config.threadsNo]; mutex mutex; int order = 0; REP(i, config.threadsNo) threads[i] = thread([&] { mutex.lock(); int offset = order++; mutex.unlock(); for (int j = offset; j < samplesNo; j += config.threadsNo) { REP(k, trees.SZ) rv[j] += trees[k].estimate(features[j]); rv[j] /= trees.SZ; } }); REP(i, config.threadsNo) threads[i].join(); delete[] threads; } return rv; } LL countTotalNodes() { LL rv = 0; REP(i, trees.SZ) rv += trees[i].nodes.SZ; return rv; } }; /** Pfr Code **/ class FitsHeader { protected: map<string, double> _double_value; public: vector<string> _raw_header; double double_value(std::string key) const { return _double_value.at(key); } void add_line(std::string raw) { _raw_header.push_back(raw); istringstream iss(raw); string untrimmed_key; std::getline(iss, untrimmed_key, '='); istringstream key_iss(untrimmed_key); string key; double value; key_iss >> key; iss >> value; if (!iss.fail()) _double_value[key] = value; } }; namespace catalina { const int ADC_DISCONTINUITY_X = 2055; const int ADC_DISCONTINUITY_RECOVER_WIDTH = 3; }; const double PI = 3.1415926535897932384626433832795; namespace config { const int FRAMES = 4; const int MAX_ALLOWED_DETECTIONS = 100000; const int FrameWidth = 4110; const int FrameHeight = 4096; const int W = FrameWidth; const int H = FrameHeight; const int MAX_FRAME_DISPLACEMENT = 64; const int Margin = 128; const int MarginWidth = FrameWidth + 2*Margin; const int MarginHeight = FrameHeight + 2*Margin; const int NotEigenStride = MarginWidth; const int UNGLOW_BLOCK_SIZE = 128; const int UNGLOW_MIN_EDGE = UNGLOW_BLOCK_SIZE; const int blur_n = 5; const float blur_radius = 0.95; const float STANDARD_QUAL_FACTOR = 50; }; namespace astro { const double DEG_TO_RAD = PI/180; const double RAD_TO_DEG = 180/PI; }; using namespace config; template<class T> struct AnyVec2 { T value[2]; AnyVec2() {} AnyVec2(T x, T y) { value[0] = x; value[1] = y; } T& operator[](int i) { return value[i]; } T operator[](int i) const { return value[i]; } }; template<class S, class T> S& operator<<(S& stream, AnyVec2<T> v) { return stream << v[0] << " " << v[1]; } typedef AnyVec2<double> Vec2; typedef AnyVec2<int> Vec2i; struct Mat2d { typedef double T; T a,b,c,d; Mat2d() {} Mat2d(T a, T b, T c, T d): a(a), b(b), c(c), d(d) {} static Mat2d Zero() { return Mat2d(0,0,0,0); } T operator()(int i, int j) const { if (i==0) return j==0 ? a : b; else return j==0 ? c : d; } T at(int i, int j) const { return operator()(i,j); } Vec2 row(int i) { return Vec2(at(i,0), at(i,1)); } Vec2 col(int j) { return Vec2(at(0,j), at(1,j)); } Mat2d inverse() const { T det = a*d - b*c; return Mat2d(d/det, -b/det, -c/det, a/det); } Mat2d transpose() const { return Mat2d(a,c,b,d); } Vec2 operator*(Vec2 x) const { return Vec2(a*x[0] + b*x[1], c*x[0] + d*x[1]); } Mat2d operator*(Mat2d m) const { Vec2 col0 = (*this) * m.col(0); Vec2 col1 = (*this) * m.col(1); return Mat2d(col0[0], col1[0], col0[1], col1[1]); } Mat2d& operator+=(Mat2d y) { a += y.a; b += y.b; c += y.c; d += y.d; return *this; } }; template<class S> S& operator<<(S& stream, Mat2d m) { return stream << m.row(0) << "\n" << m.row(1); } Vec2 operator+(Vec2 a, Vec2 b) { return Vec2(a[0]+b[0], a[1]+b[1]); } Vec2 operator-(Vec2 a, Vec2 b) { return Vec2(a[0]-b[0], a[1]-b[1]); } Vec2 operator*(Vec2 a, Vec2 b) { return Vec2(a[0]*b[0], a[1]*b[1]); } Vec2 operator/(Vec2 a, Vec2 b) { return Vec2(a[0]/b[0], a[1]/b[1]); } Vec2 operator*(double b, Vec2 a) { return Vec2(a[0]*b, a[1]*b); } Vec2 operator*(Vec2 a, double b) { return Vec2(a[0]*b, a[1]*b); } Vec2 operator/(Vec2 a, double b) { return Vec2(a[0]/b, a[1]/b); } Vec2 operator-(Vec2 a) { return Vec2(-a[0], -a[1]); } typedef Vec2 Point; typedef Vec2 DarkPoint; Vec2 operator+(Vec2 a, float b) { return Vec2(a[0]+b, a[1]+b); } Vec2 operator-(Vec2 a, float b) { return Vec2(a[0]-b, a[1]-b); } Vec2i operator+(Vec2i a, int b) { return Vec2i(a[0]+b, a[1]+b); } Vec2i operator-(Vec2i a, int b) { return Vec2i(a[0]-b, a[1]-b); } float norm2(Vec2 a) { return a[0]*a[0] + a[1]*a[1]; } float sqr(float x) { return x*x; } double sqr(double x) { return x*x; } static inline void assert_invariant(bool condition) { if (!condition) throw std::logic_error("assert_invariant failed"); } static inline void range_check(bool condition) { if (!condition) throw std::out_of_range("range_check failed"); } struct PlaneToSphereMapping { Vec2 ref_pix; Vec2 ref_val; Mat2d linear_pix_to_val; Vec2 operator()(Vec2 yx) const { Vec2 yx_pix = yx - ref_pix; Vec2 xy_val = -astro::DEG_TO_RAD * (linear_pix_to_val * yx_pix); double x = xy_val[0], y = xy_val[1]; double a0 = astro::DEG_TO_RAD * ref_val[0]; double d0 = astro::DEG_TO_RAD * ref_val[1]; double D = atan(sqrt(x*x+y*y)); double B = atan2(-x, y); double XX = sin(d0)*sin(D)*cos(B) + cos(d0)*cos(D); double YY = sin(D)*sin(B); double a = a0 + atan2(YY, XX); double d = asin(sin(d0)*cos(D) - cos(d0)*sin(D)*cos(B)); return astro::RAD_TO_DEG * Vec2(a,d); } }; struct SphereToPlaneMapping { Vec2 ref_val; Vec2 ref_pix; Mat2d linear_val_to_pix; Vec2 operator()(Vec2 rd) const { double a0 = astro::DEG_TO_RAD * ref_val[0]; double d0 = astro::DEG_TO_RAD * ref_val[1]; double a = astro::DEG_TO_RAD * rd[0]; double d = astro::DEG_TO_RAD * rd[1]; double A = cos(d) * cos(a-a0); double F = astro::RAD_TO_DEG / (sin(d0)*sin(d) + cos(d0)*A); double x_val = F * cos(d) * sin(a-a0); double y_val = F * (cos(d0)*sin(d) - A * sin(d0)); Vec2 xy_val = { x_val, y_val }; Vec2 yx_pix = (linear_val_to_pix * xy_val); return yx_pix + ref_pix; } }; struct FullImage; struct AffineMap { Mat2d linear_matrix; Vec2 offset; Vec2 operator()(Vec2 yx) const { return linear_matrix * yx + offset; } AffineMap inverse() const { Mat2d inv = linear_matrix.inverse(); return AffineMap { inv, inv * -offset }; } void transform(FullImage src, FullImage dst) const; }; Mat2d outer(Vec2 x, Vec2 y) { Mat2d m(x[0]*y[0], x[0]*y[1], x[1]*y[0], x[1]*y[1]); return m; } static inline AffineMap operator*(const SphereToPlaneMapping& g, const PlaneToSphereMapping& f) { Vec2 center = { 2055, 2048 }; Vec2 im_center = g(f(center)); Mat2d left = Mat2d::Zero(); Mat2d right = Mat2d::Zero(); const int w = 4; for (int i=-w; i<=w; i++) { for (int j=-w; j<=w; j++) { Vec2 a = { i/(double)w * center[0], j/(double)w * center[1] }; Vec2 b = g(f(center + a)) - im_center; left += outer(a, a); right += outer(a, b); } } Mat2d linear_matrix = (left.inverse() * right).transpose(); Vec2 offset = im_center - linear_matrix * center; return AffineMap { linear_matrix, offset }; } struct FullImageBuffer { float raw_data[MarginHeight * MarginWidth]; }; struct FullImage { float* origin_ptr; shared_ptr<FullImageBuffer> buf; FullImage(): buf(make_shared<FullImageBuffer>()) { origin_ptr = &buf->raw_data[Margin*NotEigenStride + Margin]; } float& unsafe_at(int y, int x) const { return origin_ptr[y*NotEigenStride + x]; } float& at(int y, int x) const { range_check(-Margin <= y && y < H+Margin); range_check(-Margin <= x && x < W+Margin); return unsafe_at(y, x); } float atf(float y, float x) { int iy = (int)y; int ix = (int)x; float wy = y - iy; float wx = x - ix; return at(iy + 1, ix + 1) * wy * wx + at(iy, ix + 1) * (1 - wy) * wx + at(iy + 1, ix) * wy * (1 - wx) + at(iy, ix) * (1 - wy) * (1 - wx); } float& at(Vec2i yx) const { return at(yx[0], yx[1]); } template<class T> void fill_with(const T& callable) { for (int i=0; i<H; i++) for (int j=0; j<W; j++) unsafe_at(i,j) = callable(i,j); } }; struct FullImageSet { FullImage image[FRAMES]; FullImage& operator[](int f) { return image[f]; } template<class T> void fill_with(const T& callable) { for (int f=0; f<FRAMES; f++) image[f].fill_with([f,callable](int i, int j) -> float { return callable(f,i,j); }); } }; struct Series { std::string id; PlaneToSphereMapping darkToSphere[FRAMES]; SphereToPlaneMapping sphereToDark[FRAMES]; AffineMap darkToStar[FRAMES]; AffineMap starToDark[FRAMES]; FitsHeader frame_head[FRAMES]; float frame_bias[FRAMES]; double time_delta; void setup() { time_delta = (frame_head[FRAMES-1].double_value("MJD") - frame_head[0].double_value("MJD")) / (FRAMES-1); for (int f=0; f<FRAMES; f++) { const FitsHeader& head = frame_head[f]; Vec2 ref_pix = Vec2(head.double_value("CRPIX2"), head.double_value("CRPIX1")); Vec2 ref_val = Vec2(head.double_value("CRVAL1"), head.double_value("CRVAL2")); Mat2d pix_to_val( head.double_value("CD1_2"), head.double_value("CD1_1"), head.double_value("CD2_2"), head.double_value("CD2_1")); darkToSphere[f] = PlaneToSphereMapping { ref_pix, ref_val, pix_to_val }; sphereToDark[f] = SphereToPlaneMapping { ref_val, ref_pix, pix_to_val.inverse() }; darkToStar[f] = sphereToDark[0] * darkToSphere[f]; starToDark[f] = darkToStar[f].inverse(); } } }; struct Detection { Series* series; Point yx0; Vec2 dyx; float score; float gain_Kobj = NAN; float gain_Vobj = NAN; float gain_histogram[FRAMES] = { NAN, NAN, NAN, NAN }; bool neo_candidate = false; bool is_duplicate = false; Detection(Series* series, Point yx0, Vec2 dyx, float score) : series(series), yx0(yx0), dyx(dyx), score(score) {} bool operator<(const Detection& o) const { return score > o.score; } Point yx(int f) const { return yx0 + dyx*f; } }; struct DiskSet { vector<Point> points; float radius2; DiskSet(float radius): radius2(radius*radius) {} bool includes(Point p) const { for (const Point& q : points) { Vec2 d = p-q; if (d[0]*d[0] + d[1]*d[1] <= radius2) return true; } return false; } void add(Point p) { points.push_back(p); } }; template<class T> void resize_if_larger(vector<T>& v, int max_size) { if ((int)v.size() > max_size) { v.erase(v.begin() + max_size, v.end()); } } struct BrightAnchor { Series* series; int fr; Point yxr; float score; bool operator<(const BrightAnchor& o) const { return score > o.score; } }; vector<Detection> detectBright(Series* series, FullImageSet Z, FullImageSet &Z2) { for (int f=0; f<FRAMES; f++) for (int y=0; y<H; y++) for (int x=0; x<W; x++) { float z = Z[f].at(y,x); z = max(0.f, z); Z2[f].at(y,x) = sqr(z) / (2 * sqr(STANDARD_QUAL_FACTOR)); } const int anchor_step = 9; //TODO: splitting to 9x9 blocks far from good const float anchor_thresh = sqr(1.5); const int max_frame_anchors = 3000; //TODO: increase const int max_anchors = 4*max_frame_anchors; const int SPEED_RANGE = 30; //TODO: increase max speed range const float TRACK_MERIT = .075; //TODO: tweak (decrease -> more detections) const int max_tracks = 3000; //TODO: increase const int min_track_distance = 12; //TODO: tweak const float MEAN_SPEED_THRESHOLD_SCORE = 10; //it's median, d'oh const float delta_sigma = .23; const float speed_sigma = 70; double minimumDistanceFromEdge = 0; for (int f=0; f<FRAMES; f++) { Point p = series->starToDark[f](Point { H/2, W/2 }) - Point{H/2,W/2}; minimumDistanceFromEdge = max(minimumDistanceFromEdge, max(abs(p[0]), abs(p[1]))); } vector<BrightAnchor> anchors; for (int f=0; f<FRAMES; f++) { const int D = anchor_step; for (int bi=0; bi<H/D; bi++) { for (int bj=0; bj<W/D; bj++) { float best_val = 0; Vec2i best_pos = Vec2i{0,0}; for (int i=0; i<D; i++) for (int j=0; j<D; j++) { float val = Z2[f].at(bi*D+i, bj*D+j); Vec2i pos = Vec2i(bi*D+i, bj*D+j); if (val >= best_val) { best_val = val; best_pos = Vec2i(bi*D+i, bj*D+j); } } //TODO: consult if we should remove asteroids close to border?? if (best_pos[0]<15 || best_pos[1]<38) continue; if (best_pos[0]>H-15 || best_pos[1]>W-25) continue; // if (best_pos[0]<minimumDistanceFromEdge || best_pos[1]<minimumDistanceFromEdge) // continue; // if (best_pos[0]>H-minimumDistanceFromEdge || best_pos[1]>W-minimumDistanceFromEdge) // continue; if (best_val >= anchor_thresh) anchors.push_back(BrightAnchor { series, f, series->darkToStar[f](Vec2(best_pos[0], best_pos[1])), best_val }); } } } sort(anchors.begin(), anchors.end()); if ((int)anchors.size() > max_anchors) { resize_if_larger(anchors, max_anchors); } vector<Detection> allTracks; for (BrightAnchor& anchor : anchors) { int fr = anchor.fr; Point yxr = anchor.yxr; Vec2 offset_f[FRAMES]; for (int f=0; f<FRAMES; f++) offset_f[f] = series->starToDark[f](yxr); float best_merit = 0; Vec2 best_dyx = Vec2(0,0); float best_x[FRAMES]; for (int vi=-SPEED_RANGE; vi<=SPEED_RANGE; vi++) { for (int vj=-SPEED_RANGE; vj<=SPEED_RANGE; vj++) { Vec2 dyx = { vi/5.0, vj/5.0 }; //TODO: increase speed resolution float x[FRAMES]; for (int f=0; f<FRAMES; f++) x[f] = Z2[f].at( (int)(offset_f[f][0] + dyx[0] * (f-fr) + .5), (int)(offset_f[f][1] + dyx[1] * (f-fr) + .5) ); std::sort(x, x+FRAMES); float merit = 4*x[0] + 2*x[1] + x[2]; //TODO: tweak? probably pointless if (merit > best_merit) { best_merit = merit; best_dyx = dyx; for (int f=0; f<FRAMES; f++) best_x[f] = x[f]; } } } if (best_merit > TRACK_MERIT) { Detection d = Detection { series, yxr - best_dyx * fr, best_dyx, best_merit }; std::copy(&best_x[0], &best_x[FRAMES], d.gain_histogram); allTracks.push_back(d); } } //TODO: removes "duplicates" - can be improved if it's going to be the bottleneck, since it's naive O(n^2) sort(allTracks.begin(), allTracks.end()); cerr << (int)allTracks.size() << " raw tracks" << endl; vector<Detection> tracks; DiskSet diskSet(min_track_distance); for (Detection& d : allTracks) { if (diskSet.includes(d.yx0)) continue; diskSet.add(d.yx0); tracks.push_back(d); if ((int)tracks.size() >= max_tracks) break; } return tracks; } vector<string> finish(vector<Detection>& detections) { std::sort(detections.begin(), detections.end()); resize_if_larger(detections, MAX_ALLOWED_DETECTIONS); //TODO: remove duplications vector<Detection> extra_detections; for (Detection& d : detections) { Detection d2 = d; float s = d.score; float M = 1.2e9; float s2 = M/sqr(6000*(1 - .95 * max(1e-4f, 1 - 1/sqrt(s/M)/6000) * max(1e-4f, 1 - 1/sqrt(s/M)/4800))); s2 = min(s2, s - 20); d2.score = s2; d2.is_duplicate = true; extra_detections.push_back(d2); } for (Detection& d : extra_detections) { detections.push_back(d); } std::sort(detections.begin(), detections.end()); resize_if_larger(detections, MAX_ALLOWED_DETECTIONS); vector<string> lines; for (int i=0; i<(int)detections.size(); i++) { Detection& d = detections[i]; stringstream ss; ss << d.series->id << ' '; for (int f=0; f<FRAMES; f++) { Vec2 ra_dec = d.series->darkToSphere[f](d.series->starToDark[f](d.yx(f))); ss << setprecision(6) << fixed; ss << ra_dec[0] << ' ' << ra_dec[1] << ' '; } ss << (int)d.neo_candidate; lines.push_back(ss.str()); } return lines; } template<class T> static inline T lerp(T t, T a, T b) { return a + t * (b-a); } template<class T> static inline T cubic_delta(T t, T bdelta, T b, T c, T cdelta) { return lerp(t*t*(3-2*t), b, c) + 0.5*(t - t*t) * lerp(t, bdelta, -cdelta); } template<class T> static inline T cubic(T t, T a, T b, T c, T d) { return cubic_delta(t, c-a, b, c, d-b); } float arrayinterp1d_cubic_nearest(const float* ptr, int size, int stride, float fi) { int i = (int)fi; float t = fi - i; float y; if (i < 1) { if (fi < 0) { y = ((ptr[stride*(0)])); } else { y = cubic_delta(t, (2*((ptr[stride*(1)]) - (ptr[stride*(0)]))), (ptr[stride*(0)]), (ptr[stride*(1)]), (size==2 ? (2*((ptr[stride*(size-1)]) - (ptr[stride*(size-2)]))) : (ptr[stride*(2)]) - (ptr[stride*(0)]))); } } else if (i >= size-2) { if (i >= size-1) { y = ((ptr[stride*(size-1)])); } else { y = cubic_delta(t, (ptr[stride*(i+1)]) - (ptr[stride*(i-1)]), (ptr[stride*(i)]), (ptr[stride*(i+1)]), (2*((ptr[stride*(size-1)]) - (ptr[stride*(size-2)])))); } } else { y = cubic(t, (ptr[stride*(i-1)]), (ptr[stride*(i)]), (ptr[stride*(i+1)]), (ptr[stride*(i+2)])); } return y; } float arrayinterp1d_cubic_nan(const float* ptr, int size, int stride, float fi) { int i = (int)fi; float t = fi - i; float y; if (i < 1) { if (fi < 0) { y = NAN; } else { y = cubic_delta(t, (2*((ptr[stride*(1)]) - (ptr[stride*(0)]))), (ptr[stride*(0)]), (ptr[stride*(1)]), (size==2 ? (2*((ptr[stride*(size-1)]) - (ptr[stride*(size-2)]))) : (ptr[stride*(2)]) - (ptr[stride*(0)]))); } } else if (i >= size-2) { if (i >= size-1) { y = NAN; } else { y = cubic_delta(t, (ptr[stride*(i+1)]) - (ptr[stride*(i-1)]), (ptr[stride*(i)]), (ptr[stride*(i+1)]), (2*((ptr[stride*(size-1)]) - (ptr[stride*(size-2)])))); } } else { y = cubic(t, (ptr[stride*(i-1)]), (ptr[stride*(i)]), (ptr[stride*(i+1)]), (ptr[stride*(i+2)])); } return y; } static void partial_transform(float* src, float* dst, int nx, int ny, int sx, int sy, float s, float a, float b) { float idx[max(W,H)]; for (int x=0; x<nx; x++) idx[x] = x*s + b; float offset = 0; // cerr << s << "," << a << "," << b << endl; for (int y=0; y<ny; y++) { for (int x=0; x<nx; x++) { dst[y*sy + x*sx] = arrayinterp1d_cubic_nan(&src[y*sy], nx, sx, idx[x] + offset); } offset += a; } } void AffineMap::transform(FullImage img, FullImage tmp) const { AffineMap inv = this->inverse(); double xx = inv.linear_matrix(0,0); double xy = inv.linear_matrix(0,1); double x0 = inv.offset[0]; double yx = inv.linear_matrix(1,0); double yy = inv.linear_matrix(1,1); double y0 = inv.offset[1]; if (sqr(xx-1) + sqr(yy-1) + sqr(xy) + sqr(yx) + sqr(x0) + sqr(y0) < 1e-16) return; double k = xy / yy; partial_transform(&img.at(0,0), &tmp.at(0,0), H, W, NotEigenStride, 1, xx - k*yx, k, x0 - k *y0); partial_transform(&tmp.at(0,0), &img.at(0,0), W, H, 1, NotEigenStride, yy, yx, y0); } void clean_catalina_discontinuity(FullImage& img) { int x_disc = catalina::ADC_DISCONTINUITY_X; int w_disc = catalina::ADC_DISCONTINUITY_RECOVER_WIDTH; float delta[H]; for (int i=0; i<H; i++) { float s = 0; for (int j=x_disc-w_disc; j<x_disc; j++) s -= img.at(i,j); for (int j=x_disc; j<x_disc+w_disc; j++) s += img.at(i,j); delta[i] = s/w_disc; } std::nth_element(&delta[0], &delta[H/2], &delta[H]); float offset = roundf(delta[H/2]); // cerr << "ADC offset: " << offset << endl; for (int i=0; i<H; i++) for (int j=x_disc; j<W; j++) img.at(i,j) -= offset; } void computeUnglow(Series* series, FullImageSet frames) { for (int f=0; f<FRAMES; f++) { FullImage& data = frames[f]; clean_catalina_discontinuity(data); const int S = config::UNGLOW_BLOCK_SIZE; const int E = config::UNGLOW_MIN_EDGE; const int w = 1; // Point center = series->starToDark[f](Point { H/2, W/2 }); //Source of the bug, the idea to align the blocks between the frames doesn't make much sense anyway Point center = Point{H/2,W/2}; vector<int> Y, X; int i_mid = 1 + (H/2 - E)/S; int ni_full = 2*i_mid + 1; int ni = ni_full-w; int j_mid = 1 + (W/2 - E)/S; int nj_full = 2*j_mid + 1; int nj = nj_full-w; for (int i=0; i<ni_full; i++) Y.push_back(i==0 ? 0 : i<ni_full-1 ? center[0] + S*(i-i_mid) : H); for (int j=0; j<nj_full; j++) X.push_back(j==0 ? 0 : j<nj_full-1 ? center[1] + S*(j-j_mid) : W); // cerr << "about to median" << endl; vector<float> glow(ni*nj); const int M = UNGLOW_MIN_EDGE*2 + UNGLOW_BLOCK_SIZE; float glow_input[M*M]; for (int i=0; i<ni; i++) for (int j=0; j<nj; j++) { int height = Y[i+w] - X[i]; int width = X[j+w] - X[j]; range_check(0 < height && height <= M && 0 < width && width <= M); for (int y=Y[i]; y<Y[i+w]; y++) for (int x=X[j]; x<X[j+w]; x++) glow_input[(y-Y[i])*width + (x-X[j])] = data.at(y,x); int p = width*height / 2; std::nth_element(&glow_input[0], &glow_input[p], &glow_input[width*height]); glow[i*nj + j] = glow_input[p]; } // cerr << "about to expand" << endl; vector<float> glow_half_expanded(ni*W); for (int i=0; i<ni; i++) { for (int x=0; x<W; x++) { glow_half_expanded[i*W + x] = arrayinterp1d_cubic_nearest(&glow[i*nj + 0], nj, 1, (x-center[1])/S + j_mid - 0.5f * w); } } // cerr << "about to expand" << endl; for (int y=0; y<H; y++) { for (int x=0; x<W; x++) { data.at(y,x) -= arrayinterp1d_cubic_nearest(&glow_half_expanded[0*W + x], ni, W, (y-center[0])/S + i_mid - 0.5f * w); } } std::nth_element(&glow[0], &glow[ni*nj/2], &glow[ni*nj]); series->frame_bias[f] = glow[ni*nj/2]; } } void computeLayers(Series* series, FullImageSet unglow, FullImage star, FullImage dark, FullImageSet transformed, FullImageSet mov) { const float SATURATION = 15000; for (int f=0; f<FRAMES; f++) { float frame_bias = series->frame_bias[f]; // cerr << "frame_bias = " << frame_bias << endl; for (int i=0; i<H; i++) { for (int j=0; j<W; j++) { float val = unglow[f].at(i,j); float biased_val = val + frame_bias; bool invalid = biased_val<1000 || val>SATURATION || j==1190 || j<7 || j>W-7; unglow[f].at(i,j) = invalid ? NAN : val; } } } FullImage tmp; for (int f=0; f<FRAMES; f++) { for (int i=0; i<H; i++) { for (int j=0; j<W; j++) { transformed[f].at(i,j) = unglow[f].at(i,j); } } series->darkToStar[f].transform(transformed[f], tmp); } for (int i=0; i<H; i++) { for (int j=0; j<W; j++) { float buf[FRAMES]; int p = 0; for (int f=0; f<FRAMES; f++) { float x = transformed[f].at(i,j); if (x==x) buf[p++] = x; } float r; if (p==0) r = 0; else { int k = (p-1)/2; std::nth_element(&buf[0], &buf[k], &buf[p]); if ((p&1)==0) { float x = buf[k]; float y = *std::min_element(&buf[k+1], &buf[p]); r = x*y < 0 ? 0 : std::abs(x)<std::abs(y) ? x : y; } else { r = buf[k]; } } star.at(i,j) = r; } } for (int f=0; f<FRAMES; f++) { for (int i=0; i<H; i++) { for (int j=0; j<W; j++) { transformed[f].at(i,j) = star.at(i,j); } } series->starToDark[f].transform(transformed[f], tmp); } for (int i=0; i<H; i++) { for (int j=0; j<W; j++) { float buf[FRAMES]; int p = 0; for (int f=0; f<FRAMES; f++) { float x = unglow[f].at(i,j) - transformed[f].at(i,j); if (x==x) buf[p++] = x; } float r; if (p==0) r = 0; else { int k = (p-1)/2; std::nth_element(&buf[0], &buf[k], &buf[p]); if ((p&1)==0) { float x = buf[k]; float y = *std::min_element(&buf[k+1], &buf[p]); r = x*y < 0 ? 0 : std::abs(x)<std::abs(y) ? x : y; } else { r = buf[k]; } } dark.at(i,j) = r; for (int f=0; f<FRAMES; f++) { mov[f].at(i,j) = unglow[f].at(i,j) - transformed[f].at(i,j) - r; } } } } template<int n> struct SeparableKernel { float weight[n]; float& operator()(int i) { return weight[n/2+i]; } }; template<int n> SeparableKernel<n> make_gaussian(float sigma) { SeparableKernel<n> r; for (int i=-n/2; i<=n/2; i++) r(i) = expf(-i*i/(2*sigma*sigma)); float s = 0; for (int i=-n/2; i<=n/2; i++) s += r(i); for (int i=-n/2; i<=n/2; i++) r(i) /= s; return r; } template<int n> void convolve(FullImage src, FullImage dst, FullImage tmp, SeparableKernel<n> ker) { for (int i=0; i<H; i++) for (int j=0; j<W; j++) { float s = 0; for (int k=-n/2; k<=n/2; k++) s += src.unsafe_at(i,j-k) * ker(k); tmp.at(i,j) = s; } for (int i=0; i<H; i++) for (int j=0; j<W; j++) { float s = 0; for (int k=-n/2; k<=n/2; k++) s += tmp.unsafe_at(i-k,j) * ker(k); dst.at(i,j) = s; } } template<int n> void box_filter(FullImage img, FullImage tmp) { for (int i=0; i<H; i++) for (int j=0; j<W; j++) { float s = 0; for (int k=-n/2; k<=n/2; k++) s += img.unsafe_at(i,j-k); tmp.at(i,j) = s; } for (int i=0; i<H; i++) for (int j=0; j<W; j++) { float s = 0; for (int k=-n/2; k<=n/2; k++) s += tmp.unsafe_at(i-k,j); img.at(i,j) = s * (1.0f / (n*n)); } } template<int n> void max_filter(FullImage img, FullImage tmp) { for (int i=0; i<H; i++) for (int j=0; j<W; j++) { float s = -9e99; for (int k=-n/2; k<=n/2; k++) s = max(s, img.unsafe_at(i,j-k)); tmp.at(i,j) = s; } for (int i=0; i<H; i++) for (int j=0; j<W; j++) { float s = -9e99; for (int k=-n/2; k<=n/2; k++) s = max(s, tmp.unsafe_at(i-k,j)); img.at(i,j) = s; } } SeparableKernel<blur_n> gauss_kernel = make_gaussian<blur_n>(blur_radius); float fast_invsqrt(float x) { union { float f; uint32_t i; } u; u.f = x; u.i = 0x5f3759df - u.i/2; float y = u.f; return y * (1.5f - 0.5f * x * y * y); } void computeFiltered(Series* series, FullImageSet tstar, FullImage dark, FullImageSet mov, FullImageSet z) { FullImage dark_blur; FullImage dark_lowpass; FullImage w; FullImage tmp; FullImage frame_lowpass; float sigma_base = 29; float filtered_sigma_base = sigma_base / (blur_radius * sqrt(4*PI)); float dark_uncertainty_for_lowpass = .2; float dark_uncertainty = .4; float star_uncertainty = .055; const int B = 9; for (int i=0; i<H; i++) for (int j=0; j<W; j++) { w.at(i,j) = fast_invsqrt(sqr(sigma_base) + sqr(dark.at(i,j))); dark_lowpass.at(i,j) = dark.at(i,j) * w.at(i,j); } box_filter<B>(dark_lowpass, tmp); box_filter<B>(w, tmp); for (int i=0; i<H; i++) for (int j=0; j<W; j++) { float low = dark_lowpass.at(i,j) / w.at(i,j); dark.at(i,j) -= low; dark_lowpass.at(i,j) = low; } convolve<blur_n>(dark, dark_blur, tmp, gauss_kernel); for (int f=0; f<FRAMES; f++) { for (int i=0; i<H; i++) { mov[f].at(i,1190) = 0.5f*(mov[f].at(i,1189) + mov[f].at(i,1191)); } for (int i=0; i<H; i++) for (int j=0; j<W; j++) { if (mov[f].at(i,j)!=mov[f].at(i,j)) { w.at(i,j) = 0; frame_lowpass.at(i,j) = 0; } else { w.at(i,j) = fast_invsqrt(sqr(sigma_base) + sqr(dark_uncertainty_for_lowpass) * sqr(dark_blur.at(i,j)) + sqr(mov[f].at(i,j))); frame_lowpass.at(i,j) = mov[f].at(i,j) * w.at(i,j); } } box_filter<B>(frame_lowpass, tmp); box_filter<B>(w, tmp); for (int i=0; i<H; i++) for (int j=0; j<W; j++) { float low = frame_lowpass.at(i,j) / w.at(i,j); mov[f].at(i,j) -= low; frame_lowpass.at(i,j) = low; } convolve<blur_n>(mov[f], mov[f], tmp, gauss_kernel); max_filter<3>(tstar[f], tmp); convolve<blur_n>(tstar[f], tstar[f], tmp, gauss_kernel); for (int i=0; i<H; i++) for (int j=0; j<W; j++) { float sigma2 = sqr(filtered_sigma_base) + sqr(star_uncertainty) * sqr(tstar[f].at(i,j)) + sqr(dark_uncertainty) * sqr(dark.at(i,j)); z[f].at(i,j) = mov[f].at(i,j) * fast_invsqrt(sigma2); tmp.at(i,j) = z[f].at(i,j) >= -3.5; } box_filter<5>(tmp, w); for (int i=0; i<H; i++) for (int j=0; j<W; j++) { z[f].at(i,j) = tmp.at(i,j)!=1.f ? 0 : z[f].at(i,j); z[f].at(i,j) *= STANDARD_QUAL_FACTOR; } } } VF extractFeatures(Detection &detection, Series *series, FullImageSet &Z2) { //Reserved Features (not used in actual prediction) VF rv; rv.PB(0); rv.PB(0); rv.PB(0); REP(i, 4) { Vec2 ra_dec = series->darkToSphere[i](series->starToDark[i](detection.yx(i))); rv.PB(ra_dec[0]); rv.PB(ra_dec[1]); } //Actual Features float v1[4] = {0}; float v3[4] = {0}; REP(i, 4) { Vec2 offset = series->starToDark[i](detection.yx0); v1[i] = Z2[i].atf(offset[0] + detection.dyx[0] * i, offset[1] + detection.dyx[1] * i); FOR(dx, -1, 2) FOR(dy, -1, 2) v3[i] += Z2[i].atf(offset[0] + detection.dyx[0] * i + dx, offset[1] + detection.dyx[1] * i + dy); } sort(v1, v1 + 4); sort(v3, v3 + 4); rv.PB(v1[0]); rv.PB(v1[1]); rv.PB(v1[2]); rv.PB(v1[3]); rv.PB(v1[3] - v1[0]); rv.PB(v1[3] - v1[2]); rv.PB(v1[2] - v1[1]); rv.PB(v1[1] - v1[0]); rv.PB(v1[0] * 4 + v1[1] * 2 + v1[2]); rv.PB(v1[0] * 10 + v1[1] * 5 + v1[2] * 3 + v1[3]); rv.PB(v3[0]); rv.PB(v3[1]); rv.PB(v3[2]); rv.PB(v3[3]); rv.PB(v3[3] - v3[0]); rv.PB(v3[3] - v3[2]); rv.PB(v3[2] - v3[1]); rv.PB(v3[1] - v3[0]); rv.PB(v3[0] * 4 + v3[1] * 2 + v3[2]); rv.PB(v3[0] * 10 + v3[1] * 5 + v3[2] * 3 + v3[3]); if (CFG_FEATURES_USE_POSITION) { double sx = 0, sy = 0; REP(i, 4) { Vec2 ra_dec = series->darkToSphere[i](series->starToDark[i](detection.yx(i))); sx += ra_dec[0]; sy += ra_dec[1]; } rv.PB(sx); rv.PB(sy); } if (CFG_FEATURES_USE_SPEED) { rv.PB(norm2(detection.dyx)); rv.PB(norm2(detection.dyx) / sqr(series->time_delta)); } if (CFG_FEATURES_USE_DIRECTION) { rv.PB(atan2(detection.dyx[0], detection.dyx[1])); rv.PB(detection.dyx[0] / sqr(series->time_delta)); rv.PB(detection.dyx[1] / sqr(series->time_delta)); } return rv; } VVF extractAllFeatures(Series* series, FullImageSet frames) { double startTime = getTime(); FullImageSet z; computeUnglow(series, frames); // cerr << "Time Passed Unglow: " << (getTime() - startTime) << endl; FullImage star, dark; FullImageSet mov; FullImageSet tstar; computeLayers(series, frames, star, dark, tstar, mov); // cerr << "Time Passed Layers: " << (getTime() - startTime) << endl; computeFiltered(series, tstar, dark, mov, z); // cerr << "Time Passed Filtered: " << (getTime() - startTime) << endl; FullImageSet Z2; vector<Detection> detections = detectBright(series, z, Z2); // cerr << "Time Passed Bright: " << (getTime() - startTime) << endl; VVF rv; for (auto &detection : detections) rv.PB(extractFeatures(detection, series, Z2)); return rv; } class InputSession { protected: bool isTrainingMode; int numberOfSeriesRead; public: const int expectedNumberOfSeries; InputSession(int expectedNumberOfSeries): isTrainingMode(true), numberOfSeriesRead(0), expectedNumberOfSeries(expectedNumberOfSeries) {} bool finished() { return numberOfSeriesRead == expectedNumberOfSeries; } Series* readSeries(FullImageSet& frame_data) { Series* series = new Series(); //TODO: memory leak? int height, width; int dummy; if (!isTrainingMode) cin >> series->id; else series->id = "<invalid>"; cin >> width >> height; if (cin.eof()) { cerr << "premature end of file" << endl; std::exit(1); } for (int f=0; f<FRAMES; f++) { for (int i=0; i<H; i++) for (int j=0; j<W; j++) { int val; cin >> val; frame_data[f].at(i,j) = val; } int headerSize; cin >> headerSize; std::string line; std::getline(cin, line); for (int i=0; i<headerSize; i++) { std::getline(cin, line); series->frame_head[f].add_line(line); } for (int i=0; i<8; i++) std::getline(cin, line); } if (isTrainingMode) { int nDetections; cin >> nDetections; std::string line; std::getline(cin, line); for (int i=0; i<nDetections; i++) std::getline(cin, line); } if (cin.fail()) cerr << "WARNING: failure in cin!" << endl; if (isTrainingMode) { cout << 1 << endl; isTrainingMode = false; delete series; return readSeries(frame_data); } else { cout << "dummy" << endl; numberOfSeriesRead++; series->setup(); return series; } } }; static bool initialized = false; static vector<Detection> detections; VVF trainFeatures; VVF testFeatures; VF trainResults; struct AsteroidDetector { AsteroidDetector() { t0 = getTime(); } VC<VC<PDD>> convertDetections(VS &v) { VC<VC<PDD>> rv; VC<PDD> current; for (string s : v) { VS vs = splt(s, ' '); double ra = atof(vs[2].c_str()); double dec = atof(vs[3].c_str()); current.PB(MP(ra, dec)); if (current.SZ == 4) { rv.PB(current); current.clear(); } } return rv; } double resultsDistance(VC<PDD> &v1, VC<PDD> &v2) { if (v1[0].X > v2[0].X + 0.1 || v1[0].X < v2[0].X - 0.1 || v1[0].Y > v2[0].Y + 0.1 || v1[0].Y < v2[0].Y - 0.1) return 1e9; double rv = 0; REP(i, 4) rv += (v1[i].X - v2[i].X) * (v1[i].X - v2[i].X) + (v1[i].Y - v2[i].Y) * (v1[i].Y - v2[i].Y); return rv; } double resultsDistance(VF &v1, VF &v2) { if (v1[3] > v2[3] + 0.1 || v1[3] < v2[3] - 0.1 || v1[4] > v2[4] + 0.1 || v1[4] < v2[4] - 0.1) return 1e9; double rv = 0; FOR(i, 3, 11) rv += (v1[i] - v2[i]) * (v1[i] - v2[i]); return rv; } double resultsDistance(VF &v1, VC<PDD> &v2) { if (v1[3] > v2[0].X + 0.1 || v1[3] < v2[0].X - 0.1 || v1[4] > v2[0].Y + 0.1 || v1[4] < v2[0].Y - 0.1) return 1e9; double rv = 0; REP(i, 4) rv += (v1[i*2+3] - v2[i].X) * (v1[i*2+3] - v2[i].X) + (v1[i*2+4] - v2[i].Y) * (v1[i*2+4] - v2[i].Y); return rv; } int trainCall = 0; int testCall = 0; int trainingData(int width, int height, vector<int> data0, vector<string> head0, vector<double> wcs0, vector<int> data1, vector<string> head1, vector<double> wcs1, vector<int> data2, vector<string> head2, vector<double> wcs2, vector<int> data3, vector<string> head3, vector<double> wcs3, vector<string> detections) { DB(trainCall); cerr << "AsteroidDetector: time = " << getTime() - t0 << endl; FullImageSet frames; Series* series = new Series(); //TODO: memory leak? series->id = "training"; assert(width == W); assert(height == H); vector<int>* pData[FRAMES] = { &data0, &data1, &data2, &data3 }; vector<string>* pHead[FRAMES] = { &head0, &head1, &head2, &head3 }; for (int f=0; f<FRAMES; f++) { for (int i=0; i<H; i++) for (int j=0; j<W; j++) { frames[f].at(i,j) = (*pData[f])[i*W + j]; } for (string line : *pHead[f]) { series->frame_head[f].add_line(line); } } series->setup(); // cerr << "frontend: Got series " << series->id << endl; const double TRAIN_CORRECT_DISTANCE = 0.0001; VC<VC<PDD>> correct = convertDetections(detections); VVF features = extractAllFeatures(series, frames); for (VF &v : features) { REP(i, correct.SZ) if (resultsDistance(v, correct[i]) < TRAIN_CORRECT_DISTANCE) { v[1] = 1; if (splt(detections[i * 4], ' ')[7] == "1") v[2] = 1; } trainFeatures.PB(v); } trainCall++; return 0; // return trainCall >= 80 ? 1 : 0; // return 1; } VS testIDs; int testingData(string id, int width, int height, vector<int> data0, vector<string> head0, vector<double> wcs0, vector<int> data1, vector<string> head1, vector<double> wcs1, vector<int> data2, vector<string> head2, vector<double> wcs2, vector<int> data3, vector<string> head3, vector<double> wcs3) { DB(testCall); cerr << "AsteroidDetector: time = " << getTime() - t0 << endl; testIDs.PB(id); FullImageSet frames; Series* series = new Series(); //TODO: memory leak? series->id = id; assert(width == W); assert(height == H); vector<int>* pData[FRAMES] = { &data0, &data1, &data2, &data3 }; vector<string>* pHead[FRAMES] = { &head0, &head1, &head2, &head3 }; for (int f=0; f<FRAMES; f++) { for (int i=0; i<H; i++) for (int j=0; j<W; j++) { frames[f].at(i,j) = (*pData[f])[i*W + j]; } for (string line : *pHead[f]) { series->frame_head[f].add_line(line); } } series->setup(); VVF features = extractAllFeatures(series, frames); for (VF &v : features) { v[0] += testCall; testFeatures.PB(v); } testCall++; return 0; } string RFFolder; void saveRF() { if (RFFolder == "") { // not neccessary to save return; } VF trainResultsDetection; VF trainResultsNeo; for (VF v : trainFeatures) { trainResultsDetection.PB(v[1]); } DB(trainFeatures.SZ); double xtime = getTime(); double rftrainTimer = 0; double neotrainTimer = 0; RandomForestConfig cfg; RandomForest RFDetection; RandomForest RFNeo; cfg.featuresIgnored = 11; cfg.bagSize = 1.5; cfg.randomFeatures = {1, 2, 3, 4, 6, 8}; cfg.randomPositions = {4}; cfg.maxNodeSize = 15; const int TREES_NO = 1000; RFDetection.train(trainFeatures, trainResultsDetection, cfg, TREES_NO); rftrainTimer = getTime() - xtime; DB(RFDetection.countTotalNodes()); // Serialize ofstream ofs(RFFolder + "TrainedRF"); boost::archive::text_oarchive oa(ofs); oa << RFDetection; ofs.close(); /*xtime = getTime(); cfg.maxNodeSize = 50; RFNeo.train(trainFeatures, trainResultsNeo, cfg, TREESNEO_NO); neotrainTimer = getTime() - xtime; DB(RFNeo.countTotalNodes()); // Serialize ofstream neoOfs(RFFolder + "TrainedNeoRF"); boost::archive::text_oarchive neoOa(neoOfs); neoOa << RFNeo; neoOfs.close(); */ DB(rftrainTimer); DB(neotrainTimer); } int loadRF(RandomForest& RFDetection) { if (RFFolder.size() == 0) { return -1; } ifstream ifs(RFFolder + "TrainedRF"); if (ifs.good()) { // Trained RF is found, deserialize boost::archive::text_iarchive ia(ifs); ia >> RFDetection; DB(RFDetection.countTotalNodes()); } else { DBM("Failed to load the TrainedRF"); return -1; } ifs.close(); /*ifstream neoIfs(RFFolder + "TrainedNeoRF"); if (neoIfs.good()) { // Trained RF is found, deserialize boost::archive::text_iarchive ia(neoIfs); ia >> RFNeo; DB(RFNeo.countTotalNodes()); } else { DBM("Failed to load the TrainedNeoRF"); return -1; } neoIfs.close();*/ DBM("Success to load the RF data"); return 0; } vector<string> getAnswer() { cerr << "AsteroidDetector: time = " << getTime() - t0 << endl; double xtime; RandomForestConfig cfg; cfg.featuresIgnored = 11; cfg.bagSize = 1.5; cfg.randomFeatures = {1, 2, 3, 4, 6, 8}; cfg.randomPositions = {4}; cfg.maxNodeSize = 10; VF trainResults; for (VF v : trainFeatures) trainResults.PB(v[1]); int goodSamples = 0; for (VF v : trainFeatures) goodSamples += v[1] == 1; DB(goodSamples); DB(trainFeatures.SZ); DB(testFeatures.SZ); VC<pair<float,int>> vp; const int TREES_NO = 1000; RandomForest RF; int result = loadRF(RF); if (result != 0) { DBM("Failed to load the RF files. we use the train data on the fly"); xtime = getTime(); RF.train(trainFeatures, trainResults, cfg, TREES_NO); } DB(RF.countTotalNodes()); REP(i, testFeatures.SZ) { float v = RF.estimate(testFeatures[i]); vp.PB(MP(v, i)); } sort(vp.rbegin(), vp.rend()); DB(vp.SZ); //TODO: move duplication removal here // VC<unordered_map<int,VI>> choice(100); VS rv; REP(i, vp.SZ) { if (rv.SZ >= MAX_ALLOWED_DETECTIONS) break; int sampleID = vp[i].Y; float score = vp[i].X; int testID = ((int)testFeatures[sampleID][0]); string s = testIDs[testID]; char str[100]; FOR(j, 3, 11) { sprintf(str, " %.10f", testFeatures[sampleID][j]); s += str; } s += " 0"; sprintf(str, " %.10f", score); s += str; sprintf(str, " %.10f", (testFeatures[sampleID][21] + testFeatures[sampleID][22] + testFeatures[sampleID][23] + testFeatures[sampleID][24]) / 4); s += str; rv.PB(s); } DB(rv.SZ); cerr << "frontend: Finished, time = " << getTime()-t0 << endl; return rv; } vector<string> getAnswerNEO() { cerr << "AsteroidDetector: time = " << getTime() - t0 << endl; RandomForestConfig cfg; cfg.featuresIgnored = 11; cfg.bagSize = 1.5; cfg.randomFeatures = {1, 2, 3, 4, 6, 8}; cfg.randomPositions = {4}; cfg.maxNodeSize = 10; VF trainResults; for (VF v : trainFeatures) trainResults.PB(v[1]); int goodSamples = 0; for (VF v : trainFeatures) goodSamples += v[2] == 1; //This is the only place where the functions getAnswer() & getAnswerNEO() differ DB(goodSamples); DB(trainFeatures.SZ); DB(testFeatures.SZ); VC<pair<float,int>> vp; const int TREES_NO = 1000; if (trainFeatures.SZ) { RandomForest RF; RF.train(trainFeatures, trainResults, cfg, TREES_NO); DB(RF.countTotalNodes()); REP(i, testFeatures.SZ) { float v = RF.estimate(testFeatures[i]); vp.PB(MP(v, i)); } } else { //that's how original pfr solution worked REP(i, testFeatures.SZ) { float v = testFeatures[i][10] * 52 + testFeatures[i][11] * 8 + testFeatures[i][12]; vp.PB(MP(v, i)); } } sort(vp.rbegin(), vp.rend()); DB(vp.SZ); //TODO: move duplication removal here // VC<unordered_map<int,VI>> choice(100); VS rv; REP(i, vp.SZ) { if (rv.SZ >= MAX_ALLOWED_DETECTIONS) break; int sampleID = vp[i].Y; int testID = ((int)testFeatures[sampleID][0]); string s = testIDs[testID]; FOR(j, 3, 11) { char str[100]; sprintf(str, " %.10f", testFeatures[sampleID][j]); s += str; } s += " 0"; rv.PB(s); } DB(rv.SZ); cerr << "frontend: Finished, time = " << getTime()-t0 << endl; return rv; } };
27.534526
213
0.570264
d94d4d665123955a38fb06bdfc3d3146257e0381
18
cats
C
data/1/176714.cats
ks2002119/EmailAnalysis
ea7b7499794061f73ac8141694833acdf813bdb3
[ "Apache-2.0" ]
null
null
null
data/1/176714.cats
ks2002119/EmailAnalysis
ea7b7499794061f73ac8141694833acdf813bdb3
[ "Apache-2.0" ]
null
null
null
data/1/176714.cats
ks2002119/EmailAnalysis
ea7b7499794061f73ac8141694833acdf813bdb3
[ "Apache-2.0" ]
null
null
null
1,1,2 3,8,2 4,6,2
4.5
5
0.5
d94e0d829a19fe963a33b3cc57a73167cb93c51c
1,979
h
C
chrome/browser/extensions/api/content_settings/content_settings_helpers.h
tmpsantos/chromium
802d4aeeb33af25c01ee5994037bbf14086d4ac0
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/extensions/api/content_settings/content_settings_helpers.h
tmpsantos/chromium
802d4aeeb33af25c01ee5994037bbf14086d4ac0
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/extensions/api/content_settings/content_settings_helpers.h
tmpsantos/chromium
802d4aeeb33af25c01ee5994037bbf14086d4ac0
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_HELPERS_H__ #define CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_HELPERS_H__ #include <string> #include "chrome/common/content_settings.h" #include "components/content_settings/core/common/content_settings_pattern.h" #include "components/content_settings/core/common/content_settings_types.h" namespace extensions { namespace content_settings_helpers { // Parses an extension match pattern and returns a corresponding // content settings pattern object. // If |pattern_str| is invalid or can't be converted to a content settings // pattern, |error| is set to the parsing error and an invalid pattern // is returned. ContentSettingsPattern ParseExtensionPattern(const std::string& pattern_str, std::string* error); // Converts a content settings type string to the corresponding // ContentSettingsType. Returns CONTENT_SETTINGS_TYPE_DEFAULT if the string // didn't specify a valid content settings type. ContentSettingsType StringToContentSettingsType( const std::string& content_type); // Returns a string representation of a ContentSettingsType. const char* ContentSettingsTypeToString(ContentSettingsType type); // Converts a content setting string to the corresponding ContentSetting. // Returns true if |setting_str| specifies a valid content setting, // false otherwise. bool StringToContentSetting(const std::string& setting_str, ContentSetting* setting); // Returns a string representation of a ContentSetting. const char* ContentSettingToString(ContentSetting setting); } // namespace content_settings_helpers } // namespace extensions #endif // CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_HELPERS_H__
43.977778
86
0.793835
d94e4922b8b6c54430bc5c1e0116a4397026d485
868
c
C
minihv/vga.c
denisvieriu/Bare-Metal-Lightweight-Hypervisor
1ab83cc8a11eee4fa72a609dbe1efc8ad6001ced
[ "MIT" ]
7
2018-06-02T01:22:23.000Z
2022-02-02T07:55:49.000Z
minihv/vga.c
denisvieriu/Bare-Metal-Lightweight-Hypervisor
1ab83cc8a11eee4fa72a609dbe1efc8ad6001ced
[ "MIT" ]
null
null
null
minihv/vga.c
denisvieriu/Bare-Metal-Lightweight-Hypervisor
1ab83cc8a11eee4fa72a609dbe1efc8ad6001ced
[ "MIT" ]
3
2018-12-15T07:30:03.000Z
2020-09-21T23:46:05.000Z
#include "vga.h" extern BYTE x; extern BYTE y; extern PWORD video; VOID VgaTextInit() { VgaTextClear(); VgaTextSetCursor(0); } VOID VgaTextClear() { BYTE attributeByte; WORD attribute; WORD idx; attributeByte = (0 << 4) | (15 & 0x0F); attribute = 0x20 | (attributeByte << 8); // 0x20 - space character for (idx = 0; idx < 80 * 25; idx++) { video[idx] = attribute; } x = 0; y = 0; VgaTextSetCursor(0); } VOID VgaTextSetCursor(WORD cursorLocation) { __outbyte(0x3D4, 14); // Tell the VGA board we are setting the high cursor byte. __outbyte(0x3D5, cursorLocation >> 8); // Send the high cursor byte. __outbyte(0x3D4, 15); // Tell the VGA board we are setting the low cursor byte. __outbyte(0x3D5, cursorLocation); // Send the low cursor byte. }
20.666667
101
0.601382
d94eac694c6a136ebafb1a8e1d68b534b1b6dce7
7,898
h
C
src/ui_about.h
ARRUKIDDINGME/WalkThePlank
11015c574b274198f42b145aa7e167b8434b4486
[ "MIT" ]
null
null
null
src/ui_about.h
ARRUKIDDINGME/WalkThePlank
11015c574b274198f42b145aa7e167b8434b4486
[ "MIT" ]
null
null
null
src/ui_about.h
ARRUKIDDINGME/WalkThePlank
11015c574b274198f42b145aa7e167b8434b4486
[ "MIT" ]
null
null
null
/******************************************************************************** ** Form generated from reading UI file 'about.ui' ** ** Created by: Qt User Interface Compiler version 5.9.5 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_ABOUT_H #define UI_ABOUT_H #include <QtCore/QVariant> #include <QtWidgets/QAction> #include <QtWidgets/QApplication> #include <QtWidgets/QButtonGroup> #include <QtWidgets/QDialog> #include <QtWidgets/QDialogButtonBox> #include <QtWidgets/QGroupBox> #include <QtWidgets/QHeaderView> #include <QtWidgets/QLabel> #include <QtWidgets/QScrollArea> #include <QtWidgets/QVBoxLayout> #include <QtWidgets/QWidget> QT_BEGIN_NAMESPACE class Ui_about { public: QVBoxLayout *verticalLayout; QGroupBox *groupBox; QVBoxLayout *verticalLayout_2; QLabel *versionLabel; QScrollArea *scrollArea; QWidget *scrollAreaWidgetContents; QVBoxLayout *verticalLayout_3; QLabel *label; QDialogButtonBox *buttonBox; void setupUi(QDialog *about) { if (about->objectName().isEmpty()) about->setObjectName(QStringLiteral("about")); about->resize(497, 448); verticalLayout = new QVBoxLayout(about); verticalLayout->setObjectName(QStringLiteral("verticalLayout")); groupBox = new QGroupBox(about); groupBox->setObjectName(QStringLiteral("groupBox")); groupBox->setTitle(QStringLiteral("WalkThePlank")); verticalLayout_2 = new QVBoxLayout(groupBox); verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2")); versionLabel = new QLabel(groupBox); versionLabel->setObjectName(QStringLiteral("versionLabel")); versionLabel->setText(QStringLiteral("Version")); verticalLayout_2->addWidget(versionLabel); verticalLayout->addWidget(groupBox); scrollArea = new QScrollArea(about); scrollArea->setObjectName(QStringLiteral("scrollArea")); scrollArea->setWidgetResizable(true); scrollAreaWidgetContents = new QWidget(); scrollAreaWidgetContents->setObjectName(QStringLiteral("scrollAreaWidgetContents")); scrollAreaWidgetContents->setGeometry(QRect(0, 0, 463, 517)); verticalLayout_3 = new QVBoxLayout(scrollAreaWidgetContents); verticalLayout_3->setObjectName(QStringLiteral("verticalLayout_3")); label = new QLabel(scrollAreaWidgetContents); label->setObjectName(QStringLiteral("label")); label->setText(QString::fromUtf8("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.1pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:'Ubuntu'; font-size:11pt;\">Copyright (c) 2019 Duke Leto, David Mercer and Aditya Kulkarni. (MIT License)</span></p>\n" "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;\"><br /></p>\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:'Ubuntu'; font-size:11pt;\">Special thanks to:</span></p>\n" "<p s" "tyle=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:'Ubuntu'; font-size:11pt;\">JSON for Modern C++ : </span><a href=\"https://nlohmann.github.io/json/\"><span style=\" font-size:8pt; text-decoration: underline; color:#0000ff;\">https://nlohmann.github.io/json/</span></a></p>\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:'Ubuntu'; font-size:11pt;\">QR Code generator library Nayuki : </span><a href=\"https://www.nayuki.io/page/qr-code-generator-library\"><span style=\" font-size:8pt; text-decoration: underline; color:#0000ff;\">https://www.nayuki.io/page/qr-code-ge\342\200\246</span></a></p>\n" "<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:'Ubuntu'; font-size:11pt;\">Made with QT : </span><a href=\"https://www.q" "t.io/\"><span style=\" font-size:8pt; text-decoration: underline; color:#0000ff;\">https://www.qt.io/</span></a></p>\n" "<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:'Ubuntu'; font-size:11pt;\">LICENSE:</span></p>\n" "<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:'Ubuntu'; font-size:11pt;\">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &quot;Software&quot;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</span></p>\n" "<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px;" " margin-right: 0px; -qt-list-indent: 1;\"><li style=\" font-family:'Ubuntu'; font-size:11pt;\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</li>\n" "<li style=\" font-family:'Ubuntu'; font-size:11pt;\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The Software is provided &quot;as is&quot;, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.</li></ul></body></html>")); label->setWordWrap(true); label->setOpenExternalLinks(true); label->setTextInteractionFlags(Qt::LinksAccessibleByMouse); verticalLayout_3->addWidget(label); scrollArea->setWidget(scrollAreaWidgetContents); verticalLayout->addWidget(scrollArea); buttonBox = new QDialogButtonBox(about); buttonBox->setObjectName(QStringLiteral("buttonBox")); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Ok); verticalLayout->addWidget(buttonBox); retranslateUi(about); QObject::connect(buttonBox, SIGNAL(accepted()), about, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(rejected()), about, SLOT(reject())); QMetaObject::connectSlotsByName(about); } // setupUi void retranslateUi(QDialog *about) { about->setWindowTitle(QApplication::translate("about", "About", Q_NULLPTR)); } // retranslateUi }; namespace Ui { class about: public Ui_about {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_ABOUT_H
62.188976
672
0.689542
d94fa57aca9b80d7cadd1933aa6ffe349b166f67
1,356
h
C
include/influxdb.h
cortoproject/driver-fmt-influxdb
7cdbd93af4bbc37bcf1444803d02e33f1fec77bb
[ "MIT" ]
null
null
null
include/influxdb.h
cortoproject/driver-fmt-influxdb
7cdbd93af4bbc37bcf1444803d02e33f1fec77bb
[ "MIT" ]
null
null
null
include/influxdb.h
cortoproject/driver-fmt-influxdb
7cdbd93af4bbc37bcf1444803d02e33f1fec77bb
[ "MIT" ]
null
null
null
/* influxdb.h * This is the main package file. Include this file in other projects. * Only modify inside the header-end and body-end sections. */ #ifndef DRIVER_FMT_INFLUXDB_H #define DRIVER_FMT_INFLUXDB_H #include <driver/fmt/influxdb/_project.h> #include <tags/c/c.h> #include <corto/c/c.h> #include <tags/tags.h> /* $header() */ #ifdef __cplusplus extern "C" { #endif /* Implements the line protocol used by InfluxDb */ corto_string influxdb_fromValue( corto_fmt_opt* opt, corto_value *v); /* Stub: line protocol is only used to store data in InfluxDb so this function * will never be used. */ corto_int16 influxdb_toValue( corto_fmt_opt* opt, corto_value *v, corto_string data); corto_int16 influxdb_toObject( corto_fmt_opt* opt, corto_object* o, char *s); corto_string influxdb_fromObject( corto_fmt_opt* opt, corto_object o); corto_word influxdb_fromResult( corto_fmt_opt* opt, corto_record *r); corto_int16 influxdb_toResult( corto_fmt_opt* opt, corto_record *r, char *influx); void influxdb_release( char *data); corto_string influxdb_copy( char *data); void influxdb_safeString( corto_buffer *b, corto_string source); #ifdef __cplusplus } #endif /* $end */ /* $body() */ /* Definitions here that need your package headers go here. */ /* $end */ #endif
19.652174
78
0.710914
d950cfcf12945bd2156d52aa3f2bb413051dd0e4
5,218
c
C
src/artwork.c
MichaelMCE/VLCStream
6d08698f963d88e796ccc33e2d085490fc560a5d
[ "Xnet", "X11" ]
null
null
null
src/artwork.c
MichaelMCE/VLCStream
6d08698f963d88e796ccc33e2d085490fc560a5d
[ "Xnet", "X11" ]
null
null
null
src/artwork.c
MichaelMCE/VLCStream
6d08698f963d88e796ccc33e2d085490fc560a5d
[ "Xnet", "X11" ]
null
null
null
// libmylcd - http://mylcd.sourceforge.net/ // An LCD framebuffer library // Michael McElligott // okio@users.sourceforge.net // Copyright (c) 2005-2009 Michael McElligott // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU LIBRARY GENERAL PUBLIC LICENSE for more details. // // You should have received a copy of the GNU Library General Public // License along with this library; if not, write to the Free // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #if 0 #include "common.h" // see vlceventcb.c extern volatile int SHUTDOWN; static inline int artworkIsValid8 (const char *path) { if (!path || !*path) return 0; int ret = 0; if (!strncmp(path, "file:///", 8)){ char *out = decodeURI(path, strlen(path)); if (out){ ret = doesFileExistUtf8(out); my_free(out); } } return ret; } #if 0 int artworkLoad (TVLCPLAYER *vp, TTAGIMG *art, const wchar_t *path) { if (art->aimg[0].image) return 2; if (!doesFileExistW(path)) return 0; //int tid = (int)GetCurrentThreadId(); //float t0 = getTime(vp); //printf("loadArt %i\n", tid); //wprintf(L"loadart %x '%s'\n", art->hash, path); int ret = 0; TFRAME *newImg = newImage(vp, path, LFRM_BPP_32A); if (newImg){ int w, h; imageBestFit(vp->gui.artMaxWidth, vp->gui.artMaxHeight, newImg->width, newImg->height, &w, &h); TFRAME *img = lNewFrame(vp->ml->hw, w, h, LFRM_BPP_32); if (img){ //copyAreaScaled(newImg, img, 0, 0, newImg->width, newImg->height, 0, 0, w, h); // slower transScale(newImg, img, w, h, 0, 0, SCALE_BILINEAR); // faster art->aimg[0].image = img; art->aimg[0].scale = 1.000; art->aimg[0].swidth = img->width; art->aimg[0].sheight = img->height; art->timeAdded = getTickCount(); art->enabled = 1; ret = 1; //float t1 = getTime(vp)-t0; //printf("loadArt %i Exit %.2f\n", tid, t1); //printf("loadArt %i Exit\n", tid); } lDeleteFrame(newImg); } //float t1 = getTime(vp)-t0; //printf("loadArt %i Exit %.2f\n", tid, t1); //printf("loadArt %i Exit\n", tid); return ret; } #endif void artworkEvent_MediaParsedChanged (art_work *aw, art_job *aj, job_detail *jd) { int art = 0; char url[MAX_PATH_UTF8+1]; tagRetrieveByHash(jd->tagc, jd->hash, MTAG_ArtworkURL, url, MAX_PATH_UTF8); if (*url) art = artworkIsValid8(url); if (!*url || !art){ char *artmrl = libvlc_media_get_meta(jd->m, MTAG_ArtworkURL); if (artmrl){ if (!strncmp(artmrl, "file:", 5)){ artJobTimeSet(aj, getTickCount() + 500); // got an mrl, let VLC process media before attempting read tagAddByHash(jd->tagc, jd->path, jd->hash, MTAG_ArtworkURL, artmrl, 1); artWorkSignalReady(aw); } libvlc_free(artmrl); } } } void artwork_EventCB (const libvlc_event_t *event, void *udata) { if (SHUTDOWN) return; job_thread *jt = libvlc_media_get_user_data(event->p_obj); if (!jt) return; art_work *aw = artThreadGetWork(jt); if (!aw) return; const int juid = (int)udata; art_job *aj = artJobFind(aw, juid); if (!aj) return; //printf("%s: %i %p %p\n", vlc_EventTypeToName(event->type), juid, aw, aj); if (event->type == libvlc_MediaParsedChanged) artworkEvent_MediaParsedChanged(aw, aj, &aj->detail); } libvlc_media_t *artworkCreateMediaInstance (libvlc_instance_t *hLib, const char *path, void *udata) { libvlc_media_t *m = libvlc_media_new_path(hLib, path); if (m){ libvlc_media_set_user_data(m, udata); libvlc_media_add_option(m, "no-audio"); libvlc_media_add_option(m, "no-video"); libvlc_media_add_option(m, "album-art=2"); //libvlc_media_add_option(m, "ignore-config"); return m; } return NULL; } void vlcEventGetArt (libvlc_instance_t *hLib, job_controller *jc, TARTMANAGER *am, const char *path, const int hash, const TMETACOMPLETIONCB *mccb, const unsigned int uid, const int position) { if (!artThreadLockWait(jt)) return; if (artDetailFind(artThreadGetWork(jt), hash)){ //printf("vlcEvent GetArt found, quiting %X\n", hash); artThreadLockRelease(jt); return; } job_detail jd; memset(&jd, 0, sizeof(job_detail)); char url[MAX_PATH_UTF8+1]; tagRetrieveByHash(tagc, hash, MTAG_ArtworkURL, url, MAX_PATH_UTF8); if (!*url) jd.m = artworkCreateMediaInstance(hLib, path, jt); jd.tagc = tagc; jd.pageSource = 0; jd.hash = hash; jd.path = my_strdup(path); jd.playlistUID = uid; jd.trackPosition = position; jd.mccb = mccbDup(mccb); art_job *aj = jobDetailAttach(artThreadGetWork(jt), &jd); if (jd.m){ jd.em = libvlc_media_event_manager(jd.m); libvlc_event_attach(jd.em, libvlc_MediaParsedChanged, artwork_EventCB, (void*)aj->jobId); libvlc_media_parse_async(jd.m); char *tag = libvlc_media_get_meta(jd.m, MTAG_ArtworkURL); if (tag) libvlc_free(tag); } artWorkSignalReady(artThreadGetWork(jt)); artThreadLockRelease(jt); } #endif
26.48731
191
0.687428
d950f1f9b4504ade38f8d51de3641576440f2634
124
h
C
bsp/bluetrum/libcpu/cpu/interrupt.h
BreederBai/rt-thread
53ed0314982556dfa9c5db75d4f3e02485d16ab5
[ "Apache-2.0" ]
7,482
2015-01-01T09:23:08.000Z
2022-03-31T19:34:05.000Z
bsp/bluetrum/libcpu/cpu/interrupt.h
ArdaFu/rt-thread
eebb2561ec166e0016187c7b7998ada4f8212b3a
[ "Apache-2.0" ]
2,543
2015-01-09T02:01:34.000Z
2022-03-31T23:10:14.000Z
bsp/bluetrum/libcpu/cpu/interrupt.h
ArdaFu/rt-thread
eebb2561ec166e0016187c7b7998ada4f8212b3a
[ "Apache-2.0" ]
4,645
2015-01-06T07:05:31.000Z
2022-03-31T18:21:50.000Z
#ifndef INTERRUPT_H__ #define INTERRUPT_H__ void rt_hw_irq_enable(int vector); void rt_hw_irq_disable(int vector); #endif
15.5
35
0.822581
d951bfb053d23c54a4e574a8a564b8f0103e646f
1,262
h
C
src/controller/search/SearchController.h
kilel/DGraphMark
e88418340b303434ccc75cd4079115e8d42fbeb5
[ "Apache-2.0" ]
1
2016-06-17T20:19:34.000Z
2016-06-17T20:19:34.000Z
src/controller/search/SearchController.h
kilel/DGraphMark
e88418340b303434ccc75cd4079115e8d42fbeb5
[ "Apache-2.0" ]
null
null
null
src/controller/search/SearchController.h
kilel/DGraphMark
e88418340b303434ccc75cd4079115e8d42fbeb5
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2014 Kislitsyn Ilya * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SEARCHCONTROLLER_H #define SEARCHCONTROLLER_H #include "../Controller.h" #include "../../task/search/SearchTask.h" #include "../../generator/GraphGenerator.h" namespace dgmark { class SearchController : public Controller { public: SearchController(Intracomm *comm, int argc, char **argv); SearchController(const SearchController& orig); virtual ~SearchController(); virtual void run(vector<Task*> *tasks); virtual void clean(vector<Task*> *tasks); protected: virtual string getSpecificStatistics(); private: GraphGenerator *generator; GraphGenerator* createGenerator(); }; } #endif /* SEARCHCONTROLLER_H */
28.044444
77
0.727417
d9523f5c3b300014317fa0243df771a64ec4ee36
5,279
h
C
elfloader-tool/include/binaries/efi/efi.h
maybe-sybr/seL4_tools
14918280911366d08454bd495916b686e94dbb3a
[ "BSD-2-Clause" ]
null
null
null
elfloader-tool/include/binaries/efi/efi.h
maybe-sybr/seL4_tools
14918280911366d08454bd495916b686e94dbb3a
[ "BSD-2-Clause" ]
null
null
null
elfloader-tool/include/binaries/efi/efi.h
maybe-sybr/seL4_tools
14918280911366d08454bd495916b686e94dbb3a
[ "BSD-2-Clause" ]
null
null
null
/* * Copyright 2017, Data61 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) * ABN 41 687 119 230. * * This software may be distributed and modified according to the terms of * the GNU General Public License version 2. Note that NO WARRANTY is provided. * See "LICENSE_GPLv2.txt" for details. * * @TAG(DATA61_GPL) */ #pragma once #include <printf.h> #include <types.h> typedef union { uint8_t b[16]; struct { uint32_t timeLow; uint16_t timeMid; uint16_t timeHigh; uint8_t clockSeqHighAndReserved; uint8_t clockSeqLow; uint8_t node[6]; } s; } efi_guid_t; /* See UEFI Spec v2.7 Appendix A "GUID and Time Formats". */ static inline efi_guid_t make_efi_guid(uint32_t timeLow, uint16_t timeMid, uint16_t timeHighAndVersion, uint8_t clockSeqHighAndReserved, uint8_t clockSeqLow, uint8_t n0, uint8_t n1, uint8_t n2, uint8_t n3, uint8_t n4, uint8_t n5) { efi_guid_t u; u.s.timeLow = timeLow; u.s.timeMid = timeMid; u.s.timeHigh = timeHighAndVersion; u.s.clockSeqHighAndReserved = clockSeqHighAndReserved; u.s.clockSeqLow = clockSeqLow; u.s.node[0] = n0; u.s.node[1] = n1; u.s.node[2] = n2; u.s.node[3] = n3; u.s.node[4] = n4; u.s.node[5] = n5; return u; } typedef struct { efi_guid_t guid; uintptr_t table; } efi_config_table_t; typedef struct { uint64_t signature; uint32_t revision; uint32_t headersize; uint32_t crc32; uint32_t reserved; } efi_table_hdr_t; typedef struct { efi_table_hdr_t hdr; void *fw_vendor; uint32_t fw_revision; /* padding on 64-bit */ void *con_in_handle; void *con_in; void *con_out_handle; void *con_out; void *stderr_handle; void *stderr; void *runtime; void *boottime; uint32_t nr_tables; /* padding on 64-bit */ void *tables; } efi_system_table_t; extern void *__application_handle; extern efi_system_table_t *__efi_system_table; #define EFI_SUCCESS 0 #define EFI_LOAD_ERROR (1 | (1UL << ((BYTE_PER_WORD * 8) - 1))) #define EFI_BUFFER_TOO_SMALL (5 | (1UL << ((BYTE_PER_WORD * 8) - 1))) /* EFI Memory types: */ #define EFI_RESERVED_TYPE 0 #define EFI_LOADER_CODE 1 #define EFI_LOADER_DATA 2 #define EFI_BOOT_SERVICES_CODE 3 #define EFI_BOOT_SERVICES_DATA 4 #define EFI_RUNTIME_SERVICES_CODE 5 #define EFI_RUNTIME_SERVICES_DATA 6 #define EFI_CONVENTIONAL_MEMORY 7 #define EFI_UNUSABLE_MEMORY 8 #define EFI_ACPI_RECLAIM_MEMORY 9 #define EFI_ACPI_MEMORY_NVS 10 #define EFI_MEMORY_MAPPED_IO 11 #define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12 #define EFI_PAL_CODE 13 #define EFI_PERSISTENT_MEMORY 14 #define EFI_MAX_MEMORY_TYPE 15 /* Attribute values: */ #define EFI_MEMORY_UC ((uint64_t)0x1ULL) /* uncached */ #define EFI_MEMORY_WC ((uint64_t)0x2ULL) /* write-coalescing */ #define EFI_MEMORY_WT ((uint64_t)0x4ULL) /* write-through */ #define EFI_MEMORY_WB ((uint64_t)0x8ULL) /* write-back */ #define EFI_MEMORY_UCE ((uint64_t)0x10ULL) /* uncached, exported */ #define EFI_MEMORY_WP ((uint64_t)0x1000ULL) /* write-protect */ #define EFI_MEMORY_RP ((uint64_t)0x2000ULL) /* read-protect */ #define EFI_MEMORY_XP ((uint64_t)0x4000ULL) /* execute-protect */ #define EFI_MEMORY_MORE_RELIABLE ((uint64_t)0x10000ULL) /* higher reliability */ #define EFI_MEMORY_RO ((uint64_t)0x20000ULL) /* read-only */ #define EFI_MEMORY_RUNTIME ((uint64_t)0x8000000000000000ULL) /* range requires runtime mapping */ #define EFI_MEMORY_DESCRIPTOR_VERSION 1 #define EFI_PAGE_BITS 12 #define EFI_PAGE_SIZE (1UL << EFI_PAGE_BITS) typedef struct { uint32_t type; uint32_t padding_1; uint64_t phys_addr; uint64_t virt_addr; uint64_t num_pages; uint64_t attribute; } efi_memory_desc_t; typedef struct { efi_table_hdr_t hdr; uintptr_t padding_1[4]; unsigned long (*get_memory_map)(unsigned long *, void *, unsigned long *, unsigned long *, uint32_t *); unsigned long (*allocate_pool)(int, unsigned long, void **); unsigned long (*free_pool)(void *); uintptr_t padding_2[19]; unsigned long (*exit_boot_services)(void *, unsigned long); uintptr_t padding_3[17]; } efi_boot_services_t; typedef struct { uintptr_t padding_1; unsigned long (*output_string)(void *, void *); uintptr_t padding_2; } efi_simple_text_output_protocol_t; int efi_guideq(efi_guid_t a, efi_guid_t b); efi_boot_services_t *get_efi_boot_services(void); efi_simple_text_output_protocol_t *get_efi_con_out(void); void efi_early_init(uintptr_t application_handle, uintptr_t efi_system_table); unsigned long efi_exit_boot_services(void); void *efi_get_fdt(void); int efi_fputc(int c, FILE *stream);
33.411392
112
0.646524
d95320bca0fed2b5e9b22a8464a6d3a0deb466a8
926
h
C
src/window/buffer_window.h
baileyforrest/calico
68f859d244e1dc62b1b690349263cb51e1c19bce
[ "MIT" ]
null
null
null
src/window/buffer_window.h
baileyforrest/calico
68f859d244e1dc62b1b690349263cb51e1c19bce
[ "MIT" ]
null
null
null
src/window/buffer_window.h
baileyforrest/calico
68f859d244e1dc62b1b690349263cb51e1c19bce
[ "MIT" ]
null
null
null
#pragma once #include <string> #include <utility> #include "src/base/buffer.h" #include "src/window/window.h" class BufferWindow : public Window { public: BufferWindow(); ~BufferWindow() override; // Window implementation: std::string Name() override = 0; void NotifySize(int rows, int cols) override; void NotifyAction(Action action) override; void NotifyChar(wchar_t key) override; void Render( const std::function<void(int row, int col, wchar_t val)>& cb) override; std::pair<int, int> GetCursorPos() override; Buffer& buf() { return buf_; } Buffer::iterator& cursor_pos() { return cursor_pos_; } private: Buffer buf_; int rows_ = 0; int cols_ = 0; // Current line we are on. Buffer::iterator cursor_pos_; int cursor_row_ = 0; // Note: Might not be real row of cursor if line is not long enough. int cursor_col_ = 0; DISALLOW_MOVE_COPY_AND_ASSIGN(BufferWindow); };
22.585366
77
0.699784
d95358949e1f4282c157453a0447adf5a7f73a9f
4,343
h
C
include/storm.h
brinkqiang/dmstorm
33b46db682862b0147dd5fc3ec382e8dff224c15
[ "MIT" ]
null
null
null
include/storm.h
brinkqiang/dmstorm
33b46db682862b0147dd5fc3ec382e8dff224c15
[ "MIT" ]
null
null
null
include/storm.h
brinkqiang/dmstorm
33b46db682862b0147dd5fc3ec382e8dff224c15
[ "MIT" ]
null
null
null
#ifndef _STORM_H #define _STORM_H #ifdef WIN32 #include "mysql.h" #else #include "mysql/mysql.h" #endif #include <string> #include <vector> #include <map> namespace ORM{ class Query; bool init(); void quit(); /* ERROR API */ std::string get_last_error(); /* CONFIGURATION API */ void configure( const std::string &key, const std::string &value); std::string &get_config( const std::string &key); /* TRANSACTION API */ bool try_begin(); void begin(); void commit(); void rollback(); /* RAW API */ MYSQL *get_db(); int raw_query(const std::string &query); int raw_query(const std::string format, ...); /* SELECT TABLE */ Query *from(const std::string &table); /* ESCAPE */ std::string escape(const std::string &str); class Query{ friend Query *from(const std::string &table); public: Query *where(const std::string &col, const std::string &value); Query *where_equal(const std::string &col, const std::string &value); Query *where_not_equal(const std::string &col, const std::string &value); Query *where_like(const std::string &col, const std::string &value); Query *where_not_like(const std::string &col, const std::string &value); Query *where_gt(const std::string &col, const std::string &value); Query *where_gte(const std::string &col, const std::string &value); Query *where_lt(const std::string &col, const std::string &value); Query *where_lte(const std::string &col, const std::string &value); Query *where_raw(const std::string &query); Query *select(const std::string &col); Query *select(int count, ...); Query *limit(int limit); Query *order_by_expr(const std::string &expr); Query *order_by_asc(const std::string &col); Query *order_by_desc(const std::string &col); void set(const std::string &key, const std::string &value); std::string &get(const std::string &key); Query *find_one(); std::vector<Query*> find_many(); std::string find_min(const std::string &col); std::string find_max(const std::string &col); std::string find_avg(const std::string &col); std::string find_sum(const std::string &col); Query *create(); bool save(); bool remove(); std::string build(); public: std::string &operator[](const std::string &key); protected: Query(); virtual ~Query(); void set_connection_object(MYSQL *mysql); void set_with_no_dirt(const std::string &key, const std::string &value); void set_query_type(int query_type); void set_table(const std::string &table); void set_limit(int limit); void add_result_column(const std::string &col); void add_condition( const std::string &col, const std::string &op, const std::string &value); void add_condition(const std::string &condition); void add_order_by(const std::string &col, const std::string &order); void add_group_by(const std::string &col); std::string build_result_columns(); std::string build_conditions(); std::string build_field_keys(); std::string build_field_values(); std::string build_changes(); std::string build_order_by(); std::string build_group_by(); std::string build_from(); std::string build_into(); std::string build_limit(); std::string build_select(); std::string build_update(); std::string build_delete(); std::string build_insert(); void dirt_field(const std::string &field_name); void clean_dirty_fields(); /* SELECT, UPDATE, INSERT, DELETE backends */ std::string find_single_value(); Query *find_single_record(); std::vector<Query*> find_records(); bool update_records(); bool insert_record(); bool remove_records(); /* MYSQL Wrapping */ int query(const std::string &query); MYSQL_RES *store_result(); void free_result(MYSQL_RES *mysql); std::vector<std::string> fetch_fields(MYSQL_RES *result); std::vector<MYSQL_ROW> fetch_rows(MYSQL_RES *result); MYSQL_ROW fetch_next_row(MYSQL_RES *result); protected: enum QueryType{ eSELECT=1, eUPDATE, eDELETE, eINSERT }; protected: int query_type; std::string table; std::vector<std::string> conditions; std::vector<std::string> results; std::vector<std::string> dirty_fields; std::vector<std::string> order_by; std::vector<std::string> group_by; std::map<std::string,std::string> fields; int n_limit; bool currupted; MYSQL *mysql; }; }; #endif //_STORM_H
24.817143
76
0.695372
d953f610aedf910c30db6378470bb95ef1670721
4,624
c
C
src/co_dnsutils.c
LiuYinCarl/colinlib
f62f58520d400faefc74ef2f86e4a6b6f760fd97
[ "MIT" ]
44
2019-10-11T11:05:15.000Z
2021-12-17T17:19:49.000Z
src/co_dnsutils.c
LiuYinCarl/colinlib
f62f58520d400faefc74ef2f86e4a6b6f760fd97
[ "MIT" ]
2
2020-11-12T08:11:00.000Z
2021-04-23T02:48:26.000Z
src/co_dnsutils.c
LiuYinCarl/colinlib
f62f58520d400faefc74ef2f86e4a6b6f760fd97
[ "MIT" ]
13
2019-10-12T00:15:11.000Z
2021-03-25T02:15:27.000Z
#include "co_dnsutils.h" #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <sys/socket.h> #include <arpa/inet.h> #pragma pack(push) #pragma pack(1) typedef struct dns_header { uint16_t tid ; uint16_t flags ; uint16_t qdcount ; uint16_t ancount ; uint16_t nscount ; uint16_t arcount ; } dns_header_t; #pragma pack(pop) #define DNS_TYPE_A 1 #define DNS_TYPE_AAAA 28 #define DNS_CLASS_IN 1 int codns_get_server(char *dnssvr, int n) { FILE * f = fopen("/etc/resolv.conf", "r"); if (f == NULL) return 1; int ret = 1; char line[512]; const char *sch = "nameserver"; while (fgets(line, 512, f)) { char* ss = strstr(line, sch); if (!ss) continue; ss = strrchr(ss, 0x20); if (!ss) continue; ss++; char *es = strchr(ss, '\n'); if (!es) continue; if (es-ss >= n) continue; strncpy(dnssvr, ss, es-ss); ret = 0; break; } fclose(f); return ret; } static uint16_t gtid = 1234; inline static uint16_t gen_tid() { return gtid++; } int codns_pack_request(uint8_t *buf, int *size, const char *name) { int maxsize = *size; if (maxsize < sizeof(dns_header_t)) return 1; int pos = 0; dns_header_t header; memset(&header, 0, sizeof(dns_header_t)); header.tid = htons(gen_tid()); header.flags = htons(0x0100); // Query, Standard Mode, Recursion Desired header.qdcount = htons(1); memcpy(buf+pos, &header, sizeof(dns_header_t)); pos += sizeof(header); const char *pname = name; const char *ppos; int len; for (;;) { ppos = strchr(pname, '.'); len = ppos ? ppos - pname : strlen(pname); if (maxsize < pos+1+len) return 1; buf[pos++] = len; memcpy(buf+pos, pname, len); pos += len; if (ppos) pname = ppos+1; else break; } if (maxsize < pos+1) return 1; buf[pos++] = '\0'; uint16_t qtype = htons(DNS_TYPE_A); // A if (maxsize < pos+2) return 1; memcpy(buf+pos, &qtype, 2); pos += 2; uint16_t qclass = htons(DNS_CLASS_IN); // IN if (maxsize < pos+2) return 1; memcpy(buf+pos, &qclass, 2); pos += 2; *size = pos; return 0; } int codns_parse_response(const uint8_t *buf, int size, ipaddr_t **addrs, int *addrnum) { if (size < sizeof(dns_header_t)) return 1; int pos = 0; dns_header_t *header = (dns_header_t *)(buf + pos); pos += sizeof(dns_header_t); // rcode int rcode = ntohs(header->flags) & 0x000F; if (rcode != 0) return rcode; // query uint16_t qdcount = ntohs(header->qdcount); if (qdcount != 1) return 1; uint8_t len; // 这里要处理名字指针的情况 while (buf[pos] != '\0') { if (size < pos+1) return 1; len = *((uint8_t*)(buf+pos)); if ((len & 0xC0) == 0xC0) { // name pointer pos++; break; } else { pos++; if (size < pos+len) return 1; pos += len; } } if (size < pos+1) return 1; pos++; if (size < pos+4) return 1; pos += 4; // answer uint16_t ancount = ntohs(header->ancount); if (ancount < 1) return 1; ipaddr_t *retads = CO_CALLOC(ancount, sizeof(ipaddr_t)); #define CHECK_BUF(n) if (size < pos+(n)) { free(retads); return 1;} int i; int num = 0; for (i = 0; i < ancount; ++i) { // 这里要处理名字指针的情况 while (buf[pos] != '\0') { CHECK_BUF(1); len = *((uint8_t*)(buf+pos)); if ((len & 0xC0) == 0xC0) { // name pointer pos++; break; } else { pos++; CHECK_BUF(len); pos += len; } } CHECK_BUF(1); pos++; // atype CHECK_BUF(2); uint16_t atype = ntohs(*((uint16_t*)(buf+pos))); pos += 2; // skip class, ttl CHECK_BUF(6); pos += 6; // rdlen CHECK_BUF(2); uint16_t rdlen = ntohs(*((uint16_t*)(buf+pos))); pos += 2; // rddata CHECK_BUF(rdlen); if (atype == DNS_TYPE_A) { retads[num].af = AF_INET; memcpy(&retads[num].addr.a4, buf+pos, 4); num++; } else if (atype == DNS_TYPE_AAAA) { retads[num].af = AF_INET6; memcpy(&retads[num].addr.a6, buf+pos, 16); num++; } pos += rdlen; } *addrs = retads; *addrnum = num; return 0; }
25.130435
88
0.511678
d95488ca944f41d5c4b41dca0fcb0cbbb7defcae
4,103
h
C
aws-cpp-sdk-pinpoint/include/aws/pinpoint/model/RandomSplitActivity.h
grujicbr/aws-sdk-cpp
bdd43c178042f09c6739645e3f6cd17822a7c35c
[ "Apache-2.0" ]
1
2020-03-11T05:36:20.000Z
2020-03-11T05:36:20.000Z
aws-cpp-sdk-pinpoint/include/aws/pinpoint/model/RandomSplitActivity.h
novaquark/aws-sdk-cpp
a0969508545bec9ae2864c9e1e2bb9aff109f90c
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-pinpoint/include/aws/pinpoint/model/RandomSplitActivity.h
novaquark/aws-sdk-cpp
a0969508545bec9ae2864c9e1e2bb9aff109f90c
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/pinpoint/Pinpoint_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <aws/pinpoint/model/RandomSplitEntry.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace Pinpoint { namespace Model { /** * <p>Specifies the settings for a random split activity in a journey. This type of * activity randomly sends specified percentages of participants down one of as * many as five paths in a journey, based on conditions that you * specify.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/pinpoint-2016-12-01/RandomSplitActivity">AWS * API Reference</a></p> */ class AWS_PINPOINT_API RandomSplitActivity { public: RandomSplitActivity(); RandomSplitActivity(Aws::Utils::Json::JsonView jsonValue); RandomSplitActivity& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>The paths for the activity, including the percentage of participants to enter * each path and the activity to perform for each path.</p> */ inline const Aws::Vector<RandomSplitEntry>& GetBranches() const{ return m_branches; } /** * <p>The paths for the activity, including the percentage of participants to enter * each path and the activity to perform for each path.</p> */ inline bool BranchesHasBeenSet() const { return m_branchesHasBeenSet; } /** * <p>The paths for the activity, including the percentage of participants to enter * each path and the activity to perform for each path.</p> */ inline void SetBranches(const Aws::Vector<RandomSplitEntry>& value) { m_branchesHasBeenSet = true; m_branches = value; } /** * <p>The paths for the activity, including the percentage of participants to enter * each path and the activity to perform for each path.</p> */ inline void SetBranches(Aws::Vector<RandomSplitEntry>&& value) { m_branchesHasBeenSet = true; m_branches = std::move(value); } /** * <p>The paths for the activity, including the percentage of participants to enter * each path and the activity to perform for each path.</p> */ inline RandomSplitActivity& WithBranches(const Aws::Vector<RandomSplitEntry>& value) { SetBranches(value); return *this;} /** * <p>The paths for the activity, including the percentage of participants to enter * each path and the activity to perform for each path.</p> */ inline RandomSplitActivity& WithBranches(Aws::Vector<RandomSplitEntry>&& value) { SetBranches(std::move(value)); return *this;} /** * <p>The paths for the activity, including the percentage of participants to enter * each path and the activity to perform for each path.</p> */ inline RandomSplitActivity& AddBranches(const RandomSplitEntry& value) { m_branchesHasBeenSet = true; m_branches.push_back(value); return *this; } /** * <p>The paths for the activity, including the percentage of participants to enter * each path and the activity to perform for each path.</p> */ inline RandomSplitActivity& AddBranches(RandomSplitEntry&& value) { m_branchesHasBeenSet = true; m_branches.push_back(std::move(value)); return *this; } private: Aws::Vector<RandomSplitEntry> m_branches; bool m_branchesHasBeenSet; }; } // namespace Model } // namespace Pinpoint } // namespace Aws
36.963964
156
0.711187
d956344b8c5f05e6e3a5a055a2f38dae8fe91d7f
2,453
h
C
include/handlers/ChunkHandlerSIQP.h
Peralex/pxgf
a4ea0ad5d2d2ff3b909782c22ef6488a0ac81662
[ "Apache-2.0" ]
1
2017-12-20T14:27:01.000Z
2017-12-20T14:27:01.000Z
include/handlers/ChunkHandlerSIQP.h
Peralex/pxgf
a4ea0ad5d2d2ff3b909782c22ef6488a0ac81662
[ "Apache-2.0" ]
null
null
null
include/handlers/ChunkHandlerSIQP.h
Peralex/pxgf
a4ea0ad5d2d2ff3b909782c22ef6488a0ac81662
[ "Apache-2.0" ]
null
null
null
#ifndef CHUNKHANDLERSIQP_H #define CHUNKHANDLERSIQP_H // Copyright 2006 Peralex Electronics (Pty) Ltd // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "../ChunkHandler.h" #include "../PXGStreamWriter.h" #include "packings/PackingSIQP.h" namespace pxgf { /// Chunk handler that describes how the data in a SSIQ chunk is packed. class cChunkHandlerSIQP : public cChunkHandler { public: /// Callback handler interface class cCallbackSIQP { public: /// Called on the callback handler whenever a SIQP /// chunk is processed. /// @param oPacking Object describing whether the data is IQ or QI packed virtual void callbackSIQP(const cPackingSIQP &oPacking) = 0; }; /// Constructor cChunkHandlerSIQP(); /// Register the object which will provide an implementation of this handler's /// callback function. /// @param pHandler The callback handler to be invoked to handle the processed data. void registerCallbackHandler(cCallbackSIQP *pHandler); /// To be used by a PXG Reader class to process the relevant chunk. /// @param vchData Vector of bytes belonging to the chunk. /// @param bBigEndian Is data big-endian? /// @return true if the chunk was processed successfully bool processChunk(const std::vector<char> &vchData, bool bBigEndian) override; /// Write a SIQP chunk to the given stream writer /// @param stream Stream to write to /// @param oPacking Object describing whether the data is IQ or QI packed void writeChunkSIQP(cPXGWriterBase &stream, const cPackingSIQP &oPacking) const; /// Get the 32 bit unique number for this chunk type /// @return Unique 32 bit chunk ID for this chunk type. int getChunkType() const override { //"SIQP" return 0x53495150; } private: cCallbackSIQP *m_pCallbackSIQPHandler; ///< Object which implements the callback handler interface. const cPackingSIQP m_oIQPacking; const cPackingSIQP m_oQIPacking; }; } #endif
33.60274
101
0.73991
d9563971ce3a636fe227737e94346c1fdaef1063
15,053
c
C
src/omxmlsec/openssl/x509.c
alexis-gruet/kt_rampart
6c756aedb9eff4fa4a559fc9475226a09d47dad4
[ "Apache-2.0" ]
1
2021-11-10T19:33:50.000Z
2021-11-10T19:33:50.000Z
wsf_c/rampartc/src/omxmlsec/openssl/x509.c
notxarb/wsf-php
3664c4123e062a75f576e69477e8bf245aa181a6
[ "Apache-2.0" ]
1
2015-08-10T16:24:08.000Z
2015-08-10T16:24:08.000Z
wsf_c/rampartc/src/omxmlsec/openssl/x509.c
notxarb/wsf-php
3664c4123e062a75f576e69477e8bf245aa181a6
[ "Apache-2.0" ]
4
2017-03-21T15:27:57.000Z
2021-05-27T11:20:00.000Z
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <stdio.h> #include <axis2_util.h> #include <openssl_rsa.h> #include <openssl/rand.h> #include <openssl/evp.h> #include <openssl/pem.h> #include <openssl/bio.h> #include <openssl/rand.h> #include <openssl/x509v3.h> #include <oxs_buffer.h> #include <oxs_error.h> #include <openssl_pkcs12.h> #include <openssl_x509.h> #include <oxs_utility.h> /*Usefull when we have BinarySecurityTokn*/ AXIS2_EXTERN axis2_status_t AXIS2_CALL openssl_x509_load_from_buffer(const axutil_env_t *env, axis2_char_t *b64_encoded_buf, X509 **cert) { unsigned char *buff = NULL; BIO *mem = NULL; int ilen = 0; axis2_char_t *formatted_buf = NULL; axis2_char_t *buf_to_format = NULL; int decode_len = 0; int decoded_len = -1; /*We should remove new lines here.*/ buf_to_format = (axis2_char_t*)axutil_strdup(env, b64_encoded_buf); if(buf_to_format) { formatted_buf = oxs_util_get_newline_removed_string(env,buf_to_format); AXIS2_FREE(env->allocator,buf_to_format); buf_to_format = NULL; } else { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "New line removed buffer creation failed."); return AXIS2_FAILURE; } decode_len = axutil_base64_decode_len(formatted_buf ); buff = AXIS2_MALLOC(env->allocator, decode_len); ilen = axutil_strlen(formatted_buf); decoded_len = axutil_base64_decode_binary(buff, formatted_buf); AXIS2_FREE(env->allocator, formatted_buf); formatted_buf = NULL; if (decoded_len < 0) { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "axutil_base64_decode_binary failed"); return AXIS2_FAILURE; } if ((mem = BIO_new_mem_buf(buff, ilen)) == NULL) { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "Cannot create a new memory buffer"); return AXIS2_FAILURE; } *cert = d2i_X509_bio(mem, NULL); /*Free*/ BIO_free(mem); mem = NULL; AXIS2_FREE(env->allocator, buff); buff = NULL; if (*cert == NULL){ return AXIS2_FAILURE; } return AXIS2_SUCCESS; } AXIS2_EXTERN axis2_status_t AXIS2_CALL openssl_x509_load_from_pem(const axutil_env_t *env, axis2_char_t *filename, X509 **cert) { BIO *in = NULL; in = BIO_new_file(filename,"r"); if (!in) { return AXIS2_FAILURE; } /*Read certificate*/ PEM_read_bio_X509(in, cert, NULL, NULL); if (-1 == BIO_reset(in) ){ BIO_free(in); return AXIS2_FAILURE; } if (-1 == BIO_free(in) ){ return AXIS2_FAILURE; } if(!*cert) { return AXIS2_FAILURE; } return AXIS2_SUCCESS; } AXIS2_EXTERN axis2_status_t AXIS2_CALL openssl_x509_load_from_pkcs12(const axutil_env_t *env, axis2_char_t *filename, axis2_char_t *password, X509 **cert, EVP_PKEY **pkey, STACK_OF(X509) **ca) { PKCS12 *p12 = NULL; axis2_status_t status = AXIS2_FAILURE; /*Load*/ status = openssl_pkcs12_load(env, filename, &p12); if(AXIS2_FAILURE == status){ return AXIS2_FAILURE; } /*Parse*/ status = openssl_pkcs12_parse(env, password, p12, pkey, cert, ca); if(AXIS2_FAILURE == status){ return AXIS2_FAILURE; } /*Free*/ status = openssl_pkcs12_free(env, p12); if(AXIS2_FAILURE == status){ return AXIS2_FAILURE; } return AXIS2_SUCCESS; } AXIS2_EXTERN axis2_status_t AXIS2_CALL openssl_x509_load_certificate(const axutil_env_t *env, openssl_x509_format_t format, axis2_char_t *filename, axis2_char_t *password, X509 **cert) { axis2_status_t status = AXIS2_FAILURE; if(OPENSSL_X509_FORMAT_PEM == format){ /*Load from PEM*/ status = openssl_x509_load_from_pem(env, filename, cert); if(AXIS2_FAILURE == status){ return AXIS2_FAILURE; } }else if(OPENSSL_X509_FORMAT_PKCS12 == format){ /*Load from PKCS12*/ EVP_PKEY *pkey = NULL; STACK_OF(X509) *ca = NULL; status = openssl_x509_load_from_pkcs12(env, filename, password, cert, &pkey, &ca); if(AXIS2_FAILURE == status){ return AXIS2_FAILURE; } }else if(OPENSSL_X509_FORMAT_DER == format){ /*Load from DER*/ }else{ /*Unspported*/ } return AXIS2_SUCCESS; } /* * Here we take data in btwn -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- */ AXIS2_EXTERN axis2_char_t *AXIS2_CALL openssl_x509_get_cert_data(const axutil_env_t *env, X509 *cert) { axis2_char_t *unformatted = NULL; axis2_char_t *core_tail = NULL; axis2_char_t *core = NULL; axis2_char_t *res = NULL; axis2_char_t *buffer = NULL; unformatted = openssl_x509_get_info(env, OPENSSL_X509_INFO_DATA_CERT, cert); core_tail = axutil_strstr(unformatted, "\n"); res = axutil_strstr(core_tail,"-----END"); res[0] = '\0'; core = (axis2_char_t*)axutil_strdup(env, core_tail); if(core) { buffer = oxs_util_get_newline_removed_string(env, core); AXIS2_FREE(env->allocator, core); AXIS2_FREE(env->allocator, unformatted); unformatted = NULL; core = NULL; return buffer; }else{ return NULL; } } AXIS2_EXTERN int AXIS2_CALL openssl_x509_get_serial( const axutil_env_t *env, X509 *cert) { axis2_char_t *serial = NULL; int no = 0; /*WARN: Do not use the serial number without converting it to the integer.*/ serial = (axis2_char_t*)i2s_ASN1_INTEGER(NULL, X509_get_serialNumber(cert)); if(serial) { no = atoi(serial); OPENSSL_free(serial); serial = NULL; return no; } else { return -1; } } AXIS2_EXTERN unsigned long AXIS2_CALL openssl_x509_get_subject_name_hash(const axutil_env_t *env, X509 *cert) { unsigned long l = 0; l=X509_subject_name_hash(cert); return l; } AXIS2_EXTERN axis2_status_t AXIS2_CALL openssl_x509_get_pubkey(const axutil_env_t *env, X509 *cert, EVP_PKEY **pubkey) { *pubkey = X509_get_pubkey(cert); return AXIS2_SUCCESS; } AXIS2_EXTERN axis2_char_t *AXIS2_CALL openssl_x509_get_subject_key_identifier(const axutil_env_t *env, X509 *cert) { X509_EXTENSION *ext; ASN1_OCTET_STRING *key_id = NULL; int index = 0; EVP_ENCODE_CTX ctx; int len, ret; char buf[1000]; char output[100]; axis2_char_t *ski = NULL; /*Get ext by ID*/ index = X509_get_ext_by_NID(cert, NID_subject_key_identifier, -1); if (index < 0) { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "The extenension index of NID_subject_key_identifier is not valid"); return NULL; } /*Get the extension*/ ext = X509_get_ext(cert, index); if (ext == NULL) { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "The extension for NID_subject_key_identifier is NULL"); return NULL; } /*Subject Key Identifier*/ key_id = (ASN1_OCTET_STRING *)X509V3_EXT_d2i(ext); if (key_id == NULL) { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "The SubjectKeyIdentifier is NULL"); return NULL; } memcpy(buf, key_id->data, key_id->length); buf[key_id->length] = 0; EVP_EncodeInit(&ctx); EVP_EncodeUpdate(&ctx, (unsigned char*)output, &len, (unsigned char*)buf, key_id->length); EVP_EncodeFinal(&ctx, (unsigned char*)(output+len), &ret); /*Free key_id*/ M_ASN1_OCTET_STRING_free(key_id); key_id = NULL; ret += len; ski = axutil_strdup(env, output); return ski; } AXIS2_EXTERN axis2_char_t *AXIS2_CALL openssl_x509_get_info(const axutil_env_t *env, openssl_x509_info_type_t type, X509 *cert) { BIO *out = NULL; unsigned char *data= NULL; axis2_char_t *result = NULL; int n = 0; out = BIO_new(BIO_s_mem()); if(OPENSSL_X509_INFO_SUBJECT==type){ X509_NAME_print_ex(out, X509_get_subject_name(cert), 0, 0); }else if(OPENSSL_X509_INFO_ISSUER == type){ X509_NAME_print_ex(out, X509_get_issuer_name(cert), 0, 0); }else if(OPENSSL_X509_INFO_VALID_FROM == type){ ASN1_TIME_print(out, X509_get_notBefore(cert)); }else if(OPENSSL_X509_INFO_VALID_TO == type){ ASN1_TIME_print(out, X509_get_notAfter(cert)); }else if(OPENSSL_X509_INFO_DATA_CERT == type){ if(!PEM_write_bio_X509_AUX(out, cert)){ return NULL; } }else if(OPENSSL_X509_INFO_FINGER == type){ const EVP_MD *digest = NULL; unsigned char md[EVP_MAX_MD_SIZE]; unsigned int _n = 0; digest = EVP_sha1();/*If we use EVP_md5(); here we can get the digest from md5. */ if(X509_digest(cert,digest,md,&_n)) { /*BIO_printf(out, "%s:", OBJ_nid2sn(EVP_MD_type(digest))); int j = 0; for (j=0; j<(int)_n; j++) { BIO_printf (out, "%02X",md[j]); if (j+1 != (int)_n) BIO_printf(out,":"); }*/ /*We need to base64 encode the digest value of the finger print*/ axis2_char_t *encoded_str = NULL; encoded_str = AXIS2_MALLOC(env->allocator, axutil_base64_encode_len(_n)); axutil_base64_encode(encoded_str, (char*)md, SHA_DIGEST_LENGTH); BIO_printf(out, "%s", encoded_str); AXIS2_FREE(env->allocator, encoded_str); } }else if(OPENSSL_X509_INFO_SIGNATURE == type){ int i = 0; unsigned char *s = NULL; n=cert->signature->length; s=cert->signature->data; for (i=0; i<n; i++) { if ( ((i%18) == 0) && (i!=0) ) BIO_printf(out,"\n"); BIO_printf(out,"%02x%s",s[i], (((i+1)%18) == 0)?"":":"); } }else if(OPENSSL_X509_INFO_VERSION == type){ long l = 0.0; l = X509_get_version(cert); BIO_printf (out,"%lu (0x%lx)",l+1,l); }else if(OPENSSL_X509_INFO_PUBKEY == type){ EVP_PKEY *pkey = NULL; pkey=X509_get_pubkey(cert); if (pkey != NULL) { if (pkey->type == EVP_PKEY_RSA){ RSA_print(out,pkey->pkey.rsa,0); }else if (pkey->type == EVP_PKEY_DSA){ DSA_print(out,pkey->pkey.dsa,0); } EVP_PKEY_free(pkey); pkey = NULL; } }else if(OPENSSL_X509_INFO_PUBKEY_ALGO == type){ X509_CINF *ci = NULL; ci = cert->cert_info; i2a_ASN1_OBJECT(out, ci->key->algor->algorithm); } n = BIO_get_mem_data(out, &data); result = axutil_strndup( env, data, n); BIO_free(out); out = NULL; return result; } AXIS2_EXTERN axis2_char_t * AXIS2_CALL openssl_x509_get_common_name( const axutil_env_t *env, X509 *cert) { X509_NAME *subject = NULL; int pos = -1; X509_NAME_ENTRY *entry = NULL; ASN1_STRING *entry_str; BIO *out = NULL; unsigned char *data= NULL; axis2_char_t *result = NULL; int n = 0; out = BIO_new(BIO_s_mem()); subject = X509_get_subject_name(cert); pos = X509_NAME_get_index_by_NID(subject, NID_commonName, -1); if(pos < 0) { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "No Common Name in given X509 Certificate!"); return NULL; } if (X509_NAME_get_index_by_NID(subject, NID_commonName, pos) >= 0) { /* Handling multiple common names. */ } if ((entry = X509_NAME_get_entry(subject, pos)) == 0) { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "Error occured during when retrieving common name from X509_NAME!"); return NULL; } if ((entry_str = X509_NAME_ENTRY_get_data(entry)) == 0) { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "Error occured during when retrieving common name from X509_NAME_ENTRY!"); return NULL; } ASN1_TIME_print(out, entry_str); n = BIO_get_mem_data(out, &data); result = axutil_strndup( env, data, n); BIO_free(out); out = NULL; return result; } AXIS2_EXTERN axis2_char_t* AXIS2_CALL openssl_x509_get_alias(const axutil_env_t* env, X509* cert) { axis2_char_t* result = NULL; unsigned char* data = NULL; int length = 0; data = X509_alias_get0(cert, &length); if (!data) return NULL; result = axutil_strndup(env, data, length); return result; } AXIS2_EXTERN void AXIS2_CALL openssl_x509_print(const axutil_env_t *env, X509 *cert) { printf("\n*************START PRINTING*****************\n"); printf("OPENSSL_X509_INFO_SUBJECT : %s\n", openssl_x509_get_info(env, OPENSSL_X509_INFO_SUBJECT,cert)); printf("OPENSSL_X509_INFO_ISSUER : %s\n", openssl_x509_get_info(env,OPENSSL_X509_INFO_ISSUER ,cert)); printf("OPENSSL_X509_INFO_VALID_FROM : %s\n", openssl_x509_get_info(env, OPENSSL_X509_INFO_VALID_FROM,cert)); printf("OPENSSL_X509_INFO_VALID_TO : %s\n", openssl_x509_get_info(env,OPENSSL_X509_INFO_VALID_TO ,cert)); printf("OPENSSL_X509_INFO_FINGER : %s\n", openssl_x509_get_info(env,OPENSSL_X509_INFO_FINGER ,cert)); printf("OPENSSL_X509_INFO_SIGNATURE : %s\n", openssl_x509_get_info(env, OPENSSL_X509_INFO_SIGNATURE,cert)); printf("OPENSSL_X509_INFO_VERSION : %s\n", openssl_x509_get_info(env,OPENSSL_X509_INFO_VERSION ,cert)); printf("OPENSSL_X509_INFO_PUBKEY : %s\n", openssl_x509_get_info(env,OPENSSL_X509_INFO_PUBKEY ,cert)); printf("OPENSSL_X509_INFO_PUBKEY_ALGO : %s\n", openssl_x509_get_info(env,OPENSSL_X509_INFO_PUBKEY_ALGO ,cert)); printf("SERIAL : %u\n", openssl_x509_get_serial(env,cert)); printf("PUBKEY : %s\n", openssl_x509_get_cert_data(env,cert)); printf("\n*************END PRINTING********************\n"); }
29.867063
115
0.628911
d9567c1ab1643273335f3e3df600066ccd97f63f
703
c
C
modules/security/keychain/test/sec_sst_test_get.c
allentree/LoRaGW-SDK
1675801538407753768e91774d857f2d7aa2ba7c
[ "Apache-2.0" ]
null
null
null
modules/security/keychain/test/sec_sst_test_get.c
allentree/LoRaGW-SDK
1675801538407753768e91774d857f2d7aa2ba7c
[ "Apache-2.0" ]
null
null
null
modules/security/keychain/test/sec_sst_test_get.c
allentree/LoRaGW-SDK
1675801538407753768e91774d857f2d7aa2ba7c
[ "Apache-2.0" ]
1
2020-07-09T06:42:54.000Z
2020-07-09T06:42:54.000Z
#include <stdio.h> #include "keychain.h" /* try to get the item of other process * can not get item of other process * check if errno is KC_ERROR_ITEM_NOT_FOUND */ void main(void) { char *key = "test_key"; char secret[128]; uint32_t secret_len = 128; uint32_t ret = 0; kc_key_type_t key_type = 0; if (kc_init()) { printf("kc init failed\n"); return; } ret = kc_get_global_item(key, secret, &secret_len, &key_type); if (ret != KC_ERROR_ITEM_NOT_FOUND) { printf("kc test get other process item failed 0x%x\n", ret); goto clean; } printf("test if can get the item of other process success\n"); clean: kc_destroy(); }
21.30303
68
0.628734
79fe486951d8dacbfd07f35b92bf097bedffc822
587
h
C
mit-pthreads/machdep/irix-5.2/dirent.h
euleryang/mysql-server-mysql-323-31
f9346bfa3055f2217fe183bcb182aa6f39bca4d9
[ "Naumen", "Condor-1.1", "MS-PL" ]
1
2020-03-31T15:03:51.000Z
2020-03-31T15:03:51.000Z
mit-pthreads/machdep/irix-5.2/dirent.h
euleryang/mysql-server-mysql-323-31
f9346bfa3055f2217fe183bcb182aa6f39bca4d9
[ "Naumen", "Condor-1.1", "MS-PL" ]
1
2020-03-31T15:04:54.000Z
2020-03-31T15:04:54.000Z
mit-pthreads/machdep/irix-5.2/dirent.h
euleryang/mysql-server-mysql-323-31
f9346bfa3055f2217fe183bcb182aa6f39bca4d9
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
#ifndef _SYS_DIRENT_H #define _SYS_DIRENT_H #if !defined(_POSIX_SOURCE) #define MAXNAMLEN 255 /* maximum filename length */ #define DIRBUF 4096 /* buffer size for fs-indep. dirs */ #endif /* !defined(_POSIX_SOURCE) */ #include <sys/types.h> struct dirent { /* data from readdir() */ ino_t d_ino; /* inode number of entry */ off_t d_off; /* offset of disk direntory entry */ unsigned short d_reclen; /* length of this record */ char d_name[MAXNAMLEN+1];/* name of file */ }; #define d_namlen d_reclen #define d_fileno d_ino #endif /* _SYS_DIRENT_H */
26.681818
58
0.679727
79ffad591f5366c79bba1471b556f816a55111d8
561
h
C
Project3D/Mesh.h
bpgas01/AieBootstrapProjects
b1df240cab4cd4ff39bdc9fd08c784b775d51244
[ "MIT" ]
null
null
null
Project3D/Mesh.h
bpgas01/AieBootstrapProjects
b1df240cab4cd4ff39bdc9fd08c784b775d51244
[ "MIT" ]
null
null
null
Project3D/Mesh.h
bpgas01/AieBootstrapProjects
b1df240cab4cd4ff39bdc9fd08c784b775d51244
[ "MIT" ]
null
null
null
#pragma once #include "glm/glm.hpp" class Mesh { public: Mesh() : triCount(0), vao(0), vbo(0), ibo(0) {}; virtual ~Mesh(); struct Vertex { glm::vec4 position; glm::vec4 normal; glm::vec2 texCoord; }; void InitialiseQuad(); void Initialise(unsigned int a_vertextCount, const Vertex* a_vertices, unsigned int a_indexCount = 0, unsigned int* a_indices = nullptr); virtual void Draw(); protected: unsigned int triCount; unsigned int vao, // Vertex Array Object vbo, // Vectex Array Buffer ibo; // Index Array Object };
14.384615
71
0.666667
030226e17036329b6a81e867f354a324700f16b0
3,003
h
C
frameworks/SendBirdSDK.framework/Headers/SBDCommand.h
NAXAM/sendbird-ios-binding
17dee30fe9fbb83b50245f6dacdc28af37a1f49e
[ "MIT" ]
null
null
null
frameworks/SendBirdSDK.framework/Headers/SBDCommand.h
NAXAM/sendbird-ios-binding
17dee30fe9fbb83b50245f6dacdc28af37a1f49e
[ "MIT" ]
null
null
null
frameworks/SendBirdSDK.framework/Headers/SBDCommand.h
NAXAM/sendbird-ios-binding
17dee30fe9fbb83b50245f6dacdc28af37a1f49e
[ "MIT" ]
null
null
null
// // SBDCommand.h // SendBirdSDK // // Created by Jed Gyeong on 5/22/16. // Copyright © 2016 SENDBIRD.COM. All rights reserved. // #import <Foundation/Foundation.h> #import "SBDUser.h" #import "SBDBaseChannel.h" #import "SBDUserMessage.h" #import "SBDGroupChannel.h" /** * SendBird internal use only. */ @interface SBDCommand : NSObject /** * Command. */ @property (strong, nonatomic, readonly, nullable) NSString *cmd; /** * Payload as string. */ @property (strong, nonatomic, readonly, nullable) NSString *payload; /** * Payload as dictionary. */ @property (strong, nonatomic, readonly, nullable) NSMutableDictionary *payloadDictionary; /** * Reques ID for ACK. */ @property (strong, nonatomic, readonly, nullable) NSString *requestId; /** * Encode to string for sending. * * @return Encoded string of command. */ - (nullable NSString *)encode; - (BOOL)isAckRequired; - (BOOL)hasRequestId; + (nullable SBDCommand *)parseMessage:(NSString * _Nonnull)message; + (nullable SBDCommand *)buildEnterChannel:(SBDBaseChannel * _Nonnull)channel; + (nullable SBDCommand *)buildExitChannel:(SBDBaseChannel * _Nonnull)aUser; + (nullable SBDCommand *)buildUserMessageWithChannelUrl:(NSString * _Nonnull)channelUrl messageText:(NSString * _Nonnull)messageText data:(NSString * _Nullable)data customType:(NSString * _Nullable)customType targetLanguages:(NSArray<NSString *> * _Nullable)targetLanguages; + (nullable SBDCommand *)buildUpdateUserMessageWithChannelUrl:(NSString * _Nonnull)channelUrl messageId:(long long)messageId messageText:(NSString * _Nullable)messageText data:(NSString * _Nullable)data customType:(NSString * _Nullable)customType; + (nullable SBDCommand *)buildFileMessageWithFileUrl:(NSString * _Nonnull)fileUrl name:(NSString * _Nullable)name type:(NSString * _Nullable)type size:(NSUInteger)size data:(NSString * _Nullable)data requestId:(NSString * _Nullable)requestId channel:(SBDBaseChannel * _Nonnull)channel customType:(NSString * _Nullable)customType thumbnails:(NSArray * _Nullable)thumbnails DEPRECATED_ATTRIBUTE; + (nullable SBDCommand *)buildFileMessageWithFileUrl:(NSString * _Nonnull)fileUrl name:(NSString * _Nullable)name type:(NSString * _Nullable)type size:(NSUInteger)size data:(NSString * _Nullable)data requestId:(NSString * _Nullable)requestId channel:(SBDBaseChannel * _Nonnull)channel customType:(NSString * _Nullable)customType thumbnails:(NSArray * _Nullable)thumbnails requireAuth:(BOOL)requireAuth; + (nullable SBDCommand *)buildUpdateFileMessageWithChannelUrl:(NSString * _Nonnull)channelUrl messageId:(long long)messageId data:(NSString * _Nullable)data customType:(NSString * _Nullable)customType; + (nullable SBDCommand *)buildPing; + (nullable SBDCommand *)buildStartTyping:(SBDGroupChannel * _Nonnull)channel startAt:(long long)startAt; + (nullable SBDCommand *)buildEndTyping:(SBDGroupChannel * _Nonnull)channel endAt:(long long)endAt; + (SBDCommand * _Nullable)buildReadOfChannel:(SBDGroupChannel * _Nonnull)channel; @end
46.2
402
0.779221
0302f3b7c30e4b53aaf0c38508ef1868a916b2da
1,522
h
C
System/Library/Frameworks/SensorKit.framework/SRFetchResult.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
System/Library/Frameworks/SensorKit.framework/SRFetchResult.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
System/Library/Frameworks/SensorKit.framework/SRFetchResult.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 11:52:45 AM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/Frameworks/SensorKit.framework/SensorKit * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ #import <SensorKit/SensorKit-Structs.h> #import <libobjc.A.dylib/NSCopying.h> @class NSData, NSDictionary; @interface SRFetchResult : NSObject <NSCopying> { double _timestamp; NSData* _sampleData; NSDictionary* _metadata; Class _sampleClass; } @property (retain) NSData * sampleData; //@synthesize sampleData=_sampleData - In the implementation block @property (retain) NSDictionary * metadata; //@synthesize metadata=_metadata - In the implementation block @property (retain) Class sampleClass; //@synthesize sampleClass=_sampleClass - In the implementation block @property (copy,readonly) id sample; @property (readonly) double timestamp; //@synthesize timestamp=_timestamp - In the implementation block +(id)new; +(void)initialize; -(id)copyWithZone:(NSZone*)arg1 ; -(void)setMetadata:(NSDictionary *)arg1 ; -(id)sample; -(NSDictionary *)metadata; -(void)dealloc; -(double)timestamp; -(id)init; -(void)setSampleClass:(Class)arg1 ; -(Class)sampleClass; -(id)initWithData:(id)arg1 timestamp:(double)arg2 metadata:(id)arg3 sampleClass:(Class)arg4 ; -(void)setSampleData:(NSData *)arg1 ; -(NSData *)sampleData; @end
34.590909
125
0.729961
03047f320af7ebb438445d561d00a2bd318918d5
10,223
h
C
Shared/Interface/smartptr.h
PengJinFa/YAPNew
fafee8031669b24d0cc74876a477c97d0d7ebadc
[ "MIT" ]
null
null
null
Shared/Interface/smartptr.h
PengJinFa/YAPNew
fafee8031669b24d0cc74876a477c97d0d7ebadc
[ "MIT" ]
null
null
null
Shared/Interface/smartptr.h
PengJinFa/YAPNew
fafee8031669b24d0cc74876a477c97d0d7ebadc
[ "MIT" ]
null
null
null
#pragma once #ifndef yapMemory_h__20160817 #define yapMemory_h__20160817 #include <cassert> #include <memory> namespace Yap { /** @remark In YAP framework, objects are often created in one module and used in another. Since different modules can be developed by different developers and built with different compilers (or different versions of compiler), objects can only be passed from one module to another in form of interface pointers. There are three typical scenarios: 1. The object are created in free store in the original module, and its ownership is transfered to one client module. In this case the client should not delete the interface pointer directly, since the client module might be using a different C runtime. Instead, the object should implement IDynamicObject interface and the client can call IDynamicObject::DeleteThis() to delete the object when it's finished with the object. 2. The object is created in free store in the original module. However, different from case 1, the object may be shared by different client modules. In this case the object should implement ISharedObject and use a reference count to manage the life cycle of the object. Client module should Lock() the IShareObject as long as the object is used, and should call Release() when it's finished with the object. An ISharedObject should delete itself when no one is using it. 3. The object is created on the stack of the original module and the address of the object is pass to client module. In this case, the object SHOULD NOT implement either IDynamicObject or ISharedObject. The client module can only use the interface pointer before the function call returns. It CAN NOT store the interface pointer for late use. Since it is the most probable scenario to cause problem. We strongly suggest not to use this. */ /** If an object is created dynamically in one module and then its ownership is transferred to another module, then the object should implement this interface, so that the client module can call DeleteThis() to safely deallocate the object. Normally, the object should use 'delete this' to delete itself when implementing DeleteThis(). */ struct IDynamicObject { /// Client of the object should call this function to delete the object, instead of delete the interface pointer directly. virtual void DeleteThis() = 0; }; /** If an object is created dynamically in one module, and then passed to several different users, it should implement this interface. The object should also implement the Clone() method, so that the object can be cloned. */ struct ISharedObject { /// Client of the object should call this function to keep the object in memory. virtual void Lock() = 0; /// Client of the object should call this function when it's finished with the object. virtual void Release() = 0; /// Return Cloned object. virtual ISharedObject * Clone() const = 0; }; /** SmartPtr is used to wrap ISharedObject object. It's similar to std::smart_ptr, however, it calles ISharedObject::Lock() to add reference, and calles ISharedObject::Release() when SmartPtr itself is destroyed. The pointer SmartPtr wraps need not to be a pointer to SmartPtr. Instead, it only need to point to an object which implements ISharedObject. @note You must use YapShared() function to create a SmartPtr wrapping a raw pointer. @remarks TYPE class should implement ISharedObject or the pointer should pointer to an object of a class derived from both ISharedObject and TYPE. */ template <typename TYPE> class SmartPtr { public: SmartPtr() : _pointer(nullptr) {} template <typename SOURCE_TYPE> explicit SmartPtr(SOURCE_TYPE * pointer = nullptr) { if (pointer == nullptr) return; _pointer = dynamic_cast<TYPE*>(pointer); assert(_pointer && "SOURCE_TYPE should be same as the TYPE, or can be convert to TYPE."); auto shared_object = dynamic_cast<ISharedObject*>(_pointer); assert(shared_object != nullptr && "Only pointers to object implementing ISharedObject can be wrapped using YapShared()."); if (shared_object != nullptr) { shared_object->Lock(); } } SmartPtr(const SmartPtr<TYPE>& source) { if (source.get() == nullptr) return; _pointer = dynamic_cast<TYPE*>(source._pointer); assert(_pointer && "SOURCE_TYPE should be same as the TYPE, or can be convert to TYPE."); auto shared_object = dynamic_cast<ISharedObject*>(_pointer); // _pointer assert(shared_object && "Only type derived from ISharedObject can be wrapped in SmartPtr."); shared_object->Lock(); } template <typename SOURCE_TYPE> SmartPtr(const SmartPtr<SOURCE_TYPE>& source) { if (source.get() == nullptr) return; assert(dynamic_cast<TYPE*>(source.get()) != nullptr && "SOURCE_TYPE should be same as the TYPE, or can be convert to TYPE."); auto shared_object = dynamic_cast<ISharedObject*>(_pointer); assert(shared_object && "Only type derived from ISharedObject can be wrapped in SmartPtr."); shared_object->Lock(); } SmartPtr(SmartPtr<TYPE>&& source) : _pointer(source._pointer) { source._pointer = nullptr; } template <typename SOURCE_TYPE> SmartPtr(SmartPtr<SOURCE_TYPE>&& source) : _pointer(dynamic_cast<TYPE*>(source.get())) { if (_pointer == nullptr && source.get() != nullptr) throw std::bad_cast(); auto shared_pointer = dynamic_cast<ISharedObject*>(_pointer); if (shared_pointer != nullptr) { shared_pointer->Lock(); } } ~SmartPtr() { auto shared_object = dynamic_cast<ISharedObject*>(_pointer); if (shared_object != nullptr) { shared_object->Release(); _pointer = nullptr; } } const SmartPtr<TYPE>& operator = (const SmartPtr<TYPE>& source) { if (_pointer != source._pointer) { auto shared_object = dynamic_cast<ISharedObject*>(_pointer); if (shared_object != nullptr) { shared_object->Release(); } _pointer = source._pointer; auto shared_object_new = dynamic_cast<ISharedObject*>(_pointer); if (shared_object_new != nullptr) { shared_object_new->Lock(); } } return *this; } const SmartPtr<TYPE>& operator = (SmartPtr<TYPE>&& source) { if (_pointer != source._pointer) { auto shared_object = dynamic_cast<ISharedObject*>(_pointer); if (shared_object != nullptr) { shared_object->Release(); } _pointer = source._pointer; source._pointer = nullptr; } return *this; } void reset() { auto shared_object = dynamic_cast<ISharedObject*>(_pointer); if (shared_object != nullptr) { shared_object->Release(); } _pointer = nullptr; } TYPE *& get() { return _pointer; } const TYPE * get() const { return _pointer; } TYPE & operator * () { return *_pointer; } const TYPE & operator * () const { return *_pointer; } const TYPE * operator -> () const { assert(_pointer != nullptr); return _pointer; } TYPE * operator -> () { assert(_pointer != nullptr); return _pointer; } operator bool() const { return _pointer != nullptr; } private: TYPE * _pointer = nullptr; template<typename TYPE> friend SmartPtr<TYPE> YapShared(TYPE * object); template<typename TYPE> friend SmartPtr<TYPE> YapShared(ISharedObject* object); }; /** This is the factory function to create an SmartPtr to wrap a pointer to an ISharedObject object. */ template <typename TYPE> SmartPtr<TYPE> YapShared(TYPE * object) { assert(object == nullptr || dynamic_cast<ISharedObject*>(object) != nullptr && "Only pointers to object implementing ISharedObject can be wrapped using YapShared()."); return Yap::SmartPtr<TYPE>(object); } /** This function should be used to help to wrap an interface pointer which is dynamically created in another module and the ownership of the object is transfered to current module. TYPE class should implement IDynamicObject or the pointer should pointer to an object of a class derived from both IDynamicObject and TYPE. Returned shared_ptr can be copied and used freely in the current module. However, the shared_ptr SHALL NOT be passed to other modules. */ template <typename TYPE> std::shared_ptr<TYPE> YapDynamic(TYPE * object) { assert((object == nullptr || dynamic_cast<IDynamicObject*>(object) != nullptr) && "Only pointers to object implementing IDynamicObject can be wrapped using YapDynamicObject()."); return std::shared_ptr<TYPE>(object, [](TYPE* pointer) { auto dynamic_object = dynamic_cast<IDynamicObject*>(pointer); assert(dynamic_object != nullptr); dynamic_object->DeleteThis(); }); } template <typename TYPE> SmartPtr<TYPE> YapShared(ISharedObject * clonable) { assert(clonable == nullptr || dynamic_cast<TYPE*>(clonable) != nullptr && "Only pointer to classes implemented TYPE interface can be wrapped using YapShared()."); assert(clonable == nullptr || dynamic_cast<ISharedObject*>(clonable) != nullptr && "Only pointers to object implementing ISharedObject can be wrapped using YapShared()."); return Yap::SmartPtr<TYPE>(dynamic_cast<TYPE*>(clonable)); } /** This function clones an object and wraps it with SmartPtr. It requires that the object implement IClonable and ISharedObject. */ template <typename TYPE> SmartPtr<TYPE> YapClone(TYPE * object) { assert(object != nullptr); assert(dynamic_cast<IClonable*>(object) != nullptr && "The object must implement IClonable."); assert(dynamic_cast<ISharedObject*>(object) != nullptr && "The object must implement ISharedObject."); } }; // namespace YAP #define IMPLEMENT_CLONE(my_class) private:\ virtual ISharedObject * Clone() const override {\ return new (std::nothrow) my_class(*this);} #define IMPLEMENT_CLONE2(my_class, my_interface) private:\ virtual my_interface * Clone() const override {\ return new (std::nothrow) my_class(*this);} #define IMPLEMENT_LOCK_RELEASE private:\ virtual void Release() override{\ if (_use_count == 0 || --_use_count == 0) \ { delete this; } \ }\ virtual void Lock() override{\ ++_use_count;}\ unsigned int _use_count = 0; #define IMPLEMENT_SHARED(my_class) IMPLEMENT_LOCK_RELEASE \ IMPLEMENT_CLONE(my_class) #define IMPLEMENT_SHARED2(my_class, my_interface) IMPLEMENT_LOCK_RELEASE \ IMPLEMENT_CLONE2(my_class, my_interface) #endif
29.979472
124
0.733835
0304cb86fe4b58daf4161bd920569241be915752
4,412
c
C
src/round-robin.c
AbdullahKady/scheduling-algorithms
848478b55e61541a2ea3e2875fc26b9e87845359
[ "MIT" ]
null
null
null
src/round-robin.c
AbdullahKady/scheduling-algorithms
848478b55e61541a2ea3e2875fc26b9e87845359
[ "MIT" ]
null
null
null
src/round-robin.c
AbdullahKady/scheduling-algorithms
848478b55e61541a2ea3e2875fc26b9e87845359
[ "MIT" ]
null
null
null
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> //Given the file name, it will return how many processes exist in the file (lines -2) int numOfProcesses(char *fileName) { FILE *file = fopen(fileName, "r"); if (!file) { return 0; } int result = 0; char buf[200]; while (fgets(buf, sizeof(buf), file)) { result++; } fclose(file); return result - 2; } //Returns the nth (specified by num) element in a csv string char *getElement(char *lines, int elementIndex) { char *current; for (current = strtok(lines, ","); current && *current; current = strtok(NULL, ",\n")) { if (!--elementIndex) return current; } return NULL; } main() { time_t start, end, tmpClock; char inputFileName[256]; char outputFileName[256]; printf("Enter input file name: "); scanf("%s", inputFileName); printf("Enter Output file name: "); scanf("%s", outputFileName); int processID = 0, totalNumOfProcesses, timeLine, remain, isFinished = 0, quantumLength; totalNumOfProcesses = numOfProcesses(inputFileName); int waitTime = 0; int turnAround = 0; int arrivalTime[totalNumOfProcesses], cpuBurst[totalNumOfProcesses], remainingTime[totalNumOfProcesses]; FILE *file = fopen(inputFileName, "r"); if (!file) { printf("FILE DOESN'T EXIST!!\n"); return 0; } char quantum_string[256]; fgets(quantum_string, sizeof(quantum_string), file); quantumLength = atoi(quantum_string); //Converting the quantum into an int remain = totalNumOfProcesses; fgets(quantum_string, sizeof(quantum_string), file); //Reading an extra line (for the tickets supposedly) char tmpProcess[256]; while (fgets(tmpProcess, sizeof(tmpProcess), file)) { //Converting each element into an int, and storing them in the appropriate corresponding array cells. char *dup = strdup(tmpProcess); int currentArrivalTime = atoi(getElement(dup, 2)); dup = strdup(tmpProcess); int currentCpuBurst = atoi(getElement(dup, 3)); arrivalTime[processID] = currentArrivalTime; cpuBurst[processID] = currentCpuBurst; remainingTime[processID] = cpuBurst[processID]; processID++; } fclose(file); //THE LOGIC PART OF THE CODE >> FILE *log = NULL; log = fopen(outputFileName, "a"); start = clock(); //Initial clock just for logging for (timeLine = 0, processID = 0; remain != 0;) { if (remainingTime[processID] <= quantumLength && remainingTime[processID] > 0) { fprintf(log, "\n"); fprintf(log, "Time %d: ", timeLine); fprintf(log, "P%d ", processID + 1); //CLOCK tmpClock = clock(); while (((double)(clock() - tmpClock) / CLOCKS_PER_SEC) * 1000 < remainingTime[processID]) { }; //CLOCK timeLine += remainingTime[processID]; remainingTime[processID] = 0; isFinished = 1; } else if (remainingTime[processID] > 0) { fprintf(log, "\n"); fprintf(log, "Time %d: ", timeLine); fprintf(log, "P%d ", processID + 1); fprintf(log, "Entering quantum "); //CLOCK tmpClock = clock(); while (((double)(clock() - tmpClock) / CLOCKS_PER_SEC) * 1000 < quantumLength) { }; //CLOCK remainingTime[processID] -= quantumLength; timeLine += quantumLength; } if (remainingTime[processID] == 0 && isFinished == 1) { remain--; fprintf(log, " ||=> Done Turn Around: %d ", timeLine - arrivalTime[processID]); fprintf(log, " || Waiting Time: %d ", timeLine - arrivalTime[processID] - cpuBurst[processID]); waitTime += timeLine - arrivalTime[processID] - cpuBurst[processID]; turnAround += timeLine - arrivalTime[processID]; isFinished = 0; } if (processID == totalNumOfProcesses - 1) { processID = 0; } else if (arrivalTime[processID + 1] <= timeLine) { processID++; } else { processID = 0; } } fprintf(log, "\n"); fprintf(log, "\nAverage Waiting Time= %f\n", waitTime * 1.0 / totalNumOfProcesses); fprintf(log, "Average Turnaround Time = %f\n", turnAround * 1.0 / totalNumOfProcesses); fclose(log); printf("Success, output file has been written to %s\n", outputFileName); end = clock(); double time_spent = ((double)(end - start) / CLOCKS_PER_SEC) * 1000; printf("Time elapsed during simulation = %f msec\n", time_spent); return 0; }
29.610738
107
0.638033
030510a75e797c004fa63c9fb09630b80096a904
4,104
h
C
lib/include/hawktracer/base_types.h
jandom/hawktracer
e53b07bc812c4cfe8f6253ddb48ac43de8fa74a8
[ "MIT" ]
116
2018-05-04T14:51:58.000Z
2022-02-08T23:47:28.000Z
lib/include/hawktracer/base_types.h
jandom/hawktracer
e53b07bc812c4cfe8f6253ddb48ac43de8fa74a8
[ "MIT" ]
58
2018-05-04T15:00:15.000Z
2020-11-06T11:34:11.000Z
lib/include/hawktracer/base_types.h
beila/hawktracer
d427c6a66097787f4e5431e1cae0278f1f03ca4c
[ "MIT" ]
32
2018-05-05T12:05:56.000Z
2021-12-06T02:18:05.000Z
#ifndef HAWKTRACER_BASE_TYPES_H #define HAWKTRACER_BASE_TYPES_H #include <hawktracer/macros.h> #include <hawktracer/mkcreflect.h> #include <inttypes.h> HT_DECLS_BEGIN /** An unsigned integer used for event klass identifiers. */ typedef uint32_t HT_EventKlassId; /** An unsigned integer used for representing timestamps in nanoseconds. */ typedef uint64_t HT_TimestampNs; /** An unsigned integer used for event identifiers. */ typedef uint64_t HT_EventId; /** An unsigned integer used for representing duration in nanoseconds. */ typedef uint64_t HT_DurationNs; /** A standard boolean type, possible values: #HT_TRUE, #HT_FALSE */ typedef int HT_Boolean; /** A pointer to a list of HT_Event (or derived) objects. */ typedef uint8_t* TEventPtr; /** An unsigned integer used for thread identifiers. */ typedef uint32_t HT_ThreadId; /** An unsigned integer guaranteed to be 8 bits on all platforms. */ typedef uint8_t HT_Byte; /** * A type of function called to destroy @a data element. * It should free all the memory and resources held by the @a data element. * * @param data the element to be destroyed. */ typedef void(*HT_DestroyCallback)(void* data); /** Defines @b true value for the HT_Boolean type. */ #define HT_TRUE 1 /** Defines @b false value for the HT_Boolean type. */ #define HT_FALSE 0 /** Defines an invalid klass identifier. */ #define HT_INVALID_KLASS_ID ((HT_EventKlassId)-1) /** Defines an invalid feature identifier. */ #define HT_INVALID_FEATURE_ID ((uint32_t)-1) /** Defines list of possible errors returned by library functions. */ typedef enum { /** No error */ HT_ERR_OK = 0, /** Unknown error */ HT_ERR_UNKNOWN, /** Memory allocation failed. This is very serious error, and * most likely your entire application is broken at this point of time. */ HT_ERR_OUT_OF_MEMORY, /** Try to register a timeline feature using ID which is already taken * by some other feature. */ HT_ERR_FEATURE_ALREADY_REGISTERED, /** Try to use feature that has not been registered in the system.*/ HT_ERR_FEATURE_NOT_REGISTERED, /** Try to register too many features in the system. */ HT_ERR_MAX_FEATURE_COUNT_REACHED, /** Try to register container with name already used in registry. * This error is used internally, and is never returned by public * API. TODO: consider removing it from public enum. */ HT_ERR_LISTENER_CONTAINER_ALREADY_REGISTERED, /** Cannot open file. */ HT_ERR_CANT_OPEN_FILE, /** Cannot start tcp server. This error might have many root causes, * some of them are: socket can't be open, library is not able to bind to a port. */ HT_ERR_CANT_START_TCP_SERVER, /** Unable to create listener container. This is most likely caused by * #HT_ERR_OUT_OF_MEMORY occured internally in the library. */ HT_ERR_CANT_CREATE_LISTENER_CONTAINER, /** Format of an input data is invalid. */ HT_ERR_INVALID_FORMAT, /** Invalid argument */ HT_ERR_INVALID_ARGUMENT, /** Out of range */ HT_ERR_OUT_OF_RANGE, /** Missing argument */ HT_ERR_MISSING_ARGUMENT } HT_ErrorCode; /** Defines supported byte ordering */ typedef enum { /** Little-endian order. */ HT_ENDIANNESS_LITTLE = 0, /** Big-endian order. */ HT_ENDIANNESS_BIG = 1 } HT_Endianness; HT_DECLS_END /** Defines list of data types of event fields. */ typedef enum { /** Data type struct. */ HT_MKCREFLECT_TYPES_EXT_STRUCT = MKCREFLECT_TYPES_STRUCT, /** Data type string. */ HT_MKCREFLECT_TYPES_EXT_STRING = MKCREFLECT_TYPES_STRING, /** Data type integer. */ HT_MKCREFLECT_TYPES_EXT_INTEGER = MKCREFLECT_TYPES_INTEGER, /** Data type float. */ HT_MKCREFLECT_TYPES_EXT_FLOAT = MKCREFLECT_TYPES_FLOAT, /** Data type double. */ HT_MKCREFLECT_TYPES_EXT_DOUBLE = MKCREFLECT_TYPES_DOUBLE, /** Data type pointer. */ HT_MKCREFLECT_TYPES_EXT_POINTER = MKCREFLECT_TYPES_POINTER, /** Data type unsigned integer. */ HT_MKCREFLECT_TYPES_EXT_UNSIGNED_INTEGER = 99 } HT_MKCREFLECT_Types_Ext; #endif /* HAWKTRACER_BASE_TYPES_H */
34.779661
88
0.728314
0305684077de385ca2fb5747ce70127bbfa2e7c8
1,401
c
C
nitan/d/huashan/jzroad5.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/d/huashan/jzroad5.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/d/huashan/jzroad5.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
// Room: /d/huashan/jzroad5.c inherit ROOM; void create() { set("short", "中條山密林"); set("long", @LONG 山路越來越小,周圍茂密森林裏和腳下的茅草封住了路,上不見 天光,後不見歸路(road),你簡直絕望了。 LONG ); set("exits", ([ "northdown" : __DIR__"jzroad4", ])); set("item_desc", ([ "road" : "路邊模模糊糊,好像有個碑。可是太暗了實在看不見。\n", ])); set("no_clean_up", 0); setup(); } void init() { add_action("do_use", "use"); add_action("do_zuan", "zuan"); } int do_use(string arg) { object me; me = this_player(); if( !arg || arg=="" ) return 0; if (!present("fire", me)) return 0; if( arg=="fire" ) { write( "你點燃了火折,發現是一圍大樹,被削去樹皮的樹幹上書“中條山”三字。 側邊一個樹洞,似乎可以鑽(zuan)過去。\n"); set_temp("marks/鑽1", 1, this_player()); return 1; } } int do_zuan(string arg) { object me; me = this_player(); if( query_temp("marks/鑽1", me)){ message("vision", me->name() + "側身滋溜一下鑽進樹洞不見了。\n", environment(me), ({me}) ); me->move(__DIR__"jzroad6"); message("vision", me->name() + "從樹裏鑽了出來。\n", environment(me), ({me}) ); delete_temp("marks/鑽1", this_player()); return 1; } else { write("你想往哪兒鑽?!\n"); return 1; } }
22.967213
63
0.463241
0305b80fceb9c236d070e374c2c91688b6b49b0d
8,709
h
C
OGDF/src/energybased/FMEKernel.h
jim-bo/silp2
1186a84b2570af0e4ed305ddfff8f931e012eadf
[ "MIT" ]
1
2018-01-29T05:00:43.000Z
2018-01-29T05:00:43.000Z
OGDF/src/energybased/FMEKernel.h
jim-bo/silp2
1186a84b2570af0e4ed305ddfff8f931e012eadf
[ "MIT" ]
1
2016-01-31T13:13:10.000Z
2016-02-02T14:16:05.000Z
OGDF/src/energybased/FMEKernel.h
jim-bo/silp2
1186a84b2570af0e4ed305ddfff8f931e012eadf
[ "MIT" ]
null
null
null
/* * $Revision: 2565 $ * * last checkin: * $Author: gutwenger $ * $Date: 2012-07-07 17:14:54 +0200 (Sa, 07. Jul 2012) $ ***************************************************************/ /** \file * \brief Declaration of FME kernel. * * \author Martin Gronemann * * \par License: * This file is part of the Open Graph Drawing Framework (OGDF). * * \par * Copyright (C)<br> * See README.txt in the root directory of the OGDF installation for details. * * \par * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * Version 2 or 3 as published by the Free Software Foundation; * see the file LICENSE.txt included in the packaging of this file * for details. * * \par * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * \par * You should have received a copy of the GNU General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * * \see http://www.gnu.org/copyleft/gpl.html ***************************************************************/ #ifdef _MSC_VER #pragma once #endif #ifndef OGDF_FME_KERNEL_H #define OGDF_FME_KERNEL_H #include <ogdf/basic/basic.h> #include "FastUtils.h" #include "ArrayGraph.h" #include "FMEThread.h" #include <list> namespace ogdf { class FMEKernel { public: FMEKernel(FMEThread* pThread) : m_pThread(pThread) { } inline void sync() { m_pThread->sync(); } //! returns the index of the thread ( 0.. numThreads()-1 ) inline __uint32 threadNr() const { return m_pThread->threadNr(); } //! returns the total number of threads in the pool inline __uint32 numThreads() const { return m_pThread->numThreads(); } //! returns true if this is the main thread ( the main thread is always the first thread ) inline bool isMainThread() const { return m_pThread->isMainThread(); } //! returns true if this run only uses one thread ) inline bool isSingleThreaded() const { return (m_pThread->numThreads() == 1); }; private: FMEThread* m_pThread; }; #define FME_KERNEL_USE_OLD #define COMPUTE_FORCE_PROTECTION_FACTOR 0.25f // makro for force computation via SSE s / max(s*0.5, (dx*dx + dy*dy)) #define _MM_COMPUTE_FORCE(dx,dy,s) _mm_div_ps((s),_mm_max_ps(_mm_mul_ps((s),_mm_set1_ps(COMPUTE_FORCE_PROTECTION_FACTOR)), _mm_add_ps(_mm_mul_ps((dx),(dx)), _mm_mul_ps((dy),(dy))))) #define COMPUTE_FORCE(dx,dy,s) (s/(max<float>(s*COMPUTE_FORCE_PROTECTION_FACTOR, (dx)*(dx) + (dy)*(dy)))) inline double move_nodes(float* x, float* y, const __uint32 begin, const __uint32 end, const float* fx, const float* fy, const float t) { double dsq_max = 0.0; for (__uint32 i=begin; i <= end; i++) { double dsq = fx[i]*fx[i] + fy[i]*fy[i]; x[i] += fx[i]*t; y[i] += fy[i]*t; dsq_max = max(dsq_max, dsq); } return dsq_max; } inline void eval_edges(const ArrayGraph& graph, const __uint32 begin, const __uint32 end, float* fx, float* fy) { const float* x = graph.nodeXPos(); const float* y = graph.nodeYPos(); const float* e = graph.desiredEdgeLength(); for (__uint32 i=begin; i <= end; i++) { const EdgeAdjInfo& e_info = graph.edgeInfo(i); const __uint32 a = e_info.a; const __uint32 b = e_info.b; const NodeAdjInfo& a_info = graph.nodeInfo(a); const NodeAdjInfo& b_info = graph.nodeInfo(b); float dx = x[a] - x[b]; float dy = y[a] - y[b]; float dsq = dx*dx + dy*dy; float f = (logf(dsq)*0.5f-logf(e[i])) * 0.25f; float fa = (float)(f/((float)a_info.degree)); float fb = (float)(f/((float)b_info.degree)); fx[a] -= dx*fa; fy[a] -= dy*fa; fx[b] += dx*fb; fy[b] += dy*fb; } } //! kernel function to evaluate forces between n points with coords x, y directly. result is stored in fx, fy inline void eval_direct(float* x, float* y, float* s, float* fx, float* fy, size_t n) { for (__uint32 i=0; i < n; i++) { for (__uint32 j=i+1; j < n; j++) { float dx = x[i] - x[j]; float dy = y[i] - y[j]; #ifdef FME_KERNEL_USE_OLD float s_sum = s[i]+s[j]; #else float s_sum = s[i]*s[j]; #endif float f = COMPUTE_FORCE(dx, dy, s_sum); fx[i] += dx*f; fy[i] += dy*f; fx[j] -= dx*f; fy[j] -= dy*f; } } } //! kernel function to evaluate forces between two sets of points with coords x1, y1 (x2, y2) directly. result is stored in fx1, fy1 (fx2, fy2 inline void eval_direct(float* x1, float* y1, float* s1, float* fx1, float* fy1, size_t n1, float* x2, float* y2, float* s2, float* fx2, float* fy2, size_t n2) { for (__uint32 i=0; i < n1; i++) { for (__uint32 j=0; j < n2; j++) { float dx = x1[i] - x2[j]; float dy = y1[i] - y2[j]; #ifdef FME_KERNEL_USE_OLD float s_sum = s1[i]+s2[j]; #else float s_sum = s1[i]*s2[j]; #endif float f = COMPUTE_FORCE(dx, dy, s_sum); fx1[i] += dx*f; fy1[i] += dy*f; fx2[j] -= dx*f; fy2[j] -= dy*f; } } } #ifndef OGDF_FME_KERNEL_USE_SSE_DIRECT //! kernel function to evaluate forces between n points with coords x, y directly. result is stored in fx, fy inline void eval_direct_fast(float* x, float* y, float* s, float* fx, float* fy, size_t n) { eval_direct(x, y, s, fx, fy, n); } //! kernel function to evaluate forces between two sets of points with coords x1, y1 (x2, y2) directly. result is stored in fx1, fy1 (fx2, fy2 inline void eval_direct_fast(float* x1, float* y1, float* s1, float* fx1, float* fy1, size_t n1, float* x2, float* y2, float* s2, float* fx2, float* fy2, size_t n2) { eval_direct(x1, y1, s1, fx1, fy1, n1, x2, y2, s2, fx2, fy2, n2); } #else //! kernel function to evaluate forces between n points with coords x, y directly. result is stored in fx, fy void eval_direct_fast(float* x, float* y, float* s, float* fx, float* fy, size_t n); //! kernel function to evaluate forces between two sets of points with coords x1, y1 (x2, y2) directly. result is stored in fx1, fy1 (fx2, fy2 void eval_direct_fast( float* x1, float* y1, float* s1, float* fx1, float* fy1, size_t n1, float* x2, float* y2, float* s2, float* fx2, float* fy2, size_t n2); #endif //! kernel function to evalute a local expansion at point x,y result is added to fx, fy void fast_multipole_l2p(double* localCoeffiecients, __uint32 numCoeffiecients, double centerX, double centerY, float x, float y, float q, float& fx, float &fy); void fast_multipole_p2m(double* mulitCoeffiecients, __uint32 numCoeffiecients, double centerX, double centerY, float x, float y, float q); class FMEBasicKernel { public: inline void edgeForces(const ArrayGraph& graph, float* fx, float* fy) { eval_edges(graph, 0, graph.numEdges()-1, fx, fy); } inline void repForces(ArrayGraph& graph, float* fx, float* fy) { eval_direct_fast(graph.nodeXPos(), graph.nodeYPos(), graph.nodeSize(), fx, fy, graph.numNodes()); } inline double moveNodes(ArrayGraph& graph, float* fx, float* fy, float timeStep) { return move_nodes(graph.nodeXPos(), graph.nodeYPos(), 0, graph.numNodes()-1, fx, fy, timeStep); } inline double simpleIteration(ArrayGraph& graph, float* fx, float* fy, float timeStep) { repForces(graph, fx, fy); edgeForces(graph, fx, fy); return moveNodes(graph, fx, fy, timeStep); } inline double simpleEdgeIteration(ArrayGraph& graph, float* fx, float* fy, float timeStep) { edgeForces(graph, fx, fy); return moveNodes(graph, fx, fy, timeStep); } inline void simpleForceDirected(ArrayGraph& graph, float timeStep, __uint32 minIt, __uint32 maxIt, __uint32 preProcIt, double threshold) { bool earlyExit = false; float* fx = (float*)MALLOC_16(sizeof(float)*graph.numNodes()); float* fy = (float*)MALLOC_16(sizeof(float)*graph.numNodes()); for (__uint32 i = 0; i<preProcIt; i++) { for (__uint32 j = 0; j<graph.numNodes(); j++) { fx[j] = 0.0f; fy[j] = 0.0f; } simpleEdgeIteration(graph, fx, fy, timeStep); } for(__uint32 i = 0; (i<maxIt) && (!earlyExit); i++) { for (__uint32 j = 0; j<graph.numNodes(); j++) { fx[j] = 0.0f; fy[j] = 0.0f; } double dsq = simpleIteration(graph, fx, fy, timeStep); if (dsq < threshold && i>(minIt)) earlyExit = true; } FREE_16(fx); FREE_16(fy); } private: }; class FMESingleKernel : FMEBasicKernel { public: //FMESingleKernel(FMEThread* pThread) : FMEKernel(pThread) {}; void operator()(ArrayGraph& graph, float timeStep, __uint32 minIt, __uint32 maxIt, double threshold) { simpleForceDirected(graph, timeStep, minIt, maxIt, 20, threshold); } }; } // end of namespace ogdf #endif
29.927835
181
0.662763
0305fa8bf9b628240b8c34d9c8d7a06b7d8db735
39
h
C
selfdrive/common/version.h
peoplethink/op10
97d5b074808b1311252785f922006884bdb1691b
[ "MIT" ]
null
null
null
selfdrive/common/version.h
peoplethink/op10
97d5b074808b1311252785f922006884bdb1691b
[ "MIT" ]
null
null
null
selfdrive/common/version.h
peoplethink/op10
97d5b074808b1311252785f922006884bdb1691b
[ "MIT" ]
null
null
null
#define COMMA_VERSION "GENESIS_0.8.10"
19.5
38
0.794872
030757697d14152511cf7304b70da7fc1a931f58
888
h
C
src/Camera.h
zippybenjiman/PythonCraft
daeb9b4eac1530c98843bf8fc412345f58e37c97
[ "MIT" ]
51
2015-08-08T22:36:47.000Z
2022-03-02T20:20:54.000Z
src/Camera.h
zippybenjiman/PythonCraft
daeb9b4eac1530c98843bf8fc412345f58e37c97
[ "MIT" ]
3
2016-04-12T16:36:58.000Z
2019-03-02T21:46:10.000Z
src/Camera.h
zippybenjiman/PythonCraft
daeb9b4eac1530c98843bf8fc412345f58e37c97
[ "MIT" ]
13
2016-03-25T07:05:40.000Z
2021-08-15T12:19:04.000Z
#ifndef _CAMERA_H_ #define _CAMERA_H_ #include "CommonInc.h" #include "Quaternion.h" #include "Vector3.h" #include "Matrix4.h" const float PI = atan(1)*4; inline float radians(float degree) { return degree*PI/180.0; } inline float degrees(float radians) { return radians*180.0/PI; } class Camera { public: Camera() float pitchAngle; float yawAngle; float rollAngle; float shiftX,shiftY,shiftZ; Quaternion pitch,yaw,roll; Vector3 position,vecX,vecY,vecZ; Matrix4 ModelViewMatrix; void setPosition(float x,float y,float z) { position = Vector3(x,y,z); position.z = -position.z; } void setPerspective() { pitch = Quaternion(radians(pitchAngle),Vector3::UNIT_X); yaw = Quaternion(radians(yawAngle),Vector3::UNIT_Y); roll = Quaternion(radians(rollAngle),Vector3::UNIT_Z); Quaternion rot = pitch * yaw * roll; Mrot.ToRotationMatrix(); } }; #endif
15.050847
58
0.716216
0307b747ca749d4aa8d2e4be75602fa99ec42bf1
4,269
h
C
include/s1ap/s1ap.h
badhrinathpa/openmme
6975dc7ba007cd111fdce8e8f64d3d52bef0a625
[ "Apache-2.0" ]
46
2019-02-19T07:47:54.000Z
2022-03-12T13:16:26.000Z
include/s1ap/s1ap.h
omec-project/openmme
181ee0a2a16fe4eea1b84986477f37d6ebbe55c3
[ "Apache-2.0" ]
71
2019-03-03T02:22:33.000Z
2020-10-07T22:34:25.000Z
include/s1ap/s1ap.h
badhrinathpa/openmme
6975dc7ba007cd111fdce8e8f64d3d52bef0a625
[ "Apache-2.0" ]
38
2019-02-19T06:36:40.000Z
2021-07-17T14:35:50.000Z
/* * Copyright 2019-present Open Networking Foundation * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd. * Copyright (c) 2017 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ #ifndef __S1AP_H_ #define __S1AP_H_ #include <stdbool.h> #include "s1ap_structs.h" #include "log.h" #include "s1ap_ie.h" #include "InitiatingMessage.h" #include "SuccessfulOutcome.h" #include "UnsuccessfulOutcome.h" #include "common_proc_info.h" #include "s1ap_config.h" /* Put all the instances within this */ typedef struct s1ap_instance { s1ap_config_t *s1ap_config; }s1ap_instance_t; int s1_init_ctx_resp_handler(SuccessfulOutcome_t *msg); int parse_IEs(char *msg, struct proto_IE *proto_ies, unsigned short proc_code); int convertToInitUeProtoIe(InitiatingMessage_t *msg, struct proto_IE* proto_ies); int convertUplinkNasToProtoIe(InitiatingMessage_t *msg, struct proto_IE* proto_ies); int convertUeCtxRelReqToProtoIe(InitiatingMessage_t *msg, struct proto_IE* proto_ies); int convertInitCtxRspToProtoIe(SuccessfulOutcome_t *msg, struct proto_IE* proto_ies); int convertUeCtxRelComplToProtoIe(SuccessfulOutcome_t *msg, struct proto_IE* proto_ies); int s1_setup_handler(InitiatingMessage_t *msg, int enb_fd); int s1_ctx_release_req_handler(InitiatingMessage_t *msg); int s1_init_ue_handler(struct proto_IE *s1_init_ies, int enb_fd); void handle_s1ap_message(void *message); int s1ap_mme_encode_ue_context_release_command( struct s1ap_common_req_Q_msg *s1apPDU, uint8_t **buffer, uint32_t *length); int s1ap_mme_encode_paging_request( struct s1ap_common_req_Q_msg *s1apPDU, uint8_t **buffer, uint32_t *length); int s1ap_mme_encode_initiating( struct s1ap_common_req_Q_msg *s1apPDU, uint8_t **buffer, uint32_t *length); int s1ap_mme_encode_outcome( struct s1ap_common_req_Q_msg *s1apPDU, uint8_t **buffer, uint32_t *length); int s1ap_mme_encode_initial_context_setup_request( struct s1ap_common_req_Q_msg *s1apPDU, uint8_t **buffer, uint32_t *length); int s1ap_mme_encode_service_rej( struct s1ap_common_req_Q_msg *s1apPDU, uint8_t **buffer, uint32_t *length); int s1ap_mme_encode_s1_setup_failure( struct s1ap_common_req_Q_msg *s1apPDU, uint8_t **buffer, uint32_t *length); int s1ap_mme_encode_s1_setup_response( struct s1ap_common_req_Q_msg *s1apPDU, uint8_t **buffer, uint32_t *length); int s1ap_mme_encode_attach_rej( struct s1ap_common_req_Q_msg *s1apPDU, uint8_t **buffer, uint32_t *length); int s1ap_mme_decode_initiating (InitiatingMessage_t *initiating_p, int enb_fd); int s1ap_mme_decode_successfull_outcome (SuccessfulOutcome_t *initiating_p); int s1ap_mme_decode_unsuccessfull_outcome (UnsuccessfulOutcome_t *initiating_p); int init_s1ap(); void read_config(); void* IAM_handler(void *data); int s1_esm_resp_handler(struct proto_IE *s1_esm_resp_ies); int s1_secmode_resp_handler(struct proto_IE *s1_sec_resp_ies); int s1_auth_resp_handler(struct proto_IE *s1_auth_resp_ies); int s1_auth_fail_handler(struct proto_IE *s1_auth_resp_ies); int s1_attach_complete_handler(struct proto_IE *s1_esm_resp_ies); int detach_stage1_handler(struct proto_IE *detach_ies, bool retransmit); int s1_identity_resp_handler(struct proto_IE *s1); int s1_tau_request_handler(struct proto_IE *s1, int enb_fd); int s1_init_ue_service_req_handler(struct proto_IE *service_req_ies, int enb_fd); int s1_ctx_release_resp_handler(SuccessfulOutcome_t *msg); int s1_ctx_release_req_handler(InitiatingMessage_t *msg); int copyU16(unsigned char *buffer, uint32_t val); int send_sctp_msg(int connSock, unsigned char *buffer, size_t len, uint16_t stream_no); void buffer_copy(struct Buffer *buffer, void *value, size_t size); /** * @brief Decode int value from the byte array received in the s1ap incoming * packet. * @param[in] bytes - Array of bytes in packet * @param[in] len - Length of the bytes array from which to extract the int * @return Integer value extracted out of bytes array. 0 if failed. */ int decode_int_val(unsigned char *bytes, short len); char* msg_to_hex_str(const char *msg, int len, char **buffer); unsigned short get_length(char **msg); #endif /*__S1AP_H_*/
26.849057
88
0.783322
0308df152e0979fc629020678527364f1f0ae238
364
h
C
src/widgets/colorlisteditor.h
aalele/MRCEditor
016f77e6f986a5134e3fd27680208c12a574129b
[ "MIT" ]
4
2018-10-31T14:49:25.000Z
2018-12-01T05:04:54.000Z
src/widgets/colorlisteditor.h
aalele/MRCEditor
016f77e6f986a5134e3fd27680208c12a574129b
[ "MIT" ]
null
null
null
src/widgets/colorlisteditor.h
aalele/MRCEditor
016f77e6f986a5134e3fd27680208c12a574129b
[ "MIT" ]
1
2019-05-21T14:29:22.000Z
2019-05-21T14:29:22.000Z
#ifndef COLORLISTEDITOR_H #define COLORLISTEDITOR_H #include <QComboBox> QT_BEGIN_NAMESPACE class QColor; class QWidget; QT_END_NAMESPACE class ColorListEditor : public QComboBox { Q_OBJECT public: ColorListEditor(QWidget *widget = nullptr); public: QColor color() const; void setColor(QColor c); private: void populateList(); }; #endif
13.481481
47
0.747253
030a4cdfe9037074b7c1b7be3dd0f0bc599b7450
155
h
C
sdlutils/sdlutils_demo.h
javics2002/Paella
53449d828b09ba63805ea9ee5a2f6b2d178490dc
[ "MIT" ]
4
2022-01-29T16:50:42.000Z
2022-03-04T09:44:59.000Z
sdlutils/sdlutils_demo.h
javics2002/Paella
53449d828b09ba63805ea9ee5a2f6b2d178490dc
[ "MIT" ]
194
2022-01-27T09:47:37.000Z
2022-03-31T21:42:06.000Z
sdlutils/sdlutils_demo.h
javics2002/Paella
53449d828b09ba63805ea9ee5a2f6b2d178490dc
[ "MIT" ]
2
2022-02-05T10:18:35.000Z
2022-03-27T11:52:13.000Z
// This file is part of the course TPV2@UCM - Samir Genaim #pragma once // declaration of functions defined in demo.cpp void sdlutils_basic_demo(void);
22.142857
58
0.76129
030a7a54a6ed62ee499458d36804b5307003c133
3,793
h
C
aws-cpp-sdk-greengrass/include/aws/greengrass/model/TelemetryConfiguration.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
1
2022-02-10T08:06:54.000Z
2022-02-10T08:06:54.000Z
aws-cpp-sdk-greengrass/include/aws/greengrass/model/TelemetryConfiguration.h
Neusoft-Technology-Solutions/aws-sdk-cpp
88c041828b0dbee18a297c3cfe98c5ecd0706d0b
[ "Apache-2.0" ]
1
2022-01-03T23:59:37.000Z
2022-01-03T23:59:37.000Z
aws-cpp-sdk-greengrass/include/aws/greengrass/model/TelemetryConfiguration.h
ravindra-wagh/aws-sdk-cpp
7d5ff01b3c3b872f31ca98fb4ce868cd01e97696
[ "Apache-2.0" ]
1
2021-12-30T04:25:33.000Z
2021-12-30T04:25:33.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/greengrass/Greengrass_EXPORTS.h> #include <aws/greengrass/model/ConfigurationSyncStatus.h> #include <aws/greengrass/model/Telemetry.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } // namespace Json } // namespace Utils namespace Greengrass { namespace Model { /** * Configuration settings for running telemetry.<p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/greengrass-2017-06-07/TelemetryConfiguration">AWS * API Reference</a></p> */ class AWS_GREENGRASS_API TelemetryConfiguration { public: TelemetryConfiguration(); TelemetryConfiguration(Aws::Utils::Json::JsonView jsonValue); TelemetryConfiguration& operator=(Aws::Utils::Json::JsonView jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * Synchronization status of the device reported configuration with the desired * configuration. */ inline const ConfigurationSyncStatus& GetConfigurationSyncStatus() const{ return m_configurationSyncStatus; } /** * Synchronization status of the device reported configuration with the desired * configuration. */ inline bool ConfigurationSyncStatusHasBeenSet() const { return m_configurationSyncStatusHasBeenSet; } /** * Synchronization status of the device reported configuration with the desired * configuration. */ inline void SetConfigurationSyncStatus(const ConfigurationSyncStatus& value) { m_configurationSyncStatusHasBeenSet = true; m_configurationSyncStatus = value; } /** * Synchronization status of the device reported configuration with the desired * configuration. */ inline void SetConfigurationSyncStatus(ConfigurationSyncStatus&& value) { m_configurationSyncStatusHasBeenSet = true; m_configurationSyncStatus = std::move(value); } /** * Synchronization status of the device reported configuration with the desired * configuration. */ inline TelemetryConfiguration& WithConfigurationSyncStatus(const ConfigurationSyncStatus& value) { SetConfigurationSyncStatus(value); return *this;} /** * Synchronization status of the device reported configuration with the desired * configuration. */ inline TelemetryConfiguration& WithConfigurationSyncStatus(ConfigurationSyncStatus&& value) { SetConfigurationSyncStatus(std::move(value)); return *this;} /** * Configure telemetry to be on or off. */ inline const Telemetry& GetTelemetry() const{ return m_telemetry; } /** * Configure telemetry to be on or off. */ inline bool TelemetryHasBeenSet() const { return m_telemetryHasBeenSet; } /** * Configure telemetry to be on or off. */ inline void SetTelemetry(const Telemetry& value) { m_telemetryHasBeenSet = true; m_telemetry = value; } /** * Configure telemetry to be on or off. */ inline void SetTelemetry(Telemetry&& value) { m_telemetryHasBeenSet = true; m_telemetry = std::move(value); } /** * Configure telemetry to be on or off. */ inline TelemetryConfiguration& WithTelemetry(const Telemetry& value) { SetTelemetry(value); return *this;} /** * Configure telemetry to be on or off. */ inline TelemetryConfiguration& WithTelemetry(Telemetry&& value) { SetTelemetry(std::move(value)); return *this;} private: ConfigurationSyncStatus m_configurationSyncStatus; bool m_configurationSyncStatusHasBeenSet; Telemetry m_telemetry; bool m_telemetryHasBeenSet; }; } // namespace Model } // namespace Greengrass } // namespace Aws
31.608333
169
0.720538
030ac49da28d30ef02d9432a9ec92f726b52d4c3
295
c
C
test cases/common/201 override with exe/subprojects/sub/foobar.c
gerion0/meson
48a5d17830820e4729d252fc33c26fb9dac66404
[ "Apache-2.0" ]
5
2019-02-27T17:09:02.000Z
2021-06-14T15:20:49.000Z
test cases/common/201 override with exe/subprojects/sub/foobar.c
gerion0/meson
48a5d17830820e4729d252fc33c26fb9dac66404
[ "Apache-2.0" ]
null
null
null
test cases/common/201 override with exe/subprojects/sub/foobar.c
gerion0/meson
48a5d17830820e4729d252fc33c26fb9dac66404
[ "Apache-2.0" ]
3
2020-07-13T09:01:35.000Z
2021-06-03T18:21:50.000Z
#include <assert.h> #include <stdio.h> int main(int argc, char* argv[]) { FILE *f = fopen(argv[1], "w"); const char msg[] = "int main(void) {return 0;}\n"; size_t w = fwrite(msg, 1, sizeof(msg) - 1, f); assert(w == sizeof(msg) - 1); int r = fclose(f); assert(r == 0); return 0; }
22.692308
52
0.566102
030b138b0828be863c93524540555c3903229b3a
6,176
h
C
source/riscvConfig.h
Imperas/riscv-ovpsim-duncgrah
eb164eaec7c6a562754f481fc3f4057cfe105dac
[ "Apache-2.0" ]
null
null
null
source/riscvConfig.h
Imperas/riscv-ovpsim-duncgrah
eb164eaec7c6a562754f481fc3f4057cfe105dac
[ "Apache-2.0" ]
null
null
null
source/riscvConfig.h
Imperas/riscv-ovpsim-duncgrah
eb164eaec7c6a562754f481fc3f4057cfe105dac
[ "Apache-2.0" ]
1
2020-09-02T14:28:17.000Z
2020-09-02T14:28:17.000Z
/* * Copyright (c) 2005-2020 Imperas Software Ltd., www.imperas.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. * * See the License for the specific language governing permissions and * limitations under the License. * */ #pragma once // Imperas header files #include "hostapi/impTypes.h" // VMI header files #include "vmi/vmiTyperefs.h" // model header files #include "riscvCSR.h" #include "riscvTypeRefs.h" #include "riscvVariant.h" // // Function type for adding documentation // #define RV_DOC_FN(_NAME) void _NAME(riscvP riscv, vmiDocNodeP node) typedef RV_DOC_FN((*riscvDocFn)); // // value indicating numHarts is 0 but configurable // #define RV_NUMHARTS_0 -1 // // This is used to specify documentation and configuration for mandatory // extensions // typedef struct riscvExtConfigS { Uns32 id; // unique extension ID const char **specificDocs; // extension-specific documentation riscvDocFn restrictionsCB; // extension-specific restrictions const void *userData; // extension-specific constant data } riscvExtConfig; // // This is used to define a processor configuration option // typedef struct riscvConfigS { const char *name; // variant name // fundamental variant configuration riscvArchitecture arch; // variant architecture riscvArchitecture archMask; // read/write bits in architecture riscvUserVer user_version; // user-level ISA version riscvPrivVer priv_version; // privileged architecture version riscvVectVer vect_version; // vector architecture version riscvFP16Ver fp16_version; // 16-bit floating point version riscvFSMode mstatus_fs_mode; // mstatus.FS update mode const char **members; // cluster member variants // configuration not visible in CSR state Uns64 reset_address; // reset vector address Uns64 nmi_address; // NMI address Uns32 local_int_num; // number of local interrupts Uns32 lr_sc_grain; // LR/SC region grain size Uns32 ASID_bits; // number of implemented ASID bits Uns32 PMP_grain; // PMP region grain size Uns32 PMP_registers; // number of implemented PMP registers Uns32 Sv_modes; // bit mask of valid Sv modes Uns32 numHarts; // number of hart contexts if MPCore Uns32 tvec_align; // trap vector alignment (vectored mode) Uns32 ELEN; // ELEN (vector extension) Uns32 SLEN; // SLEN (vector extension) Uns32 VLEN; // VLEN (vector extension) Uns32 SEW_min; // minimum SEW (vector extension) Bool debug_mode; // is Debug mode implemented? Bool Zvlsseg; // Zvlsseg implemented? Bool Zvamo; // Zvamo implemented? Bool Zvediv; // Zvediv implemented? Bool Zvqmac; // Zvqmac implemented? Bool updatePTEA; // hardware update of PTE A bit? Bool updatePTED; // hardware update of PTE D bit? Bool unaligned; // whether unaligned accesses supported Bool unalignedAMO; // whether AMO supports unaligned Bool wfi_is_nop; // whether WFI is treated as NOP Bool mtvec_is_ro; // whether mtvec is read-only Bool cycle_undefined; // whether cycle CSR is undefined Bool time_undefined; // whether time CSR is undefined Bool instret_undefined;// whether instret CSR is undefined Bool d_requires_f; // when misa D requires F to be set Bool xret_preserves_lr;// whether xRET preserves current LR Bool require_vstart0; // require vstart 0 if uninterruptible? Bool enable_CSR_bus; // enable CSR implementation bus Bool tval_ii_code; // instruction bits in [sm]tval for // illegal instruction exception? // CSR register values struct { CSR_REG_DECL (mvendorid); // mvendorid value CSR_REG_DECL (marchid); // marchid value CSR_REG_DECL (mimpid); // mimpid value CSR_REG_DECL (mhartid); // mhartid value CSR_REG_DECL (mtvec); // mtvec value CSR_REG_DECL (mstatus); // mstatus reset value } csr; // CSR register masks struct { CSR_REG_DECL (mtvec); // mtvec mask CSR_REG_DECL (stvec); // stvec mask CSR_REG_DECL (utvec); // utvec mask CSR_REG_DECL (cause); // cause mask } csrMask; // custom documentation const char **specificDocs; // custom documentation riscvDocFn restrictionsCB; // custom restrictions // extension configuration information riscvExtConfigCPP extensionConfigs; // null-terminated list of extension // configurations } riscvConfig; // // This returns the supported configuration list // riscvConfigCP riscvGetConfigList(riscvP riscv); // // Get the indexed extension configuration for the processor // inline static riscvExtConfigCP riscvGetIndexedExtConfig( riscvConfigCP config, Uns32 index ) { riscvExtConfigCPP extensionConfigs = config->extensionConfigs; return extensionConfigs ? extensionConfigs[index] : 0; }
41.173333
80
0.610589
030c399d7a262e93f240ea0c7d5b0963497625fd
3,401
c
C
AsciiEngine/EntityManager.c
RandyGaul/AsciiEngine
ffd4766e0f81c5b2efa347484585d09a6e4d2b26
[ "MIT" ]
106
2015-02-09T17:31:32.000Z
2022-03-29T11:30:26.000Z
AsciiEngine/EntityManager.c
RandyGaul/AsciiEngine
ffd4766e0f81c5b2efa347484585d09a6e4d2b26
[ "MIT" ]
null
null
null
AsciiEngine/EntityManager.c
RandyGaul/AsciiEngine
ffd4766e0f81c5b2efa347484585d09a6e4d2b26
[ "MIT" ]
25
2015-03-02T09:32:01.000Z
2022-02-07T03:47:53.000Z
//////////////////////////////////////////////////// // Copyright (c) 2012 ICRL // See the file LICENSE.txt for copying permission. // // Original Author: Randy Gaul // Date: 7/17/2012 // Contact: r.gaul@digipen.edu //////////////////////////////////////////////////// #include "EntityManager.h" #include "FrameRateController.h" // Start of linked list of Entities. // Linked list documentation: http://cecilsunkure.blogspot.com/2010/11/memory-allocation-and-linked-lists.html DEFINE_LIST( P_ENTITY ); LIST_TYPE( P_ENTITY ) *ENTITY_LIST = NULL; // // SendEntityMessage // Purpose: Sends a message to an entity via pointer to the entity. // void SendEntityMessage( ENTITY *entity, EM msg, int var1, int var2 ) { entity->EM_PROC( entity, msg, var1, var2 ); } // // DeleteEntity // Purpose: Used in the NODE_CREATE macro in the DeleteData param. // void DeleteEntity( P_ENTITY entity ) { entity->EM_PROC( (ENTITY *)entity, EM_DESTROY, 0, 0 ); } // // CallbackSendEntityMessage // Purpose: Used to send all entities a message. // RETURN_TYPE CallbackSendEntityMessage( NODE_TYPE( P_ENTITY ) *node, void *param ) { typedef struct { EM msg; int var1; int var2; } paramType; paramType *parameter = (paramType *)param; // Skip inactive entities if(node->data->inactive) return RETURN_SUCCESS; SendEntityMessage( node->data, parameter->msg, parameter->var1, parameter->var2 ); return RETURN_SUCCESS; } // // SendEntitiesMessage // Purpose: Sends a message to all live entities. // void SendEntitiesMessage( EM msg, int var1, int var2 ) { typedef struct { EM msg; int var1; int var2; } paramType; paramType parameter = { msg, var1, var2 }; LIST_CALLER( P_ENTITY, ENTITY_LIST, CallbackSendEntityMessage, &parameter ); } // // UpdateEntities // Purpose: Cycles the entity list and calls their update functions. // RETURN_TYPE UpdateEntities( void ) { float dt = GetDT( ); SendEntitiesMessage( EM_UPDATE, (int)&dt, 0 ); return RETURN_SUCCESS; } // // DrawEntities // Purpose: Cycles the Entity list and calls their draw functions. // RETURN_TYPE DrawEntities( void ) { SendEntitiesMessage( EM_DRAW, 0, 0 ); return RETURN_SUCCESS; } // // CallbackDeleteNode // Purpose: Used to delete all nodes. // RETURN_TYPE CallbackDeleteNode( NODE_TYPE( P_ENTITY ) *node, void *param ) { SendEntityMessage( node->data, EM_DESTROY, 0, 0 ); free( node->data ); LIST_REMOVE( P_ENTITY, ENTITY_LIST, node ); return RETURN_SUCCESS; } // // DestroyEntities // Purpose: Cycles the entity list and calls their destroy functions. // RETURN_TYPE DestroyEntities( void ) { LIST_CALLER( P_ENTITY, ENTITY_LIST, CallbackDeleteNode, 0 ); return RETURN_SUCCESS; } // // CallbackSerializeEntity // Purpose: Used to serialize all nodes. // RETURN_TYPE CallbackSerializeEntity( NODE_TYPE( P_ENTITY ) *node, void *param ) { EntityToFile( node->data ); return RETURN_SUCCESS; } // // SerializeAllEntities // Purpose: Serializes all active entities into a text file. // void SerializeAllEntities( const char *fileName ) { SerializerSetFile( fileName ); SerializeMapDimensions( ); LIST_CALLER( P_ENTITY, ENTITY_LIST, CallbackSerializeEntity, 0 ); SerializerCloseFile( ); }
22.97973
111
0.660688
030ef277f9fef04d6a730cf253d60e92c6b25607
748
h
C
controller/ironstack_types/openflow_switch_config.h
zteo-phd-software/ironstack
649f82ddcbb82831796fa2a1e1d1b8cc0f94a8e0
[ "BSD-3-Clause" ]
null
null
null
controller/ironstack_types/openflow_switch_config.h
zteo-phd-software/ironstack
649f82ddcbb82831796fa2a1e1d1b8cc0f94a8e0
[ "BSD-3-Clause" ]
null
null
null
controller/ironstack_types/openflow_switch_config.h
zteo-phd-software/ironstack
649f82ddcbb82831796fa2a1e1d1b8cc0f94a8e0
[ "BSD-3-Clause" ]
null
null
null
#ifndef __OPENFLOW_SWITCH_CONFIGURATION #define __OPENFLOW_SWITCH_CONFIGURATION #include <arpa/inet.h> #include <assert.h> #include <stdint.h> #include <string> #include <sstream> #include "../../common/autobuf.h" #include "../../common/openflow.h" class openflow_switch_config { public: void clear(); std::string to_string() const; bool frag_normal; // no special handling for fragments bool frag_drop; // drop fragments bool frag_reasm; // reassemble IP fragments (only if switch capabilities OFPC_IP_REASM is set) bool frag_mask; // ?? not described uint16_t max_msg_send_len; // maximum length of message summary to be sent on packet-in events autobuf serialize() const; bool deserialize(const autobuf& input); }; #endif
24.129032
96
0.748663
030fe1c7a90f702090482c6a96d0576fe6664026
5,642
h
C
arch/arm/src/tiva/hardware/tiva_qencoder.h
Mzonetd/MNuttx
13560d6fa394c0c1b1a1a0b6d60e21fe9bdf0bc2
[ "MIT" ]
51
2019-04-16T15:11:10.000Z
2022-03-30T11:58:53.000Z
arch/arm/src/tiva/hardware/tiva_qencoder.h
Mzonetd/MNuttx
13560d6fa394c0c1b1a1a0b6d60e21fe9bdf0bc2
[ "MIT" ]
18
2019-04-17T05:42:38.000Z
2022-03-04T06:51:46.000Z
arch/arm/src/tiva/hardware/tiva_qencoder.h
Mzonetd/MNuttx
13560d6fa394c0c1b1a1a0b6d60e21fe9bdf0bc2
[ "MIT" ]
26
2019-04-15T19:26:37.000Z
2022-01-29T19:45:00.000Z
/************************************************************************************ * arch/arm/src/tiva/hardware/tiva_qencoder.h * * Copyright (C) 2016 Young Mu. All rights reserved. * Author: Young Mu <young.mu@aliyun.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ************************************************************************************/ #ifndef __ARCH_ARM_SRC_TIVA_HARDWARE_TIVA_QENCODER_H #define __ARCH_ARM_SRC_TIVA_HARDWARE_TIVA_QENCODER_H /************************************************************************************ * Included Files ************************************************************************************/ /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ #define TIVA_QEI_CTL_OFFSET (0x0) /* QEI Control */ #define TIVA_QEI_STAT_OFFSET (0x4) /* QEI Status */ #define TIVA_QEI_POS_OFFSET (0x8) /* QEI Position */ #define TIVA_QEI_MAXPOS_OFFSET (0xc) /* QEI Maximum Position */ #define TIVA_QEI_LOAD_OFFSET (0x10) /* QEI Timer Load */ #define TIVA_QEI_TIME_OFFSET (0x14) /* QEI Timer */ #define TIVA_QEI_COUNT_OFFSET (0x18) /* QEI Velocity Counter */ #define TIVA_QEI_SPEED_OFFSET (0x1c) /* QEI Velocity */ #define TIVA_QEI_INTEN_OFFSET (0x20) /* QEI Interrupt Enable */ #define TIVA_QEI_RIS_OFFSET (0x24) /* QEI Raw Interrupt Status */ #define TIVA_QEI_ISC_OFFSET (0x28) /* QEI Interrupt Status and Clear */ #define TIVA_QEI_CTL_FILTCNT (16) /* (Bit) Input Filter Prescale Count */ #define TIVA_QEI_CTL_FILTEN (13) /* (Bit) Enable Input Filter */ #define TIVA_QEI_CTL_STALLEN (12) /* (Bit) Stall QEI */ #define TIVA_QEI_CTL_INVI (11) /* (Bit) Invert Index Pulse */ #define TIVA_QEI_CTL_INVB (10) /* (Bit) Invert PhB */ #define TIVA_QEI_CTL_INVA (9) /* (Bit) Invert PhA */ #define TIVA_QEI_CTL_SIGMODE (2) /* (Bit) Signal Mode */ #define TIVA_QEI_CTL_SWAP (1) /* (Bit) Swap Signals */ #define TIVA_QEI_CTL_VELDIV (6) /* (Bit) Predivide Velocity */ #define VELDIV_1 (0x0) /* (Value) Divided by 1 */ #define VELDIV_2 (0x1) /* (Value) Divided by 2 */ #define VELDIV_4 (0x2) /* (Value) Divided by 4 */ #define VELDIV_8 (0x3) /* (Value) Divided by 8 */ #define VELDIV_16 (0x4) /* (Value) Divided by 16 */ #define VELDIV_32 (0x5) /* (Value) Divided by 32 */ #define VELDIV_64 (0x6) /* (Value) Divided by 64 */ #define VELDIV_128 (0x7) /* (Value) Divided by 128 */ #define TIVA_QEI_CTL_VELEN (5) /* (Bit) Capture Velocity */ #define VELEN_DISABLE (0) /* (value) Disable Velocity Capture */ #define VELEN_ENABLE (1) /* (value) Enable Velocity Capture */ #define TIVA_QEI_CTL_RESMODE (4) /* (Bit) Reset Mode */ #define RESMODE_BY_MAXPOS (0) /* (Value) Reset by MAXPOS */ #define RESMODE_BY_INDEX_PULSE (1) /* (Value) Reset by Index Pulse */ #define TIVA_QEI_CTL_CAPMODE (3) /* (Bit) Capture Mode */ #define CAPMODE_ONLY_PHA (0) /* (Value) Count PhA both edges */ #define CAPMODE_PHA_AND_PHB (1) /* (Value) Count PhA and PhB both edges */ #define TIVA_QEI_CTL_ENABLE (0) /* (Bit) Enable QEI */ #define QEI_DISABLE (0) /* (Value) Disable QEI */ #define QEI_ENABLE (1) /* (Value) Enable QEI */ #define TIVA_QEI_STAT_DIRECTION (1) /* (Bit) Direction of Rotation */ #define DIRECTION_FORWARD (0) /* (Value) Forward */ #define DIRECTION_BACKWARD (1) /* (Value) Backward */ #endif /* __ARCH_ARM_SRC_TIVA_HARDWARE_TIVA_QENCODER_H */
56.989899
90
0.569656
03104dc44af21ed55e43da09a5dd04b6ee877515
584
h
C
onnxruntime/test/onnx/heap_buffer.h
dahburj/onnxruntime
cd5f74be6250a5a672decc1fd234e200dac36878
[ "MIT" ]
2
2019-07-30T10:37:33.000Z
2021-01-05T21:12:29.000Z
onnxruntime/test/onnx/heap_buffer.h
dahburj/onnxruntime
cd5f74be6250a5a672decc1fd234e200dac36878
[ "MIT" ]
8
2019-10-08T14:20:49.000Z
2021-04-19T16:56:52.000Z
onnxruntime/test/onnx/heap_buffer.h
dahburj/onnxruntime
cd5f74be6250a5a672decc1fd234e200dac36878
[ "MIT" ]
3
2019-10-03T16:23:35.000Z
2021-04-13T12:00:20.000Z
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #include <vector> #include <memory> struct OrtCallback; /** * A holder for delay freed buffers */ class HeapBuffer { public: HeapBuffer() = default; /** * free all the buffers allocated from 'AllocMemory' function */ ~HeapBuffer(); void* AllocMemory(size_t size) { void* p = malloc(size); buffers_.push_back(p); return p; } void AddDeleter(OrtCallback* d); private: std::vector<OrtCallback*> deleters_; std::vector<void*> buffers_; };
20.137931
63
0.681507
0311a7c1411e496c121392fca8a342264c145288
855
h
C
src/animator/SkDisplayMath.h
AsdMonio/rr-external_skia
3839e72932bcef2f26a4f8826bb92b195f6cc396
[ "Apache-2.0" ]
5,964
2016-09-27T03:46:29.000Z
2022-03-31T16:25:27.000Z
third_party/skia/src/animator/SkDisplayMath.h
w4454962/miniblink49
b294b6eacb3333659bf7b94d670d96edeeba14c0
[ "Apache-2.0" ]
459
2016-09-29T00:51:38.000Z
2022-03-07T14:37:46.000Z
third_party/skia/src/animator/SkDisplayMath.h
w4454962/miniblink49
b294b6eacb3333659bf7b94d670d96edeeba14c0
[ "Apache-2.0" ]
1,006
2016-09-27T05:17:27.000Z
2022-03-30T02:46:51.000Z
/* * Copyright 2006 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkDisplayMath_DEFINED #define SkDisplayMath_DEFINED #include "SkDisplayable.h" #include "SkMemberInfo.h" #include "SkRandom.h" class SkDisplayMath : public SkDisplayable { DECLARE_DISPLAY_MEMBER_INFO(Math); void executeFunction(SkDisplayable* , int index, SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type, SkScriptValue* ) override; const SkFunctionParamType* getFunctionsParameters() override; bool getProperty(int index, SkScriptValue* value) const override; private: mutable SkRandom fRandom; static const SkScalar gConstants[]; static const SkFunctionParamType fFunctionParameters[]; }; #endif // SkDisplayMath_DEFINED
26.71875
73
0.757895
031238d5615d713b7fee3634f97b853ae71ec4eb
13,986
c
C
src/os.c
EdwardBetts/libgroove
d2b93bbbe8bc16a088a0a3f1eb84c0666e4fb841
[ "MIT" ]
208
2015-01-03T14:50:03.000Z
2022-03-04T22:26:14.000Z
src/os.c
EdwardBetts/libgroove
d2b93bbbe8bc16a088a0a3f1eb84c0666e4fb841
[ "MIT" ]
60
2015-01-20T20:18:18.000Z
2021-09-09T11:40:31.000Z
src/os.c
EdwardBetts/libgroove
d2b93bbbe8bc16a088a0a3f1eb84c0666e4fb841
[ "MIT" ]
38
2015-03-18T02:30:55.000Z
2022-03-09T11:54:05.000Z
/* * Copyright (c) 2015 Andrew Kelley * * This file is part of libgroove, which is MIT licensed. * See http://opensource.org/licenses/MIT */ #include "os.h" #include "groove_internal.h" #include "util.h" #include "atomics.h" #include <stdlib.h> #include <time.h> #include <assert.h> #include <string.h> #include <errno.h> #include <math.h> #if defined(_WIN32) #define GROOVE_OS_WINDOWS #if !defined(NOMINMAX) #define NOMINMAX #endif #if !defined(VC_EXTRALEAN) #define VC_EXTRALEAN #endif #if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN #endif #if !defined(UNICODE) #define UNICODE #endif // require Windows 7 or later #if WINVER < 0x0601 #undef WINVER #define WINVER 0x0601 #endif #if _WIN32_WINNT < 0x0601 #undef _WIN32_WINNT #define _WIN32_WINNT 0x0601 #endif #include <windows.h> #include <mmsystem.h> #include <objbase.h> #else #include <pthread.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/fcntl.h> #endif #if defined(__FreeBSD__) || defined(__MACH__) #define GROOVE_OS_KQUEUE #include <sys/types.h> #include <sys/event.h> #include <sys/time.h> #endif #if defined(__MACH__) #include <mach/clock.h> #include <mach/mach.h> #endif struct GrooveOsThread { #if defined(GROOVE_OS_WINDOWS) HANDLE handle; DWORD id; #else pthread_t id; bool running; #endif void *arg; void (*run)(void *arg); }; struct GrooveOsMutex { #if defined(GROOVE_OS_WINDOWS) CRITICAL_SECTION id; #else pthread_mutex_t id; bool id_init; #endif }; #if defined(GROOVE_OS_KQUEUE) static const uintptr_t notify_ident = 1; struct GrooveOsCond { int kq_id; }; #elif defined(GROOVE_OS_WINDOWS) struct GrooveOsCond { CONDITION_VARIABLE id; CRITICAL_SECTION default_cs_id; }; #else struct GrooveOsCond { pthread_cond_t id; bool id_init; pthread_condattr_t attr; bool attr_init; pthread_mutex_t default_mutex_id; bool default_mutex_init; }; #endif #if defined(GROOVE_OS_WINDOWS) static INIT_ONCE win32_init_once = INIT_ONCE_STATIC_INIT; static double win32_time_resolution; static SYSTEM_INFO win32_system_info; #else static atomic_bool initialized = ATOMIC_VAR_INIT(false); static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER; #if defined(__MACH__) static clock_serv_t cclock; #endif #endif double groove_os_get_time(void) { #if defined(GROOVE_OS_WINDOWS) unsigned __int64 time; QueryPerformanceCounter((LARGE_INTEGER*) &time); return time * win32_time_resolution; #elif defined(__MACH__) mach_timespec_t mts; kern_return_t err = clock_get_time(cclock, &mts); assert(!err); double seconds = (double)mts.tv_sec; seconds += ((double)mts.tv_nsec) / 1000000000.0; return seconds; #else struct timespec tms; clock_gettime(CLOCK_MONOTONIC, &tms); double seconds = (double)tms.tv_sec; seconds += ((double)tms.tv_nsec) / 1000000000.0; return seconds; #endif } #if defined(GROOVE_OS_WINDOWS) static DWORD WINAPI run_win32_thread(LPVOID userdata) { struct GrooveOsThread *thread = (struct GrooveOsThread *)userdata; HRESULT err = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); assert(err == S_OK); thread->run(thread->arg); CoUninitialize(); return 0; } #else static void assert_no_err(int err) { assert(!err); } static void *run_pthread(void *userdata) { struct GrooveOsThread *thread = (struct GrooveOsThread *)userdata; thread->run(thread->arg); return NULL; } #endif int groove_os_thread_create( void (*run)(void *arg), void *arg, struct GrooveOsThread ** out_thread) { *out_thread = NULL; struct GrooveOsThread *thread = ALLOCATE(struct GrooveOsThread, 1); if (!thread) { groove_os_thread_destroy(thread); return GrooveErrorNoMem; } thread->run = run; thread->arg = arg; #if defined(GROOVE_OS_WINDOWS) thread->handle = CreateThread(NULL, 0, run_win32_thread, thread, 0, &thread->id); if (!thread->handle) { groove_os_thread_destroy(thread); return GrooveErrorSystemResources; } #else int err; if ((err = pthread_create(&thread->id, NULL, run_pthread, thread))) { groove_os_thread_destroy(thread); return GrooveErrorNoMem; } thread->running = true; #endif *out_thread = thread; return 0; } void groove_os_thread_destroy(struct GrooveOsThread *thread) { if (!thread) return; #if defined(GROOVE_OS_WINDOWS) if (thread->handle) { DWORD err = WaitForSingleObject(thread->handle, INFINITE); assert(err != WAIT_FAILED); BOOL ok = CloseHandle(thread->handle); assert(ok); } #else if (thread->running) { assert_no_err(pthread_join(thread->id, NULL)); } #endif free(thread); } struct GrooveOsMutex *groove_os_mutex_create(void) { struct GrooveOsMutex *mutex = ALLOCATE(struct GrooveOsMutex, 1); if (!mutex) { groove_os_mutex_destroy(mutex); return NULL; } #if defined(GROOVE_OS_WINDOWS) InitializeCriticalSection(&mutex->id); #else int err; if ((err = pthread_mutex_init(&mutex->id, NULL))) { groove_os_mutex_destroy(mutex); return NULL; } mutex->id_init = true; #endif return mutex; } void groove_os_mutex_destroy(struct GrooveOsMutex *mutex) { if (!mutex) return; #if defined(GROOVE_OS_WINDOWS) DeleteCriticalSection(&mutex->id); #else if (mutex->id_init) { assert_no_err(pthread_mutex_destroy(&mutex->id)); } #endif free(mutex); } void groove_os_mutex_lock(struct GrooveOsMutex *mutex) { #if defined(GROOVE_OS_WINDOWS) EnterCriticalSection(&mutex->id); #else assert_no_err(pthread_mutex_lock(&mutex->id)); #endif } void groove_os_mutex_unlock(struct GrooveOsMutex *mutex) { #if defined(GROOVE_OS_WINDOWS) LeaveCriticalSection(&mutex->id); #else assert_no_err(pthread_mutex_unlock(&mutex->id)); #endif } struct GrooveOsCond * groove_os_cond_create(void) { struct GrooveOsCond *cond = ALLOCATE(struct GrooveOsCond, 1); if (!cond) { groove_os_cond_destroy(cond); return NULL; } #if defined(GROOVE_OS_WINDOWS) InitializeConditionVariable(&cond->id); InitializeCriticalSection(&cond->default_cs_id); #elif defined(GROOVE_OS_KQUEUE) cond->kq_id = kqueue(); if (cond->kq_id == -1) return NULL; #else if (pthread_condattr_init(&cond->attr)) { groove_os_cond_destroy(cond); return NULL; } cond->attr_init = true; if (pthread_condattr_setclock(&cond->attr, CLOCK_MONOTONIC)) { groove_os_cond_destroy(cond); return NULL; } if (pthread_cond_init(&cond->id, &cond->attr)) { groove_os_cond_destroy(cond); return NULL; } cond->id_init = true; if ((pthread_mutex_init(&cond->default_mutex_id, NULL))) { groove_os_cond_destroy(cond); return NULL; } cond->default_mutex_init = true; #endif return cond; } void groove_os_cond_destroy(struct GrooveOsCond *cond) { if (!cond) return; #if defined(GROOVE_OS_WINDOWS) DeleteCriticalSection(&cond->default_cs_id); #elif defined(GROOVE_OS_KQUEUE) close(cond->kq_id); #else if (cond->id_init) { assert_no_err(pthread_cond_destroy(&cond->id)); } if (cond->attr_init) { assert_no_err(pthread_condattr_destroy(&cond->attr)); } if (cond->default_mutex_init) { assert_no_err(pthread_mutex_destroy(&cond->default_mutex_id)); } #endif free(cond); } void groove_os_cond_signal(struct GrooveOsCond *cond, struct GrooveOsMutex *locked_mutex) { #if defined(GROOVE_OS_WINDOWS) if (locked_mutex) { WakeConditionVariable(&cond->id); } else { EnterCriticalSection(&cond->default_cs_id); WakeConditionVariable(&cond->id); LeaveCriticalSection(&cond->default_cs_id); } #elif defined(GROOVE_OS_KQUEUE) struct kevent kev; struct timespec timeout = { 0, 0 }; memset(&kev, 0, sizeof(kev)); kev.ident = notify_ident; kev.filter = EVFILT_USER; kev.fflags = NOTE_TRIGGER; if (kevent(cond->kq_id, &kev, 1, NULL, 0, &timeout) == -1) { if (errno == EINTR) return; if (errno == ENOENT) return; assert(0); // kevent signal error } #else if (locked_mutex) { assert_no_err(pthread_cond_signal(&cond->id)); } else { assert_no_err(pthread_mutex_lock(&cond->default_mutex_id)); assert_no_err(pthread_cond_signal(&cond->id)); assert_no_err(pthread_mutex_unlock(&cond->default_mutex_id)); } #endif } void groove_os_cond_timed_wait(struct GrooveOsCond *cond, struct GrooveOsMutex *locked_mutex, double seconds) { #if defined(GROOVE_OS_WINDOWS) CRITICAL_SECTION *target_cs; if (locked_mutex) { target_cs = &locked_mutex->id; } else { target_cs = &cond->default_cs_id; EnterCriticalSection(&cond->default_cs_id); } DWORD ms = seconds * 1000.0; SleepConditionVariableCS(&cond->id, target_cs, ms); if (!locked_mutex) LeaveCriticalSection(&cond->default_cs_id); #elif defined(GROOVE_OS_KQUEUE) struct kevent kev; struct kevent out_kev; if (locked_mutex) assert_no_err(pthread_mutex_unlock(&locked_mutex->id)); memset(&kev, 0, sizeof(kev)); kev.ident = notify_ident; kev.filter = EVFILT_USER; kev.flags = EV_ADD | EV_CLEAR; // this time is relative struct timespec timeout; timeout.tv_nsec = (seconds * 1000000000L); timeout.tv_sec = timeout.tv_nsec / 1000000000L; timeout.tv_nsec = timeout.tv_nsec % 1000000000L; if (kevent(cond->kq_id, &kev, 1, &out_kev, 1, &timeout) == -1) { if (errno == EINTR) return; assert(0); // kevent wait error } if (locked_mutex) assert_no_err(pthread_mutex_lock(&locked_mutex->id)); #else pthread_mutex_t *target_mutex; if (locked_mutex) { target_mutex = &locked_mutex->id; } else { target_mutex = &cond->default_mutex_id; assert_no_err(pthread_mutex_lock(target_mutex)); } // this time is absolute struct timespec tms; clock_gettime(CLOCK_MONOTONIC, &tms); tms.tv_nsec += (seconds * 1000000000L); tms.tv_sec += tms.tv_nsec / 1000000000L; tms.tv_nsec = tms.tv_nsec % 1000000000L; int err; if ((err = pthread_cond_timedwait(&cond->id, target_mutex, &tms))) { assert(err != EPERM); assert(err != EINVAL); } if (!locked_mutex) assert_no_err(pthread_mutex_unlock(target_mutex)); #endif } void groove_os_cond_wait(struct GrooveOsCond *cond, struct GrooveOsMutex *locked_mutex) { #if defined(GROOVE_OS_WINDOWS) CRITICAL_SECTION *target_cs; if (locked_mutex) { target_cs = &locked_mutex->id; } else { target_cs = &cond->default_cs_id; EnterCriticalSection(&cond->default_cs_id); } SleepConditionVariableCS(&cond->id, target_cs, INFINITE); if (!locked_mutex) LeaveCriticalSection(&cond->default_cs_id); #elif defined(GROOVE_OS_KQUEUE) struct kevent kev; struct kevent out_kev; if (locked_mutex) assert_no_err(pthread_mutex_unlock(&locked_mutex->id)); memset(&kev, 0, sizeof(kev)); kev.ident = notify_ident; kev.filter = EVFILT_USER; kev.flags = EV_ADD | EV_CLEAR; if (kevent(cond->kq_id, &kev, 1, &out_kev, 1, NULL) == -1) { if (errno == EINTR) return; assert(0); // kevent wait error } if (locked_mutex) assert_no_err(pthread_mutex_lock(&locked_mutex->id)); #else pthread_mutex_t *target_mutex; if (locked_mutex) { target_mutex = &locked_mutex->id; } else { target_mutex = &cond->default_mutex_id; assert_no_err(pthread_mutex_lock(&cond->default_mutex_id)); } int err; if ((err = pthread_cond_wait(&cond->id, target_mutex))) { assert(err != EPERM); assert(err != EINVAL); } if (!locked_mutex) assert_no_err(pthread_mutex_unlock(&cond->default_mutex_id)); #endif } static int get_random_seed(uint32_t *seed) { int fd = open("/dev/random", O_RDONLY|O_NONBLOCK); if (fd == -1) return GrooveErrorSystemResources; int amt = read(fd, seed, 4); if (amt != 4) { close(fd); return GrooveErrorSystemResources; } close(fd); return 0; } static int internal_init(void) { #if defined(GROOVE_OS_WINDOWS) unsigned __int64 frequency; if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) { win32_time_resolution = 1.0 / (double) frequency; } else { return GrooveErrorSystemResources; } GetSystemInfo(&win32_system_info); #elif defined(__MACH__) host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock); #endif uint32_t seed; int err; if ((err = get_random_seed(&seed))) { return err; } srand(seed); return 0; } int groove_os_init(int (*init_once)(void)) { int err; #if defined(GROOVE_OS_WINDOWS) PVOID lpContext; BOOL pending; if (!InitOnceBeginInitialize(&win32_init_once, INIT_ONCE_ASYNC, &pending, &lpContext)) return GrooveErrorSystemResources; if (!pending) return 0; if ((err = internal_init())) return err; if ((err = init_once())) return err; if (!InitOnceComplete(&win32_init_once, INIT_ONCE_ASYNC, NULL)) return GrooveErrorSystemResources; #else if (atomic_load(&initialized)) return 0; assert_no_err(pthread_mutex_lock(&init_mutex)); if (atomic_load(&initialized)) { assert_no_err(pthread_mutex_unlock(&init_mutex)); return 0; } atomic_store(&initialized, true); if ((err = internal_init())) return err; if ((err = init_once())) return err; assert_no_err(pthread_mutex_unlock(&init_mutex)); #endif return 0; }
24.239168
90
0.6711
03134cb10a68fc0eb174334f77ea727daec2a075
2,686
h
C
src/sweep.h
fritzr/voronoi-game
77fcc6a40076ab092795445f4e2a73f475338090
[ "MIT" ]
null
null
null
src/sweep.h
fritzr/voronoi-game
77fcc6a40076ab092795445f4e2a73f475338090
[ "MIT" ]
null
null
null
src/sweep.h
fritzr/voronoi-game
77fcc6a40076ab092795445f4e2a73f475338090
[ "MIT" ]
1
2020-07-12T03:44:53.000Z
2020-07-12T03:44:53.000Z
#pragma once #include <queue> template<class Event, class EventCompare, class EventId=int> struct event_traits { typedef Event event_type; typedef EventId event_id_type; inline static event_id_type const& get_type(event_type const& e) { return e.type; } }; template< class Value, class Event, class Solution, class EventTraits=event_traits<Event, std::less<Event>, int>, class EventContainer=std::vector<Event>, class SolutionContainer=std::vector<Solution> > struct sla_traits { typedef Value value_type; typedef EventTraits event_traits; typedef typename event_traits::event_type event_type; typedef typename event_traits::event_compare event_compare; typedef typename event_traits::event_id_type event_id_type; typedef EventContainer event_container; typedef std::priority_queue<event_type, event_container, event_compare> queue_type; typedef Solution solution_type; typedef SolutionContainer solution_container; }; template<class Traits> class SweepLineAlgorithm { public: // Typedefs typedef Traits traits; typedef typename traits::value_type value_type; typedef typename traits::event_type event_type; typedef typename traits::event_compare event_compare; typedef typename traits::event_id_type event_id_type; typedef typename traits::event_container event_container; typedef typename traits::queue_type queue_type; typedef typename traits::solution_type solution_type; typedef typename traits::solution_container solution_container; inline static event_id_type get_type(event_type const& e) { return traits::event_traits::get_type(e); } protected: // Members queue_type queue_; inline queue_type& queue(void) { return queue_; } inline queue_type const& queue(void) const { return queue_; } solution_container solutions_; inline solution_container& solutions(void) { return solutions_; } inline solution_container const& solutions(void) const { return solutions_; } virtual void handle_event(event_id_type ty, event_type const& event)=0; virtual void initialize(void) {} virtual void finalize(void) {} public: // Methods SweepLineAlgorithm(void) {} virtual ~SweepLineAlgorithm(void) {} virtual void add_event(value_type const& v)=0; template<class ValueIter> inline void insert(ValueIter begin, ValueIter end) { while (begin != end) add_event(*begin++); } void compute(void) { initialize(); while (!queue().empty()) { typename queue_type::const_reference event = queue().top(); handle_event(get_type(event), event); queue().pop(); } finalize(); } };
28.273684
79
0.738645
0315d7c7f92eb5d261ff9e1adeff2cee11a0818b
31,122
h
C
System/Library/PrivateFrameworks/SiriOntology.framework/SiriOntology.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
5
2021-04-29T04:31:43.000Z
2021-08-19T18:59:58.000Z
System/Library/PrivateFrameworks/SiriOntology.framework/SiriOntology.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/SiriOntology.framework/SiriOntology.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
1
2022-03-19T11:16:23.000Z
2022-03-19T11:16:23.000Z
#import <SiriOntology/SIRINLUUserWantedToProceed.h> #import <SiriOntology/USOGraphNode.h> #import <SiriOntology/USOOperatorNode.h> #import <SiriOntology/USOEntityNode.h> #import <SiriOntology/USORootNode.h> #import <SiriOntology/USOTaskNode.h> #import <SiriOntology/USOStringNode.h> #import <SiriOntology/USOIntNode.h> #import <SiriOntology/USOGraph.h> #import <SiriOntology/SIRINLUTurnInput.h> #import <SiriOntology/SIRINLUDelegatedUserDialogAct.h> #import <SiriOntology/SIRINLUUserCancelled.h> #import <SiriOntology/SIRINLUSystemGaveOptions.h> #import <SiriOntology/SIRINLUUserAccepted.h> #import <SiriOntology/SIRINLUSystemReportedSuccess.h> #import <SiriOntology/SIRINLUEntityCandidate.h> #import <SiriOntology/SIRINLUSystemReportedFailure.h> #import <SiriOntology/SIRINLUUserWantedToRepeat.h> #import <SiriOntology/SIRINLUUserAcknowledged.h> #import <SiriOntology/SIRINLUTask.h> #import <SiriOntology/SIRINLUAsrHypothesis.h> #import <SiriOntology/SIRINLUSystemPrompted.h> #import <SiriOntology/SIRINLURequest.h> #import <SiriOntology/SIRINLUUserRejected.h> #import <SiriOntology/SIRINLUSystemInformed.h> #import <SiriOntology/SIRINLURequestID.h> #import <SiriOntology/SIRINLUUserStatedTask.h> #import <SiriOntology/SIRINLUResponse.h> #import <SiriOntology/SIRINLUPrintUtils.h> #import <SiriOntology/SIRINLUSystemOffered.h> #import <SiriOntology/SIRINLUUserWantedToPause.h> #import <SiriOntology/SIRINLUUserParse.h> #import <SiriOntology/USOSerializedGraphNode.h> #import <SiriOntology/USOSerializedGraphEdge.h> #import <SiriOntology/USOSerializedGraph.h> #import <SiriOntology/_TtCV12SiriOntology15TerminalElement11ScalarValue.h> #import <SiriOntology/SiriOntology.AnyMatchingSpan.h> #import <SiriOntology/SiriOntology.CodeGenBase.h> #import <SiriOntology/SiriOntology.CodeGenTaskBase.h> #import <SiriOntology/_TtCV12SiriOntology42Com_Apple_Siri_Product_Proto_DerivedOriginP33_942AB7175EC71BF9D0D08DC04D18C2E013_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology35Com_Apple_Siri_Product_Proto_OriginP33_942AB7175EC71BF9D0D08DC04D18C2E013_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology41Com_Apple_Siri_Product_Proto_ElementValueP33_942AB7175EC71BF9D0D08DC04D18C2E013_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology36Com_Apple_Siri_Product_Proto_ElementP33_942AB7175EC71BF9D0D08DC04D18C2E013_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology39Com_Apple_Siri_Product_Proto_IntentNodeP33_942AB7175EC71BF9D0D08DC04D18C2E013_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology40Com_Apple_Siri_Product_Proto_ProtoIntentP33_942AB7175EC71BF9D0D08DC04D18C2E013_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology37Siri_Vector_Dialog_Protocol_TurnInputP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology37Siri_Vector_Dialog_Protocol_UserParseP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology41Siri_Vector_Dialog_Protocol_UserDialogActP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology39Siri_Vector_Dialog_Protocol_UserStartedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology41Siri_Vector_Dialog_Protocol_UserContinuedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology40Siri_Vector_Dialog_Protocol_UserAcceptedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology40Siri_Vector_Dialog_Protocol_UserRejectedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology45Siri_Vector_Dialog_Protocol_UserDisambiguatedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology41Siri_Vector_Dialog_Protocol_UserCancelledP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology46Siri_Vector_Dialog_Protocol_UserWantedToRepeatP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology44Siri_Vector_Dialog_Protocol_UserAcknowledgedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology47Siri_Vector_Dialog_Protocol_UserWantedToProceedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology45Siri_Vector_Dialog_Protocol_UserWantedToPauseP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology41Siri_Vector_Dialog_Protocol_UserRespondedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology48Siri_Vector_Dialog_Protocol_SystemDialogActGroupP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology43Siri_Vector_Dialog_Protocol_SystemDialogActP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology42Siri_Vector_Dialog_Protocol_SystemPromptedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology41Siri_Vector_Dialog_Protocol_SystemOfferedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology42Siri_Vector_Dialog_Protocol_SystemInformedP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology49Siri_Vector_Dialog_Protocol_SystemReportedSuccessP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology49Siri_Vector_Dialog_Protocol_SystemReportedFailureP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology43Siri_Vector_Dialog_Protocol_EntityCandidateP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology32Siri_Vector_Dialog_Protocol_TaskP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology41Siri_Vector_Dialog_Protocol_AsrHypothesisP33_932486504AC56C44D36C9C054F9D1A2813_StorageClass.h> #import <SiriOntology/SiriOntology.PersonOntologyNode.h> #import <SiriOntology/_TtCV12SiriOntology33Com_Apple_Siri_Product_Proto_TimeP33_697D571C32F0AF8F560B5FAE0C121ED613_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology33Com_Apple_Siri_Product_Proto_DateP33_697D571C32F0AF8F560B5FAE0C121ED613_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology37Com_Apple_Siri_Product_Proto_DateTimeP33_697D571C32F0AF8F560B5FAE0C121ED613_StorageClass.h> #import <SiriOntology/SiriOntology.UsoGraphVocabManager.h> #import <SiriOntology/SiriOntology.AddressOntologyNode.h> #import <SiriOntology/SiriOntology.NonTerminalOntologyNode.h> #import <SiriOntology/_TtCC12SiriOntology19AddressOntologyNode15PersonPlaceNode.h> #import <SiriOntology/SiriOntology.AppOntologyNode.h> #import <SiriOntology/SiriOntology.UsoEntity_common_EventTrigger.h> #import <SiriOntology/SiriOntology.UsoEntity_commonTimer_TimerAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_common_DurationComponent.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Voicemail.h> #import <SiriOntology/SiriOntology.UsoEntity_common_RecurringDateTimeRange.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Workout.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Photo.h> #import <SiriOntology/SiriOntology.UsoEntity_common_MonthOfYear.h> #import <SiriOntology/SiriOntology.UsoEntity_common_PhoneNumber.h> #import <SiriOntology/SiriOntology.UsoEntity_commonAlarm_AlarmAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_commonContact_ContactAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_common_MeasurementUnit.h> #import <SiriOntology/SiriOntology.UsoEntity_common_PhoneCall.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Meridiem.h> #import <SiriOntology/SiriOntology.UsoEntity_common_LocalisedString.h> #import <SiriOntology/SiriOntology.UsoEntity_common_ProductCategory.h> #import <SiriOntology/SiriOntology.UsoEntity_common_StopWatch.h> #import <SiriOntology/SiriOntology.UsoEntity_commonNotification_NotificationAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_commonPhoneCall_PhoneCallAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_common_PersonName.h> #import <SiriOntology/SiriOntology.UsoEntity_common_MicroGeographicArea.h> #import <SiriOntology/SiriOntology.UsoEntity_common_PersonContact.h> #import <SiriOntology/SiriOntology.UsoEntity_common_PaymentAccount.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Timer.h> #import <SiriOntology/SiriOntology.UsoEntity_common_SearchQualifier.h> #import <SiriOntology/SiriOntology.UsoEntity_common_MultipliedNumber.h> #import <SiriOntology/SiriOntology.UsoEntity_common_DateTimeRange.h> #import <SiriOntology/SiriOntology.UsoEntity_common_DayOfWeek.h> #import <SiriOntology/SiriOntology.UsoEntity_common_TimeZone.h> #import <SiriOntology/SiriOntology.UsoEntity_common_PersonRelationship.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Email.h> #import <SiriOntology/SiriOntology.UsoEntity_common_DateTime.h> #import <SiriOntology/SiriOntology.UsoEntity_apple_PhotoMemory.h> #import <SiriOntology/SiriOntology.UsoEntity_commonMessage_MessageAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_sirikit_PaymentOrganization.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Organization.h> #import <SiriOntology/SiriOntology.UsoEntity_commonArithmetic_ArithmeticAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_common_PostalAddress.h> #import <SiriOntology/SiriOntology.UsoEntity_common_TimeUnit.h> #import <SiriOntology/SiriOntology.UsoEntity_common_PhotoCollection.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Event.h> #import <SiriOntology/SiriOntology.UsoEntity_common_RecurringDateTime.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Date.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Message.h> #import <SiriOntology/SiriOntology.UsoEntity_common_OffsetDate.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Duration.h> #import <SiriOntology/SiriOntology.UsoEntity_common_VoiceCommand.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Car.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Decimal.h> #import <SiriOntology/SiriOntology.UsoEntity_common_ReferenceType.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Uri.h> #import <SiriOntology/SiriOntology.UsoEntity_common_CurrencyAmount.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Geolocation.h> #import <SiriOntology/SiriOntology.UsoEntity_common_NotebookItem.h> #import <SiriOntology/SiriOntology.UsoEntity_commonEventTrigger_EventTriggerAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_sirikit_ContactAgent.h> #import <SiriOntology/SiriOntology.UsoEntity_common_PointOfInterest.h> #import <SiriOntology/SiriOntology.UsoEntity_common_MediaContent.h> #import <SiriOntology/SiriOntology.UsoEntity_common_DateTimeRangeQualifier.h> #import <SiriOntology/SiriOntology.UsoEntity_common_EmailAddress.h> #import <SiriOntology/SiriOntology.UsoEntity_common_CarProfile.h> #import <SiriOntology/SiriOntology.UsoEntity_common_KnowledgeQuestionAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Measurement.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Group.h> #import <SiriOntology/SiriOntology.UsoEntity_common_AppListing.h> #import <SiriOntology/SiriOntology.UsoEntity_commonNotebook_NotebookItemType.h> #import <SiriOntology/SiriOntology.UsoEntity_common_NumberSign.h> #import <SiriOntology/SiriOntology.UsoEntity_commonApp_AppAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_uso_NoEntity.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Alarm.h> #import <SiriOntology/SiriOntology.UsoEntity_common_CalendarEvent.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Contact.h> #import <SiriOntology/SiriOntology.UsoEntity_commonCalendarEvent_CalendarEventAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Writing.h> #import <SiriOntology/SiriOntology.UsoEntity_uso_NLv3UnknownEntity.h> #import <SiriOntology/SiriOntology.UsoEntity_common_OffsetDateTime.h> #import <SiriOntology/SiriOntology.UsoEntity_commonApp_AppListingAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Number.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Quantifier.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Translation.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Locale.h> #import <SiriOntology/SiriOntology.UsoEntity_common_OffsetTime.h> #import <SiriOntology/SiriOntology.UsoEntity_common_ContactAddress.h> #import <SiriOntology/SiriOntology.UsoEntity_sirikit_MusicArtist.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Communication.h> #import <SiriOntology/SiriOntology.UsoEntity_common_MediaShow.h> #import <SiriOntology/SiriOntology.UsoEntity_common_GeographicArea.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Agent.h> #import <SiriOntology/SiriOntology.UsoEntity_sirikit_ContactGroup.h> #import <SiriOntology/SiriOntology.UsoEntity_common_CalendarEra.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Time12HourClock.h> #import <SiriOntology/SiriOntology.UsoEntity_commonWriting_WritingAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Arithmetic.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Time24HourClock.h> #import <SiriOntology/SiriOntology.UsoEntity_common_App.h> #import <SiriOntology/SiriOntology.UsoEntity_commonNotebook_NotebookAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_common_KnowledgeQuestion.h> #import <SiriOntology/SiriOntology.UsoEntity_common_NotebookList.h> #import <SiriOntology/SiriOntology.UsoEntity_common_ListPosition.h> #import <SiriOntology/SiriOntology.UsoEntity_commonEmail_EmailAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_sirikit_AudiobookAuthor.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Notification.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Currency.h> #import <SiriOntology/SiriOntology.UsoEntity_common_OffsetDirection.h> #import <SiriOntology/SiriOntology.UsoEntity_common_MixedFraction.h> #import <SiriOntology/SiriOntology.UsoEntity_common_MediaPlaylist.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Similarity.h> #import <SiriOntology/SiriOntology.UsoEntity_sirikit_MediaShow.h> #import <SiriOntology/SiriOntology.UsoEntity_common_CalendarSystem.h> #import <SiriOntology/SiriOntology.UsoEntity_common_KnowledgeQuestionPersonAttribute.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Device.h> #import <SiriOntology/SiriOntology.UsoEntity_common_MediaItem.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Audiobook.h> #import <SiriOntology/SiriOntology.UsoEntity_common_MeasurementComponent.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Person.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Time.h> #import <SiriOntology/SiriOntology.UsoEntity_common_Integer.h> #import <SiriOntology/SiriOntology.UsoTask.h> #import <SiriOntology/SiriOntology.UsoValue.h> #import <SiriOntology/SiriOntology.UsoEntity.h> #import <SiriOntology/SiriOntology.UsoExpression.h> #import <SiriOntology/_TtCC12SiriOntology19AddressOntologyNode17StreetAddressNode.h> #import <SiriOntology/SiriOntology.NodeRef.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_uso_unknown_entity.h> #import <SiriOntology/_TtCV12SiriOntology31Siri_Nl_Core_Protocol_TurnInputP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology31Siri_Nl_Core_Protocol_UserParseP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology35Siri_Nl_Core_Protocol_UserDialogActP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology33Siri_Nl_Core_Protocol_UserStartedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology35Siri_Nl_Core_Protocol_UserContinuedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology34Siri_Nl_Core_Protocol_UserAcceptedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology34Siri_Nl_Core_Protocol_UserRejectedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology39Siri_Nl_Core_Protocol_UserDisambiguatedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology35Siri_Nl_Core_Protocol_UserCancelledP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology40Siri_Nl_Core_Protocol_UserWantedToRepeatP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology38Siri_Nl_Core_Protocol_UserAcknowledgedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology41Siri_Nl_Core_Protocol_UserWantedToProceedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology39Siri_Nl_Core_Protocol_UserWantedToPauseP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology35Siri_Nl_Core_Protocol_UserRespondedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology44Siri_Nl_Core_Protocol_DelegatedUserDialogActP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology36Siri_Nl_Core_Protocol_UserStatedTaskP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology42Siri_Nl_Core_Protocol_SystemDialogActGroupP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology37Siri_Nl_Core_Protocol_SystemDialogActP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology36Siri_Nl_Core_Protocol_SystemPromptedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology35Siri_Nl_Core_Protocol_SystemOfferedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology36Siri_Nl_Core_Protocol_SystemInformedP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology43Siri_Nl_Core_Protocol_SystemReportedSuccessP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology43Siri_Nl_Core_Protocol_SystemReportedFailureP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology37Siri_Nl_Core_Protocol_EntityCandidateP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology26Siri_Nl_Core_Protocol_TaskP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology35Siri_Nl_Core_Protocol_AsrHypothesisP33_C00432D0398FDC59A6695A04F384D31813_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology39Siri_Vector_Dialog_Protocol_Nlv4RequestP33_5E82E41F45C1643DE48BE9940D540F9013_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology40Siri_Vector_Dialog_Protocol_Nlv4ResponseP33_5E82E41F45C1643DE48BE9940D540F9013_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology30Siri_Nl_Core_Protocol_UsoGraphP33_F5C7339430FA0B31A0A7BC2C3260ABEA13_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology29Siri_Nl_Core_Protocol_UsoNodeP33_F5C7339430FA0B31A0A7BC2C3260ABEA13_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology29Siri_Nl_Core_Protocol_UsoEdgeP33_F5C7339430FA0B31A0A7BC2C3260ABEA13_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology34Siri_Nl_Core_Protocol_UsoEdgeLabelP33_F5C7339430FA0B31A0A7BC2C3260ABEA13_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology41Siri_Nl_Core_Protocol_UsoEntityIdentifierP33_F5C7339430FA0B31A0A7BC2C3260ABEA13_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology43Siri_Nl_Core_Protocol_UsoOntologyVocabularyP33_F5C7339430FA0B31A0A7BC2C3260ABEA13_StorageClass.h> #import <SiriOntology/_TtCC12SiriOntology19AddressOntologyNode12CentroidNode.h> #import <SiriOntology/_TtCV12SiriOntology36Siri_Vector_Dialog_Protocol_UsoGraphP33_2B4FC4B4C83A9BFDD38FF3BFB11ABA8613_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology35Siri_Vector_Dialog_Protocol_UsoNodeP33_2B4FC4B4C83A9BFDD38FF3BFB11ABA8613_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology35Siri_Vector_Dialog_Protocol_UsoEdgeP33_2B4FC4B4C83A9BFDD38FF3BFB11ABA8613_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology47Siri_Vector_Dialog_Protocol_UsoEntityIdentifierP33_2B4FC4B4C83A9BFDD38FF3BFB11ABA8613_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology49Siri_Vector_Dialog_Protocol_UsoOntologyVocabularyP33_2B4FC4B4C83A9BFDD38FF3BFB11ABA8613_StorageClass.h> #import <SiriOntology/SiriOntology.UsoBuilder.h> #import <SiriOntology/SiriOntology.UsoPrimitiveStringBuilder.h> #import <SiriOntology/SiriOntology.UsoPrimitiveIntegerBuilder.h> #import <SiriOntology/SiriOntology.UsoDefinedValueBuilder.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder.h> #import <SiriOntology/SiriOntology.UsoOpenEntityBuilder.h> #import <SiriOntology/SiriOntology.UsoTaskBuilder.h> #import <SiriOntology/SiriOntology.UsoOpenTaskBuilder.h> #import <SiriOntology/_TtCC12SiriOntology19AddressOntologyNode12LandmarkNode.h> #import <SiriOntology/SiriOntology.Graph.h> #import <SiriOntology/_TtCC12SiriOntology19AddressOntologyNode9PlaceNode.h> #import <SiriOntology/SiriOntology.DomainOntologyNode.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_EventTrigger.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonTimer_TimerAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_DurationComponent.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Voicemail.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_RecurringDateTimeRange.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Workout.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Photo.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_MonthOfYear.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_PhoneNumber.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonAlarm_AlarmAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonContact_ContactAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_MeasurementUnit.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_PhoneCall.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Meridiem.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_LocalisedString.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_ProductCategory.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_StopWatch.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonNotification_NotificationAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonPhoneCall_PhoneCallAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_PersonName.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_MicroGeographicArea.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_PersonContact.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_PaymentAccount.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Timer.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_SearchQualifier.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_MultipliedNumber.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_DateTimeRange.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_DayOfWeek.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_TimeZone.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_PersonRelationship.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Email.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_DateTime.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_apple_PhotoMemory.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonMessage_MessageAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_sirikit_PaymentOrganization.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Organization.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonArithmetic_ArithmeticAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_PostalAddress.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_TimeUnit.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_PhotoCollection.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Event.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_RecurringDateTime.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Date.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Message.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_OffsetDate.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Duration.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_VoiceCommand.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Car.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Decimal.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_ReferenceType.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Uri.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_CurrencyAmount.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Geolocation.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_NotebookItem.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonEventTrigger_EventTriggerAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_sirikit_ContactAgent.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_PointOfInterest.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_MediaContent.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_DateTimeRangeQualifier.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_EmailAddress.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_CarProfile.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_KnowledgeQuestionAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Measurement.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Group.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_AppListing.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonNotebook_NotebookItemType.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_NumberSign.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonApp_AppAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_uso_NoEntity.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Alarm.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_CalendarEvent.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Contact.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonCalendarEvent_CalendarEventAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Writing.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_uso_NLv3UnknownEntity.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_OffsetDateTime.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonApp_AppListingAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Number.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Quantifier.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Translation.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Locale.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_OffsetTime.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_ContactAddress.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_sirikit_MusicArtist.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Communication.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_MediaShow.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_GeographicArea.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Agent.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_sirikit_ContactGroup.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_CalendarEra.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Time12HourClock.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonWriting_WritingAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Arithmetic.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Time24HourClock.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_App.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonNotebook_NotebookAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_KnowledgeQuestion.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_NotebookList.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_ListPosition.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_commonEmail_EmailAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_sirikit_AudiobookAuthor.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Notification.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Currency.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_OffsetDirection.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_MixedFraction.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_MediaPlaylist.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Similarity.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_sirikit_MediaShow.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_CalendarSystem.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_KnowledgeQuestionPersonAttribute.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Device.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_MediaItem.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Audiobook.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_MeasurementComponent.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Person.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Time.h> #import <SiriOntology/SiriOntology.UsoEntityBuilder_common_Integer.h> #import <SiriOntology/_TtCV12SiriOntology32Siri_Nl_Core_Protocol_NluRequestP33_8AEED1117C5C9C654A79F72E61C1E7FE13_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology33Siri_Nl_Core_Protocol_NluResponseP33_8AEED1117C5C9C654A79F72E61C1E7FE13_StorageClass.h> #import <SiriOntology/_TtCC12SiriOntology19AddressOntologyNode12OccupantNode.h> #import <SiriOntology/_TtCV12SiriOntology41Com_Apple_Siri_Product_Proto_MatchingSpanP33_FC4EE5074104C85BFB570AF81C8E8EC613_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology34Com_Apple_Siri_Product_Proto_ValueP33_FC4EE5074104C85BFB570AF81C8E8EC613_StorageClass.h> #import <SiriOntology/_TtCV12SiriOntology40Com_Apple_Siri_Product_Proto_ScalarValueP33_FC4EE5074104C85BFB570AF81C8E8EC613_StorageClass.h> #import <SiriOntology/SiriOntology.AnyOntologyNode.h> #import <SiriOntology/_TtCV12SiriOntology42Com_Apple_Siri_Product_Proto_StatefulValueP33_742BA77734813F35A74C1EC32F376BD913_StorageClass.h>
81.9
146
0.906433
0318137b9dec5912d3a74cee24aedf76d3ed6d75
10,142
c
C
z2/part1/jm/random/492625577.c
kozakusek/ipp-2020-testy
09aa008fa53d159672cc7cbf969a6b237e15a7b8
[ "MIT" ]
1
2020-04-16T12:13:47.000Z
2020-04-16T12:13:47.000Z
z2/part1/jm/random/492625577.c
kozakusek/ipp-2020-testy
09aa008fa53d159672cc7cbf969a6b237e15a7b8
[ "MIT" ]
18
2020-03-06T17:50:15.000Z
2020-05-19T14:58:30.000Z
z2/part1/jm/random/492625577.c
kozakusek/ipp-2020-testy
09aa008fa53d159672cc7cbf969a6b237e15a7b8
[ "MIT" ]
18
2020-03-06T17:45:13.000Z
2020-06-09T19:18:31.000Z
#include <stdint.h> #include <stdlib.h> #include <assert.h> #include <stdio.h> #include "gamma.h" #include <stdbool.h> #include <string.h> int main() { /* scenario: test_random_actions uuid: 492625577 */ /* random actions, total chaos */ gamma_t* board = gamma_new(5, 11, 4, 20); assert( board != NULL ); assert( gamma_move(board, 1, 2, 1) == 1 ); char* board609106748 = gamma_board(board); assert( board609106748 != NULL ); assert( strcmp(board609106748, ".....\n" ".....\n" ".....\n" ".....\n" ".....\n" ".....\n" ".....\n" ".....\n" ".....\n" "..1..\n" ".....\n") == 0); free(board609106748); board609106748 = NULL; assert( gamma_move(board, 2, 1, 6) == 1 ); assert( gamma_free_fields(board, 2) == 53 ); assert( gamma_move(board, 3, 1, 3) == 1 ); assert( gamma_move(board, 3, 3, 7) == 1 ); char* board140726670 = gamma_board(board); assert( board140726670 != NULL ); assert( strcmp(board140726670, ".....\n" ".....\n" ".....\n" "...3.\n" ".2...\n" ".....\n" ".....\n" ".3...\n" ".....\n" "..1..\n" ".....\n") == 0); free(board140726670); board140726670 = NULL; assert( gamma_move(board, 4, 4, 3) == 1 ); assert( gamma_busy_fields(board, 4) == 1 ); assert( gamma_move(board, 1, 1, 6) == 0 ); assert( gamma_move(board, 2, 8, 4) == 0 ); assert( gamma_golden_possible(board, 2) == 1 ); assert( gamma_move(board, 3, 3, 3) == 1 ); assert( gamma_golden_possible(board, 3) == 1 ); assert( gamma_move(board, 4, 3, 2) == 1 ); assert( gamma_busy_fields(board, 4) == 2 ); assert( gamma_move(board, 1, 1, 1) == 1 ); assert( gamma_move(board, 1, 0, 9) == 1 ); assert( gamma_move(board, 2, 6, 4) == 0 ); assert( gamma_move(board, 3, 4, 1) == 1 ); assert( gamma_move(board, 3, 1, 2) == 1 ); assert( gamma_move(board, 4, 9, 4) == 0 ); assert( gamma_move(board, 1, 3, 2) == 0 ); assert( gamma_move(board, 1, 1, 0) == 1 ); assert( gamma_move(board, 2, 0, 0) == 1 ); assert( gamma_move(board, 2, 1, 4) == 1 ); assert( gamma_move(board, 3, 1, 7) == 1 ); assert( gamma_move(board, 4, 2, 6) == 1 ); assert( gamma_move(board, 1, 10, 4) == 0 ); assert( gamma_move(board, 1, 2, 2) == 1 ); assert( gamma_golden_possible(board, 1) == 1 ); assert( gamma_move(board, 2, 10, 2) == 0 ); assert( gamma_move(board, 2, 3, 3) == 0 ); assert( gamma_move(board, 3, 10, 1) == 0 ); assert( gamma_move(board, 3, 3, 8) == 1 ); assert( gamma_move(board, 1, 9, 2) == 0 ); assert( gamma_move(board, 1, 3, 0) == 1 ); assert( gamma_move(board, 2, 1, 1) == 0 ); assert( gamma_move(board, 2, 2, 5) == 1 ); assert( gamma_busy_fields(board, 2) == 4 ); assert( gamma_free_fields(board, 2) == 35 ); assert( gamma_move(board, 3, 2, 5) == 0 ); assert( gamma_move(board, 3, 4, 8) == 1 ); assert( gamma_move(board, 4, 1, 3) == 0 ); assert( gamma_move(board, 4, 4, 4) == 1 ); assert( gamma_move(board, 2, 3, 9) == 1 ); assert( gamma_move(board, 2, 4, 8) == 0 ); assert( gamma_busy_fields(board, 2) == 5 ); assert( gamma_move(board, 3, 5, 1) == 0 ); assert( gamma_move(board, 1, 10, 1) == 0 ); assert( gamma_move(board, 1, 0, 4) == 1 ); assert( gamma_busy_fields(board, 1) == 7 ); assert( gamma_move(board, 2, 10, 1) == 0 ); assert( gamma_move(board, 3, 0, 8) == 1 ); assert( gamma_move(board, 4, 0, 2) == 1 ); assert( gamma_move(board, 4, 0, 7) == 1 ); char* board395353149 = gamma_board(board); assert( board395353149 != NULL ); assert( strcmp(board395353149, ".....\n" "1..2.\n" "3..33\n" "43.3.\n" ".24..\n" "..2..\n" "12..4\n" ".3.34\n" "4314.\n" ".11.3\n" "21.1.\n") == 0); free(board395353149); board395353149 = NULL; assert( gamma_move(board, 1, 8, 2) == 0 ); assert( gamma_move(board, 1, 3, 5) == 1 ); assert( gamma_move(board, 2, 0, 4) == 0 ); assert( gamma_move(board, 2, 0, 3) == 1 ); assert( gamma_busy_fields(board, 2) == 6 ); assert( gamma_move(board, 3, 10, 3) == 0 ); assert( gamma_move(board, 4, 2, 4) == 1 ); assert( gamma_move(board, 4, 4, 1) == 0 ); assert( gamma_free_fields(board, 4) == 25 ); assert( gamma_golden_possible(board, 4) == 1 ); assert( gamma_move(board, 1, 8, 1) == 0 ); assert( gamma_move(board, 2, 4, 1) == 0 ); assert( gamma_move(board, 2, 2, 3) == 1 ); assert( gamma_move(board, 3, 2, 5) == 0 ); assert( gamma_move(board, 3, 0, 3) == 0 ); assert( gamma_free_fields(board, 3) == 24 ); assert( gamma_move(board, 4, 9, 2) == 0 ); assert( gamma_move(board, 4, 1, 8) == 1 ); assert( gamma_move(board, 1, 10, 0) == 0 ); assert( gamma_move(board, 2, 4, 3) == 0 ); assert( gamma_move(board, 3, 9, 4) == 0 ); assert( gamma_move(board, 3, 2, 7) == 1 ); assert( gamma_move(board, 4, 10, 3) == 0 ); assert( gamma_move(board, 1, 2, 4) == 0 ); assert( gamma_golden_move(board, 1, 9, 3) == 0 ); assert( gamma_move(board, 2, 1, 8) == 0 ); assert( gamma_move(board, 2, 0, 9) == 0 ); assert( gamma_move(board, 3, 5, 0) == 0 ); assert( gamma_move(board, 4, 3, 2) == 0 ); assert( gamma_golden_move(board, 4, 8, 3) == 0 ); assert( gamma_move(board, 1, 2, 8) == 1 ); assert( gamma_move(board, 2, 4, 9) == 1 ); assert( gamma_golden_possible(board, 2) == 1 ); assert( gamma_move(board, 3, 5, 0) == 0 ); assert( gamma_golden_possible(board, 3) == 1 ); assert( gamma_move(board, 4, 0, 4) == 0 ); assert( gamma_move(board, 4, 2, 4) == 0 ); assert( gamma_move(board, 1, 10, 3) == 0 ); assert( gamma_free_fields(board, 1) == 20 ); assert( gamma_move(board, 2, 10, 4) == 0 ); assert( gamma_move(board, 3, 1, 3) == 0 ); assert( gamma_move(board, 4, 7, 4) == 0 ); assert( gamma_move(board, 4, 2, 8) == 0 ); assert( gamma_move(board, 1, 10, 3) == 0 ); assert( gamma_move(board, 1, 1, 10) == 1 ); assert( gamma_move(board, 2, 3, 0) == 0 ); char* board252056398 = gamma_board(board); assert( board252056398 != NULL ); assert( strcmp(board252056398, ".1...\n" "1..22\n" "34133\n" "4333.\n" ".24..\n" "..21.\n" "124.4\n" "23234\n" "4314.\n" ".11.3\n" "21.1.\n") == 0); free(board252056398); board252056398 = NULL; assert( gamma_move(board, 3, 0, 5) == 1 ); assert( gamma_move(board, 3, 3, 1) == 1 ); assert( gamma_move(board, 1, 4, 3) == 0 ); assert( gamma_move(board, 1, 4, 0) == 1 ); assert( gamma_move(board, 2, 9, 2) == 0 ); assert( gamma_golden_move(board, 2, 2, 0) == 0 ); assert( gamma_move(board, 3, 10, 4) == 0 ); assert( gamma_move(board, 3, 4, 5) == 1 ); assert( gamma_move(board, 4, 7, 4) == 0 ); assert( gamma_free_fields(board, 4) == 15 ); assert( gamma_move(board, 1, 2, 0) == 1 ); assert( gamma_free_fields(board, 1) == 14 ); assert( gamma_move(board, 2, 9, 1) == 0 ); assert( gamma_move(board, 3, 2, 4) == 0 ); assert( gamma_move(board, 3, 1, 7) == 0 ); assert( gamma_move(board, 4, 10, 4) == 0 ); assert( gamma_move(board, 4, 4, 6) == 1 ); assert( gamma_move(board, 1, 4, 1) == 0 ); assert( gamma_move(board, 2, 1, 3) == 0 ); assert( gamma_golden_possible(board, 2) == 1 ); assert( gamma_move(board, 4, 9, 1) == 0 ); assert( gamma_move(board, 1, 9, 1) == 0 ); assert( gamma_move(board, 2, 3, 3) == 0 ); assert( gamma_move(board, 2, 1, 5) == 1 ); assert( gamma_busy_fields(board, 2) == 9 ); assert( gamma_move(board, 3, 3, 7) == 0 ); assert( gamma_move(board, 4, 7, 4) == 0 ); assert( gamma_move(board, 4, 3, 4) == 1 ); char* board472039531 = gamma_board(board); assert( board472039531 != NULL ); assert( strcmp(board472039531, ".1...\n" "1..22\n" "34133\n" "4333.\n" ".24.4\n" "32213\n" "12444\n" "23234\n" "4314.\n" ".1133\n" "21111\n") == 0); free(board472039531); board472039531 = NULL; assert( gamma_move(board, 2, 10, 4) == 0 ); assert( gamma_move(board, 3, 0, 10) == 1 ); assert( gamma_move(board, 3, 3, 9) == 0 ); assert( gamma_move(board, 4, 2, 4) == 0 ); assert( gamma_move(board, 1, 6, 3) == 0 ); assert( gamma_move(board, 2, 4, 7) == 1 ); assert( gamma_move(board, 3, 1, 5) == 0 ); assert( gamma_move(board, 4, 9, 1) == 0 ); assert( gamma_move(board, 1, 6, 3) == 0 ); assert( gamma_move(board, 1, 2, 3) == 0 ); assert( gamma_move(board, 2, 1, 8) == 0 ); assert( gamma_move(board, 2, 1, 2) == 0 ); assert( gamma_move(board, 3, 10, 3) == 0 ); assert( gamma_move(board, 3, 0, 1) == 1 ); assert( gamma_move(board, 4, 4, 8) == 0 ); assert( gamma_move(board, 1, 0, 4) == 0 ); assert( gamma_move(board, 2, 0, 5) == 0 ); assert( gamma_golden_possible(board, 2) == 1 ); assert( gamma_move(board, 3, 4, 1) == 0 ); assert( gamma_move(board, 4, 6, 3) == 0 ); char* board723434121 = gamma_board(board); assert( board723434121 != NULL ); assert( strcmp(board723434121, "31...\n" "1..22\n" "34133\n" "43332\n" ".24.4\n" "32213\n" "12444\n" "23234\n" "4314.\n" "31133\n" "21111\n") == 0); free(board723434121); board723434121 = NULL; assert( gamma_move(board, 1, 2, 6) == 0 ); assert( gamma_free_fields(board, 1) == 8 ); assert( gamma_golden_possible(board, 1) == 1 ); assert( gamma_move(board, 2, 9, 2) == 0 ); assert( gamma_move(board, 2, 4, 0) == 0 ); assert( gamma_move(board, 3, 0, 9) == 0 ); assert( gamma_golden_possible(board, 4) == 1 ); assert( gamma_move(board, 1, 1, 10) == 0 ); assert( gamma_move(board, 1, 3, 7) == 0 ); assert( gamma_busy_fields(board, 1) == 12 ); assert( gamma_move(board, 2, 9, 2) == 0 ); assert( gamma_move(board, 3, 3, 9) == 0 ); assert( gamma_move(board, 4, 10, 2) == 0 ); assert( gamma_move(board, 4, 2, 7) == 0 ); assert( gamma_move(board, 1, 10, 3) == 0 ); assert( gamma_move(board, 1, 4, 8) == 0 ); assert( gamma_golden_possible(board, 1) == 1 ); assert( gamma_move(board, 2, 1, 6) == 0 ); assert( gamma_move(board, 3, 10, 4) == 0 ); assert( gamma_move(board, 3, 3, 2) == 0 ); assert( gamma_move(board, 4, 4, 9) == 0 ); assert( gamma_move(board, 1, 1, 3) == 0 ); assert( gamma_golden_possible(board, 1) == 1 ); assert( gamma_move(board, 2, 10, 4) == 0 ); assert( gamma_move(board, 2, 3, 5) == 0 ); assert( gamma_move(board, 3, 9, 1) == 0 ); assert( gamma_move(board, 4, 0, 4) == 0 ); assert( gamma_golden_possible(board, 4) == 1 ); char* board265725751 = gamma_board(board); assert( board265725751 != NULL ); assert( strcmp(board265725751, "31...\n" "1..22\n" "34133\n" "43332\n" ".24.4\n" "32213\n" "12444\n" "23234\n" "4314.\n" "31133\n" "21111\n") == 0); free(board265725751); board265725751 = NULL; assert( gamma_move(board, 1, 9, 2) == 0 ); assert( gamma_busy_fields(board, 1) == 12 ); assert( gamma_move(board, 2, 6, 0) == 0 ); assert( gamma_move(board, 2, 2, 2) == 0 ); gamma_delete(board); return 0; }
30.274627
49
0.603135
0318a0f1ca4bdda7da0ac5ad559c6348cf92b503
467
h
C
extensions/cce/src/main/jni/lib_ccx/ccx_decoders_708_encoding.h
a4x4kiwi/Exo-CC
aa508582d4e6b1ea08eb1a281296fb21d13d05cb
[ "Apache-2.0" ]
2
2021-01-07T03:00:58.000Z
2021-01-12T01:01:15.000Z
extensions/cce/src/main/jni/lib_ccx/ccx_decoders_708_encoding.h
a4x4kiwi/Exo-CC
aa508582d4e6b1ea08eb1a281296fb21d13d05cb
[ "Apache-2.0" ]
2
2021-01-12T00:35:15.000Z
2021-03-23T03:11:37.000Z
extensions/cce/src/main/jni/lib_ccx/ccx_decoders_708_encoding.h
a4x4kiwi/Exo-CC
aa508582d4e6b1ea08eb1a281296fb21d13d05cb
[ "Apache-2.0" ]
1
2021-01-12T01:01:08.000Z
2021-01-12T01:01:08.000Z
#ifndef _CCX_DECODERS_708_ENCODING_H_ #define _CCX_DECODERS_708_ENCODING_H_ #define CCX_DTVCC_MUSICAL_NOTE_CHAR 9836 // Unicode Character 'BEAMED SIXTEENTH NOTES' unsigned char dtvcc_get_internal_from_G0(unsigned char g0_char); unsigned char dtvcc_get_internal_from_G1(unsigned char g1_char); unsigned char dtvcc_get_internal_from_G2(unsigned char g2_char); unsigned char dtvcc_get_internal_from_G3(unsigned char g3_char); #endif /*_CCX_DECODERS_708_ENCODING_H_*/
38.916667
86
0.867238
031ac9a3b8bf088b68f5b65e528742a5a8cc2739
199
h
C
Classes/customcontrol/UITextView+Custom.h
tuansusu/CRMOneIpad
855a25025a2e2f3d005f71ec74e838962768f774
[ "MIT" ]
null
null
null
Classes/customcontrol/UITextView+Custom.h
tuansusu/CRMOneIpad
855a25025a2e2f3d005f71ec74e838962768f774
[ "MIT" ]
null
null
null
Classes/customcontrol/UITextView+Custom.h
tuansusu/CRMOneIpad
855a25025a2e2f3d005f71ec74e838962768f774
[ "MIT" ]
null
null
null
// // UITextView+Custom.h // Voffice2.1 // // Created by VTIT on 2/24/14. // // #import <UIKit/UIKit.h> @interface UITextView (Custom) -(void) setStyleNormalWithOption : (int) smgSelect; @end
12.4375
51
0.658291
031b9818bbfbd2f5cb9e38ae91c38b1f55cbaeec
5,408
w
C
base/published/faultrep.w
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
public/internal/base/inc/faultrep.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
public/internal/base/inc/faultrep.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/****************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Module Name: faultrep.h Abstract: header for fault reporting for unhandled exceptions Revision History: created derekm 07/07/00 ******************************************************************************/ #ifndef FAULTREP_H #define FAULTREP_H #include "errorrep.h" /////////////////////////////////////////////////////////////////////////////// // structs typedef enum tagEFaultRepOptions { froNoDebugWait = (DWORD)-1, froNoDebug = 0, froDebug = 1, } EFaultRepOptions; typedef enum tagEDumpFlags { dfFilterThread = 0x1, dfFilterThreadEx = 0x2, dfCollectSig = 0x4, } EDumpFlags; typedef struct tagSMDumpOptions { DWORD cbSMDO; ULONG ulThread; ULONG ulThreadEx; ULONG ulMod; DWORD dwThreadID; DWORD dfOptions; UINT64 pvFaultAddr; WCHAR wszAppFullPath[MAX_PATH]; WCHAR wszApp[MAX_PATH]; WORD rgAppVer[4]; WCHAR wszMod[MAX_PATH]; WCHAR wszModFullPath[MAX_PATH]; WORD rgModVer[4]; UINT64 pvOffset; UINT64 pEP; BOOL fEPClient; BOOL fIncludeHeap; // Include heap in minidump } SMDumpOptions; typedef struct tagSFaultRepManifest { DWORD pidReqProcess; BOOL fIs64bit; DWORD thidFault; UINT64 pvFaultAddr; LPWSTR wszExe; UINT64 pEP; } SFaultRepManifest; typedef enum tagEEventType { eetKernelFault = 0, eetShutdown, eetUseEventInfo, } EEventType; typedef struct tagSEventInfoW { DWORD cbSEI; LPWSTR wszEventName; LPWSTR wszErrMsg; LPWSTR wszHdr; LPWSTR wszTitle; LPWSTR wszStage1; LPWSTR wszStage2; LPWSTR wszFileList; LPWSTR wszEventSrc; LPWSTR wszCorpPath; LPWSTR wszPlea; LPWSTR wszSendBtn; LPWSTR wszNoSendBtn; BOOL fUseLitePlea; BOOL fUseIEForURLs; BOOL fNoBucketLogs; BOOL fNoDefCabLimit; } SEventInfoW; /////////////////////////////////////////////////////////////////////////////// // function prototypes EFaultRepRetVal APIENTRY ReportFaultDWM(SFaultRepManifest *pfrm, LPCWSTR wszDir, HANDLE hToken, LPVOID pvEnv, PROCESS_INFORMATION *ppi, LPWSTR wszDumpFile); EFaultRepRetVal APIENTRY ReportFaultToQueue(SFaultRepManifest *pfrm); EFaultRepRetVal APIENTRY ReportFaultFromQueue(LPWSTR wszDump, BYTE *pbData, DWORD cbData); EFaultRepRetVal APIENTRY ReportKernelFaultA(LPCSTR szDump); EFaultRepRetVal APIENTRY ReportKernelFaultW(LPCWSTR wszDump); EFaultRepRetVal APIENTRY ReportKernelFaultDWW(LPCWSTR wszDump); EFaultRepRetVal APIENTRY ReportEREvent(EEventType eet, LPCWSTR wszDump, SEventInfoW *pei); EFaultRepRetVal APIENTRY ReportEREventDW(EEventType eet, LPCWSTR wszDump, SEventInfoW *pei); EFaultRepRetVal APIENTRY ReportHang(DWORD dwpid, DWORD dwtid, BOOL f64bit, HANDLE hNotify); BOOL APIENTRY CreateMinidumpA(DWORD dwpid, LPCSTR szDump, SMDumpOptions *psmdo); BOOL APIENTRY CreateMinidumpW(DWORD dwpid, LPCWSTR wszDump, SMDumpOptions *psmdo); /////////////////////////////////////////////////////////////////////////////// // function pointer typedefs typedef EFaultRepRetVal (APIENTRY *pfn_REPORTFAULTDWM)(SFaultRepManifest *, LPCWSTR, HANDLE, LPVOID, PROCESS_INFORMATION *, LPWSTR); typedef EFaultRepRetVal (APIENTRY *pfn_REPORTFAULTTOQ)(SFaultRepManifest *); typedef EFaultRepRetVal (APIENTRY *pfn_REPORTFAULTFROMQ)(LPWSTR, BYTE *, DWORD); typedef EFaultRepRetVal (APIENTRY *pfn_REPORTKERNELFAULTA)(LPCSTR); typedef EFaultRepRetVal (APIENTRY *pfn_REPORTKERNELFAULTW)(LPCWSTR); typedef EFaultRepRetVal (APIENTRY *pfn_REPORTKERNELFAULTDWW)(LPCWSTR); typedef EFaultRepRetVal (APIENTRY *pfn_REPORTEREVENT)(EEventType, LPCWSTR, SEventInfoW *); typedef EFaultRepRetVal (APIENTRY *pfn_REPORTEREVENTDW)(EEventType, LPCWSTR, SEventInfoW *); typedef EFaultRepRetVal (APIENTRY *pfn_REPORTHANG)(DWORD, DWORD, BOOL, HANDLE); typedef BOOL (APIENTRY *pfn_CREATEMINIDUMPA)(DWORD, LPCSTR, SMDumpOptions *); typedef BOOL (APIENTRY *pfn_CREATEMINIDUMPW)(DWORD, LPCWSTR, SMDumpOptions *); /////////////////////////////////////////////////////////////////////////////// // UNICODE stuff #ifdef UNICODE #define ReportKernelFault ReportKernelFaultW #define CreateMinidump CreateMinidumpW #define pfn_REPORTKERNELFAULT pfn_REPORTKERNELFAULTW #define pfn_CREATEMINIDUMP pfn_CREATEMINIDUMPW #else // not UNICODE #define ReportKernelFault ReportKernelFaultA #define CreateMinidump CreateMinidumpA #define pfn_REPORTKERNELFAULT pfn_REPORTKERNELFAULTA #define pfn_CREATEMINIDUMP pfn_CREATEMINIDUMPA #endif // UNICODE #endif // FAULTREP_H
32.190476
93
0.595784
031dd0391436f7c10bc3546191eaf7c8b34c5e92
1,480
h
C
D3D12RaytracingFallback/src/LoadInstancesPass.h
StarsX/XUSG
85838d2ab1efde1926ff4cff2cbe5f5e55609bd5
[ "MIT" ]
31
2020-04-16T02:36:55.000Z
2022-03-30T13:14:27.000Z
D3D12RaytracingFallback/src/LoadInstancesPass.h
StarsX/XUSGCore
659fd75666c05184cafc18d6c398b31c05c59051
[ "MIT" ]
null
null
null
D3D12RaytracingFallback/src/LoadInstancesPass.h
StarsX/XUSGCore
659fd75666c05184cafc18d6c398b31c05c59051
[ "MIT" ]
1
2021-12-11T16:26:39.000Z
2021-12-11T16:26:39.000Z
//********************************************************* // // Copyright (c) Microsoft. All rights reserved. // This code is licensed under the MIT License (MIT). // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. // //********************************************************* #pragma once namespace FallbackLayer { class LoadInstancesPass { public: LoadInstancesPass(ID3D12Device *pDevice, UINT nodeMask, UINT numUAVs); void LoadInstances(ID3D12GraphicsCommandList *pCommandList, D3D12_GPU_VIRTUAL_ADDRESS outputBVH, D3D12_GPU_VIRTUAL_ADDRESS instancesDesc, D3D12_ELEMENTS_LAYOUT instanceDescLayout, UINT numElements, D3D12_GPU_DESCRIPTOR_HANDLE descriptorHeapBase, D3D12_GPU_VIRTUAL_ADDRESS cachedSortBuffer); private: enum RootParameterSlot { OutputBVHRootUAV = 0, InstanceDescsSRV, GlobalDescriptorHeap, Constants, CachedSortBuffer, NumRootParameters, }; Microsoft::WRL::ComPtr<ID3D12RootSignature> m_pRootSignature; Microsoft::WRL::ComPtr<ID3D12PipelineState> m_pLoadAABBsFromArrayOfPointersPSO; Microsoft::WRL::ComPtr<ID3D12PipelineState> m_pLoadAABBsFromArrayOfInstancesPSO; }; }
36.097561
88
0.633784
03216335a19c424055a3e200731c11535c626a6c
3,990
h
C
carmel/src/cached_derivs.h
graehl/carmel
4a5d0990a17d0d853621348272b2f05a0dab3450
[ "Apache-2.0" ]
29
2015-01-05T16:52:53.000Z
2022-02-14T07:36:10.000Z
carmel/src/cached_derivs.h
graehl/carmel
4a5d0990a17d0d853621348272b2f05a0dab3450
[ "Apache-2.0" ]
1
2016-04-18T17:20:37.000Z
2016-04-23T07:36:38.000Z
carmel/src/cached_derivs.h
graehl/carmel
4a5d0990a17d0d853621348272b2f05a0dab3450
[ "Apache-2.0" ]
7
2015-06-11T14:48:13.000Z
2017-08-12T16:06:19.000Z
#ifndef GRAEHL_SHARED__CACHED_DERIVS #define GRAEHL_SHARED__CACHED_DERIVS #include <carmel/src/derivations.h> #include <carmel/src/cascade.h> #include <graehl/shared/serialize_batch.hpp> #include <graehl/shared/time_space_report.hpp> #include <graehl/shared/periodic.hpp> namespace graehl { template <class arc_counts> struct cached_derivs { WFST &x; serialize_batch<derivations> derivs; typedef arcs_table<arc_counts> arcs_t; arcs_t arcs; std::string out_derivfile; cascade_parameters const& cascade; training_corpus &corpus; WFST::deriv_cache_opts const& copt; bool cached; unsigned size() { return cached?derivs.size():corpus.size(); } double n_output() const { return corpus.n_output; } cached_derivs(WFST &x, cascade_parameters const& cascade, training_corpus &corpus, WFST::deriv_cache_opts const& copt) : x(x), derivs(copt.use_disk(), copt.disk_cache_filename, true, copt.disk_cache_bufsize), arcs(x), out_derivfile(copt.out_derivfile), cascade(cascade), corpus(corpus), copt(copt) { if ((cached = copt.cache())) cache_derivations(); first = true; // for non-caching } bool first; template <class F> void foreach_deriv(F &f) { if (first&&!out_derivfile.empty()) { std::ofstream o(out_derivfile.c_str()); foreach_deriv(f, &o); } else foreach_deriv(f, 0); } static void warn_no_derivations(WFST const& x, IOSymSeq const& s, unsigned n) { Config::warn() << "No derivations in transducer for input/output #"<<n<<":\n"; s.print(Config::warn(), x,"\n"); } template <class F> void foreach_deriv(F &f, std::ostream *od) { cascade_parameters::arcid_type aid; bool fem = od&&first; if (fem) cascade.arcids(aid); if (cached) { unsigned n = 0; for (derivs.rewind(); derivs.advance();) { ++n; derivations &d = derivs.current(); f(n, d); if (fem) cascade.fem_deriv(*od, arcs, aid, d); } } else { wfst_io_index io(x); // TODO: lift outside of foreach deriv? unsigned n = 0; List<IOSymSeq> &ex = corpus.examples; for (List<IOSymSeq>::erase_iterator i = ex.erase_begin(), end = ex.erase_end(); i!=end;) { ++n; derivations d; if (d.init_and_compute(x, io, arcs, i->i, i->o, i->weight, n, copt.cache_backward(), copt.prune())) { f(n, d); if (fem) cascade.fem_deriv(*od, arcs, aid, d); } else if (first) { warn_no_derivations(x, *i, n); if (copt.prune()) { i = ex.erase(i); continue; } } ++i; } if (first) { corpus.count(); } } first = false; } //TODO: cascade arc ids for fem deriv out void cache_derivations() { bool cache_backward = copt.cache_backward(); bool prune = copt.prune(); typedef List<IOSymSeq> Examples; Examples &ex = corpus.examples; cached = true; std::ostream &log = Config::log(); log<<"Caching derivations:\n"; graehl::time_space_report r(log,"Computed cached derivations: "); wfst_io_index io(x); unsigned n = 1; derivs.clear(); for (Examples::const_iterator i = ex.begin(), end = ex.end(); i!=end ; ++i, ++n) { num_progress(log, n, 10, 70,".","\n"); derivations &d = derivs.start_new(); corpus.clear_counts(); if (!d.init_and_compute(x, io, arcs, i->i, i->o, i->weight, n, cache_backward, prune)) { warn_no_derivations(x, *i, n); derivs.drop_new(); } else { #ifdef DEBUG_DERIVATIONS_EXTRA Config::debug() << "Derivations in transducer for input/output #"<<n<<" (final="<<d.final()<<"):\n"; i->print(Config::debug(), x,"\n"); printGraph(d.graph(), Config::debug()); #endif derivs.keep_new(); corpus.count(*i); } } log << "\n"; derivs.mark_end(); log << derivations::global_stats; } }; } #endif
27.328767
184
0.602506
0323686442b74b860a7a30a4bf16e2b2c36ba8a6
7,838
h
C
Code/Framework/AzFramework/AzFramework/Session/ISessionRequests.h
cypherdotXd/o3de
bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676
[ "Apache-2.0", "MIT" ]
1
2022-03-12T14:13:45.000Z
2022-03-12T14:13:45.000Z
Code/Framework/AzFramework/AzFramework/Session/ISessionRequests.h
cypherdotXd/o3de
bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676
[ "Apache-2.0", "MIT" ]
3
2021-09-08T03:41:27.000Z
2022-03-12T01:01:29.000Z
Code/Framework/AzFramework/AzFramework/Session/ISessionRequests.h
cypherdotXd/o3de
bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676
[ "Apache-2.0", "MIT" ]
null
null
null
/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #pragma once #include <AzCore/EBus/EBus.h> #include <AzCore/RTTI/ReflectContext.h> #include <AzCore/std/containers/unordered_map.h> #include <AzCore/std/string/string.h> #include <AzCore/Outcome/Outcome.h> namespace AzFramework { struct SessionConfig; //! CreateSessionRequest //! The container for CreateSession request parameters. struct CreateSessionRequest { AZ_RTTI(CreateSessionRequest, "{E39C2A45-89C9-4CFB-B337-9734DC798930}"); static void Reflect(AZ::ReflectContext* context); CreateSessionRequest() = default; virtual ~CreateSessionRequest() = default; // A unique identifier for a player or entity creating the session. AZStd::string m_creatorId; // A collection of custom properties for a session. AZStd::unordered_map<AZStd::string, AZStd::string> m_sessionProperties; // A descriptive label that is associated with a session. AZStd::string m_sessionName; // The maximum number of players that can be connected simultaneously to the session. uint64_t m_maxPlayer = 0; }; //! SearchSessionsRequest //! The container for SearchSessions request parameters. struct SearchSessionsRequest { AZ_RTTI(SearchSessionsRequest, "{B49207A8-8549-4ADB-B7D9-D7A4932F9B4B}"); static void Reflect(AZ::ReflectContext* context); SearchSessionsRequest() = default; virtual ~SearchSessionsRequest() = default; // String containing the search criteria for the session search. If no filter expression is included, the request returns results // for all active sessions. AZStd::string m_filterExpression; // Instructions on how to sort the search results. If no sort expression is included, the request returns results in random order. AZStd::string m_sortExpression; // The maximum number of results to return. uint8_t m_maxResult = 0; // A token that indicates the start of the next sequential page of results. AZStd::string m_nextToken; }; //! SearchSessionsResponse //! The container for SearchSession request results. struct SearchSessionsResponse { AZ_RTTI(SearchSessionsResponse, "{F93DE7DC-D381-4E08-8A3B-0B08F7C38714}"); static void Reflect(AZ::ReflectContext* context); SearchSessionsResponse() = default; virtual ~SearchSessionsResponse() = default; // A collection of sessions that match the search criteria and sorted in specific order. AZStd::vector<SessionConfig> m_sessionConfigs; // A token that indicates the start of the next sequential page of results. AZStd::string m_nextToken; }; //! JoinSessionRequest //! The container for JoinSession request parameters. struct JoinSessionRequest { AZ_RTTI(JoinSessionRequest, "{519769E8-3CDE-4385-A0D7-24DBB3685657}"); static void Reflect(AZ::ReflectContext* context); JoinSessionRequest() = default; virtual ~JoinSessionRequest() = default; // A unique identifier for the session. AZStd::string m_sessionId; // A unique identifier for a player. Player IDs are developer-defined. AZStd::string m_playerId; // Developer-defined information related to a player. AZStd::string m_playerData; }; //! ISessionRequests //! Pure virtual session interface class to abstract the details of session handling from application code. class ISessionRequests { public: AZ_RTTI(ISessionRequests, "{D6C41A71-DD8D-47FE-8515-FAF90670AE2F}"); ISessionRequests() = default; virtual ~ISessionRequests() = default; // Create a session for players to find and join. // @param createSessionRequest The request of CreateSession operation // @return The request id if session creation request succeeds; empty if it fails virtual AZStd::string CreateSession(const CreateSessionRequest& createSessionRequest) = 0; // Retrieve all active sessions that match the given search criteria and sorted in specific order. // @param searchSessionsRequest The request of SearchSessions operation // @return The response of SearchSessions operation virtual SearchSessionsResponse SearchSessions(const SearchSessionsRequest& searchSessionsRequest) const = 0; // Reserve an open player slot in a session, and perform connection from client to server. // @param joinSessionRequest The request of JoinSession operation // @return True if joining session succeeds; False otherwise virtual bool JoinSession(const JoinSessionRequest& joinSessionRequest) = 0; // Disconnect player from session. virtual void LeaveSession() = 0; }; //! ISessionAsyncRequests //! Async version of ISessionRequests class ISessionAsyncRequests { public: AZ_RTTI(ISessionAsyncRequests, "{471542AF-96B9-4930-82FE-242A4E68432D}"); ISessionAsyncRequests() = default; virtual ~ISessionAsyncRequests() = default; // CreateSession Async // @param createSessionRequest The request of CreateSession operation virtual void CreateSessionAsync(const CreateSessionRequest& createSessionRequest) = 0; // SearchSessions Async // @param searchSessionsRequest The request of SearchSessions operation virtual void SearchSessionsAsync(const SearchSessionsRequest& searchSessionsRequest) const = 0; // JoinSession Async // @param joinSessionRequest The request of JoinSession operation virtual void JoinSessionAsync(const JoinSessionRequest& joinSessionRequest) = 0; // LeaveSession Async virtual void LeaveSessionAsync() = 0; }; //! SessionAsyncRequestNotifications //! The notifications correspond to session async requests class SessionAsyncRequestNotifications : public AZ::EBusTraits { public: // Safeguard handler for multi-threaded use case using MutexType = AZStd::recursive_mutex; ////////////////////////////////////////////////////////////////////////// // EBusTraits overrides static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple; static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; ////////////////////////////////////////////////////////////////////////// // OnCreateSessionAsyncComplete is fired once CreateSessionAsync completes // @param createSessionResponse The request id if session creation request succeeds; empty if it fails virtual void OnCreateSessionAsyncComplete(const AZStd::string& createSessionReponse) = 0; // OnSearchSessionsAsyncComplete is fired once SearchSessionsAsync completes // @param searchSessionsResponse The response of SearchSessions call virtual void OnSearchSessionsAsyncComplete(const SearchSessionsResponse& searchSessionsResponse) = 0; // OnJoinSessionAsyncComplete is fired once JoinSessionAsync completes // @param joinSessionsResponse True if joining session succeeds; False otherwise virtual void OnJoinSessionAsyncComplete(bool joinSessionsResponse) = 0; // OnLeaveSessionAsyncComplete is fired once LeaveSessionAsync completes virtual void OnLeaveSessionAsyncComplete() = 0; }; using SessionAsyncRequestNotificationBus = AZ::EBus<SessionAsyncRequestNotifications>; } // namespace AzFramework
40.822917
138
0.696351
0325e093a5cadef53a7c1fedd2f493ee9211ceac
1,821
h
C
trunk/win/BumpTop Settings/include/wxWidgets/wx/mgl/private/fontmgr.h
dyzmapl/BumpTop
1329ea41411c7368516b942d19add694af3d602f
[ "Apache-2.0" ]
460
2016-01-13T12:49:34.000Z
2022-02-20T04:10:40.000Z
trunk/win/BumpTop Settings/include/wxWidgets/wx/mgl/private/fontmgr.h
dyzmapl/BumpTop
1329ea41411c7368516b942d19add694af3d602f
[ "Apache-2.0" ]
24
2016-11-07T04:59:49.000Z
2022-03-14T06:34:12.000Z
trunk/win/BumpTop Settings/include/wxWidgets/wx/mgl/private/fontmgr.h
dyzmapl/BumpTop
1329ea41411c7368516b942d19add694af3d602f
[ "Apache-2.0" ]
148
2016-01-17T03:16:43.000Z
2022-03-17T12:20:36.000Z
///////////////////////////////////////////////////////////////////////////// // Name: wx/mgl/private/fontmgr.h // Purpose: font management for MGL // Author: Vaclav Slavik // Created: 2006-11-18 // RCS-ID: $Id: fontmgr.h 43569 2006-10-11 04:09:58Z RD $ // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_MGL_PRIVATE_FONTMGR_H_ #define _WX_MGL_PRIVATE_FONTMGR_H_ struct font_info_t; struct font_lib_t; struct font_t; class wxFontInstance : public wxFontInstanceBase { public: wxFontInstance(float ptSize, bool aa, font_lib_t *fontLib); virtual ~wxFontInstance(); struct font_t *GetMGLfont_t() const { return m_font; } private: font_t *m_font; }; class wxFontFace : public wxFontFaceBase { public: wxFontFace(const wxString& filename) : m_fontLib(NULL), m_fileName(filename) {} virtual void Acquire(); virtual void Release(); virtual wxFontInstance *GetFontInstance(float ptSize, bool aa); protected: wxFontInstance *CreateFontInstance(float ptSize, bool aa); private: font_lib_t *m_fontLib; wxString m_fileName; }; class wxFontBundle : public wxFontBundleBase { public: wxFontBundle(const font_info_t *fontInfo); virtual wxString GetName() const; virtual bool IsFixed() const; const font_info_t *GetInfo() const { return m_fontInfo; } private: const font_info_t *m_fontInfo; }; class wxFontsManager : public wxFontsManagerBase { public: wxFontsManager() { AddAllFonts(); } virtual wxString GetDefaultFacename(wxFontFamily family) const; private: // adds all fonts using AddBundle() void AddAllFonts(); }; #endif // _WX_MGL_PRIVATE_FONTMGR_H_
23.960526
77
0.656233
03264b8d34a81356ca4d56cad8d4b252f6219648
699
h
C
ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/SQLQuery.h
chrisdrackett/react-native-background-geolocation
664feed6eeffa2ea7cb15cf26d6db55ba130777d
[ "MIT" ]
2,272
2015-08-12T18:20:49.000Z
2022-03-31T17:01:25.000Z
ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/SQLQuery.h
chrisdrackett/react-native-background-geolocation
664feed6eeffa2ea7cb15cf26d6db55ba130777d
[ "MIT" ]
1,346
2015-08-13T07:48:43.000Z
2022-03-31T14:26:17.000Z
ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/SQLQuery.h
chrisdrackett/react-native-background-geolocation
664feed6eeffa2ea7cb15cf26d6db55ba130777d
[ "MIT" ]
480
2015-08-19T19:37:31.000Z
2022-03-09T16:30:32.000Z
// // SQLQuery.h // TSLocationManager // // Created by Christopher Scott on 2019-10-22. // Copyright © 2019 Transistor Software. All rights reserved. // typedef enum SQLQueryOrder : NSInteger { tsSQLQueryOrderDESC = -1, tsSQLQueryOrderASC = 1 } SQLQueryOrder; @interface SQLQuery : NSObject { @protected NSString *_tableName; NSString *_orderColumn; NSString *_timestampColumn; } @property (nonatomic) double start; @property (nonatomic) double end; @property (nonatomic) int limit; @property (nonatomic) SQLQueryOrder order; - (instancetype) initWithDictionary:(NSDictionary*)params; - (NSString*) render; - (NSArray*) arguments; - (NSString*) toString; @end
19.971429
62
0.716738
0326c3f75802111bc733fd8e2979c1572115a990
535
h
C
src/MIT_alice/MAUICry2DMaterial.h
midasitdev/aliceui
3693018021892bcccbc66f29b931d9736db6f9dc
[ "MIT" ]
10
2019-02-21T13:07:06.000Z
2019-09-21T02:56:37.000Z
src/MIT_alice/MAUICry2DMaterial.h
midasitdev/aliceui
3693018021892bcccbc66f29b931d9736db6f9dc
[ "MIT" ]
5
2019-02-28T03:11:50.000Z
2019-03-08T00:16:17.000Z
src/MIT_alice/MAUICry2DMaterial.h
midasitdev/aliceui
3693018021892bcccbc66f29b931d9736db6f9dc
[ "MIT" ]
5
2019-02-25T00:53:08.000Z
2019-07-05T01:50:34.000Z
#pragma once #define MIDAS_SDK #include "MAUICryCommonDef.h" #include "../MIT_render/MMaterial.h" #include "../MIT_render/MGlossyMaterial.h" #include "HeaderPre.h" namespace mit { namespace alice { class __MY_EXT_CLASS__ MAUICry2DMaterial : public mit::render::MGlossyMaterial { MRUNTIME_DECL_KINDOF( MAUICry2DMaterial ); public: MAUICry2DMaterial( mit::render::MMaterialGearBox* pGearBox ); virtual ~MAUICry2DMaterial(); }; } } #include "HeaderPost.h"
23.26087
86
0.663551
0327f33fc64f86fa61c8a5090c883794841db0c5
8,866
h
C
exegesis/base/architecture.h
the-eager-ghosts/EXEgesis
ca6ab91c0e1f617881a34c8e794ea37466229590
[ "Apache-2.0" ]
201
2017-05-12T05:04:55.000Z
2022-03-14T15:49:37.000Z
exegesis/base/architecture.h
the-eager-ghosts/EXEgesis
ca6ab91c0e1f617881a34c8e794ea37466229590
[ "Apache-2.0" ]
7
2017-05-22T11:52:06.000Z
2022-02-26T16:30:46.000Z
exegesis/base/architecture.h
the-eager-ghosts/EXEgesis
ca6ab91c0e1f617881a34c8e794ea37466229590
[ "Apache-2.0" ]
35
2017-05-16T04:00:06.000Z
2022-02-27T03:37:16.000Z
// Copyright 2018 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Declares the 'Architecture' class, a wrapper over exegesis::ArchitectureProto // that provides efficient lookup for the data in the proto. #ifndef EXEGESIS_BASE_ARCHITECTURE_H_ #define EXEGESIS_BASE_ARCHITECTURE_H_ #include <string> #include <vector> #include "absl/container/flat_hash_map.h" #include "absl/memory/memory.h" #include "exegesis/proto/instructions.pb.h" #include "exegesis/util/index_type.h" #include "glog/logging.h" #include "src/google/protobuf/repeated_field.h" #include "src/google/protobuf/text_format.h" namespace exegesis { // Returns a unique_ptr to a Printer which prints all fields in index order and // which correctly prints instruction_group_index fields even if they have value // of 0. std::unique_ptr<google::protobuf::TextFormat::Printer> GetArchitectureProtoTextPrinter(); // Base class for classes that provide an indexing an lookup API for data stored // in an ArchitectureProto. This class contains functionality that is common for // all architectures. Certain architectures may inherit from this class and add // functionality that is specific for that particular architecture. // // std::shared_ptr<ArchitectureProto> instruction_set = // GetArchitectureProtoOrDie("registered:intel"); // Architecture architecture(architecture); // for (const Architecture::InstructionIndex i : // architecture.GetInstructionsByVendorSyntax("MOV")) { // const InstructionProto& instruction = architecture.instruction(i); // ... // } class Architecture { public: // An index of an instruction in the ISA. The indices of the instructions in // this class are an implementation detail that is internal to the given // Architecture object. The indices are safe to use with the Architecture // object that returned them, but they must not be used with other // Architecture objects. DEFINE_INDEX_TYPE(InstructionIndex, int); // An index of a microarchitecture in the ISA. The indices of the // microarchitectures in this class are an implementation detail that is // internal to the given Architecture object. The indices are safe to use with // the Architecture object that returned them, but they must not be used with // other Architecture objects. DEFINE_INDEX_TYPE(MicroArchitectureIndex, int); // An instruction index that is not used by any existing instruction. static constexpr InstructionIndex kInvalidInstruction = InstructionIndex(-1); // A microarchitecture index that is not used by any existing // microarchitecture. static constexpr MicroArchitectureIndex kInvalidMicroArchitecture = MicroArchitectureIndex(-1); // Initializes the Architecture object with the given architecture proto. Architecture(std::shared_ptr<const ArchitectureProto> architecture_proto); virtual ~Architecture() {} // Disallow copy and assign. Architecture(const Architecture&) = delete; Architecture& operator=(const Architecture&) = delete; // --------------------------------------------------------------------------- // Microarchitectures // --------------------------------------------------------------------------- // Returns the number of microarchitectures supported by this Architecture // object. MicroArchitectureIndex num_microarchitectures() const { return MicroArchitectureIndex( architecture_proto_->per_microarchitecture_itineraries_size()); } // Returns the ID of the microarchitecture at the given index. const std::string& microarchitecture_id(MicroArchitectureIndex index) const { return itineraries(index).microarchitecture_id(); } // Returns the itineraries proto for the given microarchitecture. Using an // invalid microarchitecture index will cause a CHECK failure. const InstructionSetItinerariesProto& itineraries( MicroArchitectureIndex index) const { DCHECK_GE(index, 0); DCHECK_LT(index, num_microarchitectures()); return architecture_proto_->per_microarchitecture_itineraries( index.value()); } // Returns the index of the microarchitecture with the given name, or // kInvalidMicroArchitecture if no such microarchitecture is found in this // architecture. MicroArchitectureIndex GetMicroArchitectureIndex( const std::string& microarchitecture_id) const; // --------------------------------------------------------------------------- // Instruction lookup // --------------------------------------------------------------------------- // Looks up instructions by their LLVM mnemonic. Returns a list of indices of // the instructions with this mnemonic, or an empty list if no such // instruction is found. std::vector<InstructionIndex> GetInstructionsByLLVMMnemonic( const std::string& llvm_mnemonic) const; // Returns the list of indices of instructions with the given encoding // specification string. Returns an empty list if no such instruction is // found. // Note that the encoding specifications are not necessarily unique in the // instruction set. For example on x86-64, most allow switching between direct // and indirect addressing by updating a field of the ModR/M byte. The two // versions have the same encoding specification, but they have different // latencies and use different execution units, so we list them as two // different instructions. std::vector<InstructionIndex> GetInstructionIndicesByRawEncodingSpecification( const std::string& encoding_specification) const; // Returns the ArchitectureProto powering this instruction database. const ArchitectureProto& architecture_proto() const { return *architecture_proto_; } // --------------------------------------------------------------------------- // Access to the data // --------------------------------------------------------------------------- // Returns the number of instructions in the ISA. InstructionIndex num_instructions() const { return InstructionIndex( architecture_proto_->instruction_set().instructions_size()); } // Returns the instruction proto at the given index. const InstructionProto& instruction(InstructionIndex index) const { DCHECK_GE(index, 0); DCHECK_LT(index, num_instructions()); return architecture_proto_->instruction_set().instructions(index.value()); } // Returns an iterable list of instructions of the architecture. const ::google::protobuf::RepeatedPtrField<InstructionProto>& instructions() const { return architecture_proto_->instruction_set().instructions(); } // Returns the itinerary for the given microarchitecture and instruction. const ItineraryProto& itinerary(MicroArchitectureIndex microarchitecture, InstructionIndex instruction) const { DCHECK_GE(instruction, 0); DCHECK_LT(instruction, num_instructions()); return itineraries(microarchitecture).itineraries(instruction.value()); } // Returns the first instruction proto from the given list or nullptr, if the // list is empty. Assumes that all indices in the list are valid. const InstructionProto* GetFirstInstructionOrNull( const std::vector<InstructionIndex>& indices) const { if (indices.empty()) return nullptr; return &instruction(indices.front()); } private: // TODO(ondrasej): In most use cases in this class, the list of instructions // will contain only a single instruction. Consider using a data structure // optimized for this use case. using InstructionsByString = absl::flat_hash_map<std::string, std::vector<InstructionIndex>>; // The architecture proto that contains the instruction data served by this // class. const std::shared_ptr<const ArchitectureProto> architecture_proto_; // Mappings from instruction mnemonics to indices of the corresponding // instructions in architecture_proto_. InstructionsByString llvm_to_instruction_index_; // Instructions in architecture_proto_ indexed by their raw encoding // specification. InstructionsByString raw_encoding_specification_to_instruction_index_; // The list of microarchitecture indices, indexed by their IDs. absl::flat_hash_map<std::string, MicroArchitectureIndex> microarchitectures_by_id_; }; } // namespace exegesis #endif // EXEGESIS_BASE_ARCHITECTURE_H_
42.219048
80
0.722648
032813bc1ac44df820f91a938bee7d403d4889a7
1,104
h
C
SimpleEngine3D/core/utilities/obj_loader.h
lukaszlipski/SimpleEngine3D
8fd81ff17512eed7f84e0b18e94c1a7f9754f573
[ "Apache-2.0" ]
1
2021-08-31T01:45:11.000Z
2021-08-31T01:45:11.000Z
SimpleEngine3D/core/utilities/obj_loader.h
lukaszlipski/SimpleEngine3D
8fd81ff17512eed7f84e0b18e94c1a7f9754f573
[ "Apache-2.0" ]
null
null
null
SimpleEngine3D/core/utilities/obj_loader.h
lukaszlipski/SimpleEngine3D
8fd81ff17512eed7f84e0b18e94c1a7f9754f573
[ "Apache-2.0" ]
null
null
null
#pragma once #include "../containers/dynamic_array.h" #include "../math/math.h" #include "model_loader.h" namespace SE3D { struct OBJindex { uint32 VertexIndex; uint32 TextCoordIndex; uint32 NormalIndex; }; class OBJLoader : public ModelLoader { private: DynamicArray<Vector3D> m_Vertices; DynamicArray<Vector2D> m_TextCoords; DynamicArray<Vector3D> m_Normals; DynamicArray<OBJindex> m_Indices; uint32 m_VerticesOffset; uint32 m_TextCoordsOffset; uint32 m_NormalsOffset; bool m_HasNormals; bool m_HasTextureCoordinates; Vector3D m_FurthestPoint; Vector3D m_Center; public: OBJLoader(const char* path); ~OBJLoader(); inline Vector3D GetFurthestPoint() const { return m_FurthestPoint; } inline Vector3D GetMassCenter() const { return m_Center; } private: void LoadMeshFromFile(const char* path); void AddNewMesh(const char* line); void AddVertex(const char* line); void AddTextCoord(const char* line); void AddNormal(const char* line); void AddFace(const char* line); void CalculateTangents(); void ConvertToInternalFormat() override; }; }
23
70
0.753623
032ac23c3d0ec1fe954909cdad61e6f598fc354c
13,365
c
C
processors/IA32/bochs/bios/biossums.c
bavison/opensmalltalk-vm
d494240736f7c0309e3e819784feb1d53ed0985a
[ "MIT" ]
445
2016-06-30T08:19:11.000Z
2022-03-28T06:09:49.000Z
processors/IA32/bochs/bios/biossums.c
bavison/opensmalltalk-vm
d494240736f7c0309e3e819784feb1d53ed0985a
[ "MIT" ]
439
2016-06-29T20:14:36.000Z
2022-03-17T19:59:58.000Z
processors/IA32/bochs/bios/biossums.c
bavison/opensmalltalk-vm
d494240736f7c0309e3e819784feb1d53ed0985a
[ "MIT" ]
137
2016-07-02T17:32:07.000Z
2022-03-20T11:17:25.000Z
/* * $Id: biossums.c,v 1.4 2007/05/28 08:09:13 vruppert Exp $ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* biossums.c --- written by Eike W. for the Bochs BIOS */ #include <stdlib.h> #include <stdio.h> #include <string.h> typedef unsigned char byte; void check( int value, char* message ); #define LEN_BIOS_DATA 0x10000 #define MAX_OFFSET (LEN_BIOS_DATA - 1) #define BIOS_OFFSET 0xFFFF long chksum_bios_get_offset( byte* data, long offset ); byte chksum_bios_calc_value( byte* data, long offset ); byte chksum_bios_get_value( byte* data, long offset ); void chksum_bios_set_value( byte* data, long offset, byte value ); #define _32__LEN 9 #define _32__CHKSUM 10 #define _32__MINHDR 16 long chksum__32__get_offset( byte* data, long offset ); byte chksum__32__calc_value( byte* data, long offset ); byte chksum__32__get_value( byte* data, long offset ); void chksum__32__set_value( byte* data, long offset, byte value ); #define _MP__LEN 8 #define _MP__CHKSUM 10 #define _MP__MINHDR 16 long chksum__mp__get_offset( byte* data, long offset ); byte chksum__mp__calc_value( byte* data, long offset ); byte chksum__mp__get_value( byte* data, long offset ); void chksum__mp__set_value( byte* data, long offset, byte value ); #define PCMP_BASELEN 4 #define PCMP_CHKSUM 7 #define PCMP_EXT_LEN 40 #define PCMP_EXT_CHKSUM 42 #define PCMP_MINHDR 42 long chksum_pcmp_get_offset( byte* data, long offset ); byte chksum_pcmp_calc_value( byte* data, long offset ); byte chksum_pcmp_get_value( byte* data, long offset ); void chksum_pcmp_set_value( byte* data, long offset, byte value ); #define _PIR_LEN 6 #define _PIR_CHKSUM 31 #define _PIR_MINHDR 32 long chksum__pir_get_offset( byte *data, long offset ); byte chksum__pir_calc_value( byte* data, long offset ); byte chksum__pir_get_value( byte* data, long offset ); void chksum__pir_set_value( byte* data, long offset, byte value ); byte bios_data[LEN_BIOS_DATA]; long bios_len; int main(int argc, char* argv[]) { FILE* stream; long offset, tmp_offset; byte cur_val = 0, new_val = 0; int arg = 1, hits, pad = 0; if ((argc == 3) && (!strcmp(argv[1], "-pad"))) { pad = 1; arg = 2; } else if (argc != 2) { printf("Error. Need a file-name as an argument.\n"); exit(EXIT_FAILURE); } memset(bios_data, 0xff, LEN_BIOS_DATA); if ((stream = fopen(argv[arg], "rb")) == NULL) { printf("Error opening %s for reading.\n", argv[arg]); exit(EXIT_FAILURE); } bios_len = fread(bios_data, 1, LEN_BIOS_DATA, stream); if ((bios_len < LEN_BIOS_DATA) && (pad == 0)) { printf("Error reading 64KBytes from %s.\n", argv[arg]); fclose(stream); exit(EXIT_FAILURE); } fclose(stream); if (pad == 1) goto write_bios; hits = 0; offset = 0L; while( (tmp_offset = chksum__32__get_offset( bios_data, offset )) != -1L ) { offset = tmp_offset; cur_val = chksum__32__get_value( bios_data, offset ); new_val = chksum__32__calc_value( bios_data, offset ); printf( "\n\nPCI-Bios header at: 0x%4lX\n", offset ); printf( "Current checksum: 0x%02X\n", cur_val ); printf( "Calculated checksum: 0x%02X ", new_val ); hits++; } if( hits == 1 && cur_val != new_val ) { printf( "Setting checksum." ); chksum__32__set_value( bios_data, offset, new_val ); } if( hits >= 2 ) { printf( "Multiple PCI headers! No checksum set." ); } if( hits ) { printf( "\n" ); } hits = 0; offset = 0L; while( (tmp_offset = chksum__mp__get_offset( bios_data, offset )) != -1L ) { offset = tmp_offset; cur_val = chksum__mp__get_value( bios_data, offset ); new_val = chksum__mp__calc_value( bios_data, offset ); printf( "\n\nMP header at: 0x%4lX\n", offset ); printf( "Current checksum: 0x%02X\n", cur_val ); printf( "Calculated checksum: 0x%02X ", new_val ); hits++; } if( hits == 1 && cur_val != new_val ) { printf( "Setting checksum." ); chksum__mp__set_value( bios_data, offset, new_val ); } if( hits >= 2 ) { printf( "Warning! Multiple MP headers. No checksum set." ); } if( hits ) { printf( "\n" ); } hits = 0; offset = 0L; while( (tmp_offset = chksum_pcmp_get_offset( bios_data, offset )) != -1L ) { offset = tmp_offset; cur_val = chksum_pcmp_get_value( bios_data, offset ); new_val = chksum_pcmp_calc_value( bios_data, offset ); printf( "\n\nPCMP header at: 0x%4lX\n", offset ); printf( "Current checksum: 0x%02X\n", cur_val ); printf( "Calculated checksum: 0x%02X ", new_val ); hits++; } if( hits == 1 && cur_val != new_val ) { printf( "Setting checksum." ); chksum_pcmp_set_value( bios_data, offset, new_val ); } if( hits >= 2 ) { printf( "Warning! Multiple PCMP headers. No checksum set." ); } if( hits ) { printf( "\n" ); } hits = 0; offset = 0L; while( (tmp_offset = chksum__pir_get_offset( bios_data, offset )) != -1L ) { offset = tmp_offset; cur_val = chksum__pir_get_value( bios_data, offset ); new_val = chksum__pir_calc_value( bios_data, offset ); printf( "\n\n$PIR header at: 0x%4lX\n", offset ); printf( "Current checksum: 0x%02X\n", cur_val ); printf( "Calculated checksum: 0x%02X\n ", new_val ); hits++; } if( hits == 1 && cur_val != new_val ) { printf( "Setting checksum." ); chksum__pir_set_value( bios_data, offset, new_val ); } if( hits >= 2 ) { printf( "Warning! Multiple $PIR headers. No checksum set." ); } if( hits ) { printf( "\n" ); } offset = 0L; offset = chksum_bios_get_offset( bios_data, offset ); cur_val = chksum_bios_get_value( bios_data, offset ); new_val = chksum_bios_calc_value( bios_data, offset ); printf( "\n\nBios checksum at: 0x%4lX\n", offset ); printf( "Current checksum: 0x%02X\n", cur_val ); printf( "Calculated checksum: 0x%02X ", new_val ); if( cur_val != new_val ) { printf( "Setting checksum." ); chksum_bios_set_value( bios_data, offset, new_val ); } printf( "\n" ); write_bios: if ((stream = fopen(argv[arg], "wb")) == NULL) { printf("Error opening %s for writing.\n", argv[arg]); exit(EXIT_FAILURE); } if (fwrite(bios_data, 1, LEN_BIOS_DATA, stream) < LEN_BIOS_DATA) { printf("Error writing 64KBytes to %s.\n", argv[arg]); fclose(stream); exit(EXIT_FAILURE); } fclose(stream); return(EXIT_SUCCESS); } void check(int okay, char* message) { if (!okay) { printf("\n\nError. %s.\n", message); exit(EXIT_FAILURE); } } long chksum_bios_get_offset( byte* data, long offset ) { return( BIOS_OFFSET ); } byte chksum_bios_calc_value( byte* data, long offset ) { int i; byte sum; sum = 0; for( i = 0; i < MAX_OFFSET; i++ ) { sum = sum + *( data + i ); } sum = -sum; /* iso ensures -s + s == 0 on unsigned types */ return( sum ); } byte chksum_bios_get_value( byte* data, long offset ) { return( *( data + BIOS_OFFSET ) ); } void chksum_bios_set_value( byte* data, long offset, byte value ) { *( data + BIOS_OFFSET ) = value; } byte chksum__32__calc_value( byte* data, long offset ) { int i; int len; byte sum; check( offset + _32__MINHDR <= MAX_OFFSET, "_32_ header out of bounds" ); len = *( data + offset + _32__LEN ) << 4; check( offset + len <= MAX_OFFSET, "_32_ header-length out of bounds" ); sum = 0; for( i = 0; i < len; i++ ) { if( i != _32__CHKSUM ) { sum = sum + *( data + offset + i ); } } sum = -sum; return( sum ); } long chksum__32__get_offset( byte* data, long offset ) { long result = -1L; offset = offset + 0x0F; offset = offset & ~( 0x0F ); while( offset + 16 < MAX_OFFSET ) { offset = offset + 16; if( *( data + offset + 0 ) == '_' && \ *( data + offset + 1 ) == '3' && \ *( data + offset + 2 ) == '2' && \ *( data + offset + 3 ) == '_' ) { result = offset; break; } } return( result ); } byte chksum__32__get_value( byte* data, long offset ) { check( offset + _32__CHKSUM <= MAX_OFFSET, "PCI-Bios checksum out of bounds" ); return( *( data + offset + _32__CHKSUM ) ); } void chksum__32__set_value( byte* data, long offset, byte value ) { check( offset + _32__CHKSUM <= MAX_OFFSET, "PCI-Bios checksum out of bounds" ); *( data + offset + _32__CHKSUM ) = value; } byte chksum__mp__calc_value( byte* data, long offset ) { int i; int len; byte sum; check( offset + _MP__MINHDR <= MAX_OFFSET, "_MP_ header out of bounds" ); len = *( data + offset + _MP__LEN ) << 4; check( offset + len <= MAX_OFFSET, "_MP_ header-length out of bounds" ); sum = 0; for( i = 0; i < len; i++ ) { if( i != _MP__CHKSUM ) { sum = sum + *( data + offset + i ); } } sum = -sum; return( sum ); } long chksum__mp__get_offset( byte* data, long offset ) { long result = -1L; offset = offset + 0x0F; offset = offset & ~( 0x0F ); while( offset + 16 < MAX_OFFSET ) { offset = offset + 16; if( *( data + offset + 0 ) == '_' && \ *( data + offset + 1 ) == 'M' && \ *( data + offset + 2 ) == 'P' && \ *( data + offset + 3 ) == '_' ) { result = offset; break; } } return( result ); } byte chksum__mp__get_value( byte* data, long offset ) { check( offset + _MP__CHKSUM <= MAX_OFFSET, "MP checksum out of bounds" ); return( *( data + offset + _MP__CHKSUM ) ); } void chksum__mp__set_value( byte* data, long offset, byte value ) { check( offset + _MP__CHKSUM <= MAX_OFFSET, "MP checksum out of bounds" ); *( data + offset + _MP__CHKSUM ) = value; } byte chksum_pcmp_calc_value( byte* data, long offset ) { int i; int len; byte sum; check( offset + PCMP_MINHDR <= MAX_OFFSET, "PCMP header out of bounds" ); len = *( data + offset + PCMP_BASELEN ) + \ ( *( data + offset + PCMP_BASELEN + 1 ) << 8 ); check( offset + len <= MAX_OFFSET, "PCMP header-length out of bounds" ); if( *( data + offset + PCMP_EXT_LEN ) | \ *( data + offset + PCMP_EXT_LEN + 1 ) | \ *( data + offset + PCMP_EXT_CHKSUM ) ) { check( 0, "PCMP header indicates extended tables (unsupported)" ); } sum = 0; for( i = 0; i < len; i++ ) { if( i != PCMP_CHKSUM ) { sum = sum + *( data + offset + i ); } } sum = -sum; return( sum ); } long chksum_pcmp_get_offset( byte* data, long offset ) { long result = -1L; offset = offset + 0x0F; offset = offset & ~( 0x0F ); while( offset + 16 < MAX_OFFSET ) { offset = offset + 16; if( *( data + offset + 0 ) == 'P' && \ *( data + offset + 1 ) == 'C' && \ *( data + offset + 2 ) == 'M' && \ *( data + offset + 3 ) == 'P' ) { result = offset; break; } } return( result ); } byte chksum_pcmp_get_value( byte* data, long offset ) { check( offset + PCMP_CHKSUM <= MAX_OFFSET, "PCMP checksum out of bounds" ); return( *( data + offset + PCMP_CHKSUM ) ); } void chksum_pcmp_set_value( byte* data, long offset, byte value ) { check( offset + PCMP_CHKSUM <= MAX_OFFSET, "PCMP checksum out of bounds" ); *( data + offset + PCMP_CHKSUM ) = value; } byte chksum__pir_calc_value( byte* data, long offset ) { int i; int len; byte sum; check( offset + _PIR_MINHDR <= MAX_OFFSET, "$PIR header out of bounds" ); len = *( data + offset + _PIR_LEN ) + \ ( *( data + offset + _PIR_LEN + 1 ) << 8 ); check( offset + len <= MAX_OFFSET, "$PIR header-length out of bounds" ); sum = 0; for( i = 0; i < len; i++ ) { if( i != _PIR_CHKSUM ) { sum = sum + *( data + offset + i ); } } sum = -sum; return( sum ); } long chksum__pir_get_offset( byte* data, long offset ) { long result = -1L; offset = offset + 0x0F; offset = offset & ~( 0x0F ); while( offset + 16 < MAX_OFFSET ) { offset = offset + 16; if( *( data + offset + 0 ) == '$' && \ *( data + offset + 1 ) == 'P' && \ *( data + offset + 2 ) == 'I' && \ *( data + offset + 3 ) == 'R' ) { result = offset; break; } } return( result ); } byte chksum__pir_get_value( byte* data, long offset ) { check( offset + _PIR_CHKSUM <= MAX_OFFSET, "$PIR checksum out of bounds" ); return( *( data + offset + _PIR_CHKSUM ) ); } void chksum__pir_set_value( byte* data, long offset, byte value ) { check( offset + _PIR_CHKSUM <= MAX_OFFSET, "$PIR checksum out of bounds" ); *( data + offset + _PIR_CHKSUM ) = value; }
26.465347
81
0.608679
032b3ef0db5f6d52e74b196b36747d5bee57dbd7
1,833
c
C
source/rbase/common/test/rtest.c
ray820328/funra
71cac2ad97749817e1a92f0b1a2e9fee9424d002
[ "MIT" ]
null
null
null
source/rbase/common/test/rtest.c
ray820328/funra
71cac2ad97749817e1a92f0b1a2e9fee9424d002
[ "MIT" ]
null
null
null
source/rbase/common/test/rtest.c
ray820328/funra
71cac2ad97749817e1a92f0b1a2e9fee9424d002
[ "MIT" ]
null
null
null
/** * Copyright (c) 2014 ray * * This library is free software; you can redistribute it and/or modify it * under the terms of the MIT license. See LICENSE for details. * * @author: Ray */ #include <string.h> #include "rlog.h" #include "rbase/common/test/rtest.h" #include "rlist.h" static rlist_t *test_entries = NULL; int rtest_add_test_entry(rtest_entry_type entry_func) { rlist_rpush(test_entries, entry_func); return rcode_ok; } static int init_platform(); static int run_tests(int output); static int init_platform() { test_entries = rlist_new(raymalloc); assert_true(test_entries != NULL); rlist_init(test_entries); test_entries->malloc_node = raymalloc; test_entries->free_node = rayfree; test_entries->free_self = rayfree; return rcode_ok; } int main(int argc, char **argv) { rlog_init("RLog.txt", RLOG_ALL, false, "all"); init_platform(); run_tests(0); // switch (argc) { // case 1: return run_tests(0); // default: // fprintf(stderr, "Too many arguments.\n"); // fflush(stderr); // } rlog_uninit(); #ifndef __SUNPRO_C return rcode_ok; #endif } static int run_tests(int output) { int testResult; rtest_add_test_entry(run_rstring_tests); rtest_add_test_entry(run_rthread_tests); rtest_add_test_entry(run_rarray_tests); rtest_add_test_entry(run_rcommon_tests); rtest_add_test_entry(run_rdict_tests); rtest_add_test_entry(run_rlog_tests); rtest_add_test_entry(run_rfile_tests); testResult = 0; rlist_iterator_t it = rlist_it(test_entries, rlist_dir_tail); rlist_node_t *node = NULL; while ((node = rlist_next(&it))) { testResult = ((rtest_entry_type)(node->val))(output); if (testResult != rcode_ok) { break; } } return testResult; }
21.068966
74
0.684124
032e8f87a85e8402d9d9b148a35456505f9b4320
9,466
h
C
Source/ThirdParty/NewtonDynamics/include/packages/dCustomJoints/dCustomControllerManager.h
nigeyuk/HevEn
0dc970d6ecd0e5fd5512441562e2fdb4620214f0
[ "CC-BY-3.0" ]
15
2017-03-15T15:41:13.000Z
2022-01-11T01:15:12.000Z
Source/ThirdParty/NewtonDynamics/include/packages/dCustomJoints/dCustomControllerManager.h
nigeyuk/HevEn
0dc970d6ecd0e5fd5512441562e2fdb4620214f0
[ "CC-BY-3.0" ]
null
null
null
Source/ThirdParty/NewtonDynamics/include/packages/dCustomJoints/dCustomControllerManager.h
nigeyuk/HevEn
0dc970d6ecd0e5fd5512441562e2fdb4620214f0
[ "CC-BY-3.0" ]
3
2017-03-17T12:28:48.000Z
2020-03-19T19:32:02.000Z
/* Copyright (c) <2003-2016> <Newton Game Dynamics> * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely */ // dCustomControllerManager.h: interface for the dCustomControllerManager class. // ////////////////////////////////////////////////////////////////////// #ifndef D_CUSTOM_CONTROLLER_MANAGER_H_ #define D_CUSTOM_CONTROLLER_MANAGER_H_ #include <dCustomJointLibraryStdAfx.h> #include <dCustomAlloc.h> class dCustomControllerConvexCastPreFilter { public: dCustomControllerConvexCastPreFilter () :m_me(NULL) { } dCustomControllerConvexCastPreFilter (const NewtonBody* const me) :m_me(me) { } ~dCustomControllerConvexCastPreFilter () { } virtual unsigned Prefilter(const NewtonBody* const body, const NewtonCollision* const myCollision) { return NewtonCollisionGetMode(myCollision); } private: CUSTOM_JOINTS_API static unsigned Prefilter(const NewtonBody* const body, const NewtonCollision* const myCollision, void* const userData) { dCustomControllerConvexCastPreFilter* const filter = (dCustomControllerConvexCastPreFilter*) userData; return (body != filter->m_me) ? filter->Prefilter (body, myCollision) : 0; } protected: const NewtonBody* m_me; friend class dCustomPlayerController; friend class dCustomVehicleControllerManager; }; class dCustomControllerConvexRayFilter: public dCustomControllerConvexCastPreFilter { public: CUSTOM_JOINTS_API dCustomControllerConvexRayFilter (const NewtonBody* const me) :dCustomControllerConvexCastPreFilter() ,m_hitBody(NULL) ,m_shapeHit(NULL) ,m_collisionID(0) { m_me = me; } CUSTOM_JOINTS_API static dFloat Filter (const NewtonBody* const body, const NewtonCollision* const shapeHit, const dFloat* const hitContact, const dFloat* const hitNormal, dLong collisionID, void* const userData, dFloat intersectParam) { dCustomControllerConvexRayFilter* const filter = (dCustomControllerConvexRayFilter*) userData; dAssert (body != filter->m_me); if (intersectParam < filter->m_intersectParam) { filter->m_hitBody = body; filter->m_shapeHit = shapeHit; filter->m_collisionID = collisionID; filter->m_intersectParam = intersectParam; filter->m_hitContact = dVector(hitContact[0], hitContact[1], hitContact[2], 0.0f); filter->m_hitNormal = dVector(hitNormal[0], hitNormal[1], hitNormal[2], 0.0f); } return intersectParam; } dVector m_hitContact; dVector m_hitNormal; const NewtonBody* m_hitBody; const NewtonCollision* m_shapeHit; dLong m_collisionID; dFloat m_intersectParam; }; class dCustomControllerBase { public: dCustomControllerBase () :m_userData(NULL) ,m_body(NULL) ,m_manager(NULL) { } virtual ~dCustomControllerBase () { } void* GetUserData () const { return m_userData; } void SetUserData (void* const userData) { m_userData = userData; } NewtonBody* GetBody() const { return m_body; } void* GetManager() const { return m_manager; } bool operator== (const dCustomControllerBase& copy) const { dAssert (0); return false; } virtual void PreUpdate (dFloat timestep, int threadIndex) = 0; virtual void PostUpdate (dFloat timestep, int threadIndex) = 0; void* m_userData; NewtonBody* m_body; void* m_manager; }; template<class CONTROLLER_BASE> class dCustomControllerManager: public dList<CONTROLLER_BASE> { public: dCustomControllerManager(NewtonWorld* const world, const char* const managerName); ~dCustomControllerManager(); NewtonWorld* GetWorld() const { return m_world; } dFloat GetTimeStep() const { return m_curTimestep; } virtual CONTROLLER_BASE* CreateController (); virtual void DestroyController (CONTROLLER_BASE* const controller); virtual void OnDestroyBody (NewtonBody* const body) { } virtual void Debug () const; virtual void PreUpdate(dFloat timestep); virtual void PostUpdate(dFloat timestep); private: void DestroyAllController (); static void Destroy (const NewtonWorld* const world, void* const listenerUserData); static void PreUpdate (const NewtonWorld* const world, void* const listenerUserData, dFloat timestep); static void PostUpdate (const NewtonWorld* const world, void* const listenerUserData, dFloat timestep); static void OnBodyDestroy (const NewtonWorld* const world, void* const listener, NewtonBody* const body); static void PreUpdateKernel (NewtonWorld* const world, void* const context, int threadIndex); static void PostUpdateKernel (NewtonWorld* const world, void* const context, int threadIndex); protected: NewtonWorld* m_world; dFloat m_curTimestep; }; template<class CONTROLLER_BASE> dCustomControllerManager<CONTROLLER_BASE>::dCustomControllerManager(NewtonWorld* const world, const char* const managerName) :m_world(world) ,m_curTimestep(0.0f) { void* const prelistener = NewtonWorldAddPreListener (world, managerName, this, PreUpdate, NULL); NewtonWorldAddPostListener (world, managerName, this, PostUpdate, Destroy); NewtonWorldListenerSetBodyDestroyCallback (world, prelistener, OnBodyDestroy); } template<class CONTROLLER_BASE> dCustomControllerManager<CONTROLLER_BASE>::~dCustomControllerManager() { } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::DestroyAllController () { while (dCustomControllerManager<CONTROLLER_BASE>::GetCount()) { DestroyController (&dCustomControllerManager<CONTROLLER_BASE>::GetLast()->GetInfo()); } } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::Debug () const { } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::PreUpdate(dFloat timestep) { for (typename dCustomControllerManager<CONTROLLER_BASE>::dListNode* node = dCustomControllerManager<CONTROLLER_BASE>::GetFirst(); node; node = node->GetNext()) { NewtonDispachThreadJob(m_world, PreUpdateKernel, &node->GetInfo()); } NewtonSyncThreadJobs(m_world); } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::PostUpdate(dFloat timestep) { for (typename dList<CONTROLLER_BASE>::dListNode* node = dList<CONTROLLER_BASE>::GetFirst(); node; node = node->GetNext()) { NewtonDispachThreadJob(m_world, PostUpdateKernel, &node->GetInfo()); } NewtonSyncThreadJobs(m_world); } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::PreUpdate (const NewtonWorld* const world, void* const listenerUserData, dFloat timestep) { dCustomControllerManager* const me = (dCustomControllerManager*) listenerUserData; me->m_curTimestep = timestep; me->PreUpdate(timestep); } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::PostUpdate (const NewtonWorld* const world, void* const listenerUserData, dFloat timestep) { dCustomControllerManager* const me = (dCustomControllerManager*) listenerUserData; me->m_curTimestep = timestep; me->PostUpdate(timestep); } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::Destroy (const NewtonWorld* const world, void* const listenerUserData) { dCustomControllerManager* const me = (dCustomControllerManager*) listenerUserData; me->DestroyAllController (); delete me; } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::OnBodyDestroy (const NewtonWorld* const world, void* const listener, NewtonBody* const body) { dCustomControllerManager* const me = (dCustomControllerManager*) NewtonWorldGetListenerUserData(world, listener); me->OnDestroyBody(body); /* for (typename dList<CONTROLLER_BASE>::dListNode* node = me->GetFirst(); node; node = node->GetNext()) { CONTROLLER_BASE& controller = node->GetInfo(); if (controller.GetBody() == body) { me->DestroyController (&controller); } } */ } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::PreUpdateKernel (NewtonWorld* const world, void* const context, int threadIndex) { dTimeTrackerEvent(__FUNCTION__); dCustomControllerBase* const controller = (dCustomControllerBase*) context; controller->PreUpdate(((dCustomControllerManager*)controller->m_manager)->GetTimeStep(), threadIndex); } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::PostUpdateKernel (NewtonWorld* const world, void* const context, int threadIndex) { dTimeTrackerEvent(__FUNCTION__); class dCustomControllerBase* const controller = (dCustomControllerBase*) context; controller->PostUpdate(((dCustomControllerManager*)controller->m_manager)->GetTimeStep(), threadIndex); } template<class CONTROLLER_BASE> CONTROLLER_BASE* dCustomControllerManager<CONTROLLER_BASE>::CreateController () { CONTROLLER_BASE* const controller = &dCustomControllerManager<CONTROLLER_BASE>::Append()->GetInfo(); controller->m_manager = this; return controller; } template<class CONTROLLER_BASE> void dCustomControllerManager<CONTROLLER_BASE>::DestroyController (CONTROLLER_BASE* const controller) { dAssert (dCustomControllerManager<CONTROLLER_BASE>::GetNodeFromInfo (*controller)); typename dCustomControllerManager<CONTROLLER_BASE>::dListNode* const node = dCustomControllerManager<CONTROLLER_BASE>::GetNodeFromInfo (*controller); dCustomControllerManager<CONTROLLER_BASE>::Remove (node); } #endif
30.050794
236
0.780266
032f93ee630480cfe9fb070e7e3148146c520727
1,503
h
C
source/extensions/filters/http/original_src/original_src.h
lopter-dbx/envoy
d342e96e7ba2319329838e799021838354e88118
[ "Apache-2.0" ]
218
2019-05-10T01:11:27.000Z
2022-01-12T07:12:59.000Z
source/extensions/filters/http/original_src/original_src.h
lopter-dbx/envoy
d342e96e7ba2319329838e799021838354e88118
[ "Apache-2.0" ]
624
2020-10-19T12:21:29.000Z
2021-05-09T22:47:00.000Z
source/extensions/filters/http/original_src/original_src.h
lopter-dbx/envoy
d342e96e7ba2319329838e799021838354e88118
[ "Apache-2.0" ]
93
2019-05-10T00:15:21.000Z
2021-10-14T09:32:30.000Z
#pragma once #include "envoy/http/filter.h" #include "envoy/network/address.h" #include "common/common/logger.h" #include "extensions/filters/http/original_src/config.h" namespace Envoy { namespace Extensions { namespace HttpFilters { namespace OriginalSrc { /** * Implements the Original Src http filter. This filter places the downstream source address of the * request, as determined by the stream's `downstreamRemoteAddress()`, into an option which will be * used to partition upstream connections. This does not support non-ip (e.g. AF_UNIX) connections; * they will use the same address they would have had this filter not been installed. */ class OriginalSrcFilter : public Http::StreamDecoderFilter, Logger::Loggable<Logger::Id::filter> { public: explicit OriginalSrcFilter(const Config& config); // Http::StreamFilterBase void onDestroy() override; // Http::StreamDecoderFilter Http::FilterHeadersStatus decodeHeaders(Http::RequestHeaderMap& headers, bool end_stream) override; Http::FilterDataStatus decodeData(Buffer::Instance& data, bool end_stream) override; Http::FilterTrailersStatus decodeTrailers(Http::RequestTrailerMap& trailers) override; void setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks& callbacks) override; private: Config config_; Http::StreamDecoderFilterCallbacks* callbacks_{}; }; } // namespace OriginalSrc } // namespace HttpFilters } // namespace Extensions } // namespace Envoy
34.159091
100
0.759814
0330078ff7880a34c94e275c19d128b989762355
7,699
c
C
src/linux-3.7.10/arch/arm/mach-imx/mach-kzm_arm11_01.c
marmolak/gray386linux
1f46fe66ceb2adfa91a5c702fdad07a1a147192b
[ "BSD-2-Clause" ]
null
null
null
src/linux-3.7.10/arch/arm/mach-imx/mach-kzm_arm11_01.c
marmolak/gray386linux
1f46fe66ceb2adfa91a5c702fdad07a1a147192b
[ "BSD-2-Clause" ]
1
2022-02-16T20:50:59.000Z
2022-02-19T21:16:04.000Z
src/linux-3.7.10/arch/arm/mach-imx/mach-kzm_arm11_01.c
marmolak/gray386linux
1f46fe66ceb2adfa91a5c702fdad07a1a147192b
[ "BSD-2-Clause" ]
null
null
null
/* * KZM-ARM11-01 support * Copyright (C) 2009 Yoichi Yuasa <yuasa@linux-mips.org> * * based on code for MX31ADS, * Copyright (C) 2000 Deep Blue Solutions Ltd * Copyright (C) 2002 Shane Nay (shane@minirl.com) * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <linux/gpio.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/serial_8250.h> #include <linux/smsc911x.h> #include <linux/types.h> #include <linux/regulator/machine.h> #include <linux/regulator/fixed.h> #include <asm/irq.h> #include <asm/mach-types.h> #include <asm/memory.h> #include <asm/setup.h> #include <asm/mach/arch.h> #include <asm/mach/irq.h> #include <asm/mach/map.h> #include <asm/mach/time.h> #include <mach/common.h> #include <mach/hardware.h> #include <mach/iomux-mx3.h> #include "devices-imx31.h" #define KZM_ARM11_IO_ADDRESS(x) (IOMEM( \ IMX_IO_P2V_MODULE(x, MX31_CS4) ?: \ IMX_IO_P2V_MODULE(x, MX31_CS5)) ?: \ MX31_IO_ADDRESS(x)) /* * KZM-ARM11-01 Board Control Registers on FPGA */ #define KZM_ARM11_CTL1 (MX31_CS4_BASE_ADDR + 0x1000) #define KZM_ARM11_CTL2 (MX31_CS4_BASE_ADDR + 0x1001) #define KZM_ARM11_RSW1 (MX31_CS4_BASE_ADDR + 0x1002) #define KZM_ARM11_BACK_LIGHT (MX31_CS4_BASE_ADDR + 0x1004) #define KZM_ARM11_FPGA_REV (MX31_CS4_BASE_ADDR + 0x1008) #define KZM_ARM11_7SEG_LED (MX31_CS4_BASE_ADDR + 0x1010) #define KZM_ARM11_LEDS (MX31_CS4_BASE_ADDR + 0x1020) #define KZM_ARM11_DIPSW2 (MX31_CS4_BASE_ADDR + 0x1003) /* * External UART for touch panel on FPGA */ #define KZM_ARM11_16550 (MX31_CS4_BASE_ADDR + 0x1050) #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) /* * KZM-ARM11-01 has an external UART on FPGA */ static struct plat_serial8250_port serial_platform_data[] = { { .membase = KZM_ARM11_IO_ADDRESS(KZM_ARM11_16550), .mapbase = KZM_ARM11_16550, /* irq number is run-time assigned */ .irqflags = IRQ_TYPE_EDGE_RISING, .uartclk = 14745600, .regshift = 0, .iotype = UPIO_MEM, .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_BUGGY_UART, }, {}, }; static struct resource serial8250_resources[] = { { .start = KZM_ARM11_16550, .end = KZM_ARM11_16550 + 0x10, .flags = IORESOURCE_MEM, }, { /* irq number is run-time assigned */ .flags = IORESOURCE_IRQ, }, }; static struct platform_device serial_device = { .name = "serial8250", .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = serial_platform_data, }, .num_resources = ARRAY_SIZE(serial8250_resources), .resource = serial8250_resources, }; static int __init kzm_init_ext_uart(void) { u8 tmp; /* * GPIO 1-1: external UART interrupt line */ mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO)); gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "ext-uart-int"); gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); /* * Unmask UART interrupt */ tmp = __raw_readb(KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1)); tmp |= 0x2; __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1)); serial_platform_data[0].irq = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); serial8250_resources[1].start = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); serial8250_resources[1].end = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); return platform_device_register(&serial_device); } #else static inline int kzm_init_ext_uart(void) { return 0; } #endif /* * SMSC LAN9118 */ #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) static struct smsc911x_platform_config kzm_smsc9118_config = { .phy_interface = PHY_INTERFACE_MODE_MII, .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH, .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, }; static struct resource kzm_smsc9118_resources[] = { { .start = MX31_CS5_BASE_ADDR, .end = MX31_CS5_BASE_ADDR + SZ_128K - 1, .flags = IORESOURCE_MEM, }, { /* irq number is run-time assigned */ .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, }, }; static struct platform_device kzm_smsc9118_device = { .name = "smsc911x", .id = -1, .num_resources = ARRAY_SIZE(kzm_smsc9118_resources), .resource = kzm_smsc9118_resources, .dev = { .platform_data = &kzm_smsc9118_config, }, }; static struct regulator_consumer_supply dummy_supplies[] = { REGULATOR_SUPPLY("vdd33a", "smsc911x"), REGULATOR_SUPPLY("vddvario", "smsc911x"), }; static int __init kzm_init_smsc9118(void) { /* * GPIO 1-2: SMSC9118 interrupt line */ mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO)); gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2), "smsc9118-int"); gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2)); regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); kzm_smsc9118_resources[1].start = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2)); kzm_smsc9118_resources[1].end = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2)); return platform_device_register(&kzm_smsc9118_device); } #else static inline int kzm_init_smsc9118(void) { return 0; } #endif #if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE) static const struct imxuart_platform_data uart_pdata __initconst = { .flags = IMXUART_HAVE_RTSCTS, }; static void __init kzm_init_imx_uart(void) { imx31_add_imx_uart0(&uart_pdata); imx31_add_imx_uart1(&uart_pdata); } #else static inline void kzm_init_imx_uart(void) { } #endif static int kzm_pins[] __initdata = { MX31_PIN_CTS1__CTS1, MX31_PIN_RTS1__RTS1, MX31_PIN_TXD1__TXD1, MX31_PIN_RXD1__RXD1, MX31_PIN_DCD_DCE1__DCD_DCE1, MX31_PIN_RI_DCE1__RI_DCE1, MX31_PIN_DSR_DCE1__DSR_DCE1, MX31_PIN_DTR_DCE1__DTR_DCE1, MX31_PIN_CTS2__CTS2, MX31_PIN_RTS2__RTS2, MX31_PIN_TXD2__TXD2, MX31_PIN_RXD2__RXD2, MX31_PIN_DCD_DTE1__DCD_DTE2, MX31_PIN_RI_DTE1__RI_DTE2, MX31_PIN_DSR_DTE1__DSR_DTE2, MX31_PIN_DTR_DTE1__DTR_DTE2, }; /* * Board specific initialization. */ static void __init kzm_board_init(void) { imx31_soc_init(); mxc_iomux_setup_multiple_pins(kzm_pins, ARRAY_SIZE(kzm_pins), "kzm"); kzm_init_ext_uart(); kzm_init_smsc9118(); kzm_init_imx_uart(); pr_info("Clock input source is 26MHz\n"); } /* * This structure defines static mappings for the kzm-arm11-01 board. */ static struct map_desc kzm_io_desc[] __initdata = { { .virtual = (unsigned long)MX31_CS4_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR), .length = MX31_CS4_SIZE, .type = MT_DEVICE }, { .virtual = (unsigned long)MX31_CS5_BASE_ADDR_VIRT, .pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR), .length = MX31_CS5_SIZE, .type = MT_DEVICE }, }; /* * Set up static virtual mappings. */ static void __init kzm_map_io(void) { mx31_map_io(); iotable_init(kzm_io_desc, ARRAY_SIZE(kzm_io_desc)); } static void __init kzm_timer_init(void) { mx31_clocks_init(26000000); } static struct sys_timer kzm_timer = { .init = kzm_timer_init, }; MACHINE_START(KZM_ARM11_01, "Kyoto Microcomputer Co., Ltd. KZM-ARM11-01") .atag_offset = 0x100, .map_io = kzm_map_io, .init_early = imx31_init_early, .init_irq = mx31_init_irq, .handle_irq = imx31_handle_irq, .timer = &kzm_timer, .init_machine = kzm_board_init, .restart = mxc_restart, MACHINE_END
25.493377
74
0.754124
03317e1e618586ebd1bb841343d9fcb08fa68c7f
703
h
C
linsched-linsched-alpha/arch/powerpc/include/asm/mpc8260.h
usenixatc2021/SoftRefresh_Scheduling
589ba06c8ae59538973c22edf28f74a59d63aa14
[ "MIT" ]
55
2015-01-20T00:09:45.000Z
2021-08-19T05:40:27.000Z
linsched-linsched-alpha/arch/powerpc/include/asm/mpc8260.h
usenixatc2021/SoftRefresh_Scheduling
589ba06c8ae59538973c22edf28f74a59d63aa14
[ "MIT" ]
5
2020-04-04T09:24:09.000Z
2020-04-19T12:33:55.000Z
linsched-linsched-alpha/arch/powerpc/include/asm/mpc8260.h
usenixatc2021/SoftRefresh_Scheduling
589ba06c8ae59538973c22edf28f74a59d63aa14
[ "MIT" ]
36
2015-02-13T00:58:22.000Z
2021-08-19T08:08:07.000Z
/* * Since there are many different boards and no standard configuration, * we have a unique include file for each. Rather than change every * file that has to include MPC8260 configuration, they all include * this one and the configuration switching is done here. */ #ifdef __KERNEL__ #ifndef __ASM_POWERPC_MPC8260_H__ #define __ASM_POWERPC_MPC8260_H__ #define MPC82XX_BCR_PLDP 0x00800000 /* Pipeline Maximum Depth */ #ifdef CONFIG_8260 #if defined(CONFIG_PQ2ADS) || defined (CONFIG_PQ2FADS) #include <platforms/82xx/pq2ads.h> #endif #ifdef CONFIG_PCI_8260 #include <platforms/82xx/m82xx_pci.h> #endif #endif /* CONFIG_8260 */ #endif /* !__ASM_POWERPC_MPC8260_H__ */ #endif /* __KERNEL__ */
27.038462
71
0.775249
03329fa83d1a6c0f75f0dce12b28f46d4cc2195e
667
h
C
src/npf/cgnat/cgn_test.h
pavelrn/vyatta-dataplane
8863a5634d68453c1fb00ccb8687c2f6a99c0f91
[ "BSD-2-Clause" ]
null
null
null
src/npf/cgnat/cgn_test.h
pavelrn/vyatta-dataplane
8863a5634d68453c1fb00ccb8687c2f6a99c0f91
[ "BSD-2-Clause" ]
null
null
null
src/npf/cgnat/cgn_test.h
pavelrn/vyatta-dataplane
8863a5634d68453c1fb00ccb8687c2f6a99c0f91
[ "BSD-2-Clause" ]
null
null
null
/* * Copyright (c) 2021, AT&T Intellectual Property. All rights reserved. * * SPDX-License-Identifier: LGPL-2.1-only */ #ifndef _CGN_TEST_H_ #define _CGN_TEST_H_ #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include "npf/cgnat/cgn_dir.h" /* * Used by CGNAT unit-tests only */ struct ifnet; struct rte_mbuf; void dp_test_npf_clear_cgnat(void); bool ipv4_cgnat_test(struct rte_mbuf **mbufp, struct ifnet *ifp, enum cgn_dir dir, int *error); /* * The following fetch json strings directly without going through opd */ struct cgn_sess_fltr; void cgn_ut_show_sessions(char **buf, size_t *bufsz, struct cgn_sess_fltr *fltr); #endif
19.057143
81
0.731634
0333f04bc448cc2987be3e13b8954c306134ba31
57,114
c
C
Sample/Platform/Generic/RuntimeDxe/FvbServices/Common/FWBlockService.c
bitcrystal/edk
321b15a55b946372eb21b3e95d323be245c31021
[ "BSD-3-Clause" ]
14
2016-09-25T02:27:49.000Z
2021-09-22T15:39:44.000Z
Sample/Platform/Generic/RuntimeDxe/FvbServices/Common/FWBlockService.c
bitcrystal/edk
321b15a55b946372eb21b3e95d323be245c31021
[ "BSD-3-Clause" ]
1
2015-12-04T20:53:47.000Z
2015-12-04T20:53:47.000Z
Sample/Platform/Generic/RuntimeDxe/FvbServices/Common/FWBlockService.c
bitcrystal/edk
321b15a55b946372eb21b3e95d323be245c31021
[ "BSD-3-Clause" ]
17
2015-07-21T10:18:21.000Z
2021-11-22T17:36:53.000Z
/*++ Copyright (c) 2004 - 2007, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: FWBlockService.c Abstract: Revision History --*/ #include "FWBlockService.h" #include "EfiFlashMap.h" #include EFI_GUID_DEFINITION (FlashMapHob) ESAL_FWB_GLOBAL *mFvbModuleGlobal; EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = { FVB_DEVICE_SIGNATURE, { { { HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, { sizeof (MEMMAP_DEVICE_PATH), 0 } }, EfiMemoryMappedIO, 0, 0, }, { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } } }, 0, { FvbProtocolGetAttributes, FvbProtocolSetAttributes, FvbProtocolGetPhysicalAddress, FvbProtocolGetBlockSize, FvbProtocolRead, FvbProtocolWrite, FvbProtocolEraseBlocks, NULL }, { FvbExtendProtocolEraseCustomBlockRange } }; EFI_DRIVER_ENTRY_POINT (FvbInitialize) EFI_RUNTIMESERVICE VOID EFIAPI FvbVirtualddressChangeEvent ( IN EFI_EVENT Event, IN VOID *Context ) /*++ Routine Description: Fixup internal data so that EFI and SAL can be call in virtual mode. Call the passed in Child Notify event and convert the mFvbModuleGlobal date items to there virtual address. mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] - Physical copy of instance data mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] - Virtual pointer to common instance data. Arguments: (Standard EFI notify event - EFI_EVENT_NOTIFY) Returns: None --*/ { EFI_FW_VOL_INSTANCE *FwhInstance; UINTN Index; EfiConvertPointer (EFI_INTERNAL_POINTER, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]); // // Convert the base address of all the instances // Index = 0; FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]; while (Index < mFvbModuleGlobal->NumFv) { EfiConvertPointer (EFI_INTERNAL_POINTER, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]); EfiConvertPointer (EFI_INTERNAL_POINTER, (VOID **) &FwhInstance->FvWriteBase[FVB_VIRTUAL]); FwhInstance = (EFI_FW_VOL_INSTANCE *) ((UINTN)((UINT8 *)FwhInstance) + FwhInstance->VolumeHeader.HeaderLength + (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))); Index++; } EfiConvertPointer (EFI_INTERNAL_POINTER, (VOID **) &mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL]); EfiConvertPointer (EFI_INTERNAL_POINTER, (VOID **) &mFvbModuleGlobal); } VOID FvbMemWrite8 ( IN UINT64 Dest, IN UINT8 Byte ) { EfiMemWrite (EfiCpuIoWidthUint8, Dest, 1, &Byte); return ; } EFI_STATUS GetFvbInstance ( IN UINTN Instance, IN ESAL_FWB_GLOBAL *Global, OUT EFI_FW_VOL_INSTANCE **FwhInstance, IN BOOLEAN Virtual ) /*++ Routine Description: Retrieves the physical address of a memory mapped FV Arguments: Instance - The FV instance whose base address is going to be returned Global - Pointer to ESAL_FWB_GLOBAL that contains all instance data FwhInstance - The EFI_FW_VOL_INSTANCE fimrware instance structure Virtual - Whether CPU is in virtual or physical mode Returns: EFI_SUCCESS - Successfully returns EFI_INVALID_PARAMETER - Instance not found --*/ { EFI_FW_VOL_INSTANCE *FwhRecord; if (Instance >= Global->NumFv) { return EFI_INVALID_PARAMETER; } // // Find the right instance of the FVB private data // FwhRecord = Global->FvInstance[Virtual]; while (Instance > 0) { FwhRecord = (EFI_FW_VOL_INSTANCE *) ((UINTN)((UINT8 *)FwhRecord) + FwhRecord->VolumeHeader.HeaderLength + (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))); Instance--; } *FwhInstance = FwhRecord; return EFI_SUCCESS; } EFI_STATUS FvbGetPhysicalAddress ( IN UINTN Instance, OUT EFI_PHYSICAL_ADDRESS *Address, IN ESAL_FWB_GLOBAL *Global, IN BOOLEAN Virtual ) /*++ Routine Description: Retrieves the physical address of a memory mapped FV Arguments: Instance - The FV instance whose base address is going to be returned Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS that on successful return, contains the base address of the firmware volume. Global - Pointer to ESAL_FWB_GLOBAL that contains all instance data Virtual - Whether CPU is in virtual or physical mode Returns: EFI_SUCCESS - Successfully returns EFI_INVALID_PARAMETER - Instance not found --*/ { EFI_FW_VOL_INSTANCE *FwhInstance; EFI_STATUS Status; // // Find the right instance of the FVB private data // Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); ASSERT_EFI_ERROR (Status); *Address = FwhInstance->FvBase[Virtual]; return EFI_SUCCESS; } EFI_STATUS FvbGetVolumeAttributes ( IN UINTN Instance, OUT EFI_FVB_ATTRIBUTES *Attributes, IN ESAL_FWB_GLOBAL *Global, IN BOOLEAN Virtual ) /*++ Routine Description: Retrieves attributes, insures positive polarity of attribute bits, returns resulting attributes in output parameter Arguments: Instance - The FV instance whose attributes is going to be returned Attributes - Output buffer which contains attributes Global - Pointer to ESAL_FWB_GLOBAL that contains all instance data Virtual - Whether CPU is in virtual or physical mode Returns: EFI_SUCCESS - Successfully returns EFI_INVALID_PARAMETER - Instance not found --*/ { EFI_FW_VOL_INSTANCE *FwhInstance; EFI_STATUS Status; // // Find the right instance of the FVB private data // Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); ASSERT_EFI_ERROR (Status); *Attributes = FwhInstance->VolumeHeader.Attributes; return EFI_SUCCESS; } EFI_STATUS FvbGetLbaAddress ( IN UINTN Instance, IN EFI_LBA Lba, OUT UINTN *LbaAddress, OUT UINTN *LbaWriteAddress, OUT UINTN *LbaLength, OUT UINTN *NumOfBlocks, IN ESAL_FWB_GLOBAL *Global, IN BOOLEAN Virtual ) /*++ Routine Description: Retrieves the starting address of an LBA in an FV Arguments: Instance - The FV instance which the Lba belongs to Lba - The logical block address LbaAddress - On output, contains the physical starting address of the Lba LbaWriteAddress - On output, contains the physical starting address of the Lba for writing LbaLength - On output, contains the length of the block NumOfBlocks - A pointer to a caller allocated UINTN in which the number of consecutive blocks starting with Lba is returned. All blocks in this range have a size of BlockSize Global - Pointer to ESAL_FWB_GLOBAL that contains all instance data Virtual - Whether CPU is in virtual or physical mode Returns: EFI_SUCCESS - Successfully returns EFI_INVALID_PARAMETER - Instance not found --*/ { UINT32 NumBlocks; UINT32 BlockLength; UINTN Offset; EFI_LBA StartLba; EFI_LBA NextLba; EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FV_BLOCK_MAP_ENTRY *BlockMap; EFI_STATUS Status; // // Find the right instance of the FVB private data // Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); ASSERT_EFI_ERROR (Status); StartLba = 0; Offset = 0; BlockMap = &(FwhInstance->VolumeHeader.FvBlockMap[0]); // // Parse the blockmap of the FV to find which map entry the Lba belongs to // while (TRUE) { NumBlocks = BlockMap->NumBlocks; BlockLength = BlockMap->BlockLength; if (NumBlocks == 0 || BlockLength == 0) { return EFI_INVALID_PARAMETER; } NextLba = StartLba + NumBlocks; // // The map entry found // if (Lba >= StartLba && Lba < NextLba) { Offset = Offset + (UINTN) MultU64x32 ((Lba - StartLba), BlockLength); if (LbaAddress) { *LbaAddress = FwhInstance->FvBase[Virtual] + Offset; } if (LbaWriteAddress) { *LbaWriteAddress = FwhInstance->FvWriteBase[Virtual] + Offset; } if (LbaLength) { *LbaLength = BlockLength; } if (NumOfBlocks) { *NumOfBlocks = (UINTN) (NextLba - Lba); } return EFI_SUCCESS; } StartLba = NextLba; Offset = Offset + NumBlocks * BlockLength; BlockMap++; } } EFI_STATUS FvbReadBlock ( IN UINTN Instance, IN EFI_LBA Lba, IN UINTN BlockOffset, IN OUT UINTN *NumBytes, IN UINT8 *Buffer, IN ESAL_FWB_GLOBAL *Global, IN BOOLEAN Virtual ) /*++ Routine Description: Reads specified number of bytes into a buffer from the specified block Arguments: Instance - The FV instance to be read from Lba - The logical block address to be read from BlockOffset - Offset into the block at which to begin reading NumBytes - Pointer that on input contains the total size of the buffer. On output, it contains the total number of bytes read Buffer - Pointer to a caller allocated buffer that will be used to hold the data read Global - Pointer to ESAL_FWB_GLOBAL that contains all instance data Virtual - Whether CPU is in virtual or physical mode Returns: EFI_SUCCESS - The firmware volume was read successfully and contents are in Buffer EFI_BAD_BUFFER_SIZE - Read attempted across a LBA boundary. On output, NumBytes contains the total number of bytes returned in Buffer EFI_ACCESS_DENIED - The firmware volume is in the ReadDisabled state EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be read EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL --*/ { EFI_FVB_ATTRIBUTES Attributes; UINTN LbaAddress; UINTN LbaLength; EFI_STATUS Status; // // Check for invalid conditions // if ((NumBytes == NULL) || (Buffer == NULL)) { return EFI_INVALID_PARAMETER; } if (*NumBytes == 0) { return EFI_INVALID_PARAMETER; } Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, NULL, &LbaLength, NULL, Global, Virtual); if (EFI_ERROR (Status)) { return Status; } // // Check if the FV is read enabled // FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual); if ((Attributes & EFI_FVB_READ_STATUS) == 0) { return EFI_ACCESS_DENIED; } // // Perform boundary checks and adjust NumBytes // if (BlockOffset > LbaLength) { return EFI_INVALID_PARAMETER; } if (LbaLength < (*NumBytes + BlockOffset)) { *NumBytes = (UINT32) (LbaLength - BlockOffset); Status = EFI_BAD_BUFFER_SIZE; } EfiCommonLibCopyMem (Buffer, (VOID *) (LbaAddress + BlockOffset), (UINTN) *NumBytes); return Status; } EFI_STATUS FlashFdWrite ( IN UINTN WriteAddress, IN UINTN Address, IN OUT UINTN *NumBytes, IN UINT8 *Buffer, IN UINTN LbaLength ) /*++ Routine Description: Writes specified number of bytes from the input buffer to the address Arguments: Returns: --*/ { UINT8 *Src; UINT8 *Dest; UINTN Count; EFI_STATUS Status; UINT8 HubCommand; UINT8 HubData; UINTN RetryTimes; Status = EFI_SUCCESS; EnableFvbWrites (TRUE); // // Grab the lock before entering critical code section // // bugbug // Commented out since locking mechanisium is not correctly implemented // on IA32 so that it will assert in runtime environment. // // EfiAcquireLock(&(FwhInstance->FvbDevLock)); // // Write data one byte at a time, don't write if the src and dest bytes match // Dest = (UINT8 *) WriteAddress; Src = Buffer; for (Count = 0; Count < *NumBytes; Count++, Dest++, Src++) { HubCommand = FWH_WRITE_SETUP_COMMAND; FvbMemWrite8 ((UINT64) ((UINTN) Dest), HubCommand); FvbMemWrite8 ((UINT64) ((UINTN) Dest), *Src); // // Device error if time out occurs // RetryTimes = 0; while (RetryTimes < FVB_MAX_RETRY_TIMES) { HubCommand = FWH_READ_STATUS_COMMAND; FvbMemWrite8 ((UINT64) ((UINTN) Dest), HubCommand); EfiMemRead (EfiCpuIoWidthUint8, (UINT64) ((UINTN) Dest), 0x1, &HubData); if (HubData & FWH_WRITE_STATE_STATUS) { break; } RetryTimes++; } if (RetryTimes >= FVB_MAX_RETRY_TIMES) { *NumBytes = Count; Status = EFI_DEVICE_ERROR; break; } } // // Clear status register // HubCommand = FWH_CLEAR_STATUS_COMMAND; FvbMemWrite8 ((UINT64) ((UINTN) WriteAddress), HubCommand); // // Issue read array command to return the FWH state machine to the // normal operational state // HubCommand = FWH_READ_ARRAY_COMMAND; FvbMemWrite8 ((UINT64) ((UINTN) WriteAddress), HubCommand); // // Flush the changed area to make the cache consistent // EfiCpuFlushCache (WriteAddress, *NumBytes); // // End of critical code section, release lock. // // EfiReleaseLock(&(FwhInstance->FvbDevLock)); // EnableFvbWrites (FALSE); return Status; } EFI_STATUS FlashFdErase ( IN UINTN WriteAddress, IN UINTN Address, IN UINTN LbaLength ) /*++ Routine Description: Erase a certain block from address LbaWriteAddress Arguments: Returns: --*/ { EFI_STATUS Status; UINT8 HubCommand; UINT8 HubData; UINTN RetryTimes; Status = EFI_SUCCESS; EnableFvbWrites (TRUE); // // Grab the lock before entering critical code section // // EfiAcquireLock(&(FwhInstance->FvbDevLock)); // // Send erase commands to FWH // HubCommand = FWH_BLOCK_ERASE_SETUP_COMMAND; FvbMemWrite8 ((UINT64) WriteAddress, HubCommand); HubCommand = FWH_BLOCK_ERASE_CONFIRM_COMMAND; FvbMemWrite8 ((UINT64) WriteAddress, HubCommand); // // Wait for completion. Indicated by FWH_WRITE_STATE_STATUS bit becoming 0 // Device error if time out occurs // RetryTimes = 0; while (RetryTimes < FVB_MAX_RETRY_TIMES) { HubCommand = FWH_READ_STATUS_COMMAND; FvbMemWrite8 ((UINT64) WriteAddress, HubCommand); EfiMemRead (EfiCpuIoWidthUint8, (UINT64) WriteAddress, 0x1, &HubData); if (HubData & FWH_WRITE_STATE_STATUS) { break; } RetryTimes++; } if (RetryTimes >= FVB_MAX_RETRY_TIMES) { Status = EFI_DEVICE_ERROR; } // // Clear status register // HubCommand = FWH_CLEAR_STATUS_COMMAND; FvbMemWrite8 ((UINT64) WriteAddress, HubCommand); // // Issue read array command to return the FWH state machine to the normal op state // HubCommand = FWH_READ_ARRAY_COMMAND; FvbMemWrite8 ((UINT64) ((UINTN) WriteAddress), HubCommand); EfiCpuFlushCache (Address, LbaLength); // // End of critical code section, release lock. // // EfiReleaseLock(&(FwhInstance->FvbDevLock)); // EnableFvbWrites (FALSE); return Status; } EFI_STATUS FvbWriteBlock ( IN UINTN Instance, IN EFI_LBA Lba, IN UINTN BlockOffset, IN OUT UINTN *NumBytes, IN UINT8 *Buffer, IN ESAL_FWB_GLOBAL *Global, IN BOOLEAN Virtual ) /*++ Routine Description: Writes specified number of bytes from the input buffer to the block Arguments: Instance - The FV instance to be written to Lba - The starting logical block index to write to BlockOffset - Offset into the block at which to begin writing NumBytes - Pointer that on input contains the total size of the buffer. On output, it contains the total number of bytes actually written Buffer - Pointer to a caller allocated buffer that contains the source for the write Global - Pointer to ESAL_FWB_GLOBAL that contains all instance data Virtual - Whether CPU is in virtual or physical mode Returns: EFI_SUCCESS - The firmware volume was written successfully EFI_BAD_BUFFER_SIZE - Write attempted across a LBA boundary. On output, NumBytes contains the total number of bytes actually written EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be written EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL --*/ { EFI_FVB_ATTRIBUTES Attributes; UINTN LbaAddress; UINTN LbaWriteAddress; UINTN LbaLength; EFI_FW_VOL_INSTANCE *FwhInstance; EFI_STATUS Status; EFI_STATUS ReturnStatus; // // Find the right instance of the FVB private data // Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); ASSERT_EFI_ERROR (Status); // // Writes are enabled in the init routine itself // if (!FwhInstance->WriteEnabled) { return EFI_ACCESS_DENIED; } // // Check for invalid conditions // if ((NumBytes == NULL) || (Buffer == NULL)) { return EFI_INVALID_PARAMETER; } if (*NumBytes == 0) { return EFI_INVALID_PARAMETER; } Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaWriteAddress, &LbaLength, NULL, Global, Virtual); if (EFI_ERROR (Status)) { return Status; } // // Check if the FV is write enabled // FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual); if ((Attributes & EFI_FVB_WRITE_STATUS) == 0) { return EFI_ACCESS_DENIED; } // // Perform boundary checks and adjust NumBytes // if (BlockOffset > LbaLength) { return EFI_INVALID_PARAMETER; } if (LbaLength < (*NumBytes + BlockOffset)) { *NumBytes = (UINT32) (LbaLength - BlockOffset); Status = EFI_BAD_BUFFER_SIZE; } ReturnStatus = FlashFdWrite ( LbaWriteAddress + BlockOffset, LbaAddress, NumBytes, Buffer, LbaLength ); if (EFI_ERROR (ReturnStatus)) { return ReturnStatus; } return Status; } EFI_STATUS FvbEraseBlock ( IN UINTN Instance, IN EFI_LBA Lba, IN ESAL_FWB_GLOBAL *Global, IN BOOLEAN Virtual ) /*++ Routine Description: Erases and initializes a firmware volume block Arguments: Instance - The FV instance to be erased Lba - The logical block index to be erased Global - Pointer to ESAL_FWB_GLOBAL that contains all instance data Virtual - Whether CPU is in virtual or physical mode Returns: EFI_SUCCESS - The erase request was successfully completed EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be written. Firmware device may have been partially erased EFI_INVALID_PARAMETER - Instance not found --*/ { EFI_FVB_ATTRIBUTES Attributes; UINTN LbaAddress; UINTN LbaWriteAddress; EFI_FW_VOL_INSTANCE *FwhInstance; UINTN LbaLength; EFI_STATUS Status; // // Find the right instance of the FVB private data // Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); ASSERT_EFI_ERROR (Status); // // Writes are enabled in the init routine itself // if (!FwhInstance->WriteEnabled) { return EFI_ACCESS_DENIED; } // // Check if the FV is write enabled // FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual); if ((Attributes & EFI_FVB_WRITE_STATUS) == 0) { return EFI_ACCESS_DENIED; } // // Get the starting address of the block for erase. For debug reasons, // LbaWriteAddress may not be the same as LbaAddress. // Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaWriteAddress, &LbaLength, NULL, Global, Virtual); if (EFI_ERROR (Status)) { return Status; } return FlashFdErase ( LbaWriteAddress, LbaAddress, LbaLength ); } EFI_STATUS FvbEraseCustomBlockRange ( IN UINTN Instance, IN EFI_LBA StartLba, IN UINTN OffsetStartLba, IN EFI_LBA LastLba, IN UINTN OffsetLastLba, IN ESAL_FWB_GLOBAL *Global, IN BOOLEAN Virtual ) /*++ Routine Description: Erases and initializes a specified range of a firmware volume Arguments: Instance - The FV instance to be erased StartLba - The starting logical block index to be erased OffsetStartLba - Offset into the starting block at which to begin erasing LastLba - The last logical block index to be erased OffsetStartLba - Offset into the last block at which to end erasing Global - Pointer to ESAL_FWB_GLOBAL that contains all instance data Virtual - Whether CPU is in virtual or physical mode Returns: EFI_SUCCESS - The firmware volume was erased successfully EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be written. Firmware device may have been partially erased EFI_INVALID_PARAMETER - Instance not found --*/ { EFI_LBA Index; UINTN LbaSize; UINTN ScratchLbaSizeData; // // First LBA. // FvbGetLbaAddress (Instance, StartLba, NULL, NULL, &LbaSize, NULL, Global, Virtual); // // Use the scratch space as the intermediate buffer to transfer data // Back up the first LBA in scratch space. // FvbReadBlock (Instance, StartLba, 0, &LbaSize, Global->FvbScratchSpace[Virtual], Global, Virtual); // // erase now // FvbEraseBlock (Instance, StartLba, Global, Virtual); ScratchLbaSizeData = OffsetStartLba; // // write the data back to the first block // if (ScratchLbaSizeData > 0) { FvbWriteBlock (Instance, StartLba, 0, &ScratchLbaSizeData, Global->FvbScratchSpace[Virtual], Global, Virtual); } // // Middle LBAs // if (LastLba > (StartLba + 1)) { for (Index = (StartLba + 1); Index <= (LastLba - 1); Index++) { FvbEraseBlock (Instance, Index, Global, Virtual); } } // // Last LBAs, the same as first LBAs // if (LastLba > StartLba) { FvbGetLbaAddress (Instance, LastLba, NULL, NULL, &LbaSize, NULL, Global, Virtual); FvbReadBlock (Instance, LastLba, 0, &LbaSize, Global->FvbScratchSpace[Virtual], Global, Virtual); FvbEraseBlock (Instance, LastLba, Global, Virtual); } ScratchLbaSizeData = LbaSize - (OffsetStartLba + 1); return FvbWriteBlock ( Instance, LastLba, (OffsetLastLba + 1), &ScratchLbaSizeData, Global->FvbScratchSpace[Virtual], Global, Virtual ); } EFI_STATUS FvbSetVolumeAttributes ( IN UINTN Instance, IN OUT EFI_FVB_ATTRIBUTES *Attributes, IN ESAL_FWB_GLOBAL *Global, IN BOOLEAN Virtual ) /*++ Routine Description: Modifies the current settings of the firmware volume according to the input parameter, and returns the new setting of the volume Arguments: Instance - The FV instance whose attributes is going to be modified Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES containing the desired firmware volume settings. On successful return, it contains the new settings of the firmware volume Global - Pointer to ESAL_FWB_GLOBAL that contains all instance data Virtual - Whether CPU is in virtual or physical mode Returns: EFI_SUCCESS - Successfully returns EFI_ACCESS_DENIED - The volume setting is locked and cannot be modified EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are in conflict with the capabilities as declared in the firmware volume header --*/ { EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FVB_ATTRIBUTES OldAttributes; EFI_FVB_ATTRIBUTES *AttribPtr; UINT32 Capabilities; UINT32 OldStatus; UINT32 NewStatus; EFI_STATUS Status; // // Find the right instance of the FVB private data // Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); ASSERT_EFI_ERROR (Status); AttribPtr = (EFI_FVB_ATTRIBUTES *) &(FwhInstance->VolumeHeader.Attributes); OldAttributes = *AttribPtr; Capabilities = OldAttributes & EFI_FVB_CAPABILITIES; OldStatus = OldAttributes & EFI_FVB_STATUS; NewStatus = *Attributes & EFI_FVB_STATUS; // // If firmware volume is locked, no status bit can be updated // if (OldAttributes & EFI_FVB_LOCK_STATUS) { if (OldStatus ^ NewStatus) { return EFI_ACCESS_DENIED; } } // // Test read disable // if ((Capabilities & EFI_FVB_READ_DISABLED_CAP) == 0) { if ((NewStatus & EFI_FVB_READ_STATUS) == 0) { return EFI_INVALID_PARAMETER; } } // // Test read enable // if ((Capabilities & EFI_FVB_READ_ENABLED_CAP) == 0) { if (NewStatus & EFI_FVB_READ_STATUS) { return EFI_INVALID_PARAMETER; } } // // Test write disable // if ((Capabilities & EFI_FVB_WRITE_DISABLED_CAP) == 0) { if ((NewStatus & EFI_FVB_WRITE_STATUS) == 0) { return EFI_INVALID_PARAMETER; } } // // Test write enable // if ((Capabilities & EFI_FVB_WRITE_ENABLED_CAP) == 0) { if (NewStatus & EFI_FVB_WRITE_STATUS) { return EFI_INVALID_PARAMETER; } } // // Test lock // if ((Capabilities & EFI_FVB_LOCK_CAP) == 0) { if (NewStatus & EFI_FVB_LOCK_STATUS) { return EFI_INVALID_PARAMETER; } } *AttribPtr = (*AttribPtr) & (0xFFFFFFFF & (~EFI_FVB_STATUS)); *AttribPtr = (*AttribPtr) | NewStatus; *Attributes = *AttribPtr; return EFI_SUCCESS; } // // FVB protocol APIs // EFI_STATUS EFIAPI FvbProtocolGetPhysicalAddress ( IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, OUT EFI_PHYSICAL_ADDRESS *Address ) /*++ Routine Description: Retrieves the physical address of the device. Arguments: This - Calling context Address - Output buffer containing the address. Returns: Returns: EFI_SUCCESS - Successfully returns --*/ { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; FvbDevice = FVB_DEVICE_FROM_THIS (This); return FvbGetPhysicalAddress (FvbDevice->Instance, Address, mFvbModuleGlobal, EfiGoneVirtual ()); } EFI_STATUS EFIAPI FvbProtocolGetBlockSize ( IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN EFI_LBA Lba, OUT UINTN *BlockSize, OUT UINTN *NumOfBlocks ) /*++ Routine Description: Retrieve the size of a logical block Arguments: This - Calling context Lba - Indicates which block to return the size for. BlockSize - A pointer to a caller allocated UINTN in which the size of the block is returned NumOfBlocks - a pointer to a caller allocated UINTN in which the number of consecutive blocks starting with Lba is returned. All blocks in this range have a size of BlockSize Returns: EFI_SUCCESS - The firmware volume was read successfully and contents are in Buffer --*/ { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; FvbDevice = FVB_DEVICE_FROM_THIS (This); return FvbGetLbaAddress ( FvbDevice->Instance, Lba, NULL, NULL, BlockSize, NumOfBlocks, mFvbModuleGlobal, EfiGoneVirtual () ); } EFI_STATUS EFIAPI FvbProtocolGetAttributes ( IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, OUT EFI_FVB_ATTRIBUTES *Attributes ) /*++ Routine Description: Retrieves Volume attributes. No polarity translations are done. Arguments: This - Calling context Attributes - output buffer which contains attributes Returns: EFI_SUCCESS - Successfully returns --*/ { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; FvbDevice = FVB_DEVICE_FROM_THIS (This); return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ()); } EFI_STATUS EFIAPI FvbProtocolSetAttributes ( IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN OUT EFI_FVB_ATTRIBUTES *Attributes ) /*++ Routine Description: Sets Volume attributes. No polarity translations are done. Arguments: This - Calling context Attributes - output buffer which contains attributes Returns: EFI_SUCCESS - Successfully returns --*/ { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; FvbDevice = FVB_DEVICE_FROM_THIS (This); return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ()); } EFI_STATUS EFIAPI FvbProtocolEraseBlocks ( IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, ... ) /*++ Routine Description: The EraseBlock() function erases one or more blocks as denoted by the variable argument list. The entire parameter list of blocks must be verified prior to erasing any blocks. If a block is requested that does not exist within the associated firmware volume (it has a larger index than the last block of the firmware volume), the EraseBlock() function must return EFI_INVALID_PARAMETER without modifying the contents of the firmware volume. Arguments: This - Calling context ... - Starting LBA followed by Number of Lba to erase. a -1 to terminate the list. Returns: EFI_SUCCESS - The erase request was successfully completed EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be written. Firmware device may have been partially erased --*/ { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; EFI_FW_VOL_INSTANCE *FwhInstance; UINTN NumOfBlocks; VA_LIST args; EFI_LBA StartingLba; UINTN NumOfLba; EFI_STATUS Status; FvbDevice = FVB_DEVICE_FROM_THIS (This); Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ()); ASSERT_EFI_ERROR (Status); NumOfBlocks = FwhInstance->NumOfBlocks; VA_START (args, This); do { StartingLba = VA_ARG (args, EFI_LBA); if (StartingLba == EFI_LBA_LIST_TERMINATOR) { break; } NumOfLba = VA_ARG (args, UINT32); // // Check input parameters // if ((NumOfLba == 0) || ((StartingLba + NumOfLba) > NumOfBlocks)) { VA_END (args); return EFI_INVALID_PARAMETER; } } while (1); VA_END (args); VA_START (args, This); do { StartingLba = VA_ARG (args, EFI_LBA); if (StartingLba == EFI_LBA_LIST_TERMINATOR) { break; } NumOfLba = VA_ARG (args, UINT32); while (NumOfLba > 0) { Status = FvbEraseBlock (FvbDevice->Instance, StartingLba, mFvbModuleGlobal, EfiGoneVirtual ()); if (EFI_ERROR (Status)) { VA_END (args); return Status; } StartingLba++; NumOfLba--; } } while (1); VA_END (args); return EFI_SUCCESS; } EFI_STATUS EFIAPI FvbProtocolWrite ( IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN EFI_LBA Lba, IN UINTN Offset, IN OUT UINTN *NumBytes, IN UINT8 *Buffer ) /*++ Routine Description: Writes data beginning at Lba:Offset from FV. The write terminates either when *NumBytes of data have been written, or when a block boundary is reached. *NumBytes is updated to reflect the actual number of bytes written. The write opertion does not include erase. This routine will attempt to write only the specified bytes. If the writes do not stick, it will return an error. Arguments: This - Calling context Lba - Block in which to begin write Offset - Offset in the block at which to begin write NumBytes - On input, indicates the requested write size. On output, indicates the actual number of bytes written Buffer - Buffer containing source data for the write. Returns: EFI_SUCCESS - The firmware volume was written successfully EFI_BAD_BUFFER_SIZE - Write attempted across a LBA boundary. On output, NumBytes contains the total number of bytes actually written EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be written EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL --*/ { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; FvbDevice = FVB_DEVICE_FROM_THIS (This); return FvbWriteBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ()); } EFI_STATUS EFIAPI FvbProtocolRead ( IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN EFI_LBA Lba, IN UINTN Offset, IN OUT UINTN *NumBytes, IN UINT8 *Buffer ) /*++ Routine Description: Reads data beginning at Lba:Offset from FV. The Read terminates either when *NumBytes of data have been read, or when a block boundary is reached. *NumBytes is updated to reflect the actual number of bytes written. The write opertion does not include erase. This routine will attempt to write only the specified bytes. If the writes do not stick, it will return an error. Arguments: This - Calling context Lba - Block in which to begin Read Offset - Offset in the block at which to begin Read NumBytes - On input, indicates the requested write size. On output, indicates the actual number of bytes Read Buffer - Buffer containing source data for the Read. Returns: EFI_SUCCESS - The firmware volume was read successfully and contents are in Buffer EFI_BAD_BUFFER_SIZE - Read attempted across a LBA boundary. On output, NumBytes contains the total number of bytes returned in Buffer EFI_ACCESS_DENIED - The firmware volume is in the ReadDisabled state EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be read EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL --*/ { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; FvbDevice = FVB_DEVICE_FROM_THIS (This); return FvbReadBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ()); } // // FVB Extension Protocols // EFI_STATUS EFIAPI FvbExtendProtocolEraseCustomBlockRange ( IN EFI_FVB_EXTENSION_PROTOCOL *This, IN EFI_LBA StartLba, IN UINTN OffsetStartLba, IN EFI_LBA LastLba, IN UINTN OffsetLastLba ) /*++ Routine Description: Erases and initializes a specified range of a firmware volume Arguments: This - Calling context StartLba - The starting logical block index to be erased OffsetStartLba - Offset into the starting block at which to begin erasing LastLba - The last logical block index to be erased OffsetStartLba - Offset into the last block at which to end erasing Returns: EFI_SUCCESS - The firmware volume was erased successfully EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be written. Firmware device may have been partially erased --*/ { EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; FvbDevice = FVB_EXTEND_DEVICE_FROM_THIS (This); return FvbEraseCustomBlockRange ( FvbDevice->Instance, StartLba, OffsetStartLba, LastLba, OffsetLastLba, mFvbModuleGlobal, EfiGoneVirtual () ); } STATIC EFI_STATUS ValidateFvHeader ( EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader ) /*++ Routine Description: Check the integrity of firmware volume header Arguments: FwVolHeader - A pointer to a firmware volume header Returns: EFI_SUCCESS - The firmware volume is consistent EFI_NOT_FOUND - The firmware volume has corrupted. So it is not an FV --*/ { UINT16 *Ptr; UINT16 HeaderLength; UINT16 Checksum; // // Verify the header revision, header signature, length // Length of FvBlock cannot be 2**64-1 // HeaderLength cannot be an odd number if (((FwVolHeader->Revision != EFI_FVH_REVISION)&& (FwVolHeader->Revision != EFI_FVH_PI_REVISION)) || (FwVolHeader->Signature != EFI_FVH_SIGNATURE) || (FwVolHeader->FvLength == ((UINTN) -1)) || ((FwVolHeader->HeaderLength & 0x01) != 0) ) { return EFI_NOT_FOUND; } // // Verify the header checksum // HeaderLength = (UINT16) (FwVolHeader->HeaderLength / 2); Ptr = (UINT16 *) FwVolHeader; Checksum = 0; while (HeaderLength > 0) { Checksum = Checksum + (*Ptr); HeaderLength--; Ptr++; } if (Checksum != 0) { return EFI_NOT_FOUND; } return EFI_SUCCESS; } BOOLEAN FvbGetCfiSupported ( IN UINTN LbaAddress ) /*++ Routine Description: Check if the firmware volume is CFI typed flash Arguments: LbaAddress - The physical address of the firmware volume Returns: TRUE - CFI supported FALSE - CFI un-supported --*/ { UINT8 HubData[8]; UINT8 HubCommand; BOOLEAN Supported; Supported = TRUE; // // Issue CFI Query (98h) to address 55h // HubCommand = CFI_QUERY; FvbMemWrite8 ((LbaAddress + 0x55), HubCommand); // // x8 device in 8-bit mode? // EfiMemRead (EfiCpuIoWidthUint8, (LbaAddress + 0x10), 0x3, &HubData); if (!EfiCompareMem (HubData, "QRY", 3)) { goto Done; } // // paired x8 devices? // EfiMemRead (EfiCpuIoWidthUint8, (LbaAddress + 0x20), 0x6, &HubData); if (!EfiCompareMem (HubData, "QQRRYY", 6)) { goto Done; } // // x16 device in 16-bit mode? // EfiMemRead (EfiCpuIoWidthUint8, (LbaAddress + 0x20), 0x4, &HubData); if ((!EfiCompareMem (&HubData[0], "Q", 2)) && (!EfiCompareMem (&HubData[2], "R", 2))) { goto Done; } // // x16 device in 8-bit mode? // EfiMemRead (EfiCpuIoWidthUint8, (LbaAddress + 0x20), 0x3, &HubData); if (!EfiCompareMem (HubData, "QQR", 3)) { goto Done; } // // 2 x16 devices in 8-bit mode (paired chip configuration)? // EfiMemRead (EfiCpuIoWidthUint8, (LbaAddress + 0x40), 0x6, &HubData); if (!EfiCompareMem (HubData, "QQQQRR", 6)) { goto Done; } // // x32 device in 8-bit mode // EfiMemRead (EfiCpuIoWidthUint8, (LbaAddress + 0x40), 0x5, &HubData); if (!EfiCompareMem (HubData, "QQQQR", 5)) { goto Done; } // // x32 device in 32-bit mode // if ((!EfiCompareMem (&HubData[0], "Q", 2)) && (((UINT16) HubData[2]) == 0) && (HubData[4] == 'R')) { goto Done; } // // If it got to here, CFI is not supported // Supported = FALSE; Done: // // Issue command FWH_READ_ARRAY_COMMAND (0xff) at the end of this service to // guarantee that the FWH is back in read mode again // HubCommand = FWH_READ_ARRAY_COMMAND; FvbMemWrite8 (LbaAddress, HubCommand); return Supported; } EFI_STATUS GetFvbHeader ( VOID **HobList, EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader, EFI_PHYSICAL_ADDRESS *BaseAddress, BOOLEAN *WriteBack ) { EFI_STATUS Status; VOID *Buffer; EFI_FLASH_MAP_ENTRY_DATA *FlashMapEntry; EFI_FLASH_SUBAREA_ENTRY *FlashMapSubEntry; Status = EFI_SUCCESS; *FwVolHeader = NULL; *WriteBack = FALSE; Status = GetNextGuidHob (HobList, &gEfiFlashMapHobGuid, &Buffer, NULL); if (EFI_ERROR (Status)) { return EFI_NOT_FOUND; } FlashMapEntry = (EFI_FLASH_MAP_ENTRY_DATA *) Buffer; FlashMapSubEntry = &FlashMapEntry->Entries[0]; // // Check if it is a "FVB" area // if (!EfiCompareGuid (&FlashMapSubEntry->FileSystem, &gEfiFirmwareVolumeBlockProtocolGuid)) { return Status; } // // Check if it is a "real" flash // if (FlashMapSubEntry->Attributes != (EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV)) { return Status; } *BaseAddress = FlashMapSubEntry->Base; DEBUG ((EFI_D_ERROR, "FlashMap HOB: BaseAddress = 0x%lx\n", *BaseAddress)); *FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (*BaseAddress); Status = ValidateFvHeader (*FwVolHeader); if (EFI_ERROR (Status)) { // // Get FvbInfo // *WriteBack = TRUE; DEBUG ((EFI_D_ERROR, "BaseAddress = 0x%lx\n", BaseAddress)); Status = GetFvbInfo (*BaseAddress, FwVolHeader); DEBUG ((EFI_D_ERROR, "Fvb: FV header invalid, GetFvbInfo - %r\n", Status)); ASSERT_EFI_ERROR (Status); } return EFI_SUCCESS; } EFI_STATUS EFIAPI FvbInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: This function does common initialization for FVB services Arguments: Returns: --*/ { EFI_STATUS Status; EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; VOID *HobList; VOID *FirmwareVolumeHobList; UINT32 BufferSize; EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry; UINTN LbaAddress; UINT8 Data; UINTN BlockIndex2; BOOLEAN WriteEnabled; BOOLEAN WriteLocked; EFI_HANDLE FwbHandle; EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface; EFI_DEVICE_PATH_PROTOCOL *TempFwbDevicePath; FV_DEVICE_PATH TempFvbDevicePathData; UINT32 MaxLbaSize; BOOLEAN CfiEnabled; EFI_PHYSICAL_ADDRESS BaseAddress; BOOLEAN WriteBack; UINTN NumOfBlocks; UINTN HeaderLength; INITIALIZE_SCRIPT (ImageHandle, SystemTable); EfiInitializeRuntimeDriverLib (ImageHandle, SystemTable, FvbVirtualddressChangeEvent); Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList); HeaderLength = 0; // // No FV HOBs found // ASSERT_EFI_ERROR (Status); // // Allocate runtime services data for global variable, which contains // the private data of all firmware volume block instances // Status = gBS->AllocatePool ( EfiRuntimeServicesData, sizeof (ESAL_FWB_GLOBAL), &mFvbModuleGlobal ); ASSERT_EFI_ERROR (Status); EnablePlatformFvb (); EnableFvbWrites (TRUE); // // Calculate the total size for all firmware volume block instances // BufferSize = 0; FirmwareVolumeHobList = HobList; do { Status = GetFvbHeader (&FirmwareVolumeHobList, &FwVolHeader, &BaseAddress, &WriteBack); if (EFI_ERROR (Status)) { break; } if (FwVolHeader) { BufferSize += (FwVolHeader->HeaderLength + sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)); } } while (TRUE); // // Only need to allocate once. There is only one copy of physical memory for // the private data of each FV instance. But in virtual mode or in physical // mode, the address of the the physical memory may be different. // Status = gBS->AllocatePool ( EfiRuntimeServicesData, BufferSize, &mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] ); ASSERT_EFI_ERROR (Status); // // Make a virtual copy of the FvInstance pointer. // FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]; mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] = FwhInstance; mFvbModuleGlobal->NumFv = 0; FirmwareVolumeHobList = HobList; MaxLbaSize = 0; // // Fill in the private data of each firmware volume block instance // do { Status = GetFvbHeader (&FirmwareVolumeHobList, &FwVolHeader, &BaseAddress, &WriteBack); if (EFI_ERROR (Status)) { break; } if (!FwVolHeader) { continue; } EfiCopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, FwVolHeader->HeaderLength); FwVolHeader = &(FwhInstance->VolumeHeader); FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress; FwhInstance->FvBase[FVB_VIRTUAL] = (UINTN) BaseAddress; // // FwhInstance->FvWriteBase may not be the same as FwhInstance->FvBase // PlatformGetFvbWriteBase ( (UINTN) BaseAddress, (UINTN *) &(FwhInstance->FvWriteBase[FVB_PHYSICAL]), &WriteEnabled ); // // Every pointer should have a virtual copy. // FwhInstance->FvWriteBase[FVB_VIRTUAL] = FwhInstance->FvWriteBase[FVB_PHYSICAL]; FwhInstance->WriteEnabled = WriteEnabled; EfiInitializeLock (&(FwhInstance->FvbDevLock), EFI_TPL_HIGH_LEVEL); LbaAddress = (UINTN) FwhInstance->FvWriteBase[0]; NumOfBlocks = 0; WriteLocked = FALSE; if (WriteEnabled) { CfiEnabled = FvbGetCfiSupported (LbaAddress); for (PtrBlockMapEntry = FwVolHeader->FvBlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) { for (BlockIndex2 = 0; BlockIndex2 < PtrBlockMapEntry->NumBlocks; BlockIndex2++) { if (SetPlatformFvbLock (LbaAddress)) { // // Clear all write-lock and read-lock HW bits // For sync3, the software will enforce the protection // if (CfiEnabled) { Data = CFI_BLOCK_LOCK_UNLOCK; FvbMemWrite8 (LbaAddress, Data); Data = CFI_BLOCK_UNLOCK_CONFIRM; FvbMemWrite8 (LbaAddress, Data); while (TRUE) { EfiMemRead (EfiCpuIoWidthUint8, (LbaAddress + 2), 1, &Data); if (Data & 0x80) { break; } } Data = FWH_READ_ARRAY_COMMAND; FvbMemWrite8 (LbaAddress, Data); } else { EfiMemRead (EfiCpuIoWidthUint8, (LbaAddress - 0x400000 + 2), 0x1, &Data); // // bugbug: lock down is block based, not FV based. Here we assume that // the FV is locked if one of its block is locked // if ((Data & FWH_WRITE_LOCK) && (Data & FWH_LOCK_DOWN)) { // // the flash is locked and locked down // WriteLocked = TRUE; } else { Data &= ~(FWH_WRITE_LOCK | FWH_READ_LOCK | FWH_LOCK_DOWN); // // Save boot script for S3 resume // SCRIPT_MEM_WRITE ( EFI_ACPI_S3_RESUME_SCRIPT_TABLE, EfiBootScriptWidthUint8, (UINT64) (LbaAddress - 0x400000 + 2), 1, &Data ); FvbMemWrite8 ((LbaAddress - 0x400000 + 2), Data); } } } LbaAddress += PtrBlockMapEntry->BlockLength; } // // Get the maximum size of a block. The size will be used to allocate // buffer for Scratch space, the intermediate buffer for FVB extension // protocol // if (MaxLbaSize < PtrBlockMapEntry->BlockLength) { MaxLbaSize = PtrBlockMapEntry->BlockLength; } NumOfBlocks = NumOfBlocks + PtrBlockMapEntry->NumBlocks; } // // Write back a healthy FV header // if (WriteBack && (!WriteLocked)) { Status = FlashFdErase ( (UINTN) FwhInstance->FvWriteBase[0], (UINTN) BaseAddress, FwVolHeader->FvBlockMap->BlockLength ); HeaderLength = (UINTN) FwVolHeader->HeaderLength; Status = FlashFdWrite ( (UINTN) FwhInstance->FvWriteBase[0], (UINTN) BaseAddress, (UINTN *) &HeaderLength, (UINT8 *) FwVolHeader, FwVolHeader->FvBlockMap->BlockLength ); FwVolHeader->HeaderLength = (UINT16) HeaderLength; DEBUG ((EFI_D_ERROR, "Fvb: FV header invalid, write back - %r\n", Status)); } } // // The total number of blocks in the FV. // FwhInstance->NumOfBlocks = NumOfBlocks; // // If the FV is write locked, set the appropriate attributes // if (WriteLocked) { // // write disabled // FwhInstance->VolumeHeader.Attributes &= ~EFI_FVB_WRITE_STATUS; // // lock enabled // FwhInstance->VolumeHeader.Attributes |= EFI_FVB_LOCK_STATUS; } // // Add a FVB Protocol Instance // Status = gBS->AllocatePool ( EfiRuntimeServicesData, sizeof (EFI_FW_VOL_BLOCK_DEVICE), &FvbDevice ); ASSERT_EFI_ERROR (Status); EfiCopyMem (FvbDevice, &mFvbDeviceTemplate, sizeof (EFI_FW_VOL_BLOCK_DEVICE)); FvbDevice->Instance = mFvbModuleGlobal->NumFv; mFvbModuleGlobal->NumFv++; // // Set up the devicepath // FvbDevice->DevicePath.MemMapDevPath.StartingAddress = BaseAddress; FvbDevice->DevicePath.MemMapDevPath.EndingAddress = BaseAddress + (FwVolHeader->FvLength - 1); // // Find a handle with a matching device path that has supports FW Block protocol // TempFwbDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &TempFvbDevicePathData; EfiCopyMem (TempFwbDevicePath, &FvbDevice->DevicePath, sizeof (FV_DEVICE_PATH)); Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &TempFwbDevicePath, &FwbHandle); if (EFI_ERROR (Status)) { // // LocateDevicePath fails so install a new interface and device path // FwbHandle = NULL; Status = gBS->InstallMultipleProtocolInterfaces ( &FwbHandle, &gEfiFirmwareVolumeBlockProtocolGuid, &FvbDevice->FwVolBlockInstance, &gEfiDevicePathProtocolGuid, &FvbDevice->DevicePath, NULL ); ASSERT_EFI_ERROR (Status); } else if (EfiIsDevicePathEnd (TempFwbDevicePath)) { // // Device allready exists, so reinstall the FVB protocol // Status = gBS->HandleProtocol ( FwbHandle, &gEfiFirmwareVolumeBlockProtocolGuid, &OldFwbInterface ); ASSERT_EFI_ERROR (Status); Status = gBS->ReinstallProtocolInterface ( FwbHandle, &gEfiFirmwareVolumeBlockProtocolGuid, OldFwbInterface, &FvbDevice->FwVolBlockInstance ); ASSERT_EFI_ERROR (Status); } else { // // There was a FVB protocol on an End Device Path node // ASSERT (FALSE); } // // Install FVB Extension Protocol on the same handle // Status = gBS->InstallMultipleProtocolInterfaces ( &FwbHandle, &gEfiFvbExtensionProtocolGuid, &FvbDevice->FvbExtension, &gEfiAlternateFvBlockGuid, NULL, NULL ); ASSERT_EFI_ERROR (Status); FwhInstance = (EFI_FW_VOL_INSTANCE *) ( (UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength + (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) ); } while (TRUE); // // Allocate for scratch space, an intermediate buffer for FVB extention // Status = gBS->AllocatePool ( EfiRuntimeServicesData, MaxLbaSize, &mFvbModuleGlobal->FvbScratchSpace[FVB_PHYSICAL] ); ASSERT_EFI_ERROR (Status); mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL] = mFvbModuleGlobal->FvbScratchSpace[FVB_PHYSICAL]; FvbSpecificInitialize (mFvbModuleGlobal); return EnableFvbWrites (FALSE); }
29.409887
117
0.600361
033811c9c9d0d16bb80e5a047e27594fbd4573ab
12,869
h
C
bse-interface/bseEmp/emptrack/cppinterface.h
michelamapelli/PeTar
395942c5a35f462075fe69027d95d78aeeef0180
[ "MIT" ]
19
2020-05-26T11:22:11.000Z
2022-03-11T01:10:19.000Z
bse-interface/bseEmp/emptrack/cppinterface.h
michelamapelli/PeTar
395942c5a35f462075fe69027d95d78aeeef0180
[ "MIT" ]
14
2020-11-26T12:09:55.000Z
2022-03-18T18:29:35.000Z
bse-interface/bseEmp/emptrack/cppinterface.h
michelamapelli/PeTar
395942c5a35f462075fe69027d95d78aeeef0180
[ "MIT" ]
10
2020-05-26T11:23:01.000Z
2022-03-30T14:26:22.000Z
interface subroutine setMetallicity(zeta) bind(c, name='setMetallicity') import implicit none real(c_double) zeta end subroutine function askInUseOrNot() bind(c, name='askInUseOrNot') import implicit none logical(c_bool) askInUseOrNot end function function askInScopeOfApplication(mass) & bind(c, name='askInScopeOfApplication') import implicit none real(c_double) mass logical(c_bool) askInScopeOfApplication end function subroutine setLowerLimitOfMass(mass) & bind(c, name='setLowerLimitOfMass') import implicit none real(c_double) mass end subroutine function getLowerLimitOfMass() & bind(c, name='getLowerLimitOfMass') import implicit none real(c_double) getLowerLimitOfMass end function function getUpperLimitOfMass() & bind(c, name='getUpperLimitOfMass') import implicit none real(c_double) getUpperLimitOfMass end function function getMetallicity() bind(c, name='getMetallicity') import implicit none real(c_double) getMetallicity end function function getWindMetallicity() bind(c, name='getWindMetallicity') import implicit none real(c_double) getWindMetallicity end function function askAllBlueOrNot(mt) bind(c, name='askAllBlueOrNot') import implicit none real(c_double) mt logical(c_bool) askAllBlueOrNot end function function askBlueOrRed(aj,mass) bind(c, name='askBlueOrRed') import implicit none real(c_double) aj real(c_double) mass logical(c_bool) askBlueOrRed end function function askBlueOrRed2(lumpersun,radpersun) & bind(c, name='askBlueOrRed2') import implicit none real(c_double) lumpersun real(c_double) radpersun logical(c_bool) askBlueOrRed2 end function function askRadiativeOrNot(kw,aj,mass) & bind(c, name='askRadiativeOrNot') import implicit none integer(c_int) kw real(c_double) aj real(c_double) mass logical(c_bool) askRadiativeOrNot end function function askRadiativeOrNot2(kw,lumpersun,radpersun) & bind(c, name='askRadiativeOrNot2') import implicit none integer(c_int) kw real(c_double) lumpersun real(c_double) radpersun logical(c_bool) askRadiativeOrNot2 end function function getCriticalMassRatio(kw,aj,mass,massc) & bind(c, name='getCriticalMassRatio') import implicit none integer(c_int) kw real(c_double) aj real(c_double) mass real(c_double) massc real(c_double) getCriticalMassRatio end function function getCriticalMassRatio2(kw,lumpersun,radpersun,mass,massc) & bind(c, name='getCriticalMassRatio2') import implicit none integer(c_int) kw real(c_double) lumpersun real(c_double) radpersun real(c_double) mass real(c_double) massc real(c_double) getCriticalMassRatio2 end function function askCommonEnvelopeOrNot(kw,aj,mass,q,qc,radx,radc) & bind(c, name='askCommonEnvelopeOrNot') import implicit none integer(c_int) kw real(c_double) aj real(c_double) mass real(c_double) q real(c_double) qc real(c_double) radx real(c_double) radc logical(c_bool) askCommonEnvelopeOrNot end function function askCommonEnvelopeOrNot2(kw,lumpersun,radpersun, & mass,q,qc,radx,radc) & bind(c, name='askCommonEnvelopeOrNot2') import implicit none integer(c_int) kw real(c_double) lumpersun real(c_double) radpersun real(c_double) mass real(c_double) q real(c_double) qc real(c_double) radx real(c_double) radc logical(c_bool) askCommonEnvelopeOrNot2 end function function getRatioOfTMSTimeToHeITime(mass) & bind(c, name='getRatioOfTMSTimeToHeITime') import implicit none real(c_double) mass real(c_double) getRatioOfTMSTimeToHeITime end function function getHeITime(mass) bind(c, name='getHeITime') import implicit none real(c_double) mass real(c_double) getHeITime end function function getTimeIntervalOfCHeBPhase(mass) & bind(c, name='getTimeIntervalOfCHeBPhase') import implicit none real(c_double) mass real(c_double) getTimeIntervalOfCHeBPhase end function function getEndTimeOfBluePhase(mass) & bind(c, name='getEndTimeOfBluePhase') import implicit none real(c_double) mass real(c_double) getEndTimeOfBluePhase end function function getEndTime(mass) & bind(c, name='getEndTime') import implicit none real(c_double) mass real(c_double) getEndTime end function function getLuminosityZAMSTime(mass) & bind(c, name='getLuminosityZAMSTime') import implicit none real(c_double) mass real(c_double) getLuminosityZAMSTime end function function getLuminosityTMSTime(mass) & bind(c, name='getLuminosityTMSTime') import implicit none real(c_double) mass real(c_double) getLuminosityTMSTime end function function getDifferentialLuminosityOfHook(mass) & bind(c, name='getDifferentialLuminosityOfHook') import implicit none real(c_double) mass real(c_double) getDifferentialLuminosityOfHook end function function getAlphaOfLuminosityMSPhase(mass) & bind(c, name='getAlphaOfLuminosityMSPhase') import implicit none real(c_double) mass real(c_double) getAlphaOfLuminosityMSPhase end function function getBetaOfLuminosityMSPhase(mass) & bind(c, name='getBetaOfLuminosityMSPhase') import implicit none real(c_double) mass real(c_double) getBetaOfLuminosityMSPhase end function function getLuminosityHeITime(mass) & bind(c, name='getLuminosityHeITime') import implicit none real(c_double) mass real(c_double) getLuminosityHeITime end function function getLuminosityBAGBTime(mass) & bind(c, name='getLuminosityBAGBTime') import implicit none real(c_double) mass real(c_double) getLuminosityBAGBTime end function function getRadiusZAMSTime(mass) bind(c, name='getRadiusZAMSTime') import implicit none real(c_double) mass real(c_double) getRadiusZAMSTime end function function getRadiusTMSTime(mass) bind(c, name='getRadiusTMSTime') import implicit none real(c_double) mass real(c_double) getRadiusTMSTime end function function getDifferentialRadiusOfHook(mass) & bind(c, name='getDifferentialRadiusOfHook') import implicit none real(c_double) mass real(c_double) getDifferentialRadiusOfHook end function function getAlphaOfRadiusMSPhase(mass) & bind(c, name='getAlphaOfRadiusMSPhase') import implicit none real(c_double) mass real(c_double) getAlphaOfRadiusMSPhase end function function getBetaOfRadiusMSPhase(mass) & bind(c, name='getBetaOfRadiusMSPhase') import implicit none real(c_double) mass real(c_double) getBetaOfRadiusMSPhase end function function getGammaOfRadiusMSPhase(mass) & bind(c, name='getGammaOfRadiusMSPhase') import implicit none real(c_double) mass real(c_double) getGammaOfRadiusMSPhase end function function getRadiusHeITime(mass) & bind(c, name='getRadiusHeITime') import implicit none real(c_double) mass real(c_double) getRadiusHeITime end function function getMinimumRadiusCHeBPhase(mass) & bind(c, name='getMinimumRadiusCHeBPhase') import implicit none real(c_double) mass real(c_double) getMinimumRadiusCHeBPhase end function function getRadiusRedPhase(mass, lum) & bind(c, name='getRadiusRedPhase') import implicit none real(c_double) mass real(c_double) lum real(c_double) getRadiusRedPhase end function function getRadiusEndTimeOfBlueCHeBPhase(mass, mt, lum) & bind(c, name='getRadiusEndTimeOfBlueCHeBPhase') import implicit none real(c_double) mass real(c_double) mt real(c_double) lum real(c_double) getRadiusEndTimeOfBlueCHeBPhase end function function getHeCoreMassHeITime(mass) & bind(c, name='getHeCoreMassHeITime') import implicit none real(c_double) mass real(c_double) getHeCoreMassHeITime end function function getHeCoreMassBAGBTime(mass) & bind(c, name='getHeCoreMassBAGBTime') import implicit none real(c_double) mass real(c_double) getHeCoreMassBAGBTime end function function getCOCoreMassEndTime(mass) & bind(c, name='getCOCoreMassEndTime') import implicit none real(c_double) mass real(c_double) getCOCoreMassEndTime end function subroutine followAGBPhase(aj, mass, mt, lum, & r, rg, mcbagb, mc, mcx, mcmax) & bind(c, name='followAGBPhase') import implicit none real(c_double) aj real(c_double) mass real(c_double) mt real(c_double) lum real(c_double) r real(c_double) rg real(c_double) mcbagb real(c_double) mc real(c_double) mcx real(c_double) mcmax end subroutine subroutine calcTimestepAGBPhase(kw, aj, mass, tn, pts3, & dtm, dtr) & bind(c, name='calcTimestepAGBPhase') import implicit none integer(c_int) kw real(c_double) aj real(c_double) mass real(c_double) tn real(c_double) pts3 real(c_double) dtm real(c_double) dtr end subroutine function askInUseOfConvectiveCore() & bind(c, name='askInUseOfConvectiveCore') import implicit none logical(c_bool) askInUseOfConvectiveCore end function subroutine initializeConvectiveCore(zeta) & bind(c, name='initializeConvectiveCore') import implicit none real(c_double) zeta end subroutine function getRadiusOfConvectiveCore(kw,aj,mass) & bind(c, name='getRadiusOfConvectiveCore') import implicit none integer(c_int) kw real(c_double) aj real(c_double) mass real(c_double) getRadiusOfConvectiveCore end function function getLuminosityMSPhaseMassive(mass,tau) & bind(c, name='getLuminosityMSPhaseMassive') import implicit none real(c_double) mass real(c_double) tau real(c_double) getLuminosityMSPhaseMassive end function function getLuminosityMSPhaseIntermediate(mass,tau, & tau1,tau2,taumin,eta) & bind(c, name='getLuminosityMSPhaseIntermediate') import implicit none real(c_double) mass real(c_double) tau real(c_double) tau1 real(c_double) tau2 real(c_double) taumin real(c_double) eta real(c_double) getLuminosityMSPhaseIntermediate end function function getRadiusMSPhaseMassive(mass,tau) & bind(c, name='getRadiusMSPhaseMassive') import implicit none real(c_double) mass real(c_double) tau real(c_double) getRadiusMSPhaseMassive end function function getRadiusMSPhaseIntermediate(mass,tau, & tau1,tau2,taumin) & bind(c, name='getRadiusMSPhaseIntermediate') import implicit none real(c_double) mass real(c_double) tau real(c_double) tau1 real(c_double) tau2 real(c_double) taumin real(c_double) getRadiusMSPhaseIntermediate end function function getK2strOfBluePhase(mt,mc,rzams,rtms,rad,k2e) & bind(c, name='getK2strOfBluePhase') import implicit none real(c_double) mt real(c_double) mc real(c_double) rzams real(c_double) rtms real(c_double) rad real(c_double) k2e real(c_double) getK2strOfBluePhase end function function getConvectiveCoreRadiusOfBluePhase(mt) & bind(c, name='getConvectiveCoreRadiusOfBluePhase') import implicit none real(c_double) mt real(c_double) getConvectiveCoreRadiusOfBluePhase end function end interface
27.092632
72
0.654829
033829428dd4a8f0017e6a2b9ffb1f0afdfeebb1
2,990
c
C
mllib/ne/mutations.c
Coestaris/Zomboid3D
2ce069eda4532ff4e9a1addd00167f92e5ec60dd
[ "MIT" ]
16
2020-02-24T20:46:53.000Z
2022-01-21T01:51:06.000Z
mllib/ne/mutations.c
Coestaris/Zomboid3D
2ce069eda4532ff4e9a1addd00167f92e5ec60dd
[ "MIT" ]
2
2020-01-18T19:33:58.000Z
2020-03-19T22:58:55.000Z
mllib/ne/mutations.c
Coestaris/Zomboid3D
2ce069eda4532ff4e9a1addd00167f92e5ec60dd
[ "MIT" ]
1
2020-01-18T19:26:17.000Z
2020-01-18T19:26:17.000Z
/* // // Created by maxim on 2/4/20. // #include <assert.h> #include "genome.h" #include "connection_genome.h" #include "rand_helpers.h" void gn_mutate_node(genome_t* genome) { connection_genome_t* connection; size_t tries = 0; while((connection = gn_rand_connection(genome))->disabled) if(tries++ > GN_MUTATE_NODE_MAX_TRIES) { puts("tries++ < GN_MUTATE_NODE_MAX_TRIES"); return; } size_t id = genome->nodes_count; cg_disable(connection); gn_push_connection( genome, cg_create(connection->in_node, id, 1, i_get(), false)); gn_push_connection( genome, cg_create(id, connection->out_node, connection->weight, i_get(), false)); genome->nodes_count++; } void gn_mutate_switch(genome_t* genome, float chance) { for(size_t i = 0; i < genome->connections_count; i++) { connection_genome_t* connection = &genome->connections[i]; if(gn_rand_float() < chance) connection->disabled = !connection->disabled; } } void gn_mutate_weight_nudge(genome_t* genome, float chance, float rate) { for(size_t i = 0; i < genome->connections_count; i++) { connection_genome_t* connection = &genome->connections[i]; if(gn_rand_float() < chance) { connection->weight += gn_rand_float() * (connection->weight * rate) * (rand() % 2 ? 1.0f : -1.0f); } } } void gn_mutate_weight_random(genome_t* genome, float chance, float min, float max) { for(size_t i = 0; i < genome->connections_count; i++) { connection_genome_t* connection = &genome->connections[i]; if(gn_rand_float() < chance) { connection->weight = gn_rand_float() * (max - min) + min; } } } void gn_mutate_link(genome_t* genome) { size_t tries = 0; while(true) { bool possible = false; bool exists = false; if(tries++ > GN_MUTATE_LINK_MAX_TRIES) { //puts("tries++ > GN_MUTATE_LINK_MAX_TRIES"); return; } size_t i1 = rand() % genome->nodes_count; size_t i2 = rand() % genome->nodes_count; if (i1 != i2) { if (i1 < genome->input_count && i2 > genome->input_count + genome->output_count) // i1 - input, i2 - hidden possible = true; else if (i1 > genome->input_count + genome->output_count && i2 > genome->input_count && i2 < genome->input_count + genome->output_count) //i1 - hidden, i2 - output possible = true; } if (!possible) continue; for(size_t i = 0; i < genome->connections_count; i++) { connection_genome_t* connection = &genome->connections[i]; if(connection->in_node == i1 && connection->out_node == i2) { exists = true; break; } } if(exists) continue; gn_push_connection( genome, cg_create(i1, i2, 1, i_get(), false)); break; } }*/
24.916667
121
0.589632
033873705e2d74cf9d658a1ee08b02ddcfd3c2b2
1,469
c
C
c/Ternary/main.c
nkysg/Asenal
12444c7e50fae2be82d3c4737715a52e3693a3cd
[ "Apache-2.0" ]
5
2017-04-10T03:35:40.000Z
2020-11-26T10:00:57.000Z
c/Ternary/main.c
nkysg/Asenal
12444c7e50fae2be82d3c4737715a52e3693a3cd
[ "Apache-2.0" ]
1
2015-04-09T13:45:25.000Z
2015-04-09T13:45:25.000Z
c/Ternary/main.c
baotiao/Asenal
102170aa92ae72b1d589dd74e8bbbc9ae27a8d97
[ "Apache-2.0" ]
15
2015-03-10T04:15:10.000Z
2021-03-19T13:00:48.000Z
#include <stdio.h> #include <stdlib.h> #define clr(NAME,VALUE) memset(NAME,VALUE,sizeof(NAME)) #define MAX 0x7f7f7f7f typedef struct tnode *Tptr; typedef struct tnode { char s; Tptr lokid, eqkid, hikid; } Tnode; Tptr t; Tptr insert(Tptr p, char *s) { if (p == NULL) { p = (Tptr)malloc(sizeof(Tnode)); p->s = *s; printf("%c\n", p->s); p->lokid = p->eqkid = p->hikid = NULL; } if (*s < p->s) { p->lokid = insert(p->lokid, s); } else if (*s > p->s) { p->hikid = insert(p->hikid, s); } else { if (*s != '\0') { p->eqkid = insert(p->eqkid, ++s); } } return p; } int search(char *s) { Tptr p; p = t; if (p->lokid == NULL) { printf("True\n"); } while (p) { if (*s < p->s) { p = p->lokid; } else if (*s > p->s) { p = p->hikid; } else { if (*s == '\0') { return 1; } s++; p = p->eqkid; } } return 0; } int main() { char *s[10] = {"chenzongzhi", "xuyangyang", "guanhongyu", "zhaoanan", "lichangshu", "menglingyang", "xujianguo", "qizhebing", "xiaobaisha", "xiedeng"}; int i; t = NULL; char c; for (i = 0; i < 10; i++) { insert(t, s[i]); } Tptr p = t; printf("%d\n", p); printf("%c\n", t->s); //printf("%d\n", search("chenzongzhi")); return 0; }
19.586667
155
0.435671
0338dc6a7b95838f1c1248d01b38d2b20be107f4
640
h
C
src/vm/config.h
ArgonLang/Argon
462d3d8721acd5131894bcbfa0214b0cbcffdf66
[ "Apache-2.0" ]
13
2021-06-24T17:50:20.000Z
2022-03-13T23:00:16.000Z
src/vm/config.h
ArgonLang/Argon
462d3d8721acd5131894bcbfa0214b0cbcffdf66
[ "Apache-2.0" ]
null
null
null
src/vm/config.h
ArgonLang/Argon
462d3d8721acd5131894bcbfa0214b0cbcffdf66
[ "Apache-2.0" ]
1
2022-03-31T22:58:42.000Z
2022-03-31T22:58:42.000Z
// This source file is part of the Argon project. // // Licensed under the Apache License v2.0 #ifndef ARGON_VM_CONFIG_H_ #define ARGON_VM_CONFIG_H_ #include <utils/macros.h> #define ARGON_ENVVAR_PATH "ARGONPATH" #define ARGON_ENVVAR_UNBUFFERED "ARGONUNBUFFERED" #define ARGON_ENVVAR_STARTUP "ARGONSTARTUP" namespace argon::vm { struct Config { char **argv; int argc; bool interactive; bool quiet; bool unbuffered; int cmd; int file; }; extern const _ARGONAPI Config *global_cfg; int ConfigInit(int argc, char **argv); } #endif // !ARGON_VM_CONFIG_H_
20
49
0.673438
0339c7ef1c666eab7401dfe54428e85e99ebeafb
1,145
c
C
Estruturas/Red-black Tree/main.c
Daviqalb07/Estruturas-de-Dados
485b447402eef347d95087a1acee9a772a14043a
[ "MIT" ]
null
null
null
Estruturas/Red-black Tree/main.c
Daviqalb07/Estruturas-de-Dados
485b447402eef347d95087a1acee9a772a14043a
[ "MIT" ]
null
null
null
Estruturas/Red-black Tree/main.c
Daviqalb07/Estruturas-de-Dados
485b447402eef347d95087a1acee9a772a14043a
[ "MIT" ]
null
null
null
#include <stdio.h> #include "rbt.h" int main(void){ Tree *RBT = constructRedBlackTree(); int v[] = {20, 9, 3, 42, 4, 36, 30, 6}; for(int i = 0 ; i < 8 ; i++){ insertRBT(RBT, v[i]); } Node *root = rootRBT(RBT); // Consultando a raiz. printf("Chave do no raiz: %d\n", getKey(root)); printf("Cor do no raiz: "); // Confirmando que a raiz é BLACK. if(getColor(root) == RED) printf("Red\n"); else printf("Black\n"); printf("\n"); // Operações de busca buscaRBT(RBT, root, 30); buscaRBT(RBT, root, 15); printf("\n"); // Máximos e mínimos. Node *max = maximoRBT(RBT, root); int colorMax = getColor(max); printf("Cor do no de chave maxima: "); if(colorMax == RED) printf("Red\n"); else printf("Black\n"); Node *min = minimoRBT(RBT, root); int colorMin = getColor(min); printf("Cor do no de chave minima: "); if(colorMin == RED) printf("Red\n"); else printf("Black\n"); printf("\n"); // Imprimindo a árvore completa. printRBT(RBT, root, 0); return 0; }
22.45098
66
0.531004
0339d8bae6e241a2aae9cf78b3bad15e1bfc1db0
852
h
C
SuperVimontBros/src/Entity/Bonus/Bonus.h
vimontgames/supervimontbros
d589e42628e549273878d3db1298dd8c7525036a
[ "MIT" ]
1
2021-01-21T19:37:57.000Z
2021-01-21T19:37:57.000Z
SuperVimontBros/src/Entity/Bonus/Bonus.h
vimontgames/supervimontbros
d589e42628e549273878d3db1298dd8c7525036a
[ "MIT" ]
null
null
null
SuperVimontBros/src/Entity/Bonus/Bonus.h
vimontgames/supervimontbros
d589e42628e549273878d3db1298dd8c7525036a
[ "MIT" ]
null
null
null
#pragma once #include "Entity/Entity.h" enum class BonusType : u8 { Coca = 0, Water, Hotdog, Pizza, ChocolateEclair, Crunch, IceCream, Wine, BluePill, RedPill, GreenPill, Bone, Chicken, ChickenBone, PureeSausage, Apple, Count }; enum class PlayerType : u8; class Bonus : public Entity { public: Bonus(const sf::String & _name, BonusType _bonusType); ~Bonus(); void init() override; void respawn() override; void update(const float _dt) override; void fadeOutAndKill(uint _ms); void setRotten(bool _rotten); bool isRotten() const; bool isRottenForPlayer(PlayerType _playerType) const; bool isWine() const; bool isChocolate() const; BonusType m_bonusType; bool m_isRotten = false; bool m_forAdultsOnly = false; bool m_isForDogsOnly = false; bool m_isSpawningOtherBonus = false; using Super = Entity; };
14.689655
55
0.723005
033aa4d095a4e8179f91311a3331b5f0fda59511
1,065
h
C
Include/ARBCommon/ARBMisc.h
dconnet/AgilityBookLibs
253ff3c528a93f5236e1124ac17fea082a0140a6
[ "MIT" ]
1
2020-11-23T20:33:41.000Z
2020-11-23T20:33:41.000Z
Include/ARBCommon/ARBMisc.h
dconnet/AgilityBookLibs
253ff3c528a93f5236e1124ac17fea082a0140a6
[ "MIT" ]
null
null
null
Include/ARBCommon/ARBMisc.h
dconnet/AgilityBookLibs
253ff3c528a93f5236e1124ac17fea082a0140a6
[ "MIT" ]
3
2020-05-04T19:42:26.000Z
2022-03-08T09:36:54.000Z
#pragma once /* * Copyright (c) David Connet. All Rights Reserved. * * License: See License.txt */ /** * @file * @brief Type definitions. * @author David Connet * * Revision History * 2019-01-31 Moved GetOSInfo to LibARBWin/ARBDebug. * 2014-06-19 Added IsWin7OrBetter. * 2013-07-17 Created */ #include "LibwxARBCommon.h" #include <string> /** * Make a string safe for HTML viewing. * @param inRawData String to sanitize * @param bConvertCR Convert \n to html-breaks. */ ARBCOMMON_API std::wstring SanitizeStringForHTML(std::wstring const& inRawData, bool bConvertCR = true); /** * These are the strings we recognize as platforms. */ ARBCOMMON_API std::wstring GetARBArch(); /** * Get OS version. * @param verMajor OS major version number. * @param verMinor OS minor version number. */ ARBCOMMON_API bool GetOSInfo(int& verMajor, int& verMinor); /** * Are we running on Win7 or better? */ ARBCOMMON_API bool IsWin7OrBetter(); /** * Translate a short to a Roman numeral */ ARBCOMMON_API std::wstring ShortToRoman(short value);
19.017857
104
0.707042
033ac2ea8b56f1f72ae05781c78bb25576ed56d2
3,214
h
C
src/ui/Windows/WZSelectDB.h
raydouglass/pwsafe
16de7648ad7a5c754659a31429f8de3b638e62cc
[ "Artistic-2.0" ]
null
null
null
src/ui/Windows/WZSelectDB.h
raydouglass/pwsafe
16de7648ad7a5c754659a31429f8de3b638e62cc
[ "Artistic-2.0" ]
null
null
null
src/ui/Windows/WZSelectDB.h
raydouglass/pwsafe
16de7648ad7a5c754659a31429f8de3b638e62cc
[ "Artistic-2.0" ]
1
2020-02-15T15:03:03.000Z
2020-02-15T15:03:03.000Z
/* * Copyright (c) 2003-2016 Rony Shapiro <ronys@pwsafe.org>. * All rights reserved. Use of the code is allowed under the * Artistic License 2.0 terms, as specified in the LICENSE file * distributed with this code, or available from * http://www.opensource.org/licenses/artistic-license-2.0.php */ #pragma once #include "WZPropertyPage.h" #include "ControlExtns.h" #include "YubiMixin.h" #include "resource.h" class CVKeyBoardDlg; class CWZSelectDB : public CWZPropertyPage, public CYubiMixin { public: DECLARE_DYNAMIC(CWZSelectDB) CWZSelectDB(CWnd *pParent, int idd, UINT nIDCaption, const int nType); ~CWZSelectDB(); CString m_defexpdelim; protected: CSecEditExtn *m_pctlPasskey, *m_pctlPasskey2, *m_pctlVerify2; CEditExtn *m_pctlDB; CSecString m_passkey, m_passkey2, m_verify2; CStaticExtn m_stc_warning; CString m_filespec; int m_tries, m_state; int m_bAdvanced; CButtonBitmapExtn m_ctlSDToggle; BOOL OnInitDialog(); void DoDataExchange(CDataExchange* pDX); LRESULT OnWizardNext(); // Generated message map functions //{{AFX_MSG(CWZSelectDB) afx_msg HBRUSH OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor); virtual BOOL OnSetActive(); afx_msg void OnHelp(); afx_msg void OnPassKeyChange(); afx_msg void OnPassKey2Change(); afx_msg void OnVerify2Change(); afx_msg void OnDatabaseChange(); afx_msg void OnOpenFileBrowser(); afx_msg void OnVirtualKeyboard(); afx_msg void OnAdvanced(); afx_msg void OnPasskeySetfocus(); afx_msg void OnPasskey2Setfocus(); afx_msg void OnVerify2keySetfocus(); afx_msg void OnYubikeyBtn(); afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg LRESULT OnInsertBuffer(WPARAM, LPARAM); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: void AFXAPI DDV_CheckExpDelimiter(CDataExchange* pDX, const CString &delimiter); enum {KEYPRESENT = 1, DBPRESENT = 2, BOTHPRESENT = 3, KEY2PRESENT = 4, VERIFY2PRESENT = 8, KEY2_EQ_VERIFY2 = 16, ALLPRESENT = 31}; COLORREF m_syncwarning_cfOldColour; bool ProcessPhrase(const StringX &filename, const StringX &passkey); bool m_bFileExistsUserAsked; CVKeyBoardDlg *m_pVKeyBoardDlg; bool m_bVKAvailable; HWND m_hwndVKeyBoard; st_SaveAdvValues *m_pst_SADV; CFont m_WarningFont; // Following should be private inheritance of CPKBaseDlg, // but MFC doesn't allow us to do this. So much for OOD. static const wchar_t PSSWDCHAR; UINT m_CtrlID; UINT m_LastFocus; // Yubico-related: // Callbacks: virtual void yubiShowChallengeSent(); // request's in the air, setup GUI to wait for reply virtual void yubiProcessCompleted(YKLIB_RC yrc, unsigned short ts, const BYTE *respBuf); // called by yubiCheckCompleted() virtual void yubiInserted(void); // called when Yubikey's inserted virtual void yubiRemoved(void); // called when Yubikey's removed // Indicate that we're waiting for user to activate YubiKey: CProgressCtrl m_yubi_timeout; // Show user what's going on / what we're waiting for: CEdit m_yubi_status; CBitmap m_yubiLogo; CBitmap m_yubiLogoDisabled; }; //----------------------------------------------------------------------------- // Local variables: // mode: c++ // End:
29.486239
124
0.726509
033b4bede645c30f37c8f1e941eb79dd3c00c8b7
4,530
h
C
libraries/model-networking/src/model-networking/TextureCache.h
sodaglue/hifi
725f9e29a3d8833c6051c1562ec4831e7b72370c
[ "Apache-2.0" ]
null
null
null
libraries/model-networking/src/model-networking/TextureCache.h
sodaglue/hifi
725f9e29a3d8833c6051c1562ec4831e7b72370c
[ "Apache-2.0" ]
null
null
null
libraries/model-networking/src/model-networking/TextureCache.h
sodaglue/hifi
725f9e29a3d8833c6051c1562ec4831e7b72370c
[ "Apache-2.0" ]
null
null
null
// // TextureCache.h // libraries/model-networking/src // // Created by Andrzej Kapolka on 8/6/13. // Copyright 2013 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_TextureCache_h #define hifi_TextureCache_h #include <gpu/Texture.h> #include <QImage> #include <QMap> #include <QColor> #include <DependencyManager.h> #include <ResourceCache.h> #include <model/TextureMap.h> namespace gpu { class Batch; } class NetworkTexture; typedef QSharedPointer<NetworkTexture> NetworkTexturePointer; enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, BUMP_TEXTURE, SPECULAR_TEXTURE, EMISSIVE_TEXTURE, CUBE_TEXTURE, LIGHTMAP_TEXTURE, CUSTOM_TEXTURE }; /// Stores cached textures, including render-to-texture targets. class TextureCache : public ResourceCache, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY public: /// Returns the ID of the permutation/normal texture used for Perlin noise shader programs. This texture /// has two lines: the first, a set of random numbers in [0, 255] to be used as permutation offsets, and /// the second, a set of random unit vectors to be used as noise gradients. const gpu::TexturePointer& getPermutationNormalTexture(); /// Returns an opaque white texture (useful for a default). const gpu::TexturePointer& getWhiteTexture(); /// Returns an opaque gray texture (useful for a default). const gpu::TexturePointer& getGrayTexture(); /// Returns the a pale blue texture (useful for a normal map). const gpu::TexturePointer& getBlueTexture(); /// Returns the a black texture (useful for a default). const gpu::TexturePointer& getBlackTexture(); // Returns a map used to compress the normals through a fitting scale algorithm const gpu::TexturePointer& getNormalFittingTexture(); /// Returns a texture version of an image file static gpu::TexturePointer getImageTexture(const QString& path); /// Loads a texture from the specified URL. NetworkTexturePointer getTexture(const QUrl& url, TextureType type = DEFAULT_TEXTURE, const QByteArray& content = QByteArray()); typedef gpu::Texture* TextureLoader(const QImage& image, const std::string& srcImageName); typedef std::function<TextureLoader> TextureLoaderFunc; protected: virtual QSharedPointer<Resource> createResource(const QUrl& url, const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra); private: TextureCache(); virtual ~TextureCache(); friend class DilatableNetworkTexture; gpu::TexturePointer _permutationNormalTexture; gpu::TexturePointer _whiteTexture; gpu::TexturePointer _grayTexture; gpu::TexturePointer _blueTexture; gpu::TexturePointer _blackTexture; gpu::TexturePointer _normalFittingTexture; QHash<QUrl, QWeakPointer<NetworkTexture> > _dilatableNetworkTextures; }; /// A simple object wrapper for an OpenGL texture. class Texture { public: friend class TextureCache; gpu::TexturePointer getGPUTexture() const { return _textureSource->getGPUTexture(); } gpu::TextureSourcePointer _textureSource; }; /// A texture loaded from the network. class NetworkTexture : public Resource, public Texture { Q_OBJECT public: typedef TextureCache::TextureLoaderFunc TextureLoaderFunc; NetworkTexture(const QUrl& url, TextureType type, const QByteArray& content); NetworkTexture(const QUrl& url, const TextureLoaderFunc& textureLoader, const QByteArray& content); int getOriginalWidth() const { return _originalWidth; } int getOriginalHeight() const { return _originalHeight; } int getWidth() const { return _width; } int getHeight() const { return _height; } TextureLoaderFunc getTextureLoader() const; protected: virtual void downloadFinished(const QByteArray& data) override; Q_INVOKABLE void loadContent(const QByteArray& content); // FIXME: This void* should be a gpu::Texture* but i cannot get it to work for now, moving on... Q_INVOKABLE void setImage(const QImage& image, void* texture, int originalWidth, int originalHeight); virtual void imageLoaded(const QImage& image); private: TextureType _type; TextureLoaderFunc _textureLoader; int _originalWidth { 0 }; int _originalHeight { 0 }; int _width { 0 }; int _height { 0 }; }; #endif // hifi_TextureCache_h
32.589928
151
0.734879
033c67185d50b89443b4bdbdffbc30f3efda9761
2,055
h
C
Effects/Effect_Transform.h
ahwayakchih/Medo
acc34c189676544c092fbc6800c27a25d05de6dd
[ "MIT" ]
95
2020-12-23T02:35:35.000Z
2022-02-20T19:30:13.000Z
Effects/Effect_Transform.h
ahwayakchih/Medo
acc34c189676544c092fbc6800c27a25d05de6dd
[ "MIT" ]
21
2020-12-23T05:01:36.000Z
2022-01-11T08:38:26.000Z
Effects/Effect_Transform.h
ahwayakchih/Medo
acc34c189676544c092fbc6800c27a25d05de6dd
[ "MIT" ]
8
2020-12-23T04:47:34.000Z
2021-08-29T17:18:56.000Z
/* PROJECT: Medo * AUTHORS: Zenja Solaja, Melbourne Australia * COPYRIGHT: Zen Yes Pty Ltd, 2019-2021 * DESCRIPTION: Effect Transform */ #ifndef EFFECT_TRANSFORM_H #define EFFECT_TRANSFORM_H #ifndef _YARRA_VECTOR_H_ #include "Yarra/Math/Vector.h" #endif #ifndef EFFECT_NODE_H #include "Editor/EffectNode.h" #endif class BBitmap; class BCheckBox; class Effect_Transform : public EffectNode { public: Effect_Transform(BRect frame, const char *filename); ~Effect_Transform() override; void AttachedToWindow() override; EFFECT_GROUP GetEffectGroup() const override {return EffectNode::EFFECT_SPATIAL;} const char *GetVendorName() const override; const char *GetEffectName() const override; bool LoadParameters(const rapidjson::Value &parameters, MediaEffect *media_effect) override; bool SaveParameters(FILE *file, MediaEffect *media_effect) override; BBitmap *GetIcon() override; const char *GetTextEffectName(const uint32 language_idx) override; const char *GetTextA(const uint32 language_idx) override; const char *GetTextB(const uint32 language_idx) override; const int GetEffectListPriority() override {return 99;} MediaEffect *CreateMediaEffect() override; void MediaEffectSelected(MediaEffect *effect) override; void OutputViewMouseDown(MediaEffect *media_effect, const BPoint &point) override; void OutputViewMouseMoved(MediaEffect *media_effect, const BPoint &point) override; bool IsSpatialTransform() const override {return true;} void ChainedSpatialTransform(MediaEffect *data, int64 frame_idx) override; void RenderEffect(BBitmap *source, MediaEffect *data, int64 frame_idx, std::deque<FRAME_ITEM> & chained_effects) override; void MessageReceived(BMessage *msg) override; void AutoScale(MediaEffect *effect, MediaSource *source); private: BPoint fOutputViewMouseDown; ymath::YVector3 fOutputViewTrackPosition; BCheckBox *fCheckboxInterpolate; }; #endif //#ifndef EFFECT_TRANSFORM_H
34.25
125
0.755231
033dce5591b77e36aa450f4c3e76952506785e73
2,038
h
C
include/sk/net/AbstractSocket.h
stemkit-collection/stemkit-cpp
dfa77d831f49916ba6d134f407a4dcd0983328f6
[ "MIT" ]
4
2019-02-19T16:48:41.000Z
2022-01-31T07:57:54.000Z
include/sk/net/AbstractSocket.h
stemkit-collection/stemkit-cpp
dfa77d831f49916ba6d134f407a4dcd0983328f6
[ "MIT" ]
1
2019-01-30T04:48:35.000Z
2019-01-30T04:48:35.000Z
include/sk/net/AbstractSocket.h
stemkit-collection/stemkit-cpp
dfa77d831f49916ba6d134f407a4dcd0983328f6
[ "MIT" ]
null
null
null
/* vim: sw=2: * Copyright (c) 2011, Gennady Bystritsky <bystr@mac.com> * * Distributed under the MIT Licence. * This is free software. See 'LICENSE' for details. * You must read and accept the license prior to use. * * Author: Gennady Bystritsky */ #ifndef _SK_NET_ABSTRACTSOCKET_H_ #define _SK_NET_ABSTRACTSOCKET_H_ #include <sk/util/Object.h> #include <sk/util/Holder.hxx> #include <sk/net/InetSocketAddress.h> #include <sk/net/InetAddress.h> #include <sk/net/ConfigurableSocket.h> #include <sk/net/DirectedSocket.h> #include <sk/io/InputStream.h> #include <sk/io/OutputStream.h> namespace sk { namespace net { class AbstractSocket : public virtual sk::net::ConfigurableSocket { public: virtual ~AbstractSocket(); const sk::net::InetSocketAddress& endpoint() const; const sk::net::InetAddress& address() const; const uint16_t port() const; const sk::net::InetSocketAddress& localEndpoint() const; const sk::net::InetAddress& localAddress() const; const uint16_t localPort() const; sk::io::InputStream& inputStream() const; sk::io::OutputStream& outputStream() const; void close(); // sk::net::ConfigurableSocket implementation. void setReuseAddress(bool state); // sk::util::Object re-implementation. const sk::util::Class getClass() const; protected: AbstractSocket(sk::net::DirectedSocket* directedSocket); const sk::net::DirectedSocket& directedSocket() const; virtual bool isBound() const = 0; private: AbstractSocket& operator = (const AbstractSocket& other); void ensureBound(const bool state) const; sk::util::Holder<sk::net::DirectedSocket>::Sharing _directedSocketHolder; mutable sk::util::Holder<sk::net::InetSocketAddress>::Copying _endpointHolder; mutable sk::util::Holder<sk::net::InetSocketAddress>::Copying _localEndpointHolder; }; } } #endif /* _SK_NET_ABSTRACTSOCKET_H_ */
28.704225
91
0.675172
033f0bf785dd8f6f6dcb926967bbb186b6b87c22
220
h
C
SinaNews/ViewController/AboutViewController.h
gshe/SinaNews
372753433a63d85222d725a71f3c98b17dc49e83
[ "MIT" ]
1
2016-02-17T03:25:17.000Z
2016-02-17T03:25:17.000Z
SinaNews/ViewController/AboutViewController.h
gshe/SinaNews
372753433a63d85222d725a71f3c98b17dc49e83
[ "MIT" ]
null
null
null
SinaNews/ViewController/AboutViewController.h
gshe/SinaNews
372753433a63d85222d725a71f3c98b17dc49e83
[ "MIT" ]
null
null
null
// // AboutViewController.h // SinaNews // // Created by George She on 16/2/17. // Copyright © 2016年 Freedom. All rights reserved. // #import <UIKit/UIKit.h> @interface AboutViewController : FDViewController @end
15.714286
51
0.704545
0340e9ded8d8c79738ad079872c9131d07043f10
16,775
h
C
product/rdn1e1/include/scp_rdn1e1_irq.h
imx-hub/SCP-firmware
3160faa82592b02533bf150fa01096e08e94d273
[ "BSD-3-Clause" ]
null
null
null
product/rdn1e1/include/scp_rdn1e1_irq.h
imx-hub/SCP-firmware
3160faa82592b02533bf150fa01096e08e94d273
[ "BSD-3-Clause" ]
null
null
null
product/rdn1e1/include/scp_rdn1e1_irq.h
imx-hub/SCP-firmware
3160faa82592b02533bf150fa01096e08e94d273
[ "BSD-3-Clause" ]
1
2020-12-15T02:27:07.000Z
2020-12-15T02:27:07.000Z
/* * Arm SCP/MCP Software * Copyright (c) 2017-2019, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef SCP_RDN1E1_IRQ_H #define SCP_RDN1E1_IRQ_H #include <fwk_interrupt.h> #define SCP_WDOG_IRQ FWK_INTERRUPT_NMI /* SCP Watchdog (SP805) */ enum scp_rdn1e1_interrupt { RESERVED0_IRQ = 0, /* Reserved */ CDBG_PWR_UP_REQ_IRQ = 1, /* Coresight Debug Power Request */ CSYS_PWR_UP_REQ_IRQ = 2, /* Coresight System Power Request */ CDBG_RST_REQ_IRQ = 3, /* Coresight Debug Reset Request */ GIC_EXT_WAKEUP_IRQ = 4, /* External GIC Wakeup Request */ RESERVED5_IRQ = 5, /* Reserved */ RESERVED6_IRQ = 6, /* Reserved */ RESERVED7_IRQ = 7, /* Reserved */ RESERVED8_IRQ = 8, /* Reserved */ RESERVED9_IRQ = 9, /* Reserved */ RESERVED10_IRQ = 10, /* Reserved */ RESERVED11_IRQ = 11, /* Reserved */ RESERVED12_IRQ = 12, /* Reserved */ RESERVED13_IRQ = 13, /* Reserved */ RESERVED14_IRQ = 14, /* Reserved */ RESERVED15_IRQ = 15, /* Reserved */ SOC_WAKEUP0_IRQ = 16, /* SoC Expansion Wakeup */ SOC_WAKEUP1_IRQ = 17, /* SoC Expansion Wakeup */ SOC_WAKEUP2_IRQ = 18, /* SoC Expansion Wakeup */ SOC_WAKEUP3_IRQ = 19, /* SoC Expansion Wakeup */ SOC_WAKEUP4_IRQ = 20, /* SoC Expansion Wakeup */ SOC_WAKEUP5_IRQ = 21, /* SoC Expansion Wakeup */ SOC_WAKEUP6_IRQ = 22, /* SoC Expansion Wakeup */ SOC_WAKEUP7_IRQ = 23, /* SoC Expansion Wakeup */ SOC_WAKEUP8_IRQ = 24, /* SoC Expansion Wakeup */ SOC_WAKEUP9_IRQ = 25, /* SoC Expansion Wakeup */ SOC_WAKEUP10_IRQ = 26, /* SoC Expansion Wakeup */ SOC_WAKEUP11_IRQ = 27, /* SoC Expansion Wakeup */ SOC_WAKEUP12_IRQ = 28, /* SoC Expansion Wakeup */ SOC_WAKEUP13_IRQ = 29, /* SoC Expansion Wakeup */ SOC_WAKEUP14_IRQ = 30, /* SoC Expansion Wakeup */ SOC_WAKEUP15_IRQ = 31, /* SoC Expansion Wakeup */ RESERVED32_IRQ = 32, /* Reserved */ TIMREFCLK_IRQ = 33, /* REFCLK Physical Timer */ SYS_GEN_TIMER_SYNC_IRQ = 34, /* System Generic Timer synchronization */ CSTS_SYNC_IRQ = 35, /* Coresight Time stamp synchronization */ RESERVED36_IRQ = 36, /* Reserved */ CTI_TRIGGER0_IRQ = 37, /* SCP CTI Trigger */ CTI_TRIGGER1_IRQ = 38, /* SCP CTI Trigger */ GIC_ERROR_ECC_IRQ = 39, /* GIC Error (ECC Fatal) */ GIC_ERROR_AXIM_IRQ = 40, /* GIC Error (AXIM) */ RESERVED41_IRQ = 41, /* Reserved */ AON_UART_IRQ = 42, /* Always on UART */ RESERVED43_IRQ = 43, /* Reserved */ GEN_WD_WS0_IRQ = 44, /* Generic Watchdog timer WS0 */ GEN_WD_WS1_IRQ = 45, /* Generic Watchdog timer WS1 */ TRUSTED_WD_WS0_IRQ = 46, /* Trusted Watchdog timer WS0 */ TRUSTED_WD_WS1_IRQ = 47, /* Trusted Watchdog timer WS1 */ APPS_UART_IRQ = 48, /* Application UART */ RESERVED49_IRQ = 49, /* Reserved */ PPU_CORES0_IRQ = 50, /* Consolidated PPU Interrupt for cores 1-32, 129-160 */ PPU_CORES1_IRQ = 51, /* Consolidated PPU Interrupt for cores 33-64, 161-192 */ PPU_CORES2_IRQ = 52, /* Consolidated PPU Interrupt for cores 65-96, 193-224 */ PPU_CORES3_IRQ = 53, /* Consolidated PPU Interrupt for cores 97-128, 225-256 */ PPU_CLUSTERS_IRQ = 54, /* Consolidated clusters PPU */ PLL_CORES0_LOCK_IRQ = 55, /* Consolidated PLL lock for PLLs 1-32, 65-96, 129-160, 193-224 */ PLL_CORES1_LOCK_IRQ = 56, /* Consolidated PLL lock for PLLs 33-64, 97-128, 161-192, 225-256 */ PLL_CORES0_UNLOCK_IRQ = 57, /* Consolidated PLL unlock for PLLs 1-32, 65-96, 129-160, 193-224 */ PLL_CORES1_UNLOCK_IRQ = 58, /* Consolidated PLL unlock for PLLs 33-64, 97-128, 161-192, 225-256 */ FAULT_CORES0_IRQ = 59, /* Consolidated fault IRQ for cores 1-32, 129-160 */ FAULT_CORES1_IRQ = 60, /* Consolidated fault IRQ for cores 33-64, 161-192 */ FAULT_CORES2_IRQ = 61, /* Consolidated fault IRQ for cores 65-96, 193-224 */ FAULT_CORES3_IRQ = 62, /* Consolidated fault IRQ for cores 97-128, 225-256 */ FAULT_CLUSTERS_IRQ = 63, /* Consolidated clusters fault */ ECC_CORES0_ERROR_IRQ = 64, /* Consolidated ECC ERROR for cores 1-32, 129-160 */ ECC_CORES1_ERROR_IRQ = 65, /* Consolidated ECC ERROR for cores 33-64, 161-192 */ ECC_CORES2_ERROR_IRQ = 66, /* Consolidated ECC ERROR for cores 65-96, 193-224 */ ECC_CORES3_ERROR_IRQ = 67, /* Consolidated ECC ERROR for cores 96-128, 225-256 */ ECC_CLUSTERS_ERROR_IRQ = 68, /* Consolidated clusters ECC ERROR */ PLL_CLUSTERS_LOCK_IRQ = 69, /* Consolidated clusters PLL Lock */ PLL_CLUSTERS_UNLOCK_IRQ = 70, /* Consolidated clusters PLL Unlock*/ RESERVED71_IRQ = 71, /* Reserved */ RESERVED72_IRQ = 72, /* Reserved */ RESERVED73_IRQ = 73, /* Reserved */ RESERVED74_IRQ = 74, /* Reserved */ RESERVED75_IRQ = 75, /* Reserved */ RESERVED76_IRQ = 76, /* Reserved */ RESERVED77_IRQ = 77, /* Reserved */ RESERVED78_IRQ = 78, /* Reserved */ RESERVED79_IRQ = 79, /* Reserved */ RESERVED80_IRQ = 80, /* Reserved */ RESERVED81_IRQ = 81, /* Reserved */ MHU_AP_NONSEC_IRQ = 82, /* MHU non-secure irq bewteen SCP and AP */ MHU_AP_SEC_IRQ = 83, /* MHU secure irq bewteen SCP and AP */ MHU_MCP_NONSEC_IRQ = 84, /* MHU non-secure irq between SCP and MCP */ MHU_MCP_SEC_IRQ = 85, /* MHU secure irq bewteen SCP and MCP */ RESERVED86_IRQ = 86, /* Reserved */ RESERVED87_IRQ = 87, /* Reserved */ RESERVED88_IRQ = 88, /* Reserved */ RESERVED89_IRQ = 89, /* Reserved */ TIMER_CLUSTERS_IRQ = 90, /* Consolidated clusters timer interrupt */ RESERVED91_IRQ = 91, /* Reserved */ RESERVED92_IRQ = 92, /* Reserved */ RESERVED93_IRQ = 93, /* Reserved */ MMU_TCU_RASIRPT_IRQ = 94, /* Consolidated MMU RAS */ MMU_TBU_RASIRPT_IRQ = 95, /* Consolidated TBU RAS */ INT_PPU_IRQ = 96, /* PPU interrupt from Interconnect PPU */ INT_ERRNS_IRQ = 97, /* Non-Sec error interrupt from Interconnect PPU */ INT_ERRS_IRQ = 98, /* Secure error interrupt from Interconnect PPU */ INT_FAULTS_IRQ = 99, /* Secure fault interrupt from Interconnect PPU */ INT_FAULTNS_IRQ = 100, /* Non-Sec fault interrupt from Interconnect PPU */ INT_PMU_IRQ = 101, /* PMU count overflow interrupt */ RESERVED102_IRQ = 102, /* Reserved */ RESERVED103_IRQ = 103, /* Reserved */ RESERVED104_IRQ = 104, /* Reserved */ RESERVED105_IRQ = 105, /* Reserved */ RESERVED106_IRQ = 106, /* Reserved */ RESERVED107_IRQ = 107, /* Reserved */ RESERVED108_IRQ = 108, /* Reserved */ RESERVED109_IRQ = 109, /* Reserved */ RESERVED110_IRQ = 110, /* Reserved */ RESERVED111_IRQ = 111, /* Reserved */ RESERVED112_IRQ = 112, /* Reserved */ RESERVED113_IRQ = 113, /* Reserved */ RESERVED114_IRQ = 114, /* Reserved */ RESERVED115_IRQ = 115, /* Reserved */ RESERVED116_IRQ = 116, /* Reserved */ RESERVED117_IRQ = 117, /* Reserved */ RESERVED118_IRQ = 118, /* Reserved */ RESERVED119_IRQ = 119, /* Reserved */ PPU_DBGCH0_IRQ = 120, /* Debug Chain 0 PPU */ PPU_DBGCH1_IRQ = 121, /* Debug Chain 1 PPU */ PPU_DBGCH2_IRQ = 122, /* Debug Chain 2 PPU */ PPU_DBGCH3_IRQ = 123, /* Debug Chain 3 PPU */ PPU_DBGCH4_IRQ = 124, /* Debug Chain 4 PPU */ PPU_DBGCH5_IRQ = 125, /* Debug Chain 5 PPU */ PPU_DBGCH6_IRQ = 126, /* Debug Chain 6 PPU */ PPU_DBGCH7_IRQ = 127, /* Debug Chain 7 PPU */ RESERVED128_IRQ = 128, /* Reserved */ RESERVED129_IRQ = 129, /* Reserved */ DEBUG_PIK_IRQ = 130, /* DEBUG PIK */ PPU_LOGIC_IRQ = 131, /* PPU LOGIC */ RESERVED132_IRQ = 132, /* Reserved */ RESERVED133_IRQ = 133, /* Reserved */ RESERVED134_IRQ = 134, /* Reserved */ PPU_SRAM_IRQ = 135, /* PPU SRAM */ RESERVED136_IRQ = 136, /* Reserved */ RESERVED137_IRQ = 137, /* Reserved */ RESERVED138_IRQ = 138, /* Reserved */ MCP_WD_WS1_IRQ = 139, /* MCP watchdog reset */ PLL_SYS_LOCK_IRQ = 140, /* System PLL Lock */ PLL_SYS_UNLOCK_IRQ = 141, /* System PLL Unlock */ PLL_INT_LOCK_IRQ = 142, /* Interconnect PLL Lock */ PLL_INT_UNLOCK_IRQ = 143, /* Interconnect PLL Unlock */ RESERVED144_IRQ = 144, /* Reserved */ RESERVED145_IRQ = 145, /* Reserved */ RESERVED146_IRQ = 146, /* Reserved */ RESERVED147_IRQ = 147, /* Reserved */ RESERVED148_IRQ = 148, /* Reserved */ RESERVED149_IRQ = 149, /* Reserved */ RESERVED150_IRQ = 150, /* Reserved */ RESERVED151_IRQ = 151, /* Reserved */ RESERVED152_IRQ = 152, /* Reserved */ RESERVED153_IRQ = 153, /* Reserved */ RESERVED154_IRQ = 154, /* Reserved */ RESERVED155_IRQ = 155, /* Reserved */ RESERVED156_IRQ = 156, /* Reserved */ RESERVED157_IRQ = 157, /* Reserved */ RESERVED158_IRQ = 158, /* Reserved */ RESERVED159_IRQ = 159, /* Reserved */ RESERVED160_IRQ = 160, /* Reserved */ RESERVED161_IRQ = 161, /* Reserved */ RESERVED162_IRQ = 162, /* Reserved */ RESERVED163_IRQ = 163, /* Reserved */ RESERVED164_IRQ = 164, /* Reserved */ RESERVED165_IRQ = 165, /* Reserved */ RESERVED166_IRQ = 166, /* Reserved */ RESERVED167_IRQ = 167, /* Reserved */ RESERVED168_IRQ = 168, /* Reserved */ RESERVED169_IRQ = 169, /* Reserved */ RESERVED170_IRQ = 170, /* Reserved */ RESERVED171_IRQ = 171, /* Reserved */ RESERVED172_IRQ = 172, /* Reserved */ RESERVED173_IRQ = 173, /* Reserved */ PLL_DMC_LOCK_IRQ = 174, /* DMC PLL LOCK */ PLL_DMC_UNLOCK_IRQ = 175, /* DMC PLL LOCK */ RESERVED176_IRQ = 176, /* Reserved */ RESERVED177_IRQ = 177, /* Reserved */ RESERVED178_IRQ = 178, /* Reserved */ RESERVED179_IRQ = 179, /* Reserved */ DMCS0_MISC_OFLOW_IRQ = 180, /* DMC 0/4 Combined Error Overflow */ DMCS0_ERR_OFLOW_IRQ = 181, /* DMC 0/4 Error Overflow */ DMCS0_ECC_ERR_INT_IRQ = 182, /* DMC 0/4 ECC Error Int */ DMCS0_MISC_ACCESS_INT_IRQ = 183, /* DMC 0/4 Combined Miscellaneous access int */ DMCS0_TEMPERATURE_EVENT_INT_IRQ = 184, /* DMC 0/4 Temperature event int */ DMCS0_FAILED_ACCESS_INT_IRQ = 185, /* DMC 0/4 Failed access int */ DMCS0_MGR_INT_IRQ = 186, /* DMC 0/4 combined manager int */ DMCS1_MISC_OFLOW_IRQ = 187, /* DMC 1/5 Combined Error Overflow */ DMCS1_ERR_OFLOW_IRQ = 188, /* DMC 1/5 Error Overflow */ DMCS1_ECC_ERR_INT_IRQ = 189, /* DMC 1/5 ECC Error Int */ DMCS1_MISC_ACCESS_INT_IRQ = 190, /* DMC 1/5 Combined Miscellaneous access int */ DMCS1_TEMPERATURE_EVENT_INT_IRQ = 191, /* DMC 1/5 Temperature event int */ DMCS1_FAILED_ACCESS_INT_IRQ = 192, /* DMC 1/5 Failed access int */ DMCS1_MGR_INT_IRQ = 193, /* DMC 1/5 combined manager int */ DMCS2_MISC_OFLOW_IRQ = 194, /* DMC 2/6 Combined Error Overflow */ DMCS2_ERR_OFLOW_IRQ = 195, /* DMC 2/6 Error Overflow */ DMCS2_ECC_ERR_INT_IRQ = 196, /* DMC 2/6 ECC Error Int */ DMCS2_MISC_ACCESS_INT_IRQ = 197, /* DMC 2/6 Combined Miscellaneous access int */ DMCS2_TEMPERATURE_EVENT_INT_IRQ = 198, /* DMC 2/6 Temperature event int */ DMCS2_FAILED_ACCESS_INT_IRQ = 199, /* DMC 2/6 Failed access int */ DMCS2_MGR_INT_IRQ = 200, /* DMC 2/6 combined manager int */ DMCS3_MISC_OFLOW_IRQ = 201, /* DMC 3/7 Combined Error Overflow */ DMCS3_ERR_OFLOW_IRQ = 202, /* DMC 3/7 Error Overflow */ DMCS3_ECC_ERR_INT_IRQ = 203, /* DMC 3/7 ECC Error Int */ DMCS3_MISC_ACCESS_INT_IRQ = 204, /* DMC 3/7 Combined Miscellaneous access int */ DMCS3_TEMPERATURE_EVENT_INT_IRQ = 205, /* DMC 3/7 Temperature event int */ DMCS3_FAILED_ACCESS_INT_IRQ = 206, /* DMC 3/7 Failed access int */ DMCS3_MGR_INT_IRQ = 207, /* DMC 3/7 combined manager int */ SCP_EXT_INTR0_IRQ = 208, /* SCP Customer Extension */ SCP_EXT_INTR1_IRQ = 209, /* SCP Customer Extension */ SCP_EXT_INTR2_IRQ = 210, /* SCP Customer Extension */ SCP_EXT_INTR3_IRQ = 211, /* SCP Customer Extension */ SCP_EXT_INTR4_IRQ = 212, /* SCP Customer Extension */ SCP_EXT_INTR5_IRQ = 213, /* SCP Customer Extension */ SCP_EXT_INTR6_IRQ = 214, /* SCP Customer Extension */ SCP_EXT_INTR7_IRQ = 215, /* SCP Customer Extension */ SCP_EXT_INTR8_IRQ = 216, /* SCP Customer Extension */ SCP_EXT_INTR9_IRQ = 217, /* SCP Customer Extension */ SCP_EXT_INTR10_IRQ = 218, /* SCP Customer Extension */ SCP_EXT_INTR11_IRQ = 219, /* SCP Customer Extension */ SCP_EXT_INTR12_IRQ = 220, /* SCP Customer Extension */ SCP_EXT_INTR13_IRQ = 221, /* SCP Customer Extension */ SCP_EXT_INTR14_IRQ = 222, /* SCP Customer Extension */ SCP_EXT_INTR15_IRQ = 223, /* SCP Customer Extension */ SCP_EXT_INTR16_IRQ = 224, /* SCP Customer Extension */ SCP_EXT_INTR17_IRQ = 225, /* SCP Customer Extension */ SCP_EXT_INTR18_IRQ = 226, /* SCP Customer Extension */ SCP_EXT_INTR19_IRQ = 227, /* SCP Customer Extension */ SCP_EXT_INTR20_IRQ = 228, /* SCP Customer Extension */ SCP_EXT_INTR21_IRQ = 229, /* SCP Customer Extension */ SCP_EXT_INTR22_IRQ = 230, /* SCP Customer Extension */ SCP_EXT_INTR23_IRQ = 231, /* SCP Customer Extension */ SCP_EXT_INTR24_IRQ = 232, /* SCP Customer Extension */ SCP_EXT_INTR25_IRQ = 233, /* SCP Customer Extension */ SCP_EXT_INTR26_IRQ = 234, /* SCP Customer Extension */ SCP_EXT_INTR27_IRQ = 235, /* SCP Customer Extension */ SCP_EXT_INTR28_IRQ = 236, /* SCP Customer Extension */ SCP_EXT_INTR29_IRQ = 237, /* SCP Customer Extension */ SCP_EXT_INTR30_IRQ = 238, /* SCP Customer Extension */ SCP_EXT_INTR31_IRQ = 239 /* SCP Customer Extension */ }; #endif /* SCP_RDN1E1_IRQ_H */
59.066901
80
0.534069
03440f0eac5dacd63fac7b934d2bbd110a2e6066
12,561
c
C
Roadstar_CD-354MP/src/cd354mp.c
kbiva/stm32f103_projects
8a42d5149d4f05f98f9fab0bc4ad80303bd51d31
[ "MIT" ]
19
2015-07-06T18:39:45.000Z
2022-02-13T09:59:51.000Z
Roadstar_CD-354MP/src/cd354mp.c
kbiva/stm32f103_projects
8a42d5149d4f05f98f9fab0bc4ad80303bd51d31
[ "MIT" ]
null
null
null
Roadstar_CD-354MP/src/cd354mp.c
kbiva/stm32f103_projects
8a42d5149d4f05f98f9fab0bc4ad80303bd51d31
[ "MIT" ]
14
2015-07-20T21:05:50.000Z
2021-08-08T10:59:33.000Z
/* * cd354mp.c * * Roadstar CD-354MP face plate demo * * Author: Kestutis Bivainis */ #include "stm32f10x_conf.h" #include "cd354mp.h" #include "delay.h" #include "font.h" __align(4) uint8_t display_data[20]; static PIN pins[]={ {{CLK_Pin,CLK_Speed,CLK_Mode},CLK_Port,CLK_Bus}, {{DO_Pin,DO_Speed,DO_Mode},DO_Port,DO_Bus}, {{CE_Pin, CE_Speed, CE_Mode}, CE_Port, CE_Bus}, {{INH_Pin, INH_Speed, INH_Mode}, INH_Port, INH_Bus}, {{KEY1_Pin, KEY1_Speed, KEY1_Mode}, KEY1_Port, KEY1_Bus}, {{KEY2_Pin, KEY2_Speed, KEY2_Mode}, KEY2_Port, KEY2_Bus}, }; void GPIO_Configuration(void) { uint32_t i; SPI_InitTypeDef SPI_InitStructure; for(i=0;i<sizeof(pins)/sizeof(PIN);i++) { RCC_APB2PeriphClockCmd(pins[i].GPIO_Bus,ENABLE); GPIO_Init(pins[i].GPIOx,&pins[i].GPIO_InitStructure); } RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx; SPI_InitStructure.SPI_Mode = SPI_Mode_Master; SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI2, &SPI_InitStructure); SPI_Cmd(SPI2, ENABLE); } static void DMA_Configuration(void) { DMA_InitTypeDef DMA_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) &(SPI2->DR); DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)display_data; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_BufferSize = 20; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel5, &DMA_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel5_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); DMA_ITConfig(DMA1_Channel5, DMA_IT_TC, ENABLE); } void CD354MP_init(void) { DMA_Configuration(); GPIO_SetBits(INH_Port,INH_Pin); DWT_Delay(100000); } static void sendByte(uint8_t byte) { SPI_I2S_SendData(SPI2,byte); while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET){}; } void CD354MP_send(void) { //uint32_t j; while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET){}; GPIO_ResetBits(CE_Port,CE_Pin); sendByte(CMD_INPUT); GPIO_SetBits(CE_Port,CE_Pin); display_data[19]&=0xF0; DMA_Cmd(DMA1_Channel5,DISABLE); DMA_SetCurrDataCounter(DMA1_Channel5,20); DMA_Cmd(DMA1_Channel5,ENABLE); SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Tx, ENABLE); // for(j=0;j<20;j++) { // sendByte(display_data[j]); // } //GPIO_ResetBits(CE_Port,CE_Pin); } void CD354MP_char(char chr,uint8_t pos,uint8_t flush) { switch(pos) { case 0: display_data[0]=(FONT[chr-0x20][0]>>1)|(display_data[0]&0x80); display_data[1]=((FONT[chr-0x20][0]&0x01)<<7)|(FONT[chr-0x20][1]>>1)|(display_data[1]&0x09); break; case 1: display_data[2]=FONT[chr-0x20][0]; display_data[3]=FONT[chr-0x20][1]|(display_data[3]&0x13); break; case 2: display_data[3]=((FONT[chr-0x20][0]&0x80)>>7)|(display_data[3]&0xFE); display_data[4]=((FONT[chr-0x20][0])<<1)|((FONT[chr-0x20][1]&0x80)>>7); display_data[5]=((FONT[chr-0x20][1])<<1)|(display_data[5]&0x27); break; case 3: display_data[5]=((FONT[chr-0x20][0]&0xC0)>>6)|(display_data[5]&0xFC); display_data[6]=((FONT[chr-0x20][0])<<2)|((FONT[chr-0x20][1]&0xC0)>>6); display_data[7]=((FONT[chr-0x20][1])<<2)|(display_data[7]&0x4F); break; case 4: display_data[7]=((FONT[chr-0x20][0]&0xE0)>>5)|(display_data[7]&0xF8); display_data[8]=((FONT[chr-0x20][0])<<3)|((FONT[chr-0x20][1]&0xE0)>>5); display_data[9]=((FONT[chr-0x20][1])<<3)|(display_data[9]&0x90); break; case 5: display_data[9]=((FONT[chr-0x20][0]&0xF0)>>4)|(display_data[9]&0xF0); display_data[10]=((FONT[chr-0x20][0])<<4)|((FONT[chr-0x20][1]&0xF0)>>4)|(display_data[10]&0x01); display_data[11]=((FONT[chr-0x20][1])<<4)|(display_data[11]&0x3F); break; case 6: display_data[11]=((FONT[chr-0x20][0]&0xF8)>>3)|(display_data[11]&0xE0); display_data[12]=((FONT[chr-0x20][0])<<5)|((FONT[chr-0x20][1]&0xF8)>>3)|(display_data[12]&0x02); display_data[13]=((FONT[chr-0x20][1])<<5)|(display_data[13]&0x7F); break; case 7: display_data[13]=((FONT[chr-0x20][0]&0xFC)>>2)|(display_data[13]&0xC0); display_data[14]=((FONT[chr-0x20][0])<<6)|((FONT[chr-0x20][1]&0xFC)>>2)|(display_data[14]&0x04); break; } if(flush) { CD354MP_send(); } } void CD354MP_text(char *pString,uint8_t start,uint8_t clear,uint8_t flush) { if(clear) { CD354MP_clear_text(FALSE); } while (*pString) { CD354MP_char(*pString++,start++,flush); if(start>7) break; } if(flush) { CD354MP_send(); } } void CD354MP_clear_text(uint8_t flush) { display_data[0]&=SYMBOL_STEREO_BIT; display_data[1]&=(SYMBOL_MP3_BIT|SYMBOL_DIGIT_TOP_BIT); display_data[2]=0x00; display_data[3]&=(SYMBOL_AF_BIT|SYMBOL_DIGIT_TOP_RIGHT_BIT); display_data[4]=0x00; display_data[5]&=(SYMBOL_TA_BIT|SYMBOL_DIGIT_MIDDLE_BIT); display_data[6]=0x00; display_data[7]&=(SYMBOL_TP_BIT|SYMBOL_DIGIT_BOTTOM_RIGHT_BIT); display_data[8]=0x00; display_data[9]&=(SYMBOL_DIR_BIT|0x80); display_data[10]&=SYMBOL_POINT_BIT; display_data[11]&=SYMBOL_PTY_BIT; display_data[12]&=SYMBOL_DIGIT_BOTTOM_BIT; display_data[13]&=SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[14]&=SYMBOL_DIGIT_TOP_LEFT_BIT; if(flush) { CD354MP_send(); } } void CD354MP_symbol(uint8_t val,uint8_t bit,uint8_t on,uint8_t flush) { if(on) { display_data[val]|=bit; } else { display_data[val]&=~bit; } if(flush) { CD354MP_send(); } } void CD354MP_digit(uint8_t val,uint8_t flush) { switch(val) { case 0: display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]|=SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]|=SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]|=SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]&=~SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]|=SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]|=SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]|=SYMBOL_DIGIT_BOTTOM_BIT; break; case 1: display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]|=SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]&=~SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]&=~SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]&=~SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]|=SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]&=~SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]&=~SYMBOL_DIGIT_BOTTOM_BIT; break; case 2: display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]|=SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]|=SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]&=~SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]|=SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]&=~SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]|=SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]|=SYMBOL_DIGIT_BOTTOM_BIT; break; case 3: display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]|=SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]|=SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]&=~SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]|=SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]|=SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]&=~SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]|=SYMBOL_DIGIT_BOTTOM_BIT; break; case 4: display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]|=SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]&=~SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]|=SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]|=SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]|=SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]&=~SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]&=~SYMBOL_DIGIT_BOTTOM_BIT; break; case 5: display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]&=~SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]|=SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]|=SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]|=SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]|=SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]&=~SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]|=SYMBOL_DIGIT_BOTTOM_BIT; break; case 6: display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]&=~SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]|=SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]|=SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]|=SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]|=SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]|=SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]|=SYMBOL_DIGIT_BOTTOM_BIT; break; case 7: display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]|=SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]|=SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]&=~SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]&=~SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]|=SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]&=~SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]&=~SYMBOL_DIGIT_BOTTOM_BIT; break; case 8: display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]|=SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]|=SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]|=SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]|=SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]|=SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]|=SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]|=SYMBOL_DIGIT_BOTTOM_BIT; break; case 9: display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]|=SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]|=SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]|=SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]|=SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]|=SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]&=~SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]|=SYMBOL_DIGIT_BOTTOM_BIT; break; } if(flush) { CD354MP_send(); } } void CD354MP_digit_off(uint8_t flush) { display_data[SYMBOL_DIGIT_TOP_RIGHT_POS]&=~SYMBOL_DIGIT_TOP_RIGHT_BIT; display_data[SYMBOL_DIGIT_TOP_POS]&=~SYMBOL_DIGIT_TOP_BIT; display_data[SYMBOL_DIGIT_TOP_LEFT_POS]&=~SYMBOL_DIGIT_TOP_LEFT_BIT; display_data[SYMBOL_DIGIT_MIDDLE_POS]&=~SYMBOL_DIGIT_MIDDLE_BIT; display_data[SYMBOL_DIGIT_BOTTOM_RIGHT_POS]&=~SYMBOL_DIGIT_BOTTOM_RIGHT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_LEFT_POS]&=~SYMBOL_DIGIT_BOTTOM_LEFT_BIT; display_data[SYMBOL_DIGIT_BOTTOM_POS]&=~SYMBOL_DIGIT_BOTTOM_BIT; if(flush) { CD354MP_send(); } }
38.530675
102
0.758936
03446ceacabec9c4bfa038e461caab1d72582259
11,486
h
C
components/csi/csi2/dsp/include/csky_common_tables.h
wstong999/AliOS-Things
6554769cb5b797e28a30a4aa89b3f4cb2ef2f5d9
[ "Apache-2.0" ]
4,538
2017-10-20T05:19:03.000Z
2022-03-30T02:29:30.000Z
components/csi/csi2/dsp/include/csky_common_tables.h
wstong999/AliOS-Things
6554769cb5b797e28a30a4aa89b3f4cb2ef2f5d9
[ "Apache-2.0" ]
1,088
2017-10-21T07:57:22.000Z
2022-03-31T08:15:49.000Z
components/csi/csi2/dsp/include/csky_common_tables.h
willianchanlovegithub/AliOS-Things
637c0802cab667b872d3b97a121e18c66f256eab
[ "Apache-2.0" ]
1,860
2017-10-20T05:22:35.000Z
2022-03-27T10:54:14.000Z
/****************************************************************************** * @file csky_common_tables.h * @brief This file has extern declaration for common tables like * Bitreverse, reciprocal etc which are used across different functions. * @version V1.0 * @date 20. Dec 2016 ******************************************************************************/ /* --------------------------------------------------------------------------- * Copyright (C) 2016 CSKY Limited. All rights reserved. * * Redistribution and use of this software in source and binary forms, * with or without modification, are permitted provided that the following * conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of CSKY Ltd. nor the names of CSKY's contributors may * be used to endorse or promote products derived from this software without * specific prior written permission of CSKY Ltd. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * -------------------------------------------------------------------------- */ #ifndef _CSKY_COMMON_TABLES_H #define _CSKY_COMMON_TABLES_H #include "csky_math.h" extern const uint16_t cskyBitRevTable[1024]; extern const q15_t cskyRecipTableQ15[64]; extern const q31_t cskyRecipTableQ31[64]; extern const uint32_t twiddleCoef_16[32]; extern const uint32_t twiddleCoef_32[64]; extern const uint32_t twiddleCoef_64[128]; extern const uint32_t twiddleCoef_128[256]; extern const uint32_t twiddleCoef_256[512]; extern const uint32_t twiddleCoef_512[1024]; extern const uint32_t twiddleCoef_1024[2048]; extern const uint32_t twiddleCoef_2048[4096]; extern const uint32_t twiddleCoef_4096[8192]; extern const q31_t twiddleCoef_16_q31[24]; extern const q31_t twiddleCoef_32_q31[48]; extern const q31_t twiddleCoef_64_q31[96]; extern const q31_t twiddleCoef_128_q31[192]; extern const q31_t twiddleCoef_256_q31[384]; extern const q31_t twiddleCoef_512_q31[768]; extern const q31_t twiddleCoef_1024_q31[1536]; extern const q31_t twiddleCoef_2048_q31[3072]; extern const q31_t twiddleCoef_4096_q31[6144]; extern const q15_t twiddleCoef_16_q15[24]; extern const q15_t twiddleCoef_32_q15[48]; extern const q15_t twiddleCoef_64_q15[96]; extern const q15_t twiddleCoef_128_q15[192]; extern const q15_t twiddleCoef_256_q15[384]; extern const q15_t twiddleCoef_512_q15[768]; extern const q15_t twiddleCoef_1024_q15[1536]; extern const q15_t twiddleCoef_2048_q15[3072]; extern const q15_t twiddleCoef_4096_q15[6144]; extern const float32_t twiddleCoef_rfft_32[32]; extern const float32_t twiddleCoef_rfft_64[64]; extern const float32_t twiddleCoef_rfft_128[128]; extern const float32_t twiddleCoef_rfft_256[256]; extern const float32_t twiddleCoef_rfft_512[512]; extern const float32_t twiddleCoef_rfft_1024[1024]; extern const float32_t twiddleCoef_rfft_2048[2048]; extern const float32_t twiddleCoef_rfft_4096[4096]; extern const float32_t twiddleCoef_rfft_8192[8192]; extern const q15_t twiddleCoef_fast_16_q15[24]; extern const q15_t twiddleCoef_fast_32_q15[56]; extern const q15_t twiddleCoef_fast_64_q15[120]; extern const q15_t twiddleCoef_fast_128_q15[248]; extern const q15_t twiddleCoef_fast_256_q15[504]; extern const q15_t twiddleCoef_fast_512_q15[1016]; extern const q15_t twiddleCoef_fast_1024_q15[2040]; extern const q15_t twiddleCoef_fast_2048_q15[4088]; extern const q15_t twiddleCoef_fast_4096_q15[8184]; extern const q31_t twiddleCoef_fast_16_q31[24]; extern const q31_t twiddleCoef_fast_32_q31[56]; extern const q31_t twiddleCoef_fast_64_q31[120]; extern const q31_t twiddleCoef_fast_128_q31[248]; extern const q31_t twiddleCoef_fast_256_q31[504]; extern const q31_t twiddleCoef_fast_512_q31[1016]; extern const q31_t twiddleCoef_fast_1024_q31[2040]; extern const q31_t twiddleCoef_fast_2048_q31[4088]; extern const q31_t twiddleCoef_fast_4096_q31[8184]; extern const uint32_t twiddleCoef_fast_16[24]; extern const uint32_t twiddleCoef_fast_32[56]; extern const uint32_t twiddleCoef_fast_64[120]; extern const uint32_t twiddleCoef_fast_128[248]; extern const uint32_t twiddleCoef_fast_256[504]; extern const uint32_t twiddleCoef_fast_512[1016]; extern const uint32_t twiddleCoef_fast_1024[2040]; extern const uint32_t twiddleCoef_fast_2048[4088]; extern const uint32_t twiddleCoef_fast_4096[8184]; extern const q15_t realCoefAQ15_8192[8192]; extern const q31_t realCoefAQ31_8192[8192]; extern const q15_t realCoefBQ15_8192[8192]; extern const q31_t realCoefBQ31_8192[8192]; /*Tables for RFFT.*/ extern const q15_t ALIGN4 realCoefAQ15_32[32]; extern const q15_t ALIGN4 realCoefAQ15_64[64]; extern const q15_t ALIGN4 realCoefAQ15_128[128]; extern const q15_t ALIGN4 realCoefAQ15_256[256]; extern const q15_t ALIGN4 realCoefAQ15_512[512]; extern const q15_t ALIGN4 realCoefAQ15_1024[1024]; extern const q15_t ALIGN4 realCoefAQ15_2048[2048]; extern const q15_t ALIGN4 realCoefAQ15_4096[4096]; extern const q15_t ALIGN4 realCoefBQ15_32[32]; extern const q15_t ALIGN4 realCoefBQ15_64[64]; extern const q15_t ALIGN4 realCoefBQ15_128[128]; extern const q15_t ALIGN4 realCoefBQ15_256[256]; extern const q15_t ALIGN4 realCoefBQ15_512[512]; extern const q15_t ALIGN4 realCoefBQ15_1024[1024]; extern const q15_t ALIGN4 realCoefBQ15_2048[2048]; extern const q15_t ALIGN4 realCoefBQ15_4096[4096]; extern const q31_t realCoefAQ31_32[32]; extern const q31_t realCoefAQ31_64[64]; extern const q31_t realCoefAQ31_128[128]; extern const q31_t realCoefAQ31_256[256]; extern const q31_t realCoefAQ31_512[512]; extern const q31_t realCoefAQ31_1024[1024]; extern const q31_t realCoefAQ31_2048[2048]; extern const q31_t realCoefAQ31_4096[4096]; extern const q31_t realCoefBQ31_32[32]; extern const q31_t realCoefBQ31_64[64]; extern const q31_t realCoefBQ31_128[128]; extern const q31_t realCoefBQ31_256[256]; extern const q31_t realCoefBQ31_512[512]; extern const q31_t realCoefBQ31_1024[1024]; extern const q31_t realCoefBQ31_2048[2048]; extern const q31_t realCoefBQ31_4096[4096]; extern const float32_t realCoefA[8192]; extern const float32_t realCoefB[8192]; /*Tables for DCT4*/ extern const q15_t ALIGN4 WeightsQ15_128[128+2]; extern const q15_t ALIGN4 WeightsQ15_512[512+2]; extern const q15_t ALIGN4 WeightsQ15_2048[2048+2]; extern const q15_t ALIGN4 WeightsQ15_8192[8192+2]; extern const q15_t ALIGN4 cos_factorsQ15_128[128]; extern const q15_t ALIGN4 cos_factorsQ15_512[512]; extern const q15_t ALIGN4 cos_factorsQ15_2048[2048]; extern const q15_t ALIGN4 cos_factorsQ15_8192[8192]; extern const q31_t WeightsQ31_128[128+2]; extern const q31_t WeightsQ31_512[512+2]; extern const q31_t WeightsQ31_2048[2048+2]; extern const q31_t WeightsQ31_8192[8192+2]; extern const q31_t cos_factorsQ31_128[128]; extern const q31_t cos_factorsQ31_512[512]; extern const q31_t cos_factorsQ31_2048[2048]; extern const q31_t cos_factorsQ31_8192[8192]; extern const float32_t Weights_128[128+2]; extern const float32_t Weights_512[512+2]; extern const float32_t Weights_2048[2048+2]; extern const float32_t Weights_8192[8192+2]; extern const float32_t cos_factors_128[128]; extern const float32_t cos_factors_512[512]; extern const float32_t cos_factors_2048[2048]; extern const float32_t cos_factors_8192[8192]; /* floating-point bit reversal tables */ #define CSKYBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) #define CSKYBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) #define CSKYBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) #define CSKYBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) #define CSKYBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) #define CSKYBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) #define CSKYBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) #define CSKYBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) #define CSKYBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) extern const uint16_t cskyBitRevIndexTable16[CSKYBITREVINDEXTABLE__16_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable32[CSKYBITREVINDEXTABLE__32_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable64[CSKYBITREVINDEXTABLE__64_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable128[CSKYBITREVINDEXTABLE_128_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable256[CSKYBITREVINDEXTABLE_256_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable512[CSKYBITREVINDEXTABLE_512_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable1024[CSKYBITREVINDEXTABLE1024_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable2048[CSKYBITREVINDEXTABLE2048_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable4096[CSKYBITREVINDEXTABLE4096_TABLE_LENGTH]; /* fixed-point bit reversal tables */ #define CSKYBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 ) #define CSKYBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 ) #define CSKYBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 ) #define CSKYBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 ) #define CSKYBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 ) #define CSKYBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 ) #define CSKYBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 ) #define CSKYBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) #define CSKYBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) extern const uint16_t cskyBitRevIndexTable_fixed_16[CSKYBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable_fixed_32[CSKYBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable_fixed_64[CSKYBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable_fixed_128[CSKYBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable_fixed_256[CSKYBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable_fixed_512[CSKYBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable_fixed_1024[CSKYBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable_fixed_2048[CSKYBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; extern const uint16_t cskyBitRevIndexTable_fixed_4096[CSKYBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; /* Tables for Fast Math Sine and Cosine */ extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; #endif /* CSKY_COMMON_TABLES_H */
48.058577
100
0.815515
0344d99c721dd73692ac063421d2ae096585b6df
1,693
h
C
mptrack/ColorConfigDlg.h
sitomani/openmpt
913396209c22a1fc6dfb29f0e34893dfb0ffa591
[ "BSD-3-Clause" ]
null
null
null
mptrack/ColorConfigDlg.h
sitomani/openmpt
913396209c22a1fc6dfb29f0e34893dfb0ffa591
[ "BSD-3-Clause" ]
null
null
null
mptrack/ColorConfigDlg.h
sitomani/openmpt
913396209c22a1fc6dfb29f0e34893dfb0ffa591
[ "BSD-3-Clause" ]
null
null
null
/* * ColorConfigDlg.cpp * ------------------ * Purpose: Implementation of the color setup dialog. * Notes : (currently none) * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. */ #pragma once #include "BuildSettings.h" #include "ColorPickerButton.h" OPENMPT_NAMESPACE_BEGIN class COptionsColors : public CPropertyPage { protected: std::array<COLORREF, MAX_MODCOLORS> CustomColors; CComboBox m_ComboItem, m_ComboFont, m_ComboPreset; ColorPickerButton m_BtnColor[3]; CButton m_BtnPreview; CSpinButtonCtrl m_ColorSpin; CStatic m_TxtColor[3]; MODPLUGDIB *m_pPreviewDib = nullptr; FontSetting patternFont, commentFont; uint32 m_nColorItem = 0; public: COptionsColors(); ~COptionsColors() { delete m_pPreviewDib; } protected: BOOL OnInitDialog() override; BOOL OnKillActive() override; void OnOK() override; void DoDataExchange(CDataExchange* pDX) override; BOOL OnSetActive() override; void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); void SelectColor(int colorIndex); afx_msg void OnChoosePatternFont(); afx_msg void OnChooseCommentFont(); afx_msg void OnUpdateDialog(); afx_msg void OnDrawItem(int nIdCtl, LPDRAWITEMSTRUCT lpdis); afx_msg void OnColorSelChanged(); afx_msg void OnSettingsChanged(); afx_msg void OnSelectColor1() { SelectColor(0); } afx_msg void OnSelectColor2() { SelectColor(1); } afx_msg void OnSelectColor3() { SelectColor(2); } afx_msg void OnPresetChange(); afx_msg void OnLoadColorScheme(); afx_msg void OnSaveColorScheme(); afx_msg void OnClearWindowCache(); afx_msg void OnPreviewChanged(); DECLARE_MESSAGE_MAP(); }; OPENMPT_NAMESPACE_END
26.873016
92
0.76964
0345b2b2c0a2a0ae942f4bfc479238d55af32b11
1,323
h
C
System/Library/PrivateFrameworks/TSReading.framework/TSTTableStrokePresetList.h
lechium/iPhoneOS_12.1.1_Headers
aac688b174273dfcbade13bab104461f463db772
[ "MIT" ]
12
2019-06-02T02:42:41.000Z
2021-04-13T07:22:20.000Z
System/Library/PrivateFrameworks/TSReading.framework/TSTTableStrokePresetList.h
lechium/iPhoneOS_12.1.1_Headers
aac688b174273dfcbade13bab104461f463db772
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/TSReading.framework/TSTTableStrokePresetList.h
lechium/iPhoneOS_12.1.1_Headers
aac688b174273dfcbade13bab104461f463db772
[ "MIT" ]
3
2019-06-11T02:46:10.000Z
2019-12-21T14:58:16.000Z
/* * This header is generated by classdump-dyld 1.0 * on Saturday, June 1, 2019 at 6:50:11 PM Mountain Standard Time * Operating System: Version 12.1.1 (Build 16C5050a) * Image Source: /System/Library/PrivateFrameworks/TSReading.framework/TSReading * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @class TSTTableStrokePresetData; @interface TSTTableStrokePresetList : NSObject { unsigned long long mCount; TSTTableStrokePresetData* mPresets[15]; } +(id)strokePresetListForDefaultPropertyMapWithHorizontalStroke:(id)arg1 verticalStroke:(id)arg2 exteriorStroke:(id)arg3 ; +(id)strokePresetListForDefaultPropertyMapForTablePresetIndex:(unsigned long long)arg1 colors:(id)arg2 ; +(id)strokePresetListForDefaultPropertyMapWithFatStroke:(id)arg1 andThinStroke:(id)arg2 ; +(id)init; -(void)setStrokePreset:(id)arg1 atIndex:(unsigned long long)arg2 ; -(id)presetAtIndex:(unsigned long long)arg1 ; -(id)horizontalStrokeForStrokePreset:(unsigned long long)arg1 ; -(id)verticalStrokeForStrokePreset:(unsigned long long)arg1 ; -(id)exteriorStrokeForStrokePreset:(unsigned long long)arg1 ; -(unsigned)maskForStrokePreset:(unsigned long long)arg1 ; -(void)setStroke:(id)arg1 forPresetIndex:(unsigned long long)arg2 ; -(void)dealloc; -(BOOL)isEqual:(id)arg1 ; -(unsigned long long)count; @end
38.911765
121
0.79743
0346abfad7866fcb9f710f84c046f383a100657e
452
c
C
mud/econ/raw/electrum.c
shentino/simud
644b7d4f56bf8d4695442b8efcfd56e0a561fe21
[ "Apache-2.0" ]
3
2015-07-18T00:19:51.000Z
2016-02-20T17:25:37.000Z
mud/econ/raw/electrum.c
shentino/simud
644b7d4f56bf8d4695442b8efcfd56e0a561fe21
[ "Apache-2.0" ]
2
2021-03-04T19:24:03.000Z
2021-03-08T10:17:34.000Z
mud/econ/raw/electrum.c
shentino/simud
644b7d4f56bf8d4695442b8efcfd56e0a561fe21
[ "Apache-2.0" ]
2
2015-12-22T06:16:53.000Z
2016-11-18T16:32:50.000Z
inherit "/obj/resource"; #include <const.h> NAME( "electrum" ) DISTANT("electrum") SPECIFIC("electrum") PLURAL("electrum") LOOK("A bunch of electrum. A shiny, pale yellow metal. It can be used to make things out of electrum.") WEIGHT( 89600 ) BULK( 10000 ) UNIT( "ingot" ) TASTE( "Just like pine wood, only different. Does not taste of chicken." ) ICON( '*', 0x88, LAYER_ITEMS ) mapping query_aspects() { return ([ C_RAW, C_METAL, C_COPPER ]); }
23.789474
103
0.69469
034b0f381aaac099e54c439802fae530e15d6f02
9,311
h
C
vendor/lerc/src/src/Lerc.h
DaYeSquad/tif2lerc-cpp
0e3a664b209a908e0db8f7fd58412360d0654a14
[ "Apache-2.0" ]
10
2017-01-23T03:14:05.000Z
2022-01-18T15:09:31.000Z
vendor/lerc/src/src/Lerc.h
DaYeSquad/tif2lerc-cpp
0e3a664b209a908e0db8f7fd58412360d0654a14
[ "Apache-2.0" ]
null
null
null
vendor/lerc/src/src/Lerc.h
DaYeSquad/tif2lerc-cpp
0e3a664b209a908e0db8f7fd58412360d0654a14
[ "Apache-2.0" ]
4
2017-01-23T03:14:09.000Z
2021-11-01T02:29:31.000Z
/* Copyright 2015 Esri Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. A local copy of the license and additional notices are located with the source distribution at: http://github.com/Esri/lerc/ Contributors: Thomas Maurer */ #pragma once #include <cstring> #include <vector> #include "Lerc_types.h" #include "BitMask.h" #include "Lerc2.h" NAMESPACE_LERC_START #ifdef HAVE_LERC1_DECODE class CntZImage; #endif class Lerc { public: Lerc() {} ~Lerc() {} // data types supported by Lerc enum DataType { DT_Char, DT_Byte, DT_Short, DT_UShort, DT_Int, DT_UInt, DT_Float, DT_Double, DT_Undefined }; // all functions are provided in 2 flavors // - using void pointers to the image data, can be called on a Lerc lib or dll // - data templated, can be called if compiled together // Encode // if more than 1 band, the outgoing Lerc blob has the single band Lerc blobs concatenated; // or, if you have multiple values per pixel and stored as [RGB, RGB, ... ], then set nDim accordingly (e.g., 3) // computes the number of bytes needed to allocate the buffer, accurate to the byte; // does not encode the image data, but uses statistics and formulas to compute the buffer size needed; // this function is optional, you can also use a buffer large enough to call Encode() directly, // or, if encoding a batch of same width / height tiles, call this function once, double the buffer size, and // then just call Encode() on all tiles; static ErrCode ComputeCompressedSize( const void* pData, // raw image data, row by row, band by band int version, // 2 = v2.2, 3 = v2.3, 4 = v2.4 DataType dt, // data type, char to double int nDim, // number of values per pixel int nCols, // number of cols int nRows, // number of rows int nBands, // number of bands const BitMask* pBitMask, // 0 if all pixels are valid double maxZErr, // max coding error per pixel, defines the precision unsigned int& numBytesNeeded); // size of outgoing Lerc blob // encodes or compresses the image data into the buffer static ErrCode Encode( const void* pData, // raw image data, row by row, band by band int version, // 2 = v2.2, 3 = v2.3, 4 = v2.4 DataType dt, // data type, char to double int nDim, // number of values per pixel int nCols, // number of cols int nRows, // number of rows int nBands, // number of bands const BitMask* pBitMask, // 0 if all pixels are valid double maxZErr, // max coding error per pixel, defines the precision Byte* pBuffer, // buffer to write to, function fails if buffer too small unsigned int numBytesBuffer, // buffer size unsigned int& numBytesWritten); // num bytes written to buffer // Decode struct LercInfo { int version, // Lerc version number (0 for old Lerc1, 1 to 4 for Lerc 2.1 to 2.4) nDim, // number of values per pixel nCols, // number of columns nRows, // number of rows numValidPixel, // number of valid pixels nBands, // number of bands blobSize; // total blob size in bytes DataType dt; // data type (float only for old Lerc1) double zMin, // min pixel value, over all data values zMax, // max pixel value, over all data values maxZError; // maxZError used for encoding void RawInit() { memset(this, 0, sizeof(struct LercInfo)); } }; // again, this function is optional; // call it on a Lerc blob to get the above struct returned, from this the data arrays // can be constructed before calling Decode(); // same as above, for a batch of Lerc blobs of the same kind, you can call this function on // the first blob, get the info, and on the other Lerc blobs just call Decode(); // this function is very fast on (newer) Lerc2 blobs as it only reads the blob headers; // Remark on param numBytesBlob. Usually it is known, either the file size of the blob written to disk, // or the size of the blob transmitted. It should be accurate for 2 reasons: // _ function finds out how many single band Lerc blobs are concatenated // _ function checks for truncated file or blob // It is OK to pass numBytesBlob too large as long as there is no other (valid) Lerc blob following next. // If in doubt, check the code in Lerc::GetLercInfo(...) for the exact logic. static ErrCode GetLercInfo(const Byte* pLercBlob, // Lerc blob to decode unsigned int numBytesBlob, // size of Lerc blob in bytes struct LercInfo& lercInfo); // setup outgoing arrays accordingly, then call Decode() static ErrCode Decode( const Byte* pLercBlob, // Lerc blob to decode unsigned int numBytesBlob, // size of Lerc blob in bytes BitMask* pBitMask, // gets filled if not 0, even if all valid int nDim, // number of values per pixel int nCols, // number of cols int nRows, // number of rows int nBands, // number of bands DataType dt, // data type of outgoing array void* pData); // outgoing data bands static ErrCode ConvertToDouble( const void* pDataIn, // pixel data of image tile of data type dt (< double) DataType dt, // data type of input data size_t nDataValues, // total number of data values (nDim * nCols * nRows * nBands) double* pDataOut); // pixel data converted to double // same as functions above, but data templated instead of using void pointers template<class T> static ErrCode ComputeCompressedSizeTempl( const T* pData, // raw image data, row by row, band by int version, // 2 = v2.2, 3 = v2.3, 4 = v2.4 int nDim, // number of values per pixel int nCols, // number of cols int nRows, // number of rows int nBands, // number of bands const BitMask* pBitMask, // 0 means all pixels are valid double maxZErr, // max coding error per pixel, defines the precision unsigned int& numBytes); // size of outgoing Lerc blob template<class T> static ErrCode EncodeTempl( const T* pData, // raw image data, row by row, band by band int version, // 2 = v2.2, 3 = v2.3, 4 = v2.4 int nDim, // number of values per pixel int nCols, // number of cols int nRows, // number of rows int nBands, // number of bands const BitMask* pBitMask, // 0 means all pixels are valid double maxZErr, // max coding error per pixel, defines the precision Byte* pBuffer, // buffer to write to, function will fail if buffer too small unsigned int numBytesBuffer, // buffer size unsigned int& numBytesWritten); // num bytes written to buffer template<class T> static ErrCode DecodeTempl( T* pData, // outgoing data bands const Byte* pLercBlob, // Lerc blob to decode unsigned int numBytesBlob, // size of Lerc blob in bytes int nDim, // number of values per pixel int nCols, // number of cols int nRows, // number of rows int nBands, // number of bands BitMask* pBitMask); // gets filled if not 0, even if all valid private: #ifdef HAVE_LERC1_DECODE template<class T> static bool Convert(const CntZImage& zImg, T* arr, BitMask* pBitMask); #endif template<class T> static ErrCode ConvertToDoubleTempl(const T* pDataIn, size_t nDataValues, double* pDataOut); }; NAMESPACE_LERC_END
48.243523
117
0.577167
034d0397acf58fece74de74175740930bd8227f0
24,664
c
C
App Installer/libProvision/libplist/plist.c
SHAKY404/App-Installer
93d89ab940fe37c5233db99eb578c1f8949fad93
[ "MIT" ]
135
2017-06-25T03:20:46.000Z
2022-03-15T12:35:33.000Z
App Installer/libProvision/libplist/plist.c
SHAKY404/App-Installer
93d89ab940fe37c5233db99eb578c1f8949fad93
[ "MIT" ]
15
2017-06-27T09:38:33.000Z
2021-05-25T22:00:51.000Z
App Installer/libProvision/libplist/plist.c
SHAKY404/App-Installer
93d89ab940fe37c5233db99eb578c1f8949fad93
[ "MIT" ]
45
2017-06-27T10:39:34.000Z
2021-08-29T10:21:55.000Z
/* * plist.c * Builds plist XML structures * * Copyright (c) 2009-2016 Nikias Bassen All Rights Reserved. * Copyright (c) 2010-2015 Martin Szulecki All Rights Reserved. * Copyright (c) 2008 Zach C. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <string.h> #include <assert.h> #include "plist.h" #include <stdlib.h> #include <stdio.h> #include <math.h> #ifdef WIN32 #include <windows.h> #else #include <pthread.h> #endif #include "libcnary/node.h" #include "libcnary/node_iterator.h" #include "hashtable.h" extern void plist_xml_init(void); extern void plist_xml_deinit(void); extern void plist_bin_init(void); extern void plist_bin_deinit(void); static void internal_plist_init(void) { plist_bin_init(); plist_xml_init(); } static void internal_plist_deinit(void) { plist_bin_deinit(); plist_xml_deinit(); } #ifdef WIN32 typedef volatile struct { LONG lock; int state; } thread_once_t; static thread_once_t init_once = {0, 0}; static thread_once_t deinit_once = {0, 0}; void thread_once(thread_once_t *once_control, void (*init_routine)(void)) { while (InterlockedExchange(&(once_control->lock), 1) != 0) { Sleep(1); } if (!once_control->state) { once_control->state = 1; init_routine(); } InterlockedExchange(&(once_control->lock), 0); } BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) { switch (dwReason) { case DLL_PROCESS_ATTACH: thread_once(&init_once, internal_plist_init); break; case DLL_PROCESS_DETACH: thread_once(&deinit_once, internal_plist_deinit); break; default: break; } return 1; } #else static pthread_once_t init_once = PTHREAD_ONCE_INIT; static pthread_once_t deinit_once = PTHREAD_ONCE_INIT; static void __attribute__((constructor)) libplist_initialize(void) { pthread_once(&init_once, internal_plist_init); } static void __attribute__((destructor)) libplist_deinitialize(void) { pthread_once(&deinit_once, internal_plist_deinit); } #endif PLIST_API int plist_is_binary(const char *plist_data, uint32_t length) { if (length < 8) { return 0; } return (memcmp(plist_data, "bplist00", 8) == 0); } PLIST_API void plist_from_memory(const char *plist_data, uint32_t length, plist_t * plist) { if (length < 8) { *plist = NULL; return; } if (plist_is_binary(plist_data, length)) { plist_from_bin(plist_data, length, plist); } else { plist_from_xml(plist_data, length, plist); } } plist_t plist_new_node(plist_data_t data) { return (plist_t) node_create(NULL, data); } plist_data_t plist_get_data(const plist_t node) { if (!node) return NULL; return ((node_t*)node)->data; } plist_data_t plist_new_plist_data(void) { plist_data_t data = (plist_data_t) calloc(sizeof(struct plist_data_s), 1); return data; } static unsigned int dict_key_hash(const void *data) { plist_data_t keydata = (plist_data_t)data; unsigned int hash = 5381; size_t i; char *str = keydata->strval; for (i = 0; i < keydata->length; str++, i++) { hash = ((hash << 5) + hash) + *str; } return hash; } static int dict_key_compare(const void* a, const void* b) { plist_data_t data_a = (plist_data_t)a; plist_data_t data_b = (plist_data_t)b; if (data_a->strval == NULL || data_b->strval == NULL) { return FALSE; } if (data_a->length != data_b->length) { return FALSE; } return (strcmp(data_a->strval, data_b->strval) == 0) ? TRUE : FALSE; } void plist_free_data(plist_data_t data) { if (data) { switch (data->type) { case PLIST_KEY: case PLIST_STRING: free(data->strval); break; case PLIST_DATA: free(data->buff); break; case PLIST_DICT: hash_table_destroy(data->hashtable); break; default: break; } free(data); } } static int plist_free_node(node_t* node) { plist_data_t data = NULL; int node_index = node_detach(node->parent, node); data = plist_get_data(node); plist_free_data(data); node->data = NULL; node_iterator_t *ni = node_iterator_create(node->children); node_t *ch; while ((ch = node_iterator_next(ni))) { plist_free_node(ch); } node_iterator_destroy(ni); node_destroy(node); return node_index; } PLIST_API plist_t plist_new_dict(void) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_DICT; return plist_new_node(data); } PLIST_API plist_t plist_new_array(void) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_ARRAY; return plist_new_node(data); } //These nodes should not be handled by users static plist_t plist_new_key(const char *val) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_KEY; data->strval = strdup(val); data->length = strlen(val); return plist_new_node(data); } PLIST_API plist_t plist_new_string(const char *val) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_STRING; data->strval = strdup(val); data->length = strlen(val); return plist_new_node(data); } PLIST_API plist_t plist_new_bool(uint8_t val) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_BOOLEAN; data->boolval = val; data->length = sizeof(uint8_t); return plist_new_node(data); } PLIST_API plist_t plist_new_uint(uint64_t val) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_UINT; data->intval = val; data->length = sizeof(uint64_t); return plist_new_node(data); } PLIST_API plist_t plist_new_uid(uint64_t val) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_UID; data->intval = val; data->length = sizeof(uint64_t); return plist_new_node(data); } PLIST_API plist_t plist_new_real(double val) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_REAL; data->realval = val; data->length = sizeof(double); return plist_new_node(data); } PLIST_API plist_t plist_new_data(const char *val, uint64_t length) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_DATA; data->buff = (uint8_t *) malloc(length); memcpy(data->buff, val, length); data->length = length; return plist_new_node(data); } PLIST_API plist_t plist_new_date(int32_t sec, int32_t usec) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_DATE; data->realval = (double)sec + (double)usec / 1000000; data->length = sizeof(double); return plist_new_node(data); } PLIST_API void plist_free(plist_t plist) { if (plist) { plist_free_node(plist); } } static void plist_copy_node(node_t *node, void *parent_node_ptr) { plist_type node_type = PLIST_NONE; plist_t newnode = NULL; plist_data_t data = plist_get_data(node); plist_data_t newdata = plist_new_plist_data(); assert(data); // plist should always have data memcpy(newdata, data, sizeof(struct plist_data_s)); node_type = plist_get_node_type(node); switch (node_type) { case PLIST_DATA: newdata->buff = (uint8_t *) malloc(data->length); memcpy(newdata->buff, data->buff, data->length); break; case PLIST_KEY: case PLIST_STRING: newdata->strval = strdup((char *) data->strval); break; case PLIST_DICT: if (data->hashtable) { hashtable_t* ht = hash_table_new(dict_key_hash, dict_key_compare, NULL); assert(ht); plist_t current = NULL; for (current = (plist_t)node_first_child(node); ht && current; current = (plist_t)node_next_sibling(node_next_sibling(current))) { hash_table_insert(ht, ((node_t*)current)->data, node_next_sibling(current)); } newdata->hashtable = ht; } break; default: break; } newnode = plist_new_node(newdata); if (*(plist_t*)parent_node_ptr) { node_attach(*(plist_t*)parent_node_ptr, newnode); } else { *(plist_t*)parent_node_ptr = newnode; } node_iterator_t *ni = node_iterator_create(node->children); node_t *ch; while ((ch = node_iterator_next(ni))) { plist_copy_node(ch, &newnode); } node_iterator_destroy(ni); } PLIST_API plist_t plist_copy(plist_t node) { plist_t copied = NULL; plist_copy_node(node, &copied); return copied; } PLIST_API uint32_t plist_array_get_size(plist_t node) { uint32_t ret = 0; if (node && PLIST_ARRAY == plist_get_node_type(node)) { ret = node_n_children(node); } return ret; } PLIST_API plist_t plist_array_get_item(plist_t node, uint32_t n) { plist_t ret = NULL; if (node && PLIST_ARRAY == plist_get_node_type(node)) { ret = (plist_t)node_nth_child(node, n); } return ret; } PLIST_API uint32_t plist_array_get_item_index(plist_t node) { plist_t father = plist_get_parent(node); if (PLIST_ARRAY == plist_get_node_type(father)) { return node_child_position(father, node); } return 0; } PLIST_API void plist_array_set_item(plist_t node, plist_t item, uint32_t n) { if (node && PLIST_ARRAY == plist_get_node_type(node)) { plist_t old_item = plist_array_get_item(node, n); if (old_item) { int idx = plist_free_node(old_item); if (idx < 0) { node_attach(node, item); } else { node_insert(node, idx, item); } } } return; } PLIST_API void plist_array_append_item(plist_t node, plist_t item) { if (node && PLIST_ARRAY == plist_get_node_type(node)) { node_attach(node, item); } return; } PLIST_API void plist_array_insert_item(plist_t node, plist_t item, uint32_t n) { if (node && PLIST_ARRAY == plist_get_node_type(node)) { node_insert(node, n, item); } return; } PLIST_API void plist_array_remove_item(plist_t node, uint32_t n) { if (node && PLIST_ARRAY == plist_get_node_type(node)) { plist_t old_item = plist_array_get_item(node, n); if (old_item) { plist_free(old_item); } } return; } PLIST_API uint32_t plist_dict_get_size(plist_t node) { uint32_t ret = 0; if (node && PLIST_DICT == plist_get_node_type(node)) { ret = node_n_children(node) / 2; } return ret; } PLIST_API void plist_dict_new_iter(plist_t node, plist_dict_iter *iter) { if (iter && *iter == NULL) { *iter = malloc(sizeof(uint32_t)); *((uint32_t*)(*iter)) = 0; } return; } PLIST_API void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val) { uint32_t* iter_int = (uint32_t*) iter; if (key) { *key = NULL; } if (val) { *val = NULL; } if (node && PLIST_DICT == plist_get_node_type(node) && *iter_int < node_n_children(node)) { if (key) { plist_get_key_val((plist_t)node_nth_child(node, *iter_int), key); } if (val) { *val = (plist_t) node_nth_child(node, *iter_int + 1); } *iter_int += 2; } return; } PLIST_API void plist_dict_get_item_key(plist_t node, char **key) { plist_t father = plist_get_parent(node); if (PLIST_DICT == plist_get_node_type(father)) { plist_get_key_val( (plist_t) node_prev_sibling(node), key); } } PLIST_API plist_t plist_dict_get_item(plist_t node, const char* key) { plist_t ret = NULL; if (node && PLIST_DICT == plist_get_node_type(node)) { plist_data_t data = plist_get_data(node); hashtable_t *ht = (hashtable_t*)data->hashtable; if (ht) { struct plist_data_s sdata; sdata.strval = (char*)key; sdata.length = strlen(key); ret = (plist_t)hash_table_lookup(ht, &sdata); } else { plist_t current = NULL; for (current = (plist_t)node_first_child(node); current; current = (plist_t)node_next_sibling(node_next_sibling(current))) { data = plist_get_data(current); assert( PLIST_KEY == plist_get_node_type(current) ); if (data && !strcmp(key, data->strval)) { ret = (plist_t)node_next_sibling(current); break; } } } } return ret; } PLIST_API void plist_dict_set_item(plist_t node, const char* key, plist_t item) { if (node && PLIST_DICT == plist_get_node_type(node)) { node_t* old_item = plist_dict_get_item(node, key); plist_t key_node = NULL; if (old_item) { int idx = plist_free_node(old_item); if (idx < 0) { node_attach(node, item); } else { node_insert(node, idx, item); } key_node = node_prev_sibling(item); } else { key_node = plist_new_key(key); node_attach(node, key_node); node_attach(node, item); } hashtable_t *ht = ((plist_data_t)((node_t*)node)->data)->hashtable; if (ht) { /* store pointer to item in hash table */ hash_table_insert(ht, (plist_data_t)((node_t*)key_node)->data, item); } else { if (((node_t*)node)->count > 500) { /* make new hash table */ ht = hash_table_new(dict_key_hash, dict_key_compare, NULL); /* calculate the hashes for all entries we have so far */ plist_t current = NULL; for (current = (plist_t)node_first_child(node); ht && current; current = (plist_t)node_next_sibling(node_next_sibling(current))) { hash_table_insert(ht, ((node_t*)current)->data, node_next_sibling(current)); } ((plist_data_t)((node_t*)node)->data)->hashtable = ht; } } } return; } PLIST_API void plist_dict_insert_item(plist_t node, const char* key, plist_t item) { plist_dict_set_item(node, key, item); } PLIST_API void plist_dict_remove_item(plist_t node, const char* key) { if (node && PLIST_DICT == plist_get_node_type(node)) { plist_t old_item = plist_dict_get_item(node, key); if (old_item) { plist_t key_node = node_prev_sibling(old_item); hashtable_t* ht = ((plist_data_t)((node_t*)node)->data)->hashtable; if (ht) { hash_table_remove(ht, ((node_t*)key_node)->data); } plist_free(key_node); plist_free(old_item); } } return; } PLIST_API void plist_dict_merge(plist_t *target, plist_t source) { if (!target || !*target || (plist_get_node_type(*target) != PLIST_DICT) || !source || (plist_get_node_type(source) != PLIST_DICT)) return; char* key = NULL; plist_dict_iter it = NULL; plist_t subnode = NULL; plist_dict_new_iter(source, &it); if (!it) return; do { plist_dict_next_item(source, it, &key, &subnode); if (!key) break; plist_dict_set_item(*target, key, plist_copy(subnode)); free(key); key = NULL; } while (1); free(it); } PLIST_API plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v) { plist_t current = plist; plist_type type = PLIST_NONE; uint32_t i = 0; for (i = 0; i < length && current; i++) { type = plist_get_node_type(current); if (type == PLIST_ARRAY) { uint32_t n = va_arg(v, uint32_t); current = plist_array_get_item(current, n); } else if (type == PLIST_DICT) { const char* key = va_arg(v, const char*); current = plist_dict_get_item(current, key); } } return current; } PLIST_API plist_t plist_access_path(plist_t plist, uint32_t length, ...) { plist_t ret = NULL; va_list v; va_start(v, length); ret = plist_access_pathv(plist, length, v); va_end(v); return ret; } static void plist_get_type_and_value(plist_t node, plist_type * type, void *value, uint64_t * length) { plist_data_t data = NULL; if (!node) return; data = plist_get_data(node); *type = data->type; *length = data->length; switch (*type) { case PLIST_BOOLEAN: *((char *) value) = data->boolval; break; case PLIST_UINT: case PLIST_UID: *((uint64_t *) value) = data->intval; break; case PLIST_REAL: case PLIST_DATE: *((double *) value) = data->realval; break; case PLIST_KEY: case PLIST_STRING: *((char **) value) = strdup(data->strval); break; case PLIST_DATA: *((uint8_t **) value) = (uint8_t *) malloc(*length * sizeof(uint8_t)); memcpy(*((uint8_t **) value), data->buff, *length * sizeof(uint8_t)); break; case PLIST_ARRAY: case PLIST_DICT: default: break; } } PLIST_API plist_t plist_get_parent(plist_t node) { return node ? (plist_t) ((node_t*) node)->parent : NULL; } PLIST_API plist_type plist_get_node_type(plist_t node) { if (node) { plist_data_t data = plist_get_data(node); if (data) return data->type; } return PLIST_NONE; } PLIST_API void plist_get_key_val(plist_t node, char **val) { plist_type type = plist_get_node_type(node); uint64_t length = 0; if (PLIST_KEY == type) plist_get_type_and_value(node, &type, (void *) val, &length); assert(length == strlen(*val)); } PLIST_API void plist_get_string_val(plist_t node, char **val) { plist_type type = plist_get_node_type(node); uint64_t length = 0; if (PLIST_STRING == type) plist_get_type_and_value(node, &type, (void *) val, &length); assert(length == strlen(*val)); } PLIST_API void plist_get_bool_val(plist_t node, uint8_t * val) { plist_type type = plist_get_node_type(node); uint64_t length = 0; if (PLIST_BOOLEAN == type) plist_get_type_and_value(node, &type, (void *) val, &length); assert(length == sizeof(uint8_t)); } PLIST_API void plist_get_uint_val(plist_t node, uint64_t * val) { plist_type type = plist_get_node_type(node); uint64_t length = 0; if (PLIST_UINT == type) plist_get_type_and_value(node, &type, (void *) val, &length); assert(length == sizeof(uint64_t) || length == 16); } PLIST_API void plist_get_uid_val(plist_t node, uint64_t * val) { plist_type type = plist_get_node_type(node); uint64_t length = 0; if (PLIST_UID == type) plist_get_type_and_value(node, &type, (void *) val, &length); assert(length == sizeof(uint64_t)); } PLIST_API void plist_get_real_val(plist_t node, double *val) { plist_type type = plist_get_node_type(node); uint64_t length = 0; if (PLIST_REAL == type) plist_get_type_and_value(node, &type, (void *) val, &length); assert(length == sizeof(double)); } PLIST_API void plist_get_data_val(plist_t node, char **val, uint64_t * length) { plist_type type = plist_get_node_type(node); if (PLIST_DATA == type) plist_get_type_and_value(node, &type, (void *) val, length); } PLIST_API void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec) { plist_type type = plist_get_node_type(node); uint64_t length = 0; double val = 0; if (PLIST_DATE == type) plist_get_type_and_value(node, &type, (void *) &val, &length); assert(length == sizeof(double)); *sec = (int32_t)val; *usec = (int32_t)fabs((val - (int64_t)val) * 1000000); } int plist_data_compare(const void *a, const void *b) { plist_data_t val_a = NULL; plist_data_t val_b = NULL; if (!a || !b) return FALSE; if (!((node_t*) a)->data || !((node_t*) b)->data) return FALSE; val_a = plist_get_data((plist_t) a); val_b = plist_get_data((plist_t) b); if (val_a->type != val_b->type) return FALSE; switch (val_a->type) { case PLIST_BOOLEAN: case PLIST_UINT: case PLIST_REAL: case PLIST_DATE: case PLIST_UID: if (val_a->length != val_b->length) return FALSE; if (val_a->intval == val_b->intval) //it is an union so this is sufficient return TRUE; else return FALSE; case PLIST_KEY: case PLIST_STRING: if (!strcmp(val_a->strval, val_b->strval)) return TRUE; else return FALSE; case PLIST_DATA: if (val_a->length != val_b->length) return FALSE; if (!memcmp(val_a->buff, val_b->buff, val_a->length)) return TRUE; else return FALSE; case PLIST_ARRAY: case PLIST_DICT: //compare pointer if (a == b) return TRUE; else return FALSE; break; default: break; } return FALSE; } PLIST_API char plist_compare_node_value(plist_t node_l, plist_t node_r) { return plist_data_compare(node_l, node_r); } static void plist_set_element_val(plist_t node, plist_type type, const void *value, uint64_t length) { //free previous allocated buffer plist_data_t data = plist_get_data(node); assert(data); // a node should always have data attached switch (data->type) { case PLIST_KEY: case PLIST_STRING: free(data->strval); data->strval = NULL; break; case PLIST_DATA: free(data->buff); data->buff = NULL; break; default: break; } //now handle value data->type = type; data->length = length; switch (type) { case PLIST_BOOLEAN: data->boolval = *((char *) value); break; case PLIST_UINT: case PLIST_UID: data->intval = *((uint64_t *) value); break; case PLIST_REAL: case PLIST_DATE: data->realval = *((double *) value); break; case PLIST_KEY: case PLIST_STRING: data->strval = strdup((char *) value); break; case PLIST_DATA: data->buff = (uint8_t *) malloc(length); memcpy(data->buff, value, length); break; case PLIST_ARRAY: case PLIST_DICT: default: break; } } PLIST_API void plist_set_key_val(plist_t node, const char *val) { plist_set_element_val(node, PLIST_KEY, val, strlen(val)); } PLIST_API void plist_set_string_val(plist_t node, const char *val) { plist_set_element_val(node, PLIST_STRING, val, strlen(val)); } PLIST_API void plist_set_bool_val(plist_t node, uint8_t val) { plist_set_element_val(node, PLIST_BOOLEAN, &val, sizeof(uint8_t)); } PLIST_API void plist_set_uint_val(plist_t node, uint64_t val) { plist_set_element_val(node, PLIST_UINT, &val, sizeof(uint64_t)); } PLIST_API void plist_set_uid_val(plist_t node, uint64_t val) { plist_set_element_val(node, PLIST_UID, &val, sizeof(uint64_t)); } PLIST_API void plist_set_real_val(plist_t node, double val) { plist_set_element_val(node, PLIST_REAL, &val, sizeof(double)); } PLIST_API void plist_set_data_val(plist_t node, const char *val, uint64_t length) { plist_set_element_val(node, PLIST_DATA, val, length); } PLIST_API void plist_set_date_val(plist_t node, int32_t sec, int32_t usec) { double val = (double)sec + (double)usec / 1000000; plist_set_element_val(node, PLIST_DATE, &val, sizeof(struct timeval)); }
25.453044
131
0.625568