blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
721
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
5
91
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
321 values
visit_date
timestamp[ns]date
2016-08-12 09:31:09
2023-09-06 10:45:07
revision_date
timestamp[ns]date
2010-09-28 14:01:40
2023-09-06 06:22:19
committer_date
timestamp[ns]date
2010-09-28 14:01:40
2023-09-06 06:22:19
github_id
int64
426
681M
star_events_count
int64
101
243k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[ns]date
2012-06-28 18:51:49
2023-09-14 21:59:16
gha_created_at
timestamp[ns]date
2008-02-11 22:55:26
2023-08-10 11:14:58
gha_language
stringclasses
147 values
src_encoding
stringclasses
26 values
language
stringclasses
2 values
is_vendor
bool
2 classes
is_generated
bool
2 classes
length_bytes
int64
6
10.2M
extension
stringclasses
115 values
filename
stringlengths
3
113
content
stringlengths
6
10.2M
ae174de51f49044ab730a4963578e47117db5017
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/Infineon/libraries/IFX_PSOC6_HAL/mtb-pdl-cat1/drivers/include/cy_adcmic.h
2653daf88402cbed08291d534c73819bb981a199
[ "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-warranty-disclaimer", "GPL-1.0-or-later" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
56,524
h
cy_adcmic.h
/***************************************************************************//** * \file cy_adcmic.h * \version 1.0 * * Provides an API declaration of the ADCMic driver. * ******************************************************************************** * \copyright * Copyright 2022 Cypress Semiconductor Corporation * SPDX-License-Identifier: Apache-2.0 * * 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. *******************************************************************************/ /** * \addtogroup group_adcmic * \{ * ADCMic driver is used to process analog and digital microphone signal and * DC signal with the mxs40adcmic IP. This IP interfaces with Delta-Sigma modulator part * of the s40adcmic and implements CIC, decimation (FIR) and biquad filters. * The ADC result is read by the CPU or the DMA from the FIFO of mxs40adcmic * (and from CIC register for DC measurement). Instead of taking modulator data * from s40adcmic, mxs40adcmic can also be configured to take PDM input * directly from an external digital microphone. * * \image html ADCMicBlockDiagram.png * * Consult the datasheet of your device for details of the * clocking system. * * The high level features of the subsystem are: * - Analog (MIC) and digital (PDM) microphones support. * - Sample rate 8/16 ksps for audio (MIC and PDM modes). * - Configurable biquad filter for custom audio equalization. * - Selectable DC measurement range. * - Interrupt & trigger generation. * - Built-in FIFO buffer (for audio only). * * \section group_adcmic_usage Usage * * The high level steps to use this driver are: * * -# \ref group_adcmic_initialization * -# \ref group_adcmic_clock * -# \ref group_adcmic_trigger * -# \ref group_adcmic_timer * -# \ref group_adcmic_interrupt * -# \ref group_adcmic_dc_measurement * -# \ref group_adcmic_fifo * * \section group_adcmic_initialization Initialization and Enabling * * To configure the ADCMic subsystem call \ref Cy_ADCMic_Init. * Pass in a pointer to the \ref MXS40ADCMIC_Type structure for the base hardware register address, * pass in the configuration structure \ref cy_stc_adcmic_config_t, and * pass in the operation mode. * * After initialization, call \ref Cy_ADCMic_Enable to enable the block. * * The configuration can be defined as follows: * \snippet adcmic_snippet/snippet.c SNIPPET_ADCMIC_CFG * * \subsection group_adcmic_mic Analog Microphone (MIC) Mode * * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_MIC_OP * * Usually the MIC mode is used with FIFO, see \ref group_adcmic_fifo * * \subsection group_adcmic_pdm Digital Microphone (PDM) Mode * * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_PDM_OP * * Usually the MIC mode is used with FIFO, see \ref group_adcmic_fifo * * \subsection group_adcmic_dc DC Measurement (DC) Mode * * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_DC_OP * * \subsection group_adcmic_biquad Biquad filter Initialization * * The biquad filter usually is used to the audio stream equalization (in MIC or PDM modes): * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_BIQUAD * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_BIQUAD_INIT * * \section group_adcmic_clock Clocks * * The ADCMic requires two input clocks: * - clk_sys - recommended frequency is 96MHz, input for the \ref group_adcmic_timer, usually is routed from one of the \ref group_sysclk_clk_hf * - clk_hf - recommended frequency is 24MHz, the audio (MIC and PDM modes) reference clock, usually is routed from one of the \ref group_sysclk_clk_hf * * For more exact information on the ADCMic clock routing, refer to the datasheet for your device. * * \section group_adcmic_trigger Triggering * * The ADCMic subsystem has two output triggers: from the timer and from the FIFO, * the timer generates trigger always if enabled, the FIFO trigger could be * configured separately for MIC and PDM modes by the \ref cy_stc_adcmic_mic_config_t::fifoTrigger and * \ref cy_stc_adcmic_pdm_config_t::fifoTrigger respectively. * * Also, they could be routed to any periphery using \ref group_trigmux driver, e.g. to DW block: * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_TRIGGER * * \section group_adcmic_timer Timer * * The Timer is used for DC measurement for two purposes: * - generate periodic events based on ADCMic clk_sys clock. * - count the CIC data update events. * * The timer period and input signal source are configured by the \ref cy_stc_adcmic_dc_config_t::timerPeriod and * \ref cy_stc_adcmic_dc_config_t::timerInput fields correspondingly. * * \section group_adcmic_interrupt Handling Interrupts * * The ADCMic subsystem has two interrupt sources: the timer and the FIFO. * The FIFO interrupt can have several reasons, see \ref group_adcmic_macros_fifo_status * * The ADCMic interrupt to the NVIC is raised any time the intersection (logic and) of the interrupt * flags and the corresponding interrupt masks are non-zero. * * Implement an interrupt routine and assign it to the ADCMic interrupt. * Use the pre-defined enumeration, adcmic_interrupt_adcmic_IRQn, as the interrupt source for the ADCMic. * * The following code snippet demonstrates how to implement a routine to handle the interrupt. * The routine gets called when any one of the ADCMic interrupts are triggered. * When servicing an interrupt, the user must clear the interrupt so that subsequent * interrupts can be handled. * * The following code snippet demonstrates how to configure and enable the interrupt. * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_ISR * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_CONFIG_INTR * * Alternately, instead of handling the interrupts, the \ref Cy_ADCMic_IsEndConversion function * allows for firmware polling of the end of DC conversion status. * * \section group_adcmic_fifo FIFO Usage * The ADCMic subsystem in the MIC and PDM modes stores the audio data into the FIFO. * It can be configured separately for the MIC and PDM modes using * \ref cy_stc_adcmic_mic_config_t::fifoFull, * \ref cy_stc_adcmic_mic_config_t::fifoEmpty and * \ref cy_stc_adcmic_pdm_config_t::fifoFull, * \ref cy_stc_adcmic_pdm_config_t::fifoEmpty * respectively and served either by ISR: * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_ISR * Or by DMA: * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_TRIGGER * * \section group_adcmic_dc_measurement DC Voltage Measurement Accuracy * * * The Offset is practically a raw count of the measured Ground voltage. * * The Gain is essentially an amount of raw counts per 1 Volt of input voltage. * It depends on the DC measurement range \ref cy_en_adcmic_dc_range_t. * * The default Offset \ref CY_ADCMIC_DC_OFFSET and * Gain for both ranges \ref CY_ADCMIC_DC_1_8_GAIN and \ref CY_ADCMIC_DC_3_6_GAIN are precalculated * based on the theory of the ADCMic operation \ref group_adcmic_macros_dc_measurement. * * So basically the raw count retrieved using \ref Cy_ADCMic_GetDcResult for the desired DC input * can be directly feed into any of the \ref Cy_ADCMic_CountsTo_Volts, \ref Cy_ADCMic_CountsTo_mVolts, * or \ref Cy_ADCMic_CountsTo_uVolts functions and have for some extend accurate result. * * However, to increase the accuracy the real ADCMic Gain and Offset can be defined by physically * measuring the Reference Ground \ref CY_ADCMIC_REFGND and the Reference BandGap \ref CY_ADCMIC_BGREF. * * For example: * \snippet adcmic_snippet/snippet.c SNIPPET_ADCMIC_DC_MEASURE_AVG * \note this code snippet is not the only valid way to use this driver - it is just one possible example how it can be used. * * \subsection group_adcmic_dc_vbg_calib BandGap Calibration * For further increase the measurement accuracy, the real BandGap voltage can be defined * using external precise reference with exact known voltage: * * Real BandGap voltage = external reference exact voltage * (BandGap counts - GND counts) / (external reference counts - GND counts). * * And then use it in the Gain calculation as shown above instead of the nominal BandGap voltage \ref CY_ADCMIC_DC_VBG. * * \subsection group_adcmic_dc_double_sampling Correlated Double Sampling * To further improve the DC measurement accuracy, the low frequency Noise could be dynamically * removed by performing two measurements for each input channel sequentially: * one measuring the desired DC input and the other one measuring the \ref CY_ADCMIC_REFGND. * The second measurement of the\ref CY_ADCMIC_REFGND contains only the low frequency Noise (Flick Noise) information. * It is important to perform these two measurements one after another as close as possible. * The final true ADC output value is then obtained by subtracting the ADC output of the * second measurement from the ADC output of the first measurement. * * For example: * \snippet adcmic_snippet/snippet.c SNIPPET_ADCMIC_DC_MEASURE_DS * \note this code snippet is not the only valid way to use this driver - it is just one possible example how it can be used. * * \section group_adcmic_more_information More Information * For more information on the ADCMic ADC subsystem, refer to the datasheet of your device. * * \section group_adcmic_changelog Changelog * <table class="doxtable"> * <tr><th>Version</th><th>Changes</th><th>Reason for Change</th></tr> * <tr> * <td>1.0</td> * <td> * The cy_en_adcmic_source_t is renamed to \ref cy_en_adcmic_mode_t.<br> * The CY_ADCMIC_480KSPS item is removed from the \ref cy_en_adcmic_sample_rate_t.<br> * The cy_en_adcmic_dc_conv_time_t is removed.<br> * The cy_stc_adcmic_fifo_config_t is removed.<br> * The cy_en_adcmic_dc_result_latch_mode_t is removed.<br> * The cy_stc_adcmic_audio_analog_path_config_t is renamed to \ref cy_stc_adcmic_mic_config_t.<br> * The cy_stc_adcmic_audio_digital_path_config_t is renamed to \ref cy_stc_adcmic_pdm_config_t.<br> * The cy_stc_adcmic_dc_path_config_t is renamed to \ref cy_stc_adcmic_dc_config_t.<br> * * The micPd parameter is removed from the \ref cy_stc_adcmic_mic_config_t<br> * * The next parameters are added into \ref cy_stc_adcmic_mic_config_t :<br> * * \ref cy_stc_adcmic_mic_config_t::sampleRate,<br> * * \ref cy_stc_adcmic_mic_config_t::biQuadConfig,<br> * * \ref cy_stc_adcmic_mic_config_t::fifoTrigger,<br> * * \ref cy_stc_adcmic_mic_config_t::fifoFull,<br> * * \ref cy_stc_adcmic_mic_config_t::fifoEmpty.<br> * * The clockDiv parameter is removed from the \ref cy_stc_adcmic_pdm_config_t<br> * * The next parameters are added into \ref cy_stc_adcmic_pdm_config_t :<br> * * \ref cy_stc_adcmic_pdm_config_t::sampleRate,<br> * * \ref cy_stc_adcmic_pdm_config_t::biQuadConfig,<br> * * \ref cy_stc_adcmic_pdm_config_t::fifoTrigger,<br> * * \ref cy_stc_adcmic_pdm_config_t::fifoFull,<br> * * \ref cy_stc_adcmic_pdm_config_t::fifoEmpty.<br> * * The next parameters are removed from the \ref cy_stc_adcmic_dc_config_t :<br> * * tmrLatch,<br> * * time.<br> * * The next parameter is renamed in the \ref cy_stc_adcmic_dc_config_t :<br> * * input -> \ref cy_stc_adcmic_dc_config_t::channel.<br> * * The next parameters are added into \ref cy_stc_adcmic_dc_config_t :<br> * * \ref cy_stc_adcmic_dc_config_t::timerPeriod,<br> * * \ref cy_stc_adcmic_dc_config_t::timerInput,<br> * * \ref cy_stc_adcmic_dc_config_t::context.<br> * * The next parameters are removed from the cy_stc_adcmic_config_t :<br> * * clockDiv,<br> * * source,<br> * * sampleRate,<br> * * biQuadConfig,<br> * * fifoConfig,<br> * * tmrTrgConfig.<br> * * The next parameters are renamed in the cy_stc_adcmic_config_t :<br> * * anaConfig -> \ref cy_stc_adcmic_config_t::micConfig,<br> * * digConfig -> \ref cy_stc_adcmic_config_t::pdmConfig.<br> * * The new parameter 'mode' is added to the \ref Cy_ADCMic_Init.<br> * The \ref Cy_ADCMic_Init functions if fixed to proper process the \ref cy_stc_adcmic_mic_config_t::micClamp setting.<br> * The Cy_ADCMic_StartConvert and Cy_ADCMic_StopConvert API functions are removed.<br> * The \ref Cy_ADCMic_Enable and \ref Cy_ADCMic_Disable are updated to inherit the Start/StopConvert functionality.<br> * The Cy_ADCMic_SleepMic and Cy_ADCMic_WakeUpMic API functions are removed.<br> * The \ref Cy_ADCMic_Enable and \ref Cy_ADCMic_Disable are updated to power down all the analog subsystems at disabling and power up them at enabling.<br> * The parameter dcChannel of the \ref Cy_ADCMic_SelectDcChannel is renamed to channel.<br> * The function Cy_ADCMic_SetDcConvTime is removed.<br> * The interface of \ref Cy_ADCMic_SetDcOffset, \ref Cy_ADCMic_SetDcGain, \ref Cy_ADCMic_CountsTo_mVolts, \ref Cy_ADCMic_CountsTo_uVolts,<br> * and \ref Cy_ADCMic_CountsTo_Volts functions is changed: the 'base' parameters are removed, and the 'context' parameters are added.<br> * The documentation is enhanced with code snippets: \ref group_adcmic_dc_measurement, \ref group_adcmic_dc_double_sampling. * </td> * <td>Usability review</td> * </tr> * <tr> * <td>0.1</td> * <td>This is a pre-production driver release. The driver is not recommended for production use, unless the functionality is delivered in Cypress-provided applications.</td> * <td>Pre-production support of the CAT1B Devices</td> * </tr> * </table> * * \defgroup group_adcmic_macros Macros * \{ * \defgroup group_adcmic_macros_interrupt Interrupt Masks * \defgroup group_adcmic_macros_triggers Triggers * \defgroup group_adcmic_macros_reg_pointers Register Pointers * \defgroup group_adcmic_macros_fifo_status FIFO Status Masks * \defgroup group_adcmic_macros_fifo_samples FIFO Samples definitions * \defgroup group_adcmic_macros_dc_measurement DC measurement definitions * \} * \defgroup group_adcmic_enums Enumerated Types * \defgroup group_adcmic_data_structures Data Structures * \defgroup group_adcmic_functions Functions * \{ * \defgroup group_adcmic_functions_basic Initialization and Basic Functions * \defgroup group_adcmic_functions_interrupt Interrupt Functions * \defgroup group_adcmic_functions_fifo FIFO Functions * \defgroup group_adcmic_functions_dc DC Measurement Functions * \defgroup group_adcmic_functions_timer Timer Functions * \defgroup group_adcmic_functions_mic Analog Microphone (MIC) Functions * \} */ #if !defined (CY_ADCMIC_H) #define CY_ADCMIC_H #include "cy_device_headers.h" #if defined (CY_IP_MXS40ADCMIC) #include "cy_syslib.h" #if defined(__cplusplus) extern "C" { #endif /** * \addtogroup group_adcmic_macros * \{ */ /** Driver major version */ #define CY_ADCMIC_DRV_VERSION_MAJOR 1 /** Driver minor version */ #define CY_ADCMIC_DRV_VERSION_MINOR 0 /** ADCMic PDL ID */ #define CY_ADCMIC_ID CY_PDL_DRV_ID(0x48U) /** * \addtogroup group_adcmic_macros_interrupt * \{ */ #define CY_ADCMIC_INTR_DC (MXS40ADCMIC_ADCMIC_INTR_INTERRUPT_DC_Msk) /**< DC interrupt mask */ #define CY_ADCMIC_INTR_DATA (MXS40ADCMIC_ADCMIC_INTR_INTERRUPT_DATA_Msk) /**< DATA interrupt mask */ #define CY_ADCMIC_INTR (CY_ADCMIC_INTR_DC | CY_ADCMIC_INTR_DATA) /**< Combined interrupt mask */ /** \} group_adcmic_macros_interrupt */ /** * \addtogroup group_adcmic_macros_triggers * \{ */ #define CY_ADCMIC_TRIG_DC (MXS40ADCMIC_ADCMIC_TRIGGER_CLR_TR_DC_Msk) /**< DC trigger mask, to be used with \ref Cy_ADCMic_ClearTrigger */ #define CY_ADCMIC_TRIG_DATA (MXS40ADCMIC_ADCMIC_TRIGGER_CLR_TR_DATA_Msk) /**< DATA trigger mask, to be used with \ref Cy_ADCMic_ClearTrigger */ #define CY_ADCMIC_TRIG (CY_ADCMIC_TRIG_DC | CY_ADCMIC_TRIG_DATA) /**< Combined interrupt mask, to be used with \ref Cy_ADCMic_ClearTrigger */ /** \} group_adcmic_macros_triggers */ /** * \addtogroup group_adcmic_macros_reg_pointers * \{ */ /** The pointer to the FIFO data read register, to be used for the DMA data acquisition */ #define CY_ADCMIC_FIFO_DATA_REG_PTR(base) ((void*)&((base)->ADCMIC_DATA)) /** The pointer to the trigger clearing register, to be used for the DMA data acquisition */ #define CY_ADCMIC_TRIGGER_CLR_REG_PTR(base) ((void*)&((base)->ADCMIC_TRIGGER_CLR)) /** \} group_adcmic_macros_reg_pointers */ /** * \addtogroup group_adcmic_macros_fifo_status * \{ */ #define CY_ADCMIC_FIFO_OVERFLOW (0x01U) /**< FIFO overflow status mask */ #define CY_ADCMIC_FIFO_PRG_FULL (0x02U) /**< FIFO programmable full status mask */ #define CY_ADCMIC_FIFO_ALMOST_FULL (0x04U) /**< FIFO almost full status mask */ #define CY_ADCMIC_FIFO_FULL (0x08U) /**< FIFO full status mask */ #define CY_ADCMIC_FIFO_UNDERFLOW (0x10U) /**< FIFO underflow status mask */ #define CY_ADCMIC_FIFO_PRG_EMPTY (0x20U) /**< FIFO programmable empty status mask */ #define CY_ADCMIC_FIFO_ALMOST_EMPTY (0x40U) /**< FIFO almost empty status mask */ #define CY_ADCMIC_FIFO_EMPTY (0x80U) /**< FIFO empty status mask */ /** \} group_adcmic_macros_fifo_status */ /** * \addtogroup group_adcmic_macros_fifo_samples * To be used with low-level API \ref Cy_ADCMic_ReadFifo. * \{ */ #define CY_ADCMIC_FIFO_FIRST_SAMPLE_Pos (0U) /**< the ADCMIC_DATA first sample position */ #define CY_ADCMIC_FIFO_FIRST_SAMPLE_Msk (0x0000FFFFUL) /**< the ADCMIC_DATA first sample mask */ #define CY_ADCMIC_FIFO_SECOND_SAMPLE_Pos (16U) /**< the ADCMIC_DATA second sample position */ #define CY_ADCMIC_FIFO_SECOND_SAMPLE_Msk (0xFFFF0000UL) /**< the ADCMIC_DATA second sample mask */ /** \} group_adcmic_macros_fifo_samples */ /** * \addtogroup group_adcmic_macros_dc_measurement * To be used for DC measurement voltage calculation/calibration. * \{ */ /** The Full Scale counts */ #define CY_ADCMIC_DC_FS (0xFFFFUL) /** The coefficient to calculate lower range limit count */ #define CY_ADCMIC_DC_LO (3U) /** The coefficient to calculate upper range limit count, scaled by 10000 to avoid fractional math */ #define CY_ADCMIC_DC_HI (3725U) /** The default raw count offset for DC measurement */ #define CY_ADCMIC_DC_OFFSET (-((int16_t)CY_SYSLIB_DIV_ROUND(CY_ADCMIC_DC_FS, CY_ADCMIC_DC_LO))) /** The upper range limit count */ #define CY_ADCMIC_DC_HI_CNT ((int16_t)CY_SYSLIB_DIV_ROUND(CY_ADCMIC_DC_FS * CY_ADCMIC_DC_HI, 10000U)) /** The full range counts, scaled by 10 to avoid fractional math */ #define CY_ADCMIC_DC_FS_CNT ((uint32_t)(CY_ADCMIC_DC_HI_CNT - CY_ADCMIC_DC_OFFSET) * 10U) /** The default amount of raw counts per 1 volt for 3.6V range */ #define CY_ADCMIC_DC_3_6_GAIN ((int16_t)CY_SYSLIB_DIV_ROUND(CY_ADCMIC_DC_FS_CNT, 36U)) /** The default amount of raw counts per 1 volt for 1.8V range */ #define CY_ADCMIC_DC_1_8_GAIN ((int16_t)CY_SYSLIB_DIV_ROUND(CY_ADCMIC_DC_FS_CNT, 18U)) /** The BandGap reference nominal voltage in millivolts */ #define CY_ADCMIC_DC_VBG (850L) /** \} group_adcmic_macros_dc_measurement */ /** \} group_adcmic_macros */ /** \addtogroup group_adcmic_enums * \{ */ /** The ADC error codes */ typedef enum { CY_ADCMIC_SUCCESS = 0x00UL, /**< Successful */ CY_ADCMIC_BAD_PARAM = CY_ADCMIC_ID | CY_PDL_STATUS_ERROR | 0x01UL, /**< One or more invalid parameters */ CY_ADCMIC_TIMEOUT = CY_ADCMIC_ID | CY_PDL_STATUS_ERROR | 0x02UL, /**< Timeout */ CY_ADCMIC_CONVERSION_NOT_COMPLETE = CY_ADCMIC_ID | CY_PDL_STATUS_INFO | 0x03UL, /**< Conversion is not complete */ CY_ADCMIC_UNKNOWN = CY_ADCMIC_ID | CY_PDL_STATUS_ERROR | 0xFFUL, /**< Unknown failure */ } cy_en_adcmic_status_t; /** The PGA gain settings */ typedef enum { CY_ADCMIC_PGA_GAIN_0 = 0U, /**< 0 db */ CY_ADCMIC_PGA_GAIN_1 = 1U, /**< 1 db */ CY_ADCMIC_PGA_GAIN_2 = 2U, /**< 2 db */ CY_ADCMIC_PGA_GAIN_3 = 3U, /**< 3 db */ CY_ADCMIC_PGA_GAIN_4 = 4U, /**< 4 db */ CY_ADCMIC_PGA_GAIN_5 = 5U, /**< 5 db */ CY_ADCMIC_PGA_GAIN_6 = 6U, /**< 6 db */ CY_ADCMIC_PGA_GAIN_7 = 7U, /**< 7 db */ CY_ADCMIC_PGA_GAIN_8 = 8U, /**< 8 db */ CY_ADCMIC_PGA_GAIN_9 = 9U, /**< 9 db */ CY_ADCMIC_PGA_GAIN_10 = 10U, /**< 10 db */ CY_ADCMIC_PGA_GAIN_11 = 11U, /**< 11 db */ CY_ADCMIC_PGA_GAIN_12 = 12U, /**< 12 db */ CY_ADCMIC_PGA_GAIN_13 = 13U, /**< 13 db */ CY_ADCMIC_PGA_GAIN_14 = 14U, /**< 14 db */ CY_ADCMIC_PGA_GAIN_15 = 15U, /**< 15 db */ CY_ADCMIC_PGA_GAIN_16 = 16U, /**< 16 db */ CY_ADCMIC_PGA_GAIN_17 = 17U, /**< 17 db */ CY_ADCMIC_PGA_GAIN_18 = 18U, /**< 18 db */ CY_ADCMIC_PGA_GAIN_19 = 19U, /**< 19 db */ CY_ADCMIC_PGA_GAIN_20 = 20U, /**< 20 db */ CY_ADCMIC_PGA_GAIN_21 = 21U, /**< 21 db */ CY_ADCMIC_PGA_GAIN_22 = 22U, /**< 22 db */ CY_ADCMIC_PGA_GAIN_23 = 23U, /**< 23 db */ CY_ADCMIC_PGA_GAIN_24 = 24U, /**< 24 db */ CY_ADCMIC_PGA_GAIN_25 = 25U, /**< 25 db */ CY_ADCMIC_PGA_GAIN_26 = 26U, /**< 26 db */ CY_ADCMIC_PGA_GAIN_27 = 27U, /**< 27 db */ CY_ADCMIC_PGA_GAIN_28 = 28U, /**< 28 db */ CY_ADCMIC_PGA_GAIN_29 = 29U, /**< 29 db */ CY_ADCMIC_PGA_GAIN_30 = 30U, /**< 30 db */ CY_ADCMIC_PGA_GAIN_31 = 31U, /**< 31 db */ CY_ADCMIC_PGA_GAIN_32 = 32U, /**< 32 db */ CY_ADCMIC_PGA_GAIN_33 = 33U, /**< 33 db */ CY_ADCMIC_PGA_GAIN_34 = 34U, /**< 34 db */ CY_ADCMIC_PGA_GAIN_35 = 35U, /**< 35 db */ CY_ADCMIC_PGA_GAIN_36 = 36U, /**< 36 db */ CY_ADCMIC_PGA_GAIN_37 = 37U, /**< 37 db */ CY_ADCMIC_PGA_GAIN_38 = 38U, /**< 38 db */ CY_ADCMIC_PGA_GAIN_39 = 39U, /**< 39 db */ CY_ADCMIC_PGA_GAIN_40 = 40U, /**< 40 db */ CY_ADCMIC_PGA_GAIN_41 = 41U, /**< 41 db */ CY_ADCMIC_PGA_GAIN_42 = 42U /**< 42 db */ } cy_en_adcmic_pga_gain_t; /** The operation mode */ typedef enum { CY_ADCMIC_DC = 1U, /**< DC voltage measurement */ CY_ADCMIC_MIC = 3U, /**< Analog microphone with PGA */ CY_ADCMIC_PDM = 4U /**< PDM digital microphone */ } cy_en_adcmic_mode_t; /** The sample rate for MIC and PDM modes */ typedef enum { CY_ADCMIC_8KSPS, /**< 8 ksps, for microphone only */ CY_ADCMIC_16KSPS /**< 16 ksps, for microphone only */ } cy_en_adcmic_sample_rate_t; /** The DC channel * \note Some options may be unavailable on particular devices. */ typedef enum { CY_ADCMIC_REFGND = 0x0FU, /**< ADC reference ground */ CY_ADCMIC_BGREF = 0x0EU, /**< ADC BG REF */ CY_ADCMIC_VDDC = 0x0DU, /**< Core supply */ CY_ADCMIC_VDDIO = 0x0CU, /**< Battery/IO supply */ CY_ADCMIC_GPIO7 = 0x17U, /**< GPIO 7 */ CY_ADCMIC_GPIO6 = 0x16U, /**< GPIO 6 */ CY_ADCMIC_GPIO5 = 0x15U, /**< GPIO 5 */ CY_ADCMIC_GPIO4 = 0x14U, /**< GPIO 4 */ CY_ADCMIC_GPIO3 = 0x13U, /**< GPIO 3 */ CY_ADCMIC_GPIO2 = 0x12U, /**< GPIO 2 */ CY_ADCMIC_GPIO1 = 0x11U, /**< GPIO 1 */ CY_ADCMIC_GPIO0 = 0x10U /**< GPIO 0 */ } cy_en_adcmic_dc_channel_t; /** Definitions for the return mode used in \ref Cy_ADCMic_IsEndConversion */ typedef enum { CY_ADCMIC_RETURN_STATUS = 0U, /**< Immediately returns the conversion status. */ CY_ADCMIC_WAIT_FOR_RESULT = 1U /**< Does not return a result until the conversion is complete. This mode is blocking. */ } cy_en_adcmic_return_mode_t; /** Definitions for the microphone bias settings */ typedef enum { CY_ADCMIC_BIAS_1_12_REF = 0U, /**< 1.12 X Reference Voltage */ CY_ADCMIC_BIAS_1_14_REF = 1U, /**< 1.14 X Reference Voltage */ CY_ADCMIC_BIAS_1_17_REF = 2U, /**< 1.12 X Reference Voltage */ CY_ADCMIC_BIAS_1_10_REF = 3U /**< 1.10 X Reference Voltage */ } cy_en_adcmic_bias_t; /** Definitions for the PGA input common mode settings */ typedef enum { CY_ADCMIC_INCM_0_4 = 0U, /**< 0.4 X aVdd */ CY_ADCMIC_INCM_0_45 = 1U, /**< 0.45 X aVdd */ CY_ADCMIC_INCM_0_35 = 2U /**< 0.35 X aVdd */ } cy_en_adcmic_pga_incm_t; /** Definitions for the PGA input common mode settings */ typedef enum { CY_ADCMIC_OUTCM_0_6 = 0U, /**< 0.6 */ CY_ADCMIC_OUTCM_0_7 = 1U, /**< 0.7 */ CY_ADCMIC_OUTCM_0_5 = 2U /**< 0.5 */ } cy_en_adcmic_pga_outcm_t; /** Definitions for the DC input range settings */ typedef enum { CY_ADCMIC_DC_RANGE_3_6V = 0U, /**< DC range 0..3.6V */ CY_ADCMIC_DC_RANGE_1_8V = 1U /**< DC range 0..1.8V */ } cy_en_adcmic_dc_range_t; /** Definitions for the timer count input settings */ typedef enum { CY_ADCMIC_TIMER_COUNT_INPUT_CIC_UPDATE = 0U, /**< Counts when CIC is updated */ CY_ADCMIC_TIMER_COUNT_INPUT_CLK_SYS = 1U /**< Counts up every clk_sys cycle */ } cy_en_adcmic_timer_count_input_t; /** \} group_adcmic_enums */ /** \addtogroup group_adcmic_data_structures * \{ */ /** The biquad filter configuration structure */ typedef struct { uint16_t bq0_num1_coeff; /**< The numerator 1 for biquad filter stage 0 */ uint16_t bq0_num2_coeff; /**< The numerator 2 for biquad filter stage 0 */ uint16_t bq0_num3_coeff; /**< The numerator 3 for biquad filter stage 0 */ uint16_t bq0_den2_coeff; /**< The denominator 2 for biquad filter stage 0 */ uint16_t bq0_den3_coeff; /**< The denominator 3 for biquad filter stage 0 */ uint16_t bq1_num1_coeff; /**< The numerator 1 for biquad filter stage 1 */ uint16_t bq1_num2_coeff; /**< The numerator 2 for biquad filter stage 1 */ uint16_t bq1_num3_coeff; /**< The numerator 3 for biquad filter stage 1 */ uint16_t bq1_den2_coeff; /**< The denominator 2 for biquad filter stage 1 */ uint16_t bq1_den3_coeff; /**< The denominator 3 for biquad filter stage 1 */ uint16_t bq2_num1_coeff; /**< The numerator 1 for biquad filter stage 2 */ uint16_t bq2_num2_coeff; /**< The numerator 2 for biquad filter stage 2 */ uint16_t bq2_num3_coeff; /**< The numerator 3 for biquad filter stage 2 */ uint16_t bq2_den2_coeff; /**< The denominator 2 for biquad filter stage 2 */ uint16_t bq2_den3_coeff; /**< The denominator 3 for biquad filter stage 2 */ uint16_t bq3_num1_coeff; /**< The numerator 1 for biquad filter stage 3 */ uint16_t bq3_num2_coeff; /**< The numerator 2 for biquad filter stage 3 */ uint16_t bq3_num3_coeff; /**< The numerator 3 for biquad filter stage 3 */ uint16_t bq3_den2_coeff; /**< The denominator 2 for biquad filter stage 3 */ uint16_t bq3_den3_coeff; /**< The denominator 3 for biquad filter stage 3 */ uint16_t bq4_num1_coeff; /**< The numerator 1 for biquad filter stage 4 */ uint16_t bq4_num2_coeff; /**< The numerator 2 for biquad filter stage 4 */ uint16_t bq4_num3_coeff; /**< The numerator 3 for biquad filter stage 4 */ uint16_t bq4_den2_coeff; /**< The denominator 2 for biquad filter stage 4 */ uint16_t bq4_den3_coeff; /**< The denominator 3 for biquad filter stage 4 */ } cy_stc_adcmic_biquad_config_t; /** The analog microphone configuration structure */ typedef struct { cy_en_adcmic_sample_rate_t sampleRate; /**< Sample rate */ cy_en_adcmic_bias_t micBias; /**< MIC bias selection */ bool micBiasLz; /**< MIC bias output impedance during power down: false - hight Z, true - low Z */ bool micClamp; /**< Enable MIC PGA clamping */ cy_en_adcmic_pga_gain_t pgaGain; /**< PGA gain 0...42 dB */ cy_en_adcmic_pga_incm_t pgaInCm; /**< PGA input common mode voltage selection */ cy_en_adcmic_pga_outcm_t pgaOutCm; /**< PGA output common mode voltage selection */ cy_stc_adcmic_biquad_config_t * biQuadConfig; /**< The pointer to the biquad filter configuration structure */ bool fifoTrigger; /**< Trigger out on valid FIFO data */ uint8_t fifoFull; /**< Count for FIFO full condition */ uint8_t fifoEmpty; /**< Count for FIFO empty condition */ } cy_stc_adcmic_mic_config_t; /** The PDM path configuration structure */ typedef struct { cy_en_adcmic_sample_rate_t sampleRate; /**< Sample rate */ bool clockInv; /**< Inverts the clock */ uint8_t latchDelay; /**< the PDM data latch delay, * when clockInv is false, the valid range is 1...8 * when clockInv is true, the valid range is 2...9 */ cy_stc_adcmic_biquad_config_t * biQuadConfig; /**< The pointer to the biquad filter configuration structure */ bool fifoTrigger; /**< Trigger out on valid FIFO data */ uint8_t fifoFull; /**< Count for FIFO full condition */ uint8_t fifoEmpty; /**< Count for FIFO empty condition */ } cy_stc_adcmic_pdm_config_t; /** The ADCMic driver context structure - it stores the gain and offset values for DC voltage measurement. */ typedef struct { int16_t offset; /**< The storage for the offset calibration value */ int16_t gain; /**< The storage for the gain calibration value */ } cy_stc_adcmic_context_t; /** The DC measurement path configuration structure */ typedef struct { cy_en_adcmic_dc_range_t range; /**< Selects the DC measurement range */ cy_en_adcmic_dc_channel_t channel; /**< DC channel to be measured */ uint16_t timerPeriod; /**< Timer period */ cy_en_adcmic_timer_count_input_t timerInput; /**< Timer count input */ cy_stc_adcmic_context_t * context; /**< The pointer to the context structure. * If none of the \ref Cy_ADCMic_CountsTo_uVolts, * \ref Cy_ADCMic_CountsTo_mVolts, * nor \ref Cy_ADCMic_CountsTo_Volts * functions is used, this pointer can be NULL. */ } cy_stc_adcmic_dc_config_t; /** The ADCMic driver configuration structure. */ typedef struct { cy_stc_adcmic_mic_config_t * micConfig; /**< The pointer to the audio analog path configuration structure */ cy_stc_adcmic_pdm_config_t * pdmConfig; /**< The pointer to the audio digital path configuration structure */ cy_stc_adcmic_dc_config_t * dcConfig; /**< The pointer to the DC measurement path configuration structure */ } cy_stc_adcmic_config_t; /** \} group_adcmic_data_structures */ /** \addtogroup group_adcmic_functions * \{ */ /** \addtogroup group_adcmic_functions_basic * This set of functions is for initialization and basic usage * \{ */ /******************************************************************************* * Function Name: Cy_ADCMic_Init ****************************************************************************//** * * Initializes the ADCMic block from a pre-initialized configuration structure. * * \param base * The pointer to the hardware ADCMic block. * * \param config * The pointer to the configuration structure \ref cy_stc_adcmic_config_t. * * \param mode * The ADCMic operation mode /ref cy_en_adcmic_mode_t. * * \return * The status \ref cy_en_adcmic_status_t. * * \funcusage * \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_MIC_OP * *******************************************************************************/ cy_en_adcmic_status_t Cy_ADCMic_Init(MXS40ADCMIC_Type * base, cy_stc_adcmic_config_t const * config, cy_en_adcmic_mode_t mode); /******************************************************************************* * Function Name: Cy_ADCMic_InitBiquad ****************************************************************************//** * * Initializes the biquad filter coefficients. * Usually is called from the \ref Cy_ADCMic_Init. * * \param base * The pointer to the hardware ADCMic block. * * \param biQuadConfig * The pointer to the biquad filter configuration structure \ref cy_stc_adcmic_biquad_config_t. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_BIQUAD_INIT * *******************************************************************************/ void Cy_ADCMic_InitBiquad(MXS40ADCMIC_Type * base, cy_stc_adcmic_biquad_config_t const * biQuadConfig); /******************************************************************************* * Function Name: Cy_ADCMic_BiquadBypass ****************************************************************************//** * * Bypasses/unbypasses the biquad filter. * Usually is called from the \ref Cy_ADCMic_Init. * * \param base * The pointer to the hardware ADCMic block. * * \param bypass * The boolean specifier to bypass(true) or unbypass(false) the biquad filter. * *******************************************************************************/ __STATIC_INLINE void Cy_ADCMic_BiquadBypass(MXS40ADCMIC_Type * base, bool bypass) { CY_REG32_CLR_SET(base->AUXADC_CTRL, MXS40ADCMIC_AUXADC_CTRL_BIQUAD_BYPASS, (bypass) ? 1UL : 0UL); } /******************************************************************************* * Function Name: Cy_ADCMic_Enable ****************************************************************************//** * * Enables the ADCMic block operation. * * \param base * The pointer to the hardware ADCMic block. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_MIC_OP * *******************************************************************************/ void Cy_ADCMic_Enable(MXS40ADCMIC_Type * base); /******************************************************************************* * Function Name: Cy_ADCMic_Disable ****************************************************************************//** * * Disables the ADCMic block operation. * * \param base * The pointer to the hardware ADCMic block. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_STOP * *******************************************************************************/ void Cy_ADCMic_Disable(MXS40ADCMIC_Type * base); /******************************************************************************* * Function Name: Cy_ADCMic_SetSampleRate ****************************************************************************//** * * Sets the specified ADC sample rate. Applicable for MIC/PDM modes only. * * \param base * The pointer to the hardware ADCMic block. * * \param sampleRate * The source value \ref cy_en_adcmic_sample_rate_t. * * \return * The status \ref cy_en_adcmic_status_t. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_MIC_OP * *******************************************************************************/ cy_en_adcmic_status_t Cy_ADCMic_SetSampleRate(MXS40ADCMIC_Type * base, cy_en_adcmic_sample_rate_t sampleRate); /******************************************************************************* * Function Name: Cy_ADCMic_ClearTrigger ****************************************************************************//** * * Clears the specified trigger signal. * * \param base * The pointer to the hardware ADC block. * * \param trigMask * The mask of triggers to clear. * Select one or more masks from \ref group_adcmic_macros_triggers and "OR" them together: * - \ref CY_ADCMIC_TRIG_DC * - \ref CY_ADCMIC_TRIG_DATA * *******************************************************************************/ __STATIC_INLINE void Cy_ADCMic_ClearTrigger(MXS40ADCMIC_Type * base, uint32_t trigMask) { base->ADCMIC_TRIGGER_CLR = trigMask & CY_ADCMIC_TRIG; } /** \} group_adcmic_functions_basic */ /** \addtogroup group_adcmic_functions_mic * This set of functions is for analog microphone resources control * \{ */ /******************************************************************************* * Function Name: Cy_ADCMic_SetPgaGain ****************************************************************************//** * * Configures the PGA gain (0dB to 42dB in steps of 1dB) * * \param base * The pointer to the hardware ADCMic block. * * \param gain * The gain value \ref cy_en_adcmic_pga_gain_t. * * \return * The status \ref cy_en_adcmic_status_t. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_GAIN * *******************************************************************************/ cy_en_adcmic_status_t Cy_ADCMic_SetPgaGain(MXS40ADCMIC_Type * base, cy_en_adcmic_pga_gain_t gain); /** \} group_adcmic_functions_mic */ /** \addtogroup group_adcmic_functions_timer * This set of functions is for Timer control * \{ */ /******************************************************************************* * Function Name: Cy_ADCMic_EnableTimer ****************************************************************************//** * * Enables the timer. * * \param base * The pointer to the hardware ADCMic block. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_TIMER * *******************************************************************************/ __STATIC_INLINE void Cy_ADCMic_EnableTimer(MXS40ADCMIC_Type * base) { base->ADCMIC_TRIG_INTRPT_TIMER_CTRL &= ~MXS40ADCMIC_ADCMIC_TRIG_INTRPT_TIMER_CTRL_TIMER_CLR_Msk; (void)base->ADCMIC_TRIG_INTRPT_TIMER_CTRL; /* Dummy read to ensure write is done before return */ } /******************************************************************************* * Function Name: Cy_ADCMic_DisableTimer ****************************************************************************//** * * Disables the timer. * * \param base * The pointer to the hardware ADCMic block. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_TIMER * *******************************************************************************/ __STATIC_INLINE void Cy_ADCMic_DisableTimer(MXS40ADCMIC_Type * base) { base->ADCMIC_TRIG_INTRPT_TIMER_CTRL |= MXS40ADCMIC_ADCMIC_TRIG_INTRPT_TIMER_CTRL_TIMER_CLR_Msk; (void)base->ADCMIC_TRIG_INTRPT_TIMER_CTRL; /* Dummy read to ensure write is done before return */ } /******************************************************************************* * Function Name: Cy_ADCMic_SetTimerPeriod ****************************************************************************//** * * Sets the timer period. * * \param base * The pointer to the hardware ADCMic block. * * \param period * The 16-bit timer period. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_TIMER * *******************************************************************************/ __STATIC_INLINE void Cy_ADCMic_SetTimerPeriod(MXS40ADCMIC_Type * base, uint16_t period) { CY_REG32_CLR_SET(base->ADCMIC_TRIG_INTRPT_TIMER_CTRL, MXS40ADCMIC_ADCMIC_TRIG_INTRPT_TIMER_CTRL_TIMER_LIMIT, period); } /** \} group_adcmic_functions_timer */ /** \addtogroup group_adcmic_functions_dc * This set of functions is for DC measurement mode * \{ */ /******************************************************************************* * Function Name: Cy_ADCMic_SelectDcChannel ****************************************************************************//** * * Sets the specified DC measurement channel. * * \param base * The pointer to the hardware ADCMic block. * * \param channel * The DC measurement channel \ref cy_en_adcmic_dc_channel_t. * * \note This function is useful for DC measurement only. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_DC_OP * *******************************************************************************/ void Cy_ADCMic_SelectDcChannel(MXS40ADCMIC_Type * base, cy_en_adcmic_dc_channel_t channel); /******************************************************************************* * Function Name: Cy_ADCMic_IsEndConversion ****************************************************************************//** * * Immediately return the status of the conversion or does not return (blocking) * until the conversion completes, depending on the retMode parameter. * In blocking mode, there is a time out of about 10 seconds for a CPU speed of * 100 MHz. * * \param base * Pointer to structure describing registers * * \param retMode * A value of the enum \ref cy_en_adcmic_return_mode_t * * \return * - \ref CY_ADCMIC_SUCCESS : the last conversion is complete * - \ref CY_ADCMIC_CONVERSION_NOT_COMPLETE : the conversion has not completed * - \ref CY_ADCMIC_TIMEOUT : the watchdog timer has expired in blocking mode * * \sideeffect * This function reads the end of conversion status interrupt bit and clears it after. * * \note * \ref CY_ADCMIC_WAIT_FOR_RESULT return modes are not recommended * for use in RTOS environment. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_DC_OP * *******************************************************************************/ cy_en_adcmic_status_t Cy_ADCMic_IsEndConversion (MXS40ADCMIC_Type * base, cy_en_adcmic_return_mode_t retMode); /******************************************************************************* * Function Name: Cy_ADCMic_GetDcResult ****************************************************************************//** * * Returns the DC conversion result from the CIC status register. * * \param base * The pointer to the hardware ADCMic block. * * \return * The signed DC conversion result. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_DC_OP * *******************************************************************************/ __STATIC_INLINE int16_t Cy_ADCMic_GetDcResult(MXS40ADCMIC_Type * base) { return ((int16_t)((uint16_t)_FLD2VAL(MXS40ADCMIC_AUXADC_CIC_STATUS_CIC, base->AUXADC_CIC_STATUS))); } /******************************************************************************* * Function Name: Cy_ADCMic_SetDcOffset ****************************************************************************//** * * Sets the offset value for DC measurement calibration. * * \param offset * The offset value. * * \param context * The pointer to the context structure \ref cy_stc_adcmic_context_t. * *******************************************************************************/ void Cy_ADCMic_SetDcOffset(int16_t offset, cy_stc_adcmic_context_t * context); /******************************************************************************* * Function Name: Cy_ADCMic_SetDcGain ****************************************************************************//** * * Sets the gain value for DC measurement calibration. * * \param gain * The gain value. * * \param context * The pointer to the context structure \ref cy_stc_adcmic_context_t. * *******************************************************************************/ void Cy_ADCMic_SetDcGain(int16_t gain, cy_stc_adcmic_context_t * context); /******************************************************************************* * Function Name: Cy_ADCMic_CountsTo_mVolts ****************************************************************************//** * * Convert the ADC output to millivolts as an int16. For example, if the ADC * measured 0.534 volts, the return value would be 534. * The calculation of voltage depends on the DC range. * The equation used is: * * mV = (RawCounts - Offset) * 1000 / Gain * * where, * - RawCounts: Raw counts returned by the \ref Cy_ADCMic_GetDcResult. * - Offset - the offset value, can be adjusted by the \ref Cy_ADCMic_SetDcOffset, * essentially it is a raw count value of the \ref CY_ADCMIC_REFGND voltage measurement. * - 1000 - amount of millivolts in 1 volt * - Gain: the gain value, can be adjusted by the \ref Cy_ADCMic_SetDcGain, depends on DC range, * essentially it is an amount of raw counts per 1 volt of input voltage. * * \note * This function is for DC measurement only. * * \param adcCounts * Conversion result from \ref Cy_ADCMic_GetDcResult * * \param context * The pointer to the context structure \ref cy_stc_adcmic_context_t. * * \return * Result in millivolts. * * \funcusage \snippet adcmic_snippet/snippet.c SNIPPET_ADCMIC_DC_MEASURE * *******************************************************************************/ int16_t Cy_ADCMic_CountsTo_mVolts(int16_t adcCounts, cy_stc_adcmic_context_t const * context); /******************************************************************************* * Function Name: Cy_ADCMic_CountsTo_uVolts ****************************************************************************//** * * Convert the ADC output to microvolts as an int32. For example, if the ADC * measured 0.534 volts, the return value would be 534000. * The calculation of voltage depends on the DC range. * The equation used is: * * uV = (RawCounts - Offset) * 1000000 / Gain * * where, * - RawCounts: Raw counts returned by the \ref Cy_ADCMic_GetDcResult. * - Offset - the offset value, can be adjusted by the \ref Cy_ADCMic_SetDcOffset, * essentially it is a raw count value of the \ref CY_ADCMIC_REFGND voltage measurement. * - 1000000 - amount of microvolts in 1 volt * - Gain: the gain value, can be adjusted by the \ref Cy_ADCMic_SetDcGain, depends on DC range, * essentially it is an amount of raw counts per 1 volt of input voltage. * * \note * This function is for DC measurement only. * * \param adcCounts * Conversion result from \ref Cy_ADCMic_GetDcResult * * \param context * The pointer to the context structure \ref cy_stc_adcmic_context_t. * * \return * Result in microvolts. * * \funcusage \snippet adcmic_snippet/snippet.c SNIPPET_ADCMIC_DC_MEASURE * *******************************************************************************/ int32_t Cy_ADCMic_CountsTo_uVolts(int16_t adcCounts, cy_stc_adcmic_context_t const * context); /******************************************************************************* * Function Name: Cy_ADCMic_CountsTo_Volts ****************************************************************************//** * * Convert the ADC output to volts as a float. For example, if the ADC * measured 0.534 volts, the return value would be 0.534. * The calculation of voltage depends on the DC range. * The equation used is: * * V = (RawCounts - Offset) / Gain * * where, * - RawCounts: Raw counts returned by the \ref Cy_ADCMic_GetDcResult. * - Offset - the offset value, can be adjusted by the \ref Cy_ADCMic_SetDcOffset, * essentially it is a raw count value of the \ref CY_ADCMIC_REFGND voltage measurement. * - Gain: the gain value, can be adjusted by the \ref Cy_ADCMic_SetDcGain, depends on DC range, * essentially it is an amount of raw counts per 1 volt of input voltage. * * \note * This function is for DC measurement only. * * \param adcCounts * Conversion result from \ref Cy_ADCMic_GetDcResult * * \param context * The pointer to the context structure \ref cy_stc_adcmic_context_t. * * \return * Result in volts. * * \funcusage \snippet adcmic_snippet/snippet.c SNIPPET_ADCMIC_DC_MEASURE * *******************************************************************************/ float Cy_ADCMic_CountsTo_Volts(int16_t adcCounts, cy_stc_adcmic_context_t const * context); /** \} group_adcmic_functions_dc */ /** \addtogroup group_adcmic_functions_interrupt * This set of functions are related to ADCMic interrupts. * \{ */ /******************************************************************************* * Function Name: Cy_ADCMic_EnableInterrupt ****************************************************************************//** * * Sets the specified interrupt bit in the interrupt mask register. * * \param base * The pointer to the hardware ADCMic block. * * \param intrMask * The mask of interrupts to enable. * Select one or more values from \ref group_adcmic_macros_interrupt and "OR" them together. * - \ref CY_ADCMIC_INTR_DC * - \ref CY_ADCMIC_INTR_DATA * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_CONFIG_INTR * *******************************************************************************/ void Cy_ADCMic_EnableInterrupt(MXS40ADCMIC_Type * base, uint32_t intrMask); /******************************************************************************* * Function Name: Cy_ADCMic_DisableInterrupt ****************************************************************************//** * * Clears the specified interrupt bit in the interrupt mask register. * * \param base * The pointer to the hardware ADCMic block. * * \param intrMask * The mask of interrupts to disable. * Select one or more values from \ref group_adcmic_macros_interrupt and "OR" them together. * - \ref CY_ADCMIC_INTR_DC * - \ref CY_ADCMIC_INTR_DATA * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_CONFIG_INTR * *******************************************************************************/ void Cy_ADCMic_DisableInterrupt(MXS40ADCMIC_Type * base, uint32_t intrMask); /******************************************************************************* * Function Name: CY_ADCMIC_GetInterruptStatus ****************************************************************************//** * * Returns the interrupt status of the specified channel. * * \param base * The pointer to the hardware ADCMic block. * * \return * The interrupt status. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_CONFIG_INTR * *******************************************************************************/ __STATIC_INLINE uint32_t Cy_ADCMic_GetInterruptStatus(MXS40ADCMIC_Type const * base) { return (base->ADCMIC_INTR & CY_ADCMIC_INTR); } /******************************************************************************* * Function Name: Cy_ADCMic_ClearInterrupt ****************************************************************************//** * * Clears the interrupt status. * * \param base * The pointer to the hardware ADC block. * * \param intrMask * The mask of interrupts to clear. Typically this will be the value returned * from \ref Cy_ADCMic_GetInterruptStatus. * Alternately, select one or more values from \ref group_adcmic_macros_interrupt and "OR" them together. * - \ref CY_ADCMIC_INTR_DC * - \ref CY_ADCMIC_INTR_DATA * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_CONFIG_INTR * *******************************************************************************/ __STATIC_INLINE void Cy_ADCMic_ClearInterrupt(MXS40ADCMIC_Type * base, uint32_t intrMask) { base->ADCMIC_INTR = intrMask & CY_ADCMIC_INTR; (void) base->ADCMIC_INTR; } /******************************************************************************* * Function Name: Cy_ADCMic_SetInterrupt ****************************************************************************//** * * Sets the interrupt for the specified channel. * Intended mostly for debugging. * * \param base * The pointer to the hardware ADCMic block. * * \param intrMask * The mask of interrupts to set. * Select one or more values from \ref group_adcmic_macros_interrupt and "OR" them together. * - \ref CY_ADCMIC_INTR_DC * - \ref CY_ADCMIC_INTR_DATA * *******************************************************************************/ __STATIC_INLINE void Cy_ADCMic_SetInterrupt(MXS40ADCMIC_Type * base, uint32_t intrMask) { base->ADCMIC_INTR_SET = intrMask & CY_ADCMIC_INTR; } /******************************************************************************* * Function Name: CY_ADCMIC_GetInterruptMask ****************************************************************************//** * * Returns the interrupt mask value of the specified channel. * * \param base * The pointer to the hardware ADCMic block. * * \return * The interrupt mask value. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_GET_INTERRUPT_MASK * *******************************************************************************/ __STATIC_INLINE uint32_t Cy_ADCMic_GetInterruptMask(MXS40ADCMIC_Type const * base) { return (base->ADCMIC_INTR_MASK & CY_ADCMIC_INTR); } /******************************************************************************* * Function Name: CY_ADCMIC_SetInterruptMask ****************************************************************************//** * * Sets an interrupt mask value for the specified channel. * * \param base * The pointer to the hardware ADCMic block. * * \param intrMask * The mask of interrupts. * Select one or more values from \ref group_adcmic_macros_interrupt and "OR" them together. * - \ref CY_ADCMIC_INTR_DC * - \ref CY_ADCMIC_INTR_DATA * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_SET_INTERRUPT_MASK * *******************************************************************************/ __STATIC_INLINE void Cy_ADCMic_SetInterruptMask(MXS40ADCMIC_Type * base, uint32_t intrMask) { base->ADCMIC_INTR_MASK = intrMask & CY_ADCMIC_INTR; } /******************************************************************************* * Function Name: CY_ADCMIC_GetInterruptStatusMasked ****************************************************************************//** * * Returns the logical AND of the corresponding INTR and INTR_MASK fields * in a single-load operation. * * \param base * The pointer to the hardware ADCMic block. * * \return * The masked interrupt status. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_CONFIG_INTR * *******************************************************************************/ __STATIC_INLINE uint32_t Cy_ADCMic_GetInterruptStatusMasked(MXS40ADCMIC_Type const * base) { return (base->ADCMIC_INTR_MASKED & CY_ADCMIC_INTR); } /** \} group_adcmic_functions_interrupt */ /** \addtogroup group_adcmic_functions_fifo * This set of functions are related to ADCMic FIFO buffer. * \{ */ /******************************************************************************* * Function Name: Cy_ADCMic_ReadFifoAll ****************************************************************************//** * * Reads whole the FIFO payload into the data array. * * \param base * The pointer to the hardware ADCMic block. * * \param data * The pointer to the uint16_t data array for the FIFO payload. * * \return * The 8-bit FIFO data count. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_ISR * *******************************************************************************/ uint8_t Cy_ADCMic_ReadFifoAll(MXS40ADCMIC_Type const * base, uint16_t * data); /******************************************************************************* * Function Name: Cy_ADCMic_ReadFifoStatus ****************************************************************************//** * * Returns the fifo status. * * \param base * The pointer to the hardware ADCMic block. * * \return * The 8-bit fifo status, see \ref group_adcmic_macros_fifo_status. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_ADCMIC_ISR * *******************************************************************************/ __STATIC_INLINE uint8_t Cy_ADCMic_GetFifoStatus(MXS40ADCMIC_Type const * base) { return ((uint8_t)_FLD2VAL(MXS40ADCMIC_ADCMIC_FIFO_CTRL_FIFO_STATUS, base->ADCMIC_FIFO_CTRL)); } /******************************************************************************* * Function Name: Cy_ADCMic_ReadFifo ****************************************************************************//** * * Low-level API which returns the ADCMIC_DATA register value * that contains \b two subsequent FIFO data samples. * * \param base * The pointer to the hardware ADCMic block. * * \return * The combined 32-bit value of two 16-bit samples. * Use \ref group_adcmic_macros_fifo_samples to parse it. * * \funcusage \snippet adcmic/snippet/adcmic_snippet.c SNIPPET_READ_FIFO * *******************************************************************************/ __STATIC_INLINE uint32_t Cy_ADCMic_ReadFifo(MXS40ADCMIC_Type const * base) { return (base->ADCMIC_DATA); } /** \} group_adcmic_functions_fifo */ /** \} group_adcmic_functions */ #if defined(__cplusplus) } #endif #endif /* CY_IP_MXS40ADCMIC */ #endif /* (CY_ADCMIC_H) */ /** \} group_adcmic */ /* [] END OF FILE */
162ec415ffc347fa345331b002ce3e55e7c64950
50dd46b8ece33f3cdd174284b15d1d51f89669d4
/third_party/edk2/StdLib/Include/sys/wait.h
64200aa999bee771e286eaf76cb58b92f21e1e03
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause", "OpenSSL" ]
permissive
google/google-ctf
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
df02323eaf945d15e124801c74abaadca2749dc7
refs/heads/master
2023-08-31T14:30:27.548081
2023-08-29T13:04:20
2023-08-29T13:04:20
131,317,137
4,136
607
Apache-2.0
2023-08-30T22:17:02
2018-04-27T15:56:03
Go
UTF-8
C
false
false
6,367
h
wait.h
/* $NetBSD: wait.h,v 1.24 2005/12/11 12:25:21 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * * 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 of the University 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 REGENTS 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 REGENTS 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. * * @(#)wait.h 8.2 (Berkeley) 7/10/94 */ #ifndef _SYS_WAIT_H_ #define _SYS_WAIT_H_ #include <sys/featuretest.h> #include <sys/types.h> /* * This file holds definitions relevent to the wait4 system call * and the alternate interfaces that use it (wait, wait3, waitpid). */ /* * Macros to test the exit status returned by wait * and extract the relevant values. */ #define _W_INT(w) (*(int *)(void *)&(w)) /* convert union wait to int */ #define _WSTATUS(x) (_W_INT(x) & 0177) #define _WSTOPPED 0177 /* _WSTATUS if process is stopped */ #define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED) #define WSTOPSIG(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff) #define WIFSIGNALED(x) (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0) #define WTERMSIG(x) (_WSTATUS(x)) #define WIFEXITED(x) (_WSTATUS(x) == 0) #define WEXITSTATUS(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff) #define WCOREFLAG 0200 #define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG) #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) #define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED) /* * Option bits for the third argument of wait4. WNOHANG causes the * wait to not hang if there are no stopped or terminated processes, rather * returning an error indication in this case (pid==0). WUNTRACED * indicates that the caller should receive status about untraced children * which stop due to signals. If children are stopped and a wait without * this option is done, it is as though they were still running... nothing * about them is returned. */ #define WNOHANG 0x00000001 /* don't hang in wait */ #define WUNTRACED 0x00000002 /* tell about stopped, untraced children */ #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) #define WALTSIG 0x00000004 /* wait for processes that exit with an alternate signal (i.e. not SIGCHLD) */ #define WALLSIG 0x00000008 /* wait for processes that exit with any signal, i.e. SIGCHLD and alternates */ /* * These are the Linux names of some of the above flags, for compatibility * with Linux's clone(2) API. */ #define __WCLONE WALTSIG #define __WALL WALLSIG /* * These bits are used in order to support SVR4 (etc) functionality * without replicating sys_wait4 5 times. */ #define WNOWAIT 0x00010000 /* Don't mark child 'P_WAITED' */ #define WNOZOMBIE 0x00020000 /* Ignore zombies */ #endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ /* POSIX extensions and 4.2/4.3 compatibility: */ /* * Tokens for special values of the "pid" parameter to wait4. */ #define WAIT_ANY (-1) /* any process */ #define WAIT_MYPGRP 0 /* any process in my process group */ /* * Deprecated: * Structure of the information in the status word returned by wait4. * If w_stopval==WSTOPPED, then the second structure describes * the information returned, else the first. */ union wait { int w_status; /* used in syscall */ /* * Terminated process status. */ struct { #if BYTE_ORDER == LITTLE_ENDIAN unsigned int w_Termsig:7, /* termination signal */ w_Coredump:1, /* core dump indicator */ w_Retcode:8, /* exit code if w_termsig==0 */ w_Filler:16; /* upper bits filler */ #endif #if BYTE_ORDER == BIG_ENDIAN unsigned int w_Filler:16, /* upper bits filler */ w_Retcode:8, /* exit code if w_termsig==0 */ w_Coredump:1, /* core dump indicator */ w_Termsig:7; /* termination signal */ #endif } w_T; /* * Stopped process status. Returned * only for traced children unless requested * with the WUNTRACED option bit. */ struct { #if BYTE_ORDER == LITTLE_ENDIAN unsigned int w_Stopval:8, /* == W_STOPPED if stopped */ w_Stopsig:8, /* signal that stopped us */ w_Filler:16; /* upper bits filler */ #endif #if BYTE_ORDER == BIG_ENDIAN unsigned int w_Filler:16, /* upper bits filler */ w_Stopsig:8, /* signal that stopped us */ w_Stopval:8; /* == W_STOPPED if stopped */ #endif } w_S; }; #define w_termsig w_T.w_Termsig #define w_coredump w_T.w_Coredump #define w_retcode w_T.w_Retcode #define w_stopval w_S.w_Stopval #define w_stopsig w_S.w_Stopsig #define WSTOPPED _WSTOPPED __BEGIN_DECLS pid_t wait(int *); #if 0 /* Normally declared here but not implemented for UEFI. */ struct rusage; /* forward declaration */ pid_t waitpid(pid_t, int *, int); pid_t wait3(int *, int, struct rusage *); pid_t wait4(pid_t, int *, int, struct rusage *); #endif __END_DECLS #endif /* !_SYS_WAIT_H_ */
27563bb45484a6bccf8ee8bba63cc60df8f40ca3
1577e1cf4e89584a125cffb855ca50a9654c6d55
/tcl/tcl/tcl/generic/tclMain.c
b3b509effee3ec62441e1faca4324a62b0c2f542
[ "TCL" ]
permissive
apple-open-source/macos
a4188b5c2ef113d90281d03cd1b14e5ee52ebffb
2d2b15f13487673de33297e49f00ef94af743a9a
refs/heads/master
2023-08-01T11:03:26.870408
2023-03-27T00:00:00
2023-03-27T00:00:00
180,595,052
124
24
null
2022-12-27T14:54:09
2019-04-10T14:06:23
null
UTF-8
C
false
false
24,642
c
tclMain.c
/* * tclMain.c -- * * Main program for Tcl shells and other Tcl-based applications. * * Copyright (c) 1988-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * Copyright (c) 2000 Ajuba Solutions. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclMain.c,v 1.44 2007/12/13 15:23:19 dgp Exp $ */ #include "tclInt.h" #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT /* * The default prompt used when the user has not overridden it. */ #define DEFAULT_PRIMARY_PROMPT "% " /* * Declarations for various library functions and variables (don't want to * include tclPort.h here, because people might copy this file out of the Tcl * source directory to make their own modified versions). */ extern CRTIMPORT int isatty(int fd); static Tcl_Obj *tclStartupScriptPath = NULL; static Tcl_Obj *tclStartupScriptEncoding = NULL; static Tcl_MainLoopProc *mainLoopProc = NULL; /* * Structure definition for information used to keep the state of an * interactive command processor that reads lines from standard input and * writes prompts and results to standard output. */ typedef enum { PROMPT_NONE, /* Print no prompt */ PROMPT_START, /* Print prompt for command start */ PROMPT_CONTINUE /* Print prompt for command continuation */ } PromptType; typedef struct InteractiveState { Tcl_Channel input; /* The standard input channel from which lines * are read. */ int tty; /* Non-zero means standard input is a * terminal-like device. Zero means it's a * file. */ Tcl_Obj *commandPtr; /* Used to assemble lines of input into Tcl * commands. */ PromptType prompt; /* Next prompt to print */ Tcl_Interp *interp; /* Interpreter that evaluates interactive * commands. */ } InteractiveState; /* * Forward declarations for functions defined later in this file. */ static void Prompt(Tcl_Interp *interp, PromptType *promptPtr); static void StdinProc(ClientData clientData, int mask); /* *---------------------------------------------------------------------- * * Tcl_SetStartupScript -- * * Sets the path and encoding of the startup script to be evaluated by * Tcl_Main, used to override the command line processing. * * Results: * None. * * Side effects: * *---------------------------------------------------------------------- */ void Tcl_SetStartupScript( Tcl_Obj *path, /* Filesystem path of startup script file */ CONST char *encoding) /* Encoding of the data in that file */ { Tcl_Obj *newEncoding = NULL; if (encoding != NULL) { newEncoding = Tcl_NewStringObj(encoding, -1); } if (tclStartupScriptPath != NULL) { Tcl_DecrRefCount(tclStartupScriptPath); } tclStartupScriptPath = path; if (tclStartupScriptPath != NULL) { Tcl_IncrRefCount(tclStartupScriptPath); } if (tclStartupScriptEncoding != NULL) { Tcl_DecrRefCount(tclStartupScriptEncoding); } tclStartupScriptEncoding = newEncoding; if (tclStartupScriptEncoding != NULL) { Tcl_IncrRefCount(tclStartupScriptEncoding); } } /* *---------------------------------------------------------------------- * * Tcl_GetStartupScript -- * * Gets the path and encoding of the startup script to be evaluated by * Tcl_Main. * * Results: * The path of the startup script; NULL if none has been set. * * Side effects: * If encodingPtr is not NULL, stores a (CONST char *) in it pointing to * the encoding name registered for the startup script. Tcl retains * ownership of the string, and may free it. Caller should make a copy * for long-term use. * *---------------------------------------------------------------------- */ Tcl_Obj * Tcl_GetStartupScript( CONST char **encodingPtr) /* When not NULL, points to storage for the * (CONST char *) that points to the * registered encoding name for the startup * script */ { if (encodingPtr != NULL) { if (tclStartupScriptEncoding == NULL) { *encodingPtr = NULL; } else { *encodingPtr = Tcl_GetString(tclStartupScriptEncoding); } } return tclStartupScriptPath; } /* *---------------------------------------------------------------------- * * TclSetStartupScriptPath -- * * Primes the startup script VFS path, used to override the command line * processing. * * Results: * None. * * Side effects: * This function initializes the VFS path of the Tcl script to run at * startup. * *---------------------------------------------------------------------- */ void TclSetStartupScriptPath( Tcl_Obj *path) { Tcl_SetStartupScript(path, NULL); } /* *---------------------------------------------------------------------- * * TclGetStartupScriptPath -- * * Gets the startup script VFS path, used to override the command line * processing. * * Results: * The startup script VFS path, NULL if none has been set. * * Side effects: * None. * *---------------------------------------------------------------------- */ Tcl_Obj * TclGetStartupScriptPath(void) { return Tcl_GetStartupScript(NULL); } /* *---------------------------------------------------------------------- * * TclSetStartupScriptFileName -- * * Primes the startup script file name, used to override the command line * processing. * * Results: * None. * * Side effects: * This function initializes the file name of the Tcl script to run at * startup. * *---------------------------------------------------------------------- */ void TclSetStartupScriptFileName( CONST char *fileName) { Tcl_Obj *path = Tcl_NewStringObj(fileName,-1); Tcl_SetStartupScript(path, NULL); } /* *---------------------------------------------------------------------- * * TclGetStartupScriptFileName -- * * Gets the startup script file name, used to override the command line * processing. * * Results: * The startup script file name, NULL if none has been set. * * Side effects: * None. * *---------------------------------------------------------------------- */ CONST char * TclGetStartupScriptFileName(void) { Tcl_Obj *path = Tcl_GetStartupScript(NULL); if (path == NULL) { return NULL; } return Tcl_GetString(path); } /*---------------------------------------------------------------------- * * Tcl_SourceRCFile -- * * This function is typically invoked by Tcl_Main of Tk_Main function to * source an application specific rc file into the interpreter at startup * time. * * Results: * None. * * Side effects: * Depends on what's in the rc script. * *---------------------------------------------------------------------- */ void Tcl_SourceRCFile( Tcl_Interp *interp) /* Interpreter to source rc file into. */ { Tcl_DString temp; CONST char *fileName; Tcl_Channel errChannel; fileName = Tcl_GetVar(interp, "tcl_rcFileName", TCL_GLOBAL_ONLY); if (fileName != NULL) { Tcl_Channel c; CONST char *fullName; Tcl_DStringInit(&temp); fullName = Tcl_TranslateFileName(interp, fileName, &temp); if (fullName == NULL) { /* * Couldn't translate the file name (e.g. it referred to a bogus * user or there was no HOME environment variable). Just do * nothing. */ } else { /* * Test for the existence of the rc file before trying to read it. */ c = Tcl_OpenFileChannel(NULL, fullName, "r", 0); if (c != (Tcl_Channel) NULL) { Tcl_Close(NULL, c); if (Tcl_EvalFile(interp, fullName) != TCL_OK) { errChannel = Tcl_GetStdChannel(TCL_STDERR); if (errChannel) { Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp)); Tcl_WriteChars(errChannel, "\n", 1); } } } } Tcl_DStringFree(&temp); } } /*---------------------------------------------------------------------- * * Tcl_Main -- * * Main program for tclsh and most other Tcl-based applications. * * Results: * None. This function never returns (it exits the process when it's * done). * * Side effects: * This function initializes the Tcl world and then starts interpreting * commands; almost anything could happen, depending on the script being * interpreted. * *---------------------------------------------------------------------- */ void Tcl_Main( int argc, /* Number of arguments. */ char **argv, /* Array of argument strings. */ Tcl_AppInitProc *appInitProc) /* Application-specific initialization * function to call after most initialization * but before starting to execute commands. */ { Tcl_Obj *path, *resultPtr, *argvPtr, *commandPtr = NULL; CONST char *encodingName = NULL; PromptType prompt = PROMPT_START; int code, length, tty, exitCode = 0; Tcl_Channel inChannel, outChannel, errChannel; Tcl_Interp *interp; Tcl_DString appName; Tcl_FindExecutable(argv[0]); interp = Tcl_CreateInterp(); Tcl_InitMemory(interp); /* * If the application has not already set a startup script, parse the * first few command line arguments to determine the script path and * encoding. */ if (NULL == Tcl_GetStartupScript(NULL)) { /* * Check whether first 3 args (argv[1] - argv[3]) look like * -encoding ENCODING FILENAME * or like * FILENAME */ if ((argc > 3) && (0 == strcmp("-encoding", argv[1])) && ('-' != argv[3][0])) { Tcl_SetStartupScript(Tcl_NewStringObj(argv[3], -1), argv[2]); argc -= 3; argv += 3; } else if ((argc > 1) && ('-' != argv[1][0])) { Tcl_SetStartupScript(Tcl_NewStringObj(argv[1], -1), NULL); argc--; argv++; } } path = Tcl_GetStartupScript(&encodingName); if (path == NULL) { Tcl_ExternalToUtfDString(NULL, argv[0], -1, &appName); } else { CONST char *pathName = Tcl_GetStringFromObj(path, &length); Tcl_ExternalToUtfDString(NULL, pathName, length, &appName); path = Tcl_NewStringObj(Tcl_DStringValue(&appName), -1); Tcl_SetStartupScript(path, encodingName); } Tcl_SetVar(interp, "argv0", Tcl_DStringValue(&appName), TCL_GLOBAL_ONLY); Tcl_DStringFree(&appName); argc--; argv++; Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY); argvPtr = Tcl_NewListObj(0, NULL); while (argc--) { Tcl_DString ds; Tcl_ExternalToUtfDString(NULL, *argv++, -1, &ds); Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj( Tcl_DStringValue(&ds), Tcl_DStringLength(&ds))); Tcl_DStringFree(&ds); } Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY); /* * Set the "tcl_interactive" variable. */ tty = isatty(0); Tcl_SetVar(interp, "tcl_interactive", ((path == NULL) && tty) ? "1" : "0", TCL_GLOBAL_ONLY); if ((path == NULL) && tty) { fprintf(stderr, "\nWARNING: This version of tcl is included in macOS " "for compatibility with legacy software. " "\nIn future versions of " "macOS the tcl runtime will not be available by " "\ndefault, and may require you to install an " "additional package.\n\n"); } /* * Invoke application-specific initialization. */ Tcl_Preserve((ClientData) interp); if ((*appInitProc)(interp) != TCL_OK) { errChannel = Tcl_GetStdChannel(TCL_STDERR); if (errChannel) { Tcl_WriteChars(errChannel, "application-specific initialization failed: ", -1); Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp)); Tcl_WriteChars(errChannel, "\n", 1); } } if (Tcl_InterpDeleted(interp)) { goto done; } if (Tcl_LimitExceeded(interp)) { goto done; } /* * If a script file was specified then just source that file and quit. * Must fetch it again, as the appInitProc might have reset it. */ path = Tcl_GetStartupScript(&encodingName); if (path != NULL) { code = Tcl_FSEvalFileEx(interp, path, encodingName); if (code != TCL_OK) { errChannel = Tcl_GetStdChannel(TCL_STDERR); if (errChannel) { Tcl_Obj *options = Tcl_GetReturnOptions(interp, code); Tcl_Obj *keyPtr, *valuePtr; TclNewLiteralStringObj(keyPtr, "-errorinfo"); Tcl_IncrRefCount(keyPtr); Tcl_DictObjGet(NULL, options, keyPtr, &valuePtr); Tcl_DecrRefCount(keyPtr); if (valuePtr) { Tcl_WriteObj(errChannel, valuePtr); } Tcl_WriteChars(errChannel, "\n", 1); } exitCode = 1; } goto done; } /* * We're running interactively. Source a user-specific startup file if the * application specified one and if the file exists. */ Tcl_SourceRCFile(interp); if (Tcl_LimitExceeded(interp)) { goto done; } /* * Process commands from stdin until there's an end-of-file. Note that we * need to fetch the standard channels again after every eval, since they * may have been changed. */ commandPtr = Tcl_NewObj(); Tcl_IncrRefCount(commandPtr); /* * Get a new value for tty if anyone writes to ::tcl_interactive */ Tcl_LinkVar(interp, "tcl_interactive", (char *) &tty, TCL_LINK_BOOLEAN); inChannel = Tcl_GetStdChannel(TCL_STDIN); outChannel = Tcl_GetStdChannel(TCL_STDOUT); while ((inChannel != (Tcl_Channel) NULL) && !Tcl_InterpDeleted(interp)) { if (mainLoopProc == NULL) { if (tty) { Prompt(interp, &prompt); if (Tcl_InterpDeleted(interp)) { break; } if (Tcl_LimitExceeded(interp)) { break; } inChannel = Tcl_GetStdChannel(TCL_STDIN); if (inChannel == (Tcl_Channel) NULL) { break; } } if (Tcl_IsShared(commandPtr)) { Tcl_DecrRefCount(commandPtr); commandPtr = Tcl_DuplicateObj(commandPtr); Tcl_IncrRefCount(commandPtr); } length = Tcl_GetsObj(inChannel, commandPtr); if (length < 0) { if (Tcl_InputBlocked(inChannel)) { /* * This can only happen if stdin has been set to * non-blocking. In that case cycle back and try again. * This sets up a tight polling loop (since we have no * event loop running). If this causes bad CPU hogging, * we might try toggling the blocking on stdin instead. */ continue; } /* * Either EOF, or an error on stdin; we're done */ break; } /* * Add the newline removed by Tcl_GetsObj back to the string. * Have to add it back before testing completeness, because * it can make a difference. [Bug 1775878]. */ if (Tcl_IsShared(commandPtr)) { Tcl_DecrRefCount(commandPtr); commandPtr = Tcl_DuplicateObj(commandPtr); Tcl_IncrRefCount(commandPtr); } Tcl_AppendToObj(commandPtr, "\n", 1); if (!TclObjCommandComplete(commandPtr)) { prompt = PROMPT_CONTINUE; continue; } prompt = PROMPT_START; /* * The final newline is syntactically redundant, and causes * some error messages troubles deeper in, so lop it back off. */ Tcl_GetStringFromObj(commandPtr, &length); Tcl_SetObjLength(commandPtr, --length); code = Tcl_RecordAndEvalObj(interp, commandPtr, TCL_EVAL_GLOBAL); inChannel = Tcl_GetStdChannel(TCL_STDIN); outChannel = Tcl_GetStdChannel(TCL_STDOUT); errChannel = Tcl_GetStdChannel(TCL_STDERR); Tcl_DecrRefCount(commandPtr); commandPtr = Tcl_NewObj(); Tcl_IncrRefCount(commandPtr); if (code != TCL_OK) { if (errChannel) { Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp)); Tcl_WriteChars(errChannel, "\n", 1); } } else if (tty) { resultPtr = Tcl_GetObjResult(interp); Tcl_IncrRefCount(resultPtr); Tcl_GetStringFromObj(resultPtr, &length); if ((length > 0) && outChannel) { Tcl_WriteObj(outChannel, resultPtr); Tcl_WriteChars(outChannel, "\n", 1); } Tcl_DecrRefCount(resultPtr); } } else { /* (mainLoopProc != NULL) */ /* * If a main loop has been defined while running interactively, we * want to start a fileevent based prompt by establishing a * channel handler for stdin. */ InteractiveState *isPtr = NULL; if (inChannel) { if (tty) { Prompt(interp, &prompt); } isPtr = (InteractiveState *) ckalloc((int) sizeof(InteractiveState)); isPtr->input = inChannel; isPtr->tty = tty; isPtr->commandPtr = commandPtr; isPtr->prompt = prompt; isPtr->interp = interp; Tcl_UnlinkVar(interp, "tcl_interactive"); Tcl_LinkVar(interp, "tcl_interactive", (char *) &(isPtr->tty), TCL_LINK_BOOLEAN); Tcl_CreateChannelHandler(inChannel, TCL_READABLE, StdinProc, (ClientData) isPtr); } (*mainLoopProc)(); mainLoopProc = NULL; if (inChannel) { tty = isPtr->tty; Tcl_UnlinkVar(interp, "tcl_interactive"); Tcl_LinkVar(interp, "tcl_interactive", (char *) &tty, TCL_LINK_BOOLEAN); prompt = isPtr->prompt; commandPtr = isPtr->commandPtr; if (isPtr->input != (Tcl_Channel) NULL) { Tcl_DeleteChannelHandler(isPtr->input, StdinProc, (ClientData) isPtr); } ckfree((char *)isPtr); } inChannel = Tcl_GetStdChannel(TCL_STDIN); outChannel = Tcl_GetStdChannel(TCL_STDOUT); errChannel = Tcl_GetStdChannel(TCL_STDERR); } #ifdef TCL_MEM_DEBUG /* * This code here only for the (unsupported and deprecated) [checkmem] * command. */ if (tclMemDumpFileName != NULL) { mainLoopProc = NULL; Tcl_DeleteInterp(interp); } #endif } done: if ((exitCode == 0) && (mainLoopProc != NULL) && !Tcl_LimitExceeded(interp)) { /* * If everything has gone OK so far, call the main loop proc, if it * exists. Packages (like Tk) can set it to start processing events at * this point. */ (*mainLoopProc)(); mainLoopProc = NULL; } if (commandPtr != NULL) { Tcl_DecrRefCount(commandPtr); } /* * Rather than calling exit, invoke the "exit" command so that users can * replace "exit" with some other command to do additional cleanup on * exit. The Tcl_EvalObjEx call should never return. */ if (!Tcl_InterpDeleted(interp)) { if (!Tcl_LimitExceeded(interp)) { Tcl_Obj *cmd = Tcl_ObjPrintf("exit %d", exitCode); Tcl_IncrRefCount(cmd); Tcl_EvalObjEx(interp, cmd, TCL_EVAL_GLOBAL); Tcl_DecrRefCount(cmd); } /* * If Tcl_EvalObjEx returns, trying to eval [exit], something unusual * is happening. Maybe interp has been deleted; maybe [exit] was * redefined, maybe we've blown up because of an exceeded limit. We * still want to cleanup and exit. */ if (!Tcl_InterpDeleted(interp)) { Tcl_DeleteInterp(interp); } } Tcl_SetStartupScript(NULL, NULL); /* * If we get here, the master interp has been deleted. Allow its * destruction with the last matching Tcl_Release. */ Tcl_Release((ClientData) interp); Tcl_Exit(exitCode); } /* *--------------------------------------------------------------- * * Tcl_SetMainLoop -- * * Sets an alternative main loop function. * * Results: * Returns the previously defined main loop function. * * Side effects: * This function will be called before Tcl exits, allowing for the * creation of an event loop. * *--------------------------------------------------------------- */ void Tcl_SetMainLoop( Tcl_MainLoopProc *proc) { mainLoopProc = proc; } /* *---------------------------------------------------------------------- * * StdinProc -- * * This function is invoked by the event dispatcher whenever standard * input becomes readable. It grabs the next line of input characters, * adds them to a command being assembled, and executes the command if * it's complete. * * Results: * None. * * Side effects: * Could be almost arbitrary, depending on the command that's typed. * *---------------------------------------------------------------------- */ /* ARGSUSED */ static void StdinProc( ClientData clientData, /* The state of interactive cmd line */ int mask) /* Not used. */ { InteractiveState *isPtr = (InteractiveState *) clientData; Tcl_Channel chan = isPtr->input; Tcl_Obj *commandPtr = isPtr->commandPtr; Tcl_Interp *interp = isPtr->interp; int code, length; if (Tcl_IsShared(commandPtr)) { Tcl_DecrRefCount(commandPtr); commandPtr = Tcl_DuplicateObj(commandPtr); Tcl_IncrRefCount(commandPtr); } length = Tcl_GetsObj(chan, commandPtr); if (length < 0) { if (Tcl_InputBlocked(chan)) { return; } if (isPtr->tty) { /* * Would be better to find a way to exit the mainLoop? Or perhaps * evaluate [exit]? Leaving as is for now due to compatibility * concerns. */ Tcl_Exit(0); } Tcl_DeleteChannelHandler(chan, StdinProc, (ClientData) isPtr); return; } if (Tcl_IsShared(commandPtr)) { Tcl_DecrRefCount(commandPtr); commandPtr = Tcl_DuplicateObj(commandPtr); Tcl_IncrRefCount(commandPtr); } Tcl_AppendToObj(commandPtr, "\n", 1); if (!TclObjCommandComplete(commandPtr)) { isPtr->prompt = PROMPT_CONTINUE; goto prompt; } isPtr->prompt = PROMPT_START; Tcl_GetStringFromObj(commandPtr, &length); Tcl_SetObjLength(commandPtr, --length); /* * Disable the stdin channel handler while evaluating the command; * otherwise if the command re-enters the event loop we might process * commands from stdin before the current command is finished. Among other * things, this will trash the text of the command being evaluated. */ Tcl_CreateChannelHandler(chan, 0, StdinProc, (ClientData) isPtr); code = Tcl_RecordAndEvalObj(interp, commandPtr, TCL_EVAL_GLOBAL); isPtr->input = chan = Tcl_GetStdChannel(TCL_STDIN); Tcl_DecrRefCount(commandPtr); isPtr->commandPtr = commandPtr = Tcl_NewObj(); Tcl_IncrRefCount(commandPtr); if (chan != (Tcl_Channel) NULL) { Tcl_CreateChannelHandler(chan, TCL_READABLE, StdinProc, (ClientData) isPtr); } if (code != TCL_OK) { Tcl_Channel errChannel = Tcl_GetStdChannel(TCL_STDERR); if (errChannel != (Tcl_Channel) NULL) { Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp)); Tcl_WriteChars(errChannel, "\n", 1); } } else if (isPtr->tty) { Tcl_Obj *resultPtr = Tcl_GetObjResult(interp); Tcl_Channel outChannel = Tcl_GetStdChannel(TCL_STDOUT); Tcl_IncrRefCount(resultPtr); Tcl_GetStringFromObj(resultPtr, &length); if ((length >0) && (outChannel != (Tcl_Channel) NULL)) { Tcl_WriteObj(outChannel, resultPtr); Tcl_WriteChars(outChannel, "\n", 1); } Tcl_DecrRefCount(resultPtr); } /* * If a tty stdin is still around, output a prompt. */ prompt: if (isPtr->tty && (isPtr->input != (Tcl_Channel) NULL)) { Prompt(interp, &(isPtr->prompt)); isPtr->input = Tcl_GetStdChannel(TCL_STDIN); } } /* *---------------------------------------------------------------------- * * Prompt -- * * Issue a prompt on standard output, or invoke a script to issue the * prompt. * * Results: * None. * * Side effects: * A prompt gets output, and a Tcl script may be evaluated in interp. * *---------------------------------------------------------------------- */ static void Prompt( Tcl_Interp *interp, /* Interpreter to use for prompting. */ PromptType *promptPtr) /* Points to type of prompt to print. Filled * with PROMPT_NONE after a prompt is * printed. */ { Tcl_Obj *promptCmdPtr; int code; Tcl_Channel outChannel, errChannel; if (*promptPtr == PROMPT_NONE) { return; } promptCmdPtr = Tcl_GetVar2Ex(interp, ((*promptPtr == PROMPT_CONTINUE) ? "tcl_prompt2" : "tcl_prompt1"), NULL, TCL_GLOBAL_ONLY); if (Tcl_InterpDeleted(interp)) { return; } if (promptCmdPtr == NULL) { defaultPrompt: outChannel = Tcl_GetStdChannel(TCL_STDOUT); if ((*promptPtr == PROMPT_START) && (outChannel != (Tcl_Channel) NULL)) { Tcl_WriteChars(outChannel, DEFAULT_PRIMARY_PROMPT, strlen(DEFAULT_PRIMARY_PROMPT)); } } else { code = Tcl_EvalObjEx(interp, promptCmdPtr, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (script that generates prompt)"); errChannel = Tcl_GetStdChannel(TCL_STDERR); if (errChannel != (Tcl_Channel) NULL) { Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp)); Tcl_WriteChars(errChannel, "\n", 1); } goto defaultPrompt; } } outChannel = Tcl_GetStdChannel(TCL_STDOUT); if (outChannel != (Tcl_Channel) NULL) { Tcl_Flush(outChannel); } *promptPtr = PROMPT_NONE; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */
fe3da722e00c321c45d9290c9b81d5bac67ba9f0
5ff4b6986e6799bc0e143e060bafc14369030d8b
/toolchain/riscv-isa-sim/riscv/insns/vfwnmsac_vv.h
ce97749e1c22b746c58351b4d054d5f7830130d8
[ "LicenseRef-scancode-bsd-3-clause-jtag", "GPL-3.0-or-later", "MIT", "LicenseRef-scancode-unknown-license-reference", "GPL-1.0-or-later", "LLVM-exception", "Apache-2.0", "BSD-3-Clause" ]
permissive
pulp-platform/mempool
7583204b2436cfc12ed95599463e51ad4df51557
c98fb3ada4f255623eaf9b09861f397a60c3d96b
refs/heads/main
2023-08-08T09:07:56.696580
2023-07-27T17:24:38
2023-07-27T17:24:38
223,218,149
178
28
Apache-2.0
2023-07-27T17:24:39
2019-11-21T16:34:37
C
UTF-8
C
false
false
161
h
vfwnmsac_vv.h
// vfwnmsac.vv vd, vs2, vs1 VI_VFP_VV_LOOP_WIDE ({ vd = f32_mulAdd(f32(vs1.v ^ F32_SIGN), vs2, vd); }, { vd = f64_mulAdd(f64(vs1.v ^ F64_SIGN), vs2, vd); })
870e7b8501dd956fff3647a87cfb1a004781cfdb
0ba9681b235b377b3f57d52532ab7212d4d4cd8a
/intTests/test0044_invariant_4/test.c
5b174d02042bc1e2b01b0ed31ed14f2fbaac3bc2
[ "BSD-3-Clause" ]
permissive
GaloisInc/saw-script
d9a3eb7b05c1bcbcc319987223cd53b903b55b5d
79ddd800bec59528958ed6d7593304e2b17b7dfb
refs/heads/master
2023-09-01T09:47:31.415255
2023-08-30T11:26:08
2023-08-30T11:26:08
34,082,065
458
82
BSD-3-Clause
2023-09-14T16:23:09
2015-04-16T21:39:32
Haskell
UTF-8
C
false
false
256
c
test.c
#include <stdint.h> #include <stdlib.h> extern void __breakpoint__inv(uint8_t**, size_t*, size_t*) __attribute__((noduplicate)); void array_inc(uint8_t a[], size_t n) { for (size_t i = 0; __breakpoint__inv(&a, &n, &i), i < n; ++i) { ++a[i]; } }
08ca136cadd5df16a250d5675c53bc442c2348ab
e73547787354afd9b717ea57fe8dd0695d161821
/include/mapfs/kpa_134_hit.h
8c2131478f1b7fd245fd5a02437e34dea43c3a4a
[]
no_license
pmret/papermario
8b514b19653cef8d6145e47499b3636b8c474a37
9774b26d93f1045dd2a67e502b6efc9599fb6c31
refs/heads/main
2023-08-31T07:09:48.951514
2023-08-21T18:07:08
2023-08-21T18:07:08
287,151,133
904
139
null
2023-09-14T02:44:23
2020-08-13T01:22:57
C
UTF-8
C
false
false
2,377
h
kpa_134_hit.h
#define COLLIDER_Root 0x39 #define COLLIDER_g120 0x38 #define COLLIDER_mae 0x37 #define COLLIDER_migi 0x36 #define COLLIDER_oku 0x35 #define COLLIDER_hidari 0x34 #define COLLIDER_g119 0x33 #define COLLIDER_o411 0x32 #define COLLIDER_s_suimen 0x31 #define COLLIDER_o358 0x30 #define COLLIDER_g98 0x2F #define COLLIDER_anaw 0x2E #define COLLIDER_naw 0x2D #define COLLIDER_ttaw 0x2C #define COLLIDER_deiliaw 0x2B #define COLLIDER_deilitaw 0x2A #define COLLIDER_noriba 0x29 #define COLLIDER_ttno 0x28 #define COLLIDER_nno 0x27 #define COLLIDER_deilino 0x26 #define COLLIDER_exite 0x25 #define COLLIDER_ne 0x24 #define COLLIDER_tte 0x23 #define COLLIDER_deilie 0x22 #define COLLIDER_deilite 0x21 #define COLLIDER_exitw 0x20 #define COLLIDER_ttw 0x1F #define COLLIDER_nw 0x1E #define COLLIDER_deiliw2 0x1D #define COLLIDER_deiliw 0x1C #define COLLIDER_deilitw 0x1B #define COLLIDER_g117 0x1A #define COLLIDER_sikake 0x19 #define COLLIDER_g114 0x18 #define COLLIDER_o384 0x17 #define COLLIDER_g112 0x16 #define COLLIDER_o383 0x15 #define COLLIDER_g107 0x14 #define COLLIDER_o378 0x13 #define COLLIDER_g101 0x12 #define COLLIDER_o372 0x11 #define COLLIDER_kakusi 0x10 #define COLLIDER_o369 0xF #define COLLIDER_o368 0xE #define COLLIDER_k_yuka 0xD #define COLLIDER_k_kabe1 0xC #define COLLIDER_u_hasira 0xB #define COLLIDER_o403 0xA #define COLLIDER_o402 0x9 #define COLLIDER_o400 0x8 #define COLLIDER_o401 0x7 #define COLLIDER_o309 0x6 #define COLLIDER_o304 0x5 #define COLLIDER_o298 0x4 #define COLLIDER_u_yuka 0x3 #define COLLIDER_s_saku 0x2 #define COLLIDER_o397 0x1 #define COLLIDER_ue 0x0 #define ZONE_Root 0x4 #define ZONE_g32 0x3 #define ZONE_3 0x2 #define ZONE_2 0x1 #define ZONE_1 0x0
845e0b1bbce6eab0fc5cdefed4150ac1b1068a75
e1ba6e7d2c51c2527158664ae4d8fbed2cb5572f
/types/regex_engine/struct_regex_compiler_state.h
32553f6d09031108278f2dcc387b893e813ff356
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
RobertElderSoftware/recc
1bc30b975bb736e7733da78653aa2b0efb2d80eb
a3e773d35f1ceda81f1e5ed2d1dfef5b10fd3848
refs/heads/master
2023-07-30T21:35:31.956235
2020-01-24T20:03:46
2020-01-24T20:03:46
28,613,742
264
22
Apache-2.0
2017-12-04T01:39:56
2014-12-30T01:57:05
C
UTF-8
C
false
false
1,205
h
struct_regex_compiler_state.h
/* Copyright 2016 Robert Elder Software 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. */ /*GETS_REPLACED_WITH_INCLUDES*/ struct regex_compiler_state{ struct memory_pool_collection * m; /* Used for optimizing memory allocation/deallocation */ struct regex_compiler_error * errors; /* Is non-null if there was an error during compillation. */ struct regex_parser_node * top_node; /* The top node of the parse tree */ struct regex_computation_node * first_computation_node; /* The first 'instruction' to execute in the regex */ unsigned char * buffer; unsigned int position; unsigned int buffer_length; unsigned int match_id; unsigned int pad; };
b5c511dd8fd95f8df229464768444eedfc7b6ae2
76f9898ff7a555f4a729d725056a317af818375d
/assets/scenes/dungeons/deku_tree/deku_tree_room_00.h
b1cdf98c4ab59a7152c065dcc0031d079ddb7cd2
[]
no_license
z64proto/sw97
0b65837ab2f2a4073faca5670761d7fe0e74d29d
f571505ade2cefd4a5b5d19da06d33e7c6b02c60
refs/heads/master
2023-08-01T02:47:42.895871
2022-05-15T20:29:08
2022-05-15T20:29:08
430,216,978
208
29
null
2021-11-22T12:23:50
2021-11-20T21:52:59
C
UTF-8
C
false
false
5,486
h
deku_tree_room_00.h
extern MeshHeader2 deku_tree_room_00MeshHeader0x000150; extern MeshEntry2 deku_tree_room_00MeshDListEntry0x00015C[16]; extern Gfx dlist0x0004A0[]; extern u64 deku_tree_room_00Tex_011B60[]; extern u64 deku_tree_room_00Tex_012B60[]; extern Gfx dlist0x000AA8[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x001458[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_015B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x002008[]; extern u64 deku_tree_room_00Tex_00E360[]; extern u64 deku_tree_room_00Tex_00F360[]; extern u64 deku_tree_room_00Tex_013B60[]; extern u64 deku_tree_room_00Tex_014B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x002838[]; extern u64 deku_tree_room_00Tex_011B60[]; extern u64 deku_tree_room_00Tex_012B60[]; extern Gfx dlist0x003370[]; extern u64 deku_tree_room_00Tex_011360[]; extern u64 deku_tree_room_00Tex_011B60[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_014B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x004268[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_014B60[]; extern u64 deku_tree_room_00Tex_015B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x004F88[]; extern u64 deku_tree_room_00Tex_00BB60[]; extern u64 deku_tree_room_00Tex_00E360[]; extern u64 deku_tree_room_00Tex_00F360[]; extern u64 deku_tree_room_00Tex_013B60[]; extern u64 deku_tree_room_00Tex_015B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x005790[]; extern u64 deku_tree_room_00Tex_011B60[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x006850[]; extern u64 deku_tree_room_00Tex_00C360[]; extern u64 deku_tree_room_00Tex_00D360[]; extern u64 deku_tree_room_00Tex_011360[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_014B60[]; extern u64 deku_tree_room_00Tex_015B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x0073D0[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_015B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x0089A8[]; extern u64 deku_tree_room_00Tex_00E360[]; extern u64 deku_tree_room_00Tex_00F360[]; extern u64 deku_tree_room_00Tex_010360[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_013B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x0093B8[]; extern u64 deku_tree_room_00Tex_011B60[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x009EA8[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_014B60[]; extern u64 deku_tree_room_00Tex_015B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x00ABB8[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_014B60[]; extern u64 deku_tree_room_00Tex_015B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[]; extern Gfx dlist0x00B6C0[]; extern u64 deku_tree_room_00Tex_00E360[]; extern u64 deku_tree_room_00Tex_00F360[]; extern u64 deku_tree_room_00Tex_013B60[]; extern u64 deku_tree_room_00Tex_014B60[]; extern u64 deku_tree_room_00Tex_015B60[]; extern u64 deku_tree_room_00Tex_016B60[]; s16 deku_tree_room_00ObjectList0x000038[]; extern ActorEntry deku_tree_room_00ActorList0x000048[16]; extern s16 deku_tree_room_00ObjectList0x000038[8]; extern ActorEntry deku_tree_room_00ActorList0x000048[16]; extern MeshHeader2 deku_tree_room_00MeshHeader0x000150; extern MeshEntry2 deku_tree_room_00MeshDListEntry0x00015C[16]; extern Gfx deku_tree_room_00Dlist0x0004A0[]; extern Gfx deku_tree_room_00Dlist0x000AA8[]; extern Gfx deku_tree_room_00Dlist0x001458[]; extern Gfx deku_tree_room_00Dlist0x002008[]; extern Gfx deku_tree_room_00Dlist0x002838[]; extern Gfx deku_tree_room_00Dlist0x003370[]; extern Gfx deku_tree_room_00Dlist0x004268[]; extern Gfx deku_tree_room_00Dlist0x004F88[]; extern Gfx deku_tree_room_00Dlist0x005790[]; extern Gfx deku_tree_room_00Dlist0x006850[]; extern Gfx deku_tree_room_00Dlist0x0073D0[]; extern Gfx deku_tree_room_00Dlist0x0089A8[]; extern Gfx deku_tree_room_00Dlist0x0093B8[]; extern Gfx deku_tree_room_00Dlist0x009EA8[]; extern Gfx deku_tree_room_00Dlist0x00ABB8[]; extern Gfx deku_tree_room_00Dlist0x00B6C0[]; extern u64 deku_tree_room_00Tex_00BB60[]; extern u64 deku_tree_room_00Tex_00C360[]; extern u64 deku_tree_room_00Tex_00D360[]; extern u64 deku_tree_room_00Tex_00E360[]; extern u64 deku_tree_room_00Tex_00F360[]; extern u64 deku_tree_room_00Tex_010360[]; extern u64 deku_tree_room_00Tex_011360[]; extern u64 deku_tree_room_00Tex_011B60[]; extern u64 deku_tree_room_00Tex_012B60[]; extern u64 deku_tree_room_00Tex_013B60[]; extern u64 deku_tree_room_00Tex_014B60[]; extern u64 deku_tree_room_00Tex_015B60[]; extern u64 deku_tree_room_00Tex_016B60[]; extern u64 deku_tree_room_00Tex_017B60[];
bf6b9e314ce237244253e3b1016db0612aae7d8f
c0669ce5f6bed1c8e474a83cf3e0df9d6af9af3e
/include/ares_version.h
5c662ec3e7567edb67656d1222e0eebf89483de6
[ "MIT", "NTP" ]
permissive
c-ares/c-ares
c247aa19379ceac4154977e8f6e69ded8966c6d7
7f3262312f246556d8c1bdd8ccc1844847f42787
refs/heads/main
2023-08-29T22:19:07.278439
2023-08-18T15:35:49
2023-08-18T15:35:49
571,708
1,395
563
NOASSERTION
2023-09-14T09:59:18
2010-03-20T19:30:23
C++
UTF-8
C
false
false
1,359
h
ares_version.h
/* * Copyright (C) Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" * without express or implied warranty. * * SPDX-License-Identifier: MIT */ #ifndef ARES__VERSION_H #define ARES__VERSION_H /* This is the global package copyright */ #define ARES_COPYRIGHT "2004 - 2023 Daniel Stenberg, <daniel@haxx.se>." #define ARES_VERSION_MAJOR 1 #define ARES_VERSION_MINOR 19 #define ARES_VERSION_PATCH 1 #define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\ (ARES_VERSION_MINOR<<8)|\ (ARES_VERSION_PATCH)) #define ARES_VERSION_STR "1.19.1" #if (ARES_VERSION >= 0x010700) # define CARES_HAVE_ARES_LIBRARY_INIT 1 # define CARES_HAVE_ARES_LIBRARY_CLEANUP 1 #else # undef CARES_HAVE_ARES_LIBRARY_INIT # undef CARES_HAVE_ARES_LIBRARY_CLEANUP #endif #endif
0a21d2d57ec6d2cbfccdc38d2a6bdc957dc495a5
3c2d22959c64816d2062778febff45c22b477c77
/flag_test.c
4d6591a66aae7d9570cdb0656be21617876a9070
[ "MIT" ]
permissive
clibs/flag
7157abe5e69495eef04766694d8d54c37dad4b38
aab6ebbb6af4ee0a4c811d3d1b23387b097a030e
refs/heads/master
2022-05-31T01:06:24.125817
2022-04-30T10:42:16
2022-04-30T10:42:16
45,357,212
127
9
MIT
2022-04-30T10:40:03
2015-11-01T20:58:37
C
UTF-8
C
false
false
5,438
c
flag_test.c
#include "describe/describe.h" #include "flag.h" int main(){ describe("flag_parse()") { it("should act as a singleton") { int n = 100, c = 5; const char *addr = NULL; const char *args[] = { "program", "--requests", "500", "--address", ":3000" }; flag_int(&n, "requests", "Number of requests"); flag_int(&c, "concurrency", "Number of concurrent requests"); flag_string(&addr, "address", "Target URL"); flag_parse(5, args, "1.0.0"); assert(n == 500); assert(c == 5); assert(addr == ":3000"); } } describe("flagset_parse()") { it("should parse flags") { int n = 1000, c = 5, b = 50; const char *args[] = { "--requests", "100", "--concurrency", "10" }; flagset_t *set = flagset_new(); flagset_int(set, &n, "requests", "Number of requests"); flagset_int(set, &c, "concurrency", "Number of concurrent requests"); flagset_int(set, &b, "batch-size", "Batch size"); flag_error err = flagset_parse(set, 4, args); assert(err == 0); assert(err == FLAG_OK); assert(n == 100); assert(c == 10); assert(b == 50); flagset_free(set); } it("should return error when parsing fails") { int n = 0; const char *args[] = { "--num", "foo" }; flagset_t *set = flagset_new(); flagset_int(set, &n, "num", "Number of requests"); flag_error err = flagset_parse(set, 2, args); assert(err == FLAG_ERROR_PARSING); assert(set->error.flag->name == "num"); flagset_free(set); } it("should return error when arg is missing") { int n = 0; const char *args[] = { "--num" }; flagset_t *set = flagset_new(); flagset_int(set, &n, "num", "Number of requests"); flag_error err = flagset_parse(set, 1, args); assert(err == FLAG_ERROR_ARG_MISSING); assert(set->error.flag->name == "num"); flagset_free(set); } it("should return error when arg is flag") { int n = 0; const char *args[] = { "--num", "--other" }; flagset_t *set = flagset_new(); flagset_int(set, &n, "num", "Number of requests"); flag_error err = flagset_parse(set, 2, args); assert(err == FLAG_ERROR_ARG_MISSING); assert(set->error.flag->name == "num"); flagset_free(set); } it("should error on undefined flags") { const char *args[] = { "--whatever" }; flagset_t *set = flagset_new(); flag_error err = flagset_parse(set, 1, args); assert(err == FLAG_ERROR_UNDEFINED_FLAG); flagset_free(set); } it("should not match flag prefixes") { const char *args[] = { "--versioning" }; flagset_t *set = flagset_new(); flag_error err = flagset_parse(set, 1, args); assert(err == FLAG_ERROR_UNDEFINED_FLAG); flagset_free(set); } it("should error on non-bool negation") { int n = 0; const char *args[] = { "--no-num" }; flagset_t *set = flagset_new(); flagset_int(set, &n, "num", ""); flag_error err = flagset_parse(set, 1, args); assert(err == FLAG_ERROR_UNDEFINED_FLAG); flagset_free(set); } it("should error on missing flag negation") { const char *args[] = { "--no-whatever" }; flagset_t *set = flagset_new(); flag_error err = flagset_parse(set, 1, args); assert(err == FLAG_ERROR_UNDEFINED_FLAG); flagset_free(set); } it("should provide resulting argc and argv") { int n = 0; const char *args[] = { "some", "--num", "5", "other", "args" }; flagset_t *set = flagset_new(); flagset_int(set, &n, "num", "Number of requests"); flag_error err = flagset_parse(set, 5, args); assert(err == FLAG_OK); assert(3 == set->argc); assert("some" == set->argv[0]); assert("other" == set->argv[1]); assert("args" == set->argv[2]); flagset_free(set); } } describe("flagset_int()") { it("should support ints") { int n = 0; const char *args[] = { "--num", "123" }; flagset_t *set = flagset_new(); flagset_int(set, &n, "num", ""); flag_error err = flagset_parse(set, 2, args); assert(err == FLAG_OK); assert(n == 123); flagset_free(set); } } describe("flagset_string()") { it("should support strings") { const char *addr = NULL; const char *args[] = { "--address", "localhost:3000" }; flagset_t *set = flagset_new(); flagset_string(set, &addr, "address", "Bind address"); flag_error err = flagset_parse(set, 2, args); assert(err == FLAG_OK); assert(addr == "localhost:3000"); flagset_free(set); } } describe("flagset_bool()") { it("should support bools") { bool v = false; const char *args[] = { "--enable" }; flagset_t *set = flagset_new(); flagset_bool(set, &v, "enable", ""); flag_error err = flagset_parse(set, 1, args); assert(err == FLAG_OK); assert(v == true); flagset_free(set); } it("should support negation") { bool v = true; const char *args[] = { "--no-colors" }; flagset_t *set = flagset_new(); flagset_bool(set, &v, "colors", ""); flag_error err = flagset_parse(set, 1, args); assert(err == FLAG_OK); assert(v == false); flagset_free(set); } } return assert_failures(); }
eb8601cf4804d59db44f3dde5090ef41c2563804
41eb0837713f297134529591b66f3d4d82bcf98e
/src/Raine/source/bonus/xkeymap.c
d495ca516b380c5aa42a8c76179c7e9f4a6d214b
[]
no_license
AlexxandreFS/Batocera.PLUS
27b196b3cbb781b6fc99e62cad855396d1d5f8f2
997ee763ae7135fdf0c34a081e789918bd2eb169
refs/heads/master
2023-08-17T21:52:39.083687
2023-08-17T15:03:44
2023-08-17T15:03:44
215,869,486
135
57
null
2023-08-14T14:46:14
2019-10-17T19:23:42
C
UTF-8
C
false
false
10,038
c
xkeymap.c
/* xkeymap.c --- create mapping from X keycodes to Allegro scancodes * * Compile with : gcc -o keymap xkeymap.c -lalleg -lalleg_unsharable * it needs at least allegro-3.9.34 (in cvs at this time) * * This file is gift-ware. This file is given to you freely * as a gift. You may use, modify, redistribute, and generally hack * it about in any way you like, and you do not have to give anyone * anything in return. * * I do not accept any responsibility for any effects, adverse or * otherwise, that this code may have on just about anything that * you can think of. Use it at your own risk. * * Copyright (C) 2000 Michael Bukin */ #include <stdio.h> #include <allegro.h> #include <xalleg.h> static struct { int key; char *string; int scancode; } keymap[] = { { KEY_ESC, "KEY_ESC", 0x01 }, { KEY_F1, "KEY_F1", 0x3B }, { KEY_F2, "KEY_F2", 0x3C }, { KEY_F3, "KEY_F3", 0x3D }, { KEY_F4, "KEY_F4", 0x3E }, { KEY_F5, "KEY_F5", 0x3F }, { KEY_F6, "KEY_F6", 0x40 }, { KEY_F7, "KEY_F7", 0x41 }, { KEY_F8, "KEY_F8", 0x42 }, { KEY_F9, "KEY_F9", 0x43 }, { KEY_F10, "KEY_F10", 0x44 }, { KEY_F11, "KEY_F11", 0x57 }, { KEY_F12, "KEY_F12", 0x58 }, { KEY_PRTSCR, "KET_PRTSCR", 0x54 | 0x80 }, { KEY_SCRLOCK, "KET_SCRLOCK", 0x46 }, { KEY_PAUSE, "KEY_PAUSE", 0x00 | 0x100 }, { KEY_TILDE, "KEY_TILDE", 0x29 }, { KEY_1, "KEY_1", 0x02 }, { KEY_2, "KEY_2", 0x03 }, { KEY_3, "KEY_3", 0x04 }, { KEY_4, "KEY_4", 0x05 }, { KEY_5, "KEY_5", 0x06 }, { KEY_6, "KEY_6", 0x07 }, { KEY_7, "KEY_7", 0x08 }, { KEY_8, "KEY_8", 0x09 }, { KEY_9, "KEY_9", 0x0A }, { KEY_0, "KEY_0", 0x0B }, { KEY_MINUS, "KEY_MINUS", 0x0C }, { KEY_EQUALS, "KEY_EQUALS", 0x0D }, { KEY_BACKSLASH, "KEY_BACKSLASH", 0x2B }, { KEY_BACKSPACE, "KEY_BACKSPACE", 0x0E }, { KEY_TAB, "KEY_TAB", 0x0F }, { KEY_Q, "KEY_Q", 0x10 }, { KEY_W, "KEY_W", 0x11 }, { KEY_E, "KEY_E", 0x12 }, { KEY_R, "KEY_R", 0x13 }, { KEY_T, "KEY_T", 0x14 }, { KEY_Y, "KEY_Y", 0x15 }, { KEY_U, "KEY_U", 0x16 }, { KEY_I, "KEY_I", 0x17 }, { KEY_O, "KEY_O", 0x18 }, { KEY_P, "KEY_P", 0x19 }, { KEY_OPENBRACE, "KEY_OPENBRACE", 0x1A }, { KEY_CLOSEBRACE, "KEY_CLOSEBRACE", 0x1B }, { KEY_ENTER, "KEY_ENTER", 0x1C }, { KEY_CAPSLOCK, "KEY_CAPSLOCK", 0x3A }, { KEY_A, "KEY_A", 0x1E }, { KEY_S, "KEY_S", 0x1F }, { KEY_D, "KEY_D", 0x20 }, { KEY_F, "KEY_F", 0x21 }, { KEY_G, "KEY_G", 0x22 }, { KEY_H, "KEY_H", 0x23 }, { KEY_J, "KEY_J", 0x24 }, { KEY_K, "KEY_K", 0x25 }, { KEY_L, "KEY_L", 0x26 }, { KEY_COLON, "KEY_COLON", 0x27 }, { KEY_QUOTE, "KEY_QUOTE", 0x28 }, { KEY_LSHIFT, "KEY_LSHIFT", 0x2A }, { KEY_Z, "KEY_Z", 0x2C }, { KEY_X, "KEY_X", 0x2D }, { KEY_C, "KEY_C", 0x2E }, { KEY_V, "KEY_V", 0x2F }, { KEY_B, "KEY_B", 0x30 }, { KEY_N, "KEY_N", 0x31 }, { KEY_M, "KEY_M", 0x32 }, { KEY_COMMA, "KEY_COMMA", 0x33 }, { KEY_STOP, "KEY_STOP", 0x34 }, { KEY_SLASH, "KEY_SLASH", 0x35 }, { KEY_RSHIFT, "KEY_RSHIFT", 0x36 }, { KEY_LCONTROL, "KEY_LCONTROL", 0x1D }, { KEY_LWIN, "KEY_LWIN", 0x5B | 0x80 }, { KEY_ALT, "KEY_ALT", 0x38 }, { KEY_SPACE, "KEY_SPACE", 0x39 }, { KEY_ALTGR, "KEY_ALRGR", 0x38 | 0x80 }, { KEY_RWIN, "KEY_RWIN", 0x5C | 0x80 }, { KEY_MENU, "KEY_MENU", 0x5D | 0x80 }, { KEY_RCONTROL, "KEY_RCONTROL", 0x1D | 0x80 }, { KEY_INSERT, "KEY_INSERT", 0x52 | 0x80 }, { KEY_HOME, "KEY_HOME", 0x47 | 0x80 }, { KEY_PGUP, "KEY_PGUP", 0x49 | 0x80 }, { KEY_DEL, "KEY_DEL", 0x53 | 0x80 }, { KEY_END, "KEY_END", 0x4F | 0x80 }, { KEY_PGDN, "KEY_PGDN", 0x51 | 0x80 }, { KEY_UP, "KEY_UP", 0x48 | 0x80 }, { KEY_LEFT, "KEY_LEFT", 0x4B | 0x80 }, { KEY_DOWN, "KEY_DOWN", 0x50 | 0x80 }, { KEY_RIGHT, "KEY_RIGHT", 0x4D | 0x80 }, { KEY_NUMLOCK, "KEY_NUMLOCK", 0x45 }, { KEY_SLASH_PAD, "KEY_SLASH_PAD", 0x35 | 0x80 }, { KEY_ASTERISK, "KEY_ASTERISK", 0x37 }, { KEY_MINUS_PAD, "KEY_MINUS_PAD", 0x4A | 0x80 }, { KEY_7_PAD, "KEY_7_PAD", 0x47 }, { KEY_8_PAD, "KEY_8_PAD", 0x48 }, { KEY_9_PAD, "KEY_9_PAD", 0x49 }, { KEY_PLUS_PAD, "KEY_PLUS_PAD", 0x4E }, { KEY_4_PAD, "KEY_4_PAD", 0x4B }, { KEY_5_PAD, "KEY_5_PAD", 0x4C }, { KEY_6_PAD, "KEY_6_PAD", 0x4D }, { KEY_1_PAD, "KEY_1_PAD", 0x4F }, { KEY_2_PAD, "KEY_2_PAD", 0x50 }, { KEY_3_PAD, "KEY_3_PAD", 0x51 }, { KEY_ENTER_PAD, "KEY_ENTER_PAD", 0x1C | 0x80 }, { KEY_0_PAD, "KEY_0_PAD", 0x52 }, { KEY_DEL_PAD, "KEY_DEL_PAD", 0x53 }, { KEY_BACKSLASH2, "KEY_BACKSLASH2", 0x56 | 0x80 }, { KEY_YEN, "KEY_YEN", 0x73 }, { KEY_YEN2, "KEY_YEN2", 0x7D }, { KEY_KANA, "KEY_KANA", 0x70 }, { KEY_HENKAN, "KEY_HENKAN", 0x79 }, { KEY_MUHENKAN, "KEY_MUHENKAN", 0x7B }, { 0, 0 } }; static int black = 0; static int white = 1; static int red = 2; static int yellow = 3; static volatile int waiting_for_key = 0; static volatile int new_keycode = 0; static int keycode_to_scancode[256]; static void get_raw_keycode (int pressed, int keycode) { if (pressed && waiting_for_key) { new_keycode = keycode; waiting_for_key = 0; } } static void setup_all_keys (void) { int i, y, ymin, ymax; static char *welcome[] = { "Press a key to map to this scancode", "Press mouse button for next scancode", 0 }; text_mode (-1); /* Clear screen and output prompt. */ clear_to_color (screen, white); for (i = 0; welcome[i] != 0; i++) textout (screen, font, welcome[i], 8, i * 8 + 8, black); ymin = i * 8 + 16; ymax = ymin + 8 * 8; y = ymin - 8; for (i = 0; keymap[i].string != 0; i++) { y += 8; if (y >= ymax) { blit (screen, screen, 8, ymin + 8, 8, ymin, 200, ymax - ymin); y -= 8; } textprintf (screen, font, 8, y, red, "scancode: %s", keymap[i].string); /* Wait while any mouse button is pressed. */ do { poll_mouse (); } while (mouse_b); /* Wait for new key press. */ new_keycode = -1; waiting_for_key = 1; do { poll_keyboard (); poll_mouse (); if (mouse_b) waiting_for_key = 0; } while (waiting_for_key); /* Save keycode to scancode mapping. */ if ((new_keycode >= 0) && (new_keycode < 256)) { _xwin.keycode_to_scancode[new_keycode] = keymap[i].scancode; keycode_to_scancode[new_keycode] = keymap[i].scancode; } } do { poll_keyboard (); poll_mouse (); } while ((key[KEY_MUHENKAN]) || (mouse_b)); clear_keybuf (); } static void test_key_map (void) { int i; static int key_was_pressed[KEY_MAX + 1]; static int key_is_pressed[KEY_MAX + 1]; static char *welcome[] = { "Key that is pressed now is marked with red", "Key that was pressed is marked with yellow", "Press mouse button or Escape to exit test", 0 }; text_mode (-1); /* Clear screen and output prompt. */ clear_to_color (screen, white); for (i = 0; welcome[i] != 0; i++) textout (screen, font, welcome[i], 8, i * 8 + 8, black); clear_to_color (screen, white); for (i = 0; keymap[i].string != 0; i++) textout (screen, font, keymap[i].string, 32 + (i % 4) * 160, 40 + (i / 4) * 14, black); do { poll_keyboard (); poll_mouse (); } while ((key[KEY_ESC]) || (mouse_b)); do { poll_keyboard (); poll_mouse (); for (i = 0; i < KEY_MAX; i++) { if (key[i]) key_was_pressed[i] = key_is_pressed[i] = 1; else key_is_pressed[i] = 0; } for (i = 0; keymap[i].string != 0; i++) { int x = 16 + (i % 4) * 160; int y = 40 + (i / 4) * 14; int k = keymap[i].key; if (key_is_pressed[k]) rectfill (screen, x, y, x + 7, y + 7, red); else if (key_was_pressed[k]) rectfill (screen, x, y, x + 7, y + 7, yellow); else rectfill (screen, x, y, x + 7, y + 7, white); } } while ((!key[KEY_ESC]) && (!mouse_b)); do { poll_keyboard (); poll_mouse (); } while ((key[KEY_ESC]) || (mouse_b)); clear_keybuf (); } static void save_key_map (void) { int i; char *section, *option_format, option[80], tmp1[80], tmp2[80]; set_config_file ("allegro.cfg"); section = uconvert_ascii ("xkeymap", tmp1); option_format = uconvert_ascii ("keycode%d", tmp2); for (i = 0; i < 256; i++) { if (keycode_to_scancode[i] > 0) { usprintf (option, option_format, i); set_config_int (section, option, keycode_to_scancode[i]); } } } static DIALOG main_dialog[] = { { d_clear_proc, 0, 0, 250, 102, 0, 0, 0, 0, 0, 0, 0 }, { d_button_proc, 10, 10, 230, 16, 0, 255, 'm', D_EXIT, 0, 0, "Setup key &mappings" }, { d_button_proc, 10, 32, 230, 16, 0, 255, 't', D_EXIT, 0, 0, "&Test key mappings" }, { d_button_proc, 10, 54, 230, 16, 0, 255, 's', D_EXIT, 0, 0, "&Save and exit" }, { d_button_proc, 10, 76, 230, 16, 0, 255, 'x', D_EXIT, 0, 0, "E&xit" }, { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, }; static void show_main_dialog (void) { int focus = 1; /* Prepare dialog. */ set_dialog_color (main_dialog, black, white); centre_dialog (main_dialog); /* Parse input. */ while (1) { focus = do_dialog (main_dialog, focus); switch (focus) { case 1: /* Setup all key mappings. */ setup_all_keys (); break; case 2: /* Test key mappings. */ test_key_map (); break; case 3: /* Save and quit. */ save_key_map (); return; case 4: /* Just exit. */ return; } } } int main (void) { int i; allegro_init (); install_keyboard (); install_mouse (); install_timer (); if (set_gfx_mode (GFX_XWINDOWS, 640, 480, 0, 0) < 0) { allegro_message ("Can not set graphics mode\n%s", allegro_error); return 0; } black = makecol (0, 0, 0); white = makecol (255, 255, 255); red = makecol (255, 0, 0); yellow = makecol (255, 255, 0); /* Clear key mappings. */ for (i = 0; i < 256; i++) keycode_to_scancode[i] = -1; /* Hook X-windows keyboard callback. */ _xwin_keyboard_callback = get_raw_keycode; show_main_dialog (); return 0; } END_OF_MAIN (); /* * xkeymap.c ends here */
80d79a8e263a76ea1885e4e53c22a8c91e82ac91
1db673907c7946c2ea857cc9aa8b6f7f4060e36a
/Include/CharType.h
45612495f9383a4411354aed6ba645fc27a99ded
[ "BSD-3-Clause" ]
permissive
pdpdds/SkyOS
a973cd9f1b4e541ae4ac26d19df29aa3f4110db3
db2ce044c581fc2dfe068723fb0be2336c7f18d9
refs/heads/master
2023-07-21T15:24:46.457637
2023-07-17T16:32:04
2023-07-17T16:32:04
97,029,119
160
49
null
2023-04-30T15:33:47
2017-07-12T16:23:01
C
UTF-8
C
false
false
1,878
h
CharType.h
#pragma once #include "windef.h" static inline BYTE ToLower(BYTE ch) { if (ch >= 'A' && ch <= 'Z') return ch + 32; else return ch; } static inline BYTE ToUpper(BYTE ch) { if (ch >= 'a' && ch <= 'z') return ch - 32; else return ch; } static inline int ToDigit(char c) { if (c <= '0') return 0; if (c >= '9') return 9; return c - '0'; } static inline char ToChar(int n) { if (n >= 9) return '9'; if (n <= 0) return '0'; return (char)(n + '0'); } static inline BYTE IsUpper(BYTE ch) { if (ch >= 'A' && ch <= 'Z') return TRUE; else return FALSE; } static inline BYTE IsLower(BYTE ch) { if (ch >= 'a' && ch <= 'z') return TRUE; else return FALSE; } static inline BYTE IsAlpha(BYTE ch) { if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) return TRUE; else return FALSE; } static inline BYTE IsAscii(int ch) { if (ch >= 0x0 && ch <= 0x7F) return TRUE; else return FALSE; } static inline BYTE IsCntrl(BYTE ch) { if (ch <= 0x1F || ch == 0x7F) return TRUE; else return FALSE; } static inline BYTE IsDigit(BYTE ch) { if (ch >= '0' && ch <= '9') return TRUE; else return FALSE; } static inline BYTE IsPrint(BYTE ch) { if (ch >= 0x20 && ch <= 0x7E) return TRUE; else return FALSE; } static inline BYTE IsGraph(BYTE ch) { if ((ch >= 0x20 && ch <= 0x7E) && ch != 0x32) return TRUE; else return FALSE; } static inline BYTE IsSpace(BYTE ch) { if ((ch >= 0x9 && ch <= 0x0D) || ch == 0x20) return TRUE; else return FALSE; } static inline BYTE IsPunct(BYTE ch) { if (IsCntrl(ch) || IsSpace(ch)) return TRUE; else return FALSE; } static inline BYTE IsXDigit(BYTE ch) { if (IsDigit(ch) || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) return TRUE; else return FALSE; }
c062937fb6e4c5ed28c94db3c3ae918da6a23406
c0bfd93cd7f26a271268e504959256f1e02c6806
/components/protocomm/proto-c/sec0.pb-c.h
82779e2be82e774864032efec33cb83d958e1c3d
[ "Apache-2.0" ]
permissive
espressif/ESP8266_RTOS_SDK
606f396e92d2675d9854f0fabd88587fbbbaf267
af0cdc36fa2600033d0a09301c754008cf1503c1
refs/heads/master
2023-08-24T22:40:15.373553
2023-05-06T02:04:24
2023-05-06T02:04:24
27,584,181
3,163
1,749
Apache-2.0
2023-08-09T10:48:13
2014-12-05T09:27:12
C
UTF-8
C
false
true
5,519
h
sec0.pb-c.h
/* Generated by the protocol buffer compiler. DO NOT EDIT! */ /* Generated from: sec0.proto */ #ifndef PROTOBUF_C_sec0_2eproto__INCLUDED #define PROTOBUF_C_sec0_2eproto__INCLUDED #include <protobuf-c/protobuf-c.h> PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. #elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif #include "constants.pb-c.h" typedef struct _S0SessionCmd S0SessionCmd; typedef struct _S0SessionResp S0SessionResp; typedef struct _Sec0Payload Sec0Payload; /* --- enums --- */ /* * A message must be of type Cmd or Resp */ typedef enum _Sec0MsgType { SEC0_MSG_TYPE__S0_Session_Command = 0, SEC0_MSG_TYPE__S0_Session_Response = 1 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(SEC0_MSG_TYPE) } Sec0MsgType; /* --- messages --- */ /* * Data structure of Session command/request packet */ struct _S0SessionCmd { ProtobufCMessage base; }; #define S0_SESSION_CMD__INIT \ { PROTOBUF_C_MESSAGE_INIT (&s0_session_cmd__descriptor) \ } /* * Data structure of Session response packet */ struct _S0SessionResp { ProtobufCMessage base; Status status; }; #define S0_SESSION_RESP__INIT \ { PROTOBUF_C_MESSAGE_INIT (&s0_session_resp__descriptor) \ , STATUS__Success } typedef enum { SEC0_PAYLOAD__PAYLOAD__NOT_SET = 0, SEC0_PAYLOAD__PAYLOAD_SC = 20, SEC0_PAYLOAD__PAYLOAD_SR = 21 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(SEC0_PAYLOAD__PAYLOAD) } Sec0Payload__PayloadCase; /* * Payload structure of session data */ struct _Sec0Payload { ProtobufCMessage base; /* *!< Type of message */ Sec0MsgType msg; Sec0Payload__PayloadCase payload_case; union { /* *!< Payload data interpreted as Cmd */ S0SessionCmd *sc; /* *!< Payload data interpreted as Resp */ S0SessionResp *sr; }; }; #define SEC0_PAYLOAD__INIT \ { PROTOBUF_C_MESSAGE_INIT (&sec0_payload__descriptor) \ , SEC0_MSG_TYPE__S0_Session_Command, SEC0_PAYLOAD__PAYLOAD__NOT_SET, {0} } /* S0SessionCmd methods */ void s0_session_cmd__init (S0SessionCmd *message); size_t s0_session_cmd__get_packed_size (const S0SessionCmd *message); size_t s0_session_cmd__pack (const S0SessionCmd *message, uint8_t *out); size_t s0_session_cmd__pack_to_buffer (const S0SessionCmd *message, ProtobufCBuffer *buffer); S0SessionCmd * s0_session_cmd__unpack (ProtobufCAllocator *allocator, size_t len, const uint8_t *data); void s0_session_cmd__free_unpacked (S0SessionCmd *message, ProtobufCAllocator *allocator); /* S0SessionResp methods */ void s0_session_resp__init (S0SessionResp *message); size_t s0_session_resp__get_packed_size (const S0SessionResp *message); size_t s0_session_resp__pack (const S0SessionResp *message, uint8_t *out); size_t s0_session_resp__pack_to_buffer (const S0SessionResp *message, ProtobufCBuffer *buffer); S0SessionResp * s0_session_resp__unpack (ProtobufCAllocator *allocator, size_t len, const uint8_t *data); void s0_session_resp__free_unpacked (S0SessionResp *message, ProtobufCAllocator *allocator); /* Sec0Payload methods */ void sec0_payload__init (Sec0Payload *message); size_t sec0_payload__get_packed_size (const Sec0Payload *message); size_t sec0_payload__pack (const Sec0Payload *message, uint8_t *out); size_t sec0_payload__pack_to_buffer (const Sec0Payload *message, ProtobufCBuffer *buffer); Sec0Payload * sec0_payload__unpack (ProtobufCAllocator *allocator, size_t len, const uint8_t *data); void sec0_payload__free_unpacked (Sec0Payload *message, ProtobufCAllocator *allocator); /* --- per-message closures --- */ typedef void (*S0SessionCmd_Closure) (const S0SessionCmd *message, void *closure_data); typedef void (*S0SessionResp_Closure) (const S0SessionResp *message, void *closure_data); typedef void (*Sec0Payload_Closure) (const Sec0Payload *message, void *closure_data); /* --- services --- */ /* --- descriptors --- */ extern const ProtobufCEnumDescriptor sec0_msg_type__descriptor; extern const ProtobufCMessageDescriptor s0_session_cmd__descriptor; extern const ProtobufCMessageDescriptor s0_session_resp__descriptor; extern const ProtobufCMessageDescriptor sec0_payload__descriptor; PROTOBUF_C__END_DECLS #endif /* PROTOBUF_C_sec0_2eproto__INCLUDED */
ab8d78a8a2439ab0f40a86d59aa39532b5077fe3
aa3befea459382dc5c01c925653d54f435b3fb0f
/libs/libc/builtin/lib_builtin_isavail.c
113618b1c1505e123794b9004fe240b0b7a84c25
[ "MIT-open-group", "BSD-3-Clause", "HPND-sell-variant", "BSD-4-Clause-UC", "LicenseRef-scancode-warranty-disclaimer", "MIT-0", "LicenseRef-scancode-bsd-atmel", "LicenseRef-scancode-gary-s-brown", "LicenseRef-scancode-proprietary-license", "SunPro", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "LicenseRef-scancode-other-permissive", "HPND", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "GPL-1.0-or-later", "CC-BY-2.0", "CC-BY-4.0" ]
permissive
apache/nuttx
14519a7bff4a87935d94fb8fb2b19edb501c7cec
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
refs/heads/master
2023-08-25T06:55:45.822534
2023-08-23T16:03:31
2023-08-24T21:25:47
228,103,273
407
241
Apache-2.0
2023-09-14T18:26:05
2019-12-14T23:27:55
C
UTF-8
C
false
false
2,498
c
lib_builtin_isavail.c
/**************************************************************************** * libs/libc/builtin/lib_builtin_isavail.c * * 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. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <string.h> #include <limits.h> #include <errno.h> #include <nuttx/lib/builtin.h> /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: builtin_isavail * * Description: * Checks for availability of an application named 'appname' registered * during compile time and, if available, returns the index into the table * of built-in applications. * * Input Parameters: * filename - Name of the linked-in binary to be started. * * Returned Value: * This is an internal function, used by by the NuttX binfmt logic and * by the application built-in logic. It returns a non-negative index to * the application entry in the table of built-in applications on success * or a negated errno value in the event of a failure. * ****************************************************************************/ int builtin_isavail(FAR const char *appname) { FAR const char *name; int i; for (i = 0; (name = builtin_getname(i)) != NULL; i++) { if (strcmp(name, appname) == 0) { return i; } } return -ENOENT; }
94b3c34095a3a4610a3e086c43b27e9c0432eba5
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
/dsp/mpeg/buffer.h
93838c6c0194af0ebb2fc60730fcb4c321f4da91
[ "ISC" ]
permissive
jart/cosmopolitan
fb11b5658939023977060a7c6c71a74093d9cb44
0d748ad58e1063dd1f8560f18a0c75293b9415b7
refs/heads/master
2023-09-06T09:17:29.303607
2023-09-02T03:49:13
2023-09-02T03:50:18
272,457,606
11,887
435
ISC
2023-09-14T17:47:58
2020-06-15T14:16:13
C
UTF-8
C
false
false
4,639
h
buffer.h
#ifndef COSMOPOLITAN_DSP_MPEG_BUFFER_H_ #define COSMOPOLITAN_DSP_MPEG_BUFFER_H_ #include "dsp/mpeg/mpeg.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ struct FILE; enum plm_buffer_mode { PLM_BUFFER_MODE_FILE, PLM_BUFFER_MODE_FIXED_MEM, PLM_BUFFER_MODE_DYNAMIC_MEM }; typedef struct plm_buffer_t { unsigned bit_index; unsigned capacity; unsigned length; int free_when_done; int close_when_done; struct FILE *fh; plm_buffer_load_callback load_callback; void *load_callback_user_data; unsigned char *bytes; enum plm_buffer_mode mode; } plm_buffer_t; typedef struct { int16_t index; int16_t value; } plm_vlc_t; typedef struct { int16_t index; uint16_t value; } plm_vlc_uint_t; /* bool plm_buffer_has(plm_buffer_t *, size_t); */ /* int plm_buffer_read(plm_buffer_t *, int); */ /* void plm_buffer_align(plm_buffer_t *); */ /* void plm_buffer_skip(plm_buffer_t *, size_t); */ /* int plm_buffer_skip_bytes(plm_buffer_t *, unsigned char); */ /* int plm_buffer_next_start_code(plm_buffer_t *); */ /* int plm_buffer_find_start_code(plm_buffer_t *, int); */ /* int plm_buffer_no_start_code(plm_buffer_t *); */ /* int16_t plm_buffer_read_vlc(plm_buffer_t *, const plm_vlc_t *); */ /* uint16_t plm_buffer_read_vlc_uint(plm_buffer_t *, const plm_vlc_uint_t *); */ void plm_buffer_discard_read_bytes(plm_buffer_t *); relegated void plm_buffer_load_file_callback(plm_buffer_t *, void *); forceinline bool plm_buffer_has(plm_buffer_t *b, size_t bits) { unsigned have; have = b->length; have <<= 3; have -= b->bit_index; if (bits <= have) { return true; } else { if (b->load_callback) { b->load_callback(b, b->load_callback_user_data); return ((b->length << 3) - b->bit_index) >= bits; } else { return false; } } } forceinline int plm_buffer_read(plm_buffer_t *self, int count) { if (!plm_buffer_has(self, count)) return 0; int value = 0; while (count) { int current_byte = self->bytes[self->bit_index >> 3]; int remaining = 8 - (self->bit_index & 7); // Remaining bits in byte int read = remaining < count ? remaining : count; // Bits in self run int shift = remaining - read; int mask = (0xff >> (8 - read)); value = (value << read) | ((current_byte & (mask << shift)) >> shift); self->bit_index += read; count -= read; } return value; } forceinline void plm_buffer_align(plm_buffer_t *self) { self->bit_index = ((self->bit_index + 7) >> 3) << 3; } forceinline void plm_buffer_skip(plm_buffer_t *self, size_t count) { if (plm_buffer_has(self, count)) { self->bit_index += count; } } forceinline int plm_buffer_skip_bytes(plm_buffer_t *self, unsigned char v) { unsigned skipped; plm_buffer_align(self); skipped = 0; while (plm_buffer_has(self, 8)) { if (v == self->bytes[self->bit_index >> 3]) { self->bit_index += 8; ++skipped; } else { break; } } return skipped; } forceinline int plm_buffer_next_start_code(plm_buffer_t *self) { plm_buffer_align(self); while (plm_buffer_has(self, (5 << 3))) { size_t byte_index = (self->bit_index) >> 3; if (self->bytes[byte_index] == 0x00 && self->bytes[byte_index + 1] == 0x00 && self->bytes[byte_index + 2] == 0x01) { self->bit_index = (byte_index + 4) << 3; return self->bytes[byte_index + 3]; } self->bit_index += 8; } self->bit_index = (self->length << 3); return -1; } forceinline int plm_buffer_find_start_code(plm_buffer_t *self, int code) { int current = 0; while (true) { current = plm_buffer_next_start_code(self); if (current == code || current == -1) { return current; } } return -1; } forceinline int plm_buffer_no_start_code(plm_buffer_t *self) { if (!plm_buffer_has(self, (5 << 3))) { return false; } size_t byte_index = ((self->bit_index + 7) >> 3); return !(self->bytes[byte_index] == 0x00 && self->bytes[byte_index + 1] == 0x00 && self->bytes[byte_index + 2] == 0x01); } forceinline int16_t plm_buffer_read_vlc(plm_buffer_t *self, const plm_vlc_t *table) { plm_vlc_t state = {0, 0}; do { state = table[state.index + plm_buffer_read(self, 1)]; } while (state.index > 0); return state.value; } forceinline uint16_t plm_buffer_read_vlc_uint(plm_buffer_t *self, const plm_vlc_uint_t *table) { return (uint16_t)plm_buffer_read_vlc(self, (plm_vlc_t *)table); } COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_DSP_MPEG_BUFFER_H_ */
c0016fd48374290386dbde828fefd6e65e3db6a7
aed47b5a4ea3af5cbacfc034c1565bd800e9461a
/src/CControl/Sources/Hardware/scan_sub_folder_names.c
e3a9d4b5f69c99865ac4d7681f3d6f7f551754a1
[ "MIT" ]
permissive
DanielMartensson/CControl
a4dcfc13af8ef8266ac83f9ec0690848f5afd1b2
25ce62ef3a0d87a55459fc9e7d4e1ee895d89ed9
refs/heads/master
2023-08-30T23:53:16.167470
2023-08-28T21:30:11
2023-08-28T21:30:11
214,724,629
169
53
MIT
2023-03-02T21:35:56
2019-10-12T22:33:21
C
ISO-8859-15
C
false
false
1,503
c
scan_sub_folder_names.c
/* * scan_sub_folder_names.c * * Created on: 24 juli 2023 * Author: Daniel Mårtensson */ #include "../../Headers/functions.h" /* * Return the amount of sub folders and also their name. Call sub_folder_names with a pointer */ #ifdef _WIN32 #undef UNICODE /* We want to use ANSI */ #include <Windows.h> size_t scan_sub_folder_names(const char folder_path[], char** sub_folder_names[]) { /* Information about how many counted folders */ char search_path[MAX_PATH]; concatenate_paths(search_path, folder_path, "*"); size_t sub_folder_count = 0; WIN32_FIND_DATA findData; HANDLE hFind = FindFirstFile(search_path, &findData); if (hFind == INVALID_HANDLE_VALUE) { return 0; } bool exist = true; while (exist) { /* Ignore the virtual folders "." and ".." */ if (strcmp(findData.cFileName, ".") != 0 && strcmp(findData.cFileName, "..") != 0) { /* If there is a folder */ if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { char* sub_folder_name = findData.cFileName; (*sub_folder_names) = (char**)realloc(*sub_folder_names, (sub_folder_count + 1) * sizeof(char*)); (*sub_folder_names)[sub_folder_count] = (char*)malloc(strlen(sub_folder_name) + 1); strcpy((*sub_folder_names)[sub_folder_count], sub_folder_name); sub_folder_count++; } } exist = FindNextFile(hFind, &findData); } FindClose(hFind); return sub_folder_count; } #else size_t get_sub_folder_names(const char folder_path[], char* sub_folder_names[]) { return 0; } #endif
dde29b984ef3d0b0e72266e29746d4e2fd53c6b6
cb80ffbfe6b12be3f42322537aff3552fd9239f2
/examples/models/models_mesh_generation.c
d17a20a12d05a5d68fe2b120126f4dfd45b42071
[ "Zlib", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference" ]
permissive
raysan5/raylib
afe80387401361d6f35f9831978b0b379d2d9971
a86c93ebc0095f6c2ffc14656bfc9e1e37070f72
refs/heads/master
2023-08-16T20:49:02.921768
2023-08-14T22:09:27
2023-08-14T22:09:27
13,836,499
15,971
2,825
Zlib
2023-09-14T21:19:02
2013-10-24T15:46:04
C
UTF-8
C
false
false
7,245
c
models_mesh_generation.c
/******************************************************************************************* * * raylib example - procedural mesh generation * * Example originally created with raylib 1.8, last time updated with raylib 4.0 * * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software * * Copyright (c) 2017-2023 Ramon Santamaria (@raysan5) * ********************************************************************************************/ #include "raylib.h" #define NUM_MODELS 9 // Parametric 3d shapes to generate static Mesh GenMeshCustom(void); // Generate a simple triangle mesh from code //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh generation"); // We generate a checked image for texturing Image checked = GenImageChecked(2, 2, 1, 1, RED, GREEN); Texture2D texture = LoadTextureFromImage(checked); UnloadImage(checked); Model models[NUM_MODELS] = { 0 }; models[0] = LoadModelFromMesh(GenMeshPlane(2, 2, 5, 5)); models[1] = LoadModelFromMesh(GenMeshCube(2.0f, 1.0f, 2.0f)); models[2] = LoadModelFromMesh(GenMeshSphere(2, 32, 32)); models[3] = LoadModelFromMesh(GenMeshHemiSphere(2, 16, 16)); models[4] = LoadModelFromMesh(GenMeshCylinder(1, 2, 16)); models[5] = LoadModelFromMesh(GenMeshTorus(0.25f, 4.0f, 16, 32)); models[6] = LoadModelFromMesh(GenMeshKnot(1.0f, 2.0f, 16, 128)); models[7] = LoadModelFromMesh(GenMeshPoly(5, 2.0f)); models[8] = LoadModelFromMesh(GenMeshCustom()); // Generated meshes could be exported as .obj files //ExportMesh(models[0].meshes[0], "plane.obj"); //ExportMesh(models[1].meshes[0], "cube.obj"); //ExportMesh(models[2].meshes[0], "sphere.obj"); //ExportMesh(models[3].meshes[0], "hemisphere.obj"); //ExportMesh(models[4].meshes[0], "cylinder.obj"); //ExportMesh(models[5].meshes[0], "torus.obj"); //ExportMesh(models[6].meshes[0], "knot.obj"); //ExportMesh(models[7].meshes[0], "poly.obj"); //ExportMesh(models[8].meshes[0], "custom.obj"); // Set checked texture as default diffuse component for all models material for (int i = 0; i < NUM_MODELS; i++) models[i].materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Define the camera to look into our 3d world Camera camera = { { 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; // Model drawing position Vector3 position = { 0.0f, 0.0f, 0.0f }; int currentModel = 0; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- UpdateCamera(&camera, CAMERA_ORBITAL); if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { currentModel = (currentModel + 1)%NUM_MODELS; // Cycle between the textures } if (IsKeyPressed(KEY_RIGHT)) { currentModel++; if (currentModel >= NUM_MODELS) currentModel = 0; } else if (IsKeyPressed(KEY_LEFT)) { currentModel--; if (currentModel < 0) currentModel = NUM_MODELS - 1; } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); BeginMode3D(camera); DrawModel(models[currentModel], position, 1.0f, WHITE); DrawGrid(10, 1.0); EndMode3D(); DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f)); DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f)); DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, 410, 10, BLUE); switch(currentModel) { case 0: DrawText("PLANE", 680, 10, 20, DARKBLUE); break; case 1: DrawText("CUBE", 680, 10, 20, DARKBLUE); break; case 2: DrawText("SPHERE", 680, 10, 20, DARKBLUE); break; case 3: DrawText("HEMISPHERE", 640, 10, 20, DARKBLUE); break; case 4: DrawText("CYLINDER", 680, 10, 20, DARKBLUE); break; case 5: DrawText("TORUS", 680, 10, 20, DARKBLUE); break; case 6: DrawText("KNOT", 680, 10, 20, DARKBLUE); break; case 7: DrawText("POLY", 680, 10, 20, DARKBLUE); break; case 8: DrawText("Custom (triangle)", 580, 10, 20, DARKBLUE); break; default: break; } EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- UnloadTexture(texture); // Unload texture // Unload models data (GPU VRAM) for (int i = 0; i < NUM_MODELS; i++) UnloadModel(models[i]); CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; } // Generate a simple triangle mesh from code static Mesh GenMeshCustom(void) { Mesh mesh = { 0 }; mesh.triangleCount = 1; mesh.vertexCount = mesh.triangleCount*3; mesh.vertices = (float *)MemAlloc(mesh.vertexCount*3*sizeof(float)); // 3 vertices, 3 coordinates each (x, y, z) mesh.texcoords = (float *)MemAlloc(mesh.vertexCount*2*sizeof(float)); // 3 vertices, 2 coordinates each (x, y) mesh.normals = (float *)MemAlloc(mesh.vertexCount*3*sizeof(float)); // 3 vertices, 3 coordinates each (x, y, z) // Vertex at (0, 0, 0) mesh.vertices[0] = 0; mesh.vertices[1] = 0; mesh.vertices[2] = 0; mesh.normals[0] = 0; mesh.normals[1] = 1; mesh.normals[2] = 0; mesh.texcoords[0] = 0; mesh.texcoords[1] = 0; // Vertex at (1, 0, 2) mesh.vertices[3] = 1; mesh.vertices[4] = 0; mesh.vertices[5] = 2; mesh.normals[3] = 0; mesh.normals[4] = 1; mesh.normals[5] = 0; mesh.texcoords[2] = 0.5f; mesh.texcoords[3] = 1.0f; // Vertex at (2, 0, 0) mesh.vertices[6] = 2; mesh.vertices[7] = 0; mesh.vertices[8] = 0; mesh.normals[6] = 0; mesh.normals[7] = 1; mesh.normals[8] = 0; mesh.texcoords[4] = 1; mesh.texcoords[5] =0; // Upload mesh data from CPU (RAM) to GPU (VRAM) memory UploadMesh(&mesh, false); return mesh; }
3c66a9ec5b592d025affef3efdfe697257ac1995
9907672fcd81ab73ac63b2a83422a82bf31eadde
/atcoder/tyama_atcoderkupc2012E-aizu2410.c
4c6012d8775d7fe8096c898735e491ec940f7256
[ "0BSD" ]
permissive
cielavenir/procon
bbe1974b9bddb51b76d58722a0686a5b477c4456
746e1a91f574f20647e8aaaac0d9e6173f741176
refs/heads/master
2023-06-21T23:11:24.562546
2023-06-11T13:15:15
2023-06-11T13:15:15
7,557,464
137
136
null
2020-10-20T09:35:52
2013-01-11T09:40:26
C++
UTF-8
C
false
false
140
c
tyama_atcoderkupc2012E-aizu2410.c
i,j,k,c;main(N){scanf("%d",&N);for(;i<N;i++,k=c==N-1?i:k)for(c=j=0;j<=N;j++)c+=getchar()=='o';for(i=1000;i--;)printf("%d\n",k?:rand()%N+1);}
5b11a67ccd7db2528b1c579ebe3e8ea0c557cfc5
04e5b6df2ee3bcfb7005d8ec91aab8e380333ac4
/python3_ios/Python3_ios/Python3_ios/Python3_ios.h
efc05992ab0397fc5a305d0579ba49dd09549f49
[ "MIT" ]
permissive
ColdGrub1384/Pyto
64e2a593957fd640907f0e4698d430ea7754a73e
7557485a733dd7e17ba0366b92794931bdb39975
refs/heads/main
2023-08-01T03:48:35.694832
2022-07-20T14:38:45
2022-07-20T14:38:45
148,944,721
884
157
MIT
2023-02-26T21:34:04
2018-09-15T22:29:07
C
UTF-8
C
false
false
389
h
Python3_ios.h
// // Python3_ios.h // Python3_ios // // Created by Nicolas Holzschuch on 16/12/2018. // Copyright © 2018 Nicolas Holzschuch. All rights reserved. // #include "Python.h" void Python_Initialize(); // In this header, you should import all the public headers of your framework using statements like #import <Python3_ios/PublicHeader.h> extern int python_main(int argc, char **argv);
0f3dadbdfb3833f7dddf4ac34c654da2a955dd1e
2308899071a849a199e3b70806b4dd1c396efc8a
/0.76_My_PuTTY/dialog.h
ad48bb8fb716924944538f828a4883784f7ef766
[ "MIT" ]
permissive
cyd01/KiTTY
b0b06d771508668ccbd6316474382b538a65bac0
0e5d8582aad192db96ba240444a6840fa82ccf05
refs/heads/master
2023-08-10T21:25:06.926589
2023-05-23T17:23:03
2023-05-23T17:56:00
154,540,955
1,451
147
NOASSERTION
2023-05-30T17:16:10
2018-10-24T17:26:24
C
UTF-8
C
false
false
26,234
h
dialog.h
/* * Exports and types from dialog.c. */ /* * This is the big union which defines a single control, of any * type. * * General principles: * - _All_ pointers in this structure are expected to point to * dynamically allocated things, unless otherwise indicated. * - `char' fields giving keyboard shortcuts are expected to be * NO_SHORTCUT if no shortcut is desired for a particular control. * - The `label' field can often be NULL, which will cause the * control to not have a label at all. This doesn't apply to * checkboxes and push buttons, in which the label is not * separate from the control. */ #define NO_SHORTCUT '\0' enum { CTRL_TEXT, /* just a static line of text */ CTRL_EDITBOX, /* label plus edit box */ CTRL_RADIO, /* label plus radio buttons */ CTRL_CHECKBOX, /* checkbox (contains own label) */ CTRL_BUTTON, /* simple push button (no label) */ CTRL_LISTBOX, /* label plus list box */ CTRL_COLUMNS, /* divide window into columns */ CTRL_FILESELECT, /* label plus filename selector */ CTRL_FONTSELECT, /* label plus font selector */ #ifdef MOD_ZMODEM CTRL_DIRECTORYSELECT, /* label plus directory selector */ #endif CTRL_TABDELAY /* see `tabdelay' below */ }; /* * Many controls have `intorptr' unions for storing user data, * since the user might reasonably want to store either an integer * or a void * pointer. Here I define a union, and two convenience * functions to create that union from actual integers or pointers. * * The convenience functions are declared as inline if possible. * Otherwise, they're declared here and defined when this header is * included with DEFINE_INTORPTR_FNS defined. This is a total pain, * but such is life. */ typedef union { void *p; int i; } intorptr; #ifndef INLINE intorptr I(int i); intorptr P(void *p); #endif #if defined DEFINE_INTORPTR_FNS || defined INLINE #ifdef INLINE #define PREFIX INLINE #else #define PREFIX #endif PREFIX intorptr I(int i) { intorptr ret; ret.i = i; return ret; } PREFIX intorptr P(void *p) { intorptr ret; ret.p = p; return ret; } #undef PREFIX #endif /* * Each control has an `int' field specifying which columns it * occupies in a multi-column part of the dialog box. These macros * pack and unpack that field. * * If a control belongs in exactly one column, just specifying the * column number is perfectly adequate. */ #define COLUMN_FIELD(start, span) ( (((span)-1) << 16) + (start) ) #define COLUMN_START(field) ( (field) & 0xFFFF ) #define COLUMN_SPAN(field) ( (((field) >> 16) & 0xFFFF) + 1 ) union control; /* * The number of event types is being deliberately kept small, on * the grounds that not all platforms might be able to report a * large number of subtle events. We have: * - the special REFRESH event, called when a control's value * needs setting * - the ACTION event, called when the user does something that * positively requests action (double-clicking a list box item, * or pushing a push-button) * - the VALCHANGE event, called when the user alters the setting * of the control in a way that is usually considered to alter * the underlying data (toggling a checkbox or radio button, * moving the items around in a drag-list, editing an edit * control) * - the SELCHANGE event, called when the user alters the setting * of the control in a more minor way (changing the selected * item in a list box). * - the CALLBACK event, which happens after the handler routine * has requested a subdialog (file selector, font selector, * colour selector) and it has come back with information. */ enum { EVENT_REFRESH, EVENT_ACTION, EVENT_VALCHANGE, EVENT_SELCHANGE, EVENT_CALLBACK }; typedef void (*handler_fn)(union control *ctrl, dlgparam *dp, void *data, int event); #define STANDARD_PREFIX \ int type; \ char *label; \ bool tabdelay; \ int column; \ handler_fn handler; \ intorptr context; \ intorptr helpctx; \ union control *align_next_to union control { /* * The first possibility in this union is the generic header * shared by all the structures, which we are therefore allowed * to access through any one of them. */ struct { int type; /* * Every control except CTRL_COLUMNS has _some_ sort of * label. By putting it in the `generic' union as well as * everywhere else, we avoid having to have an irritating * switch statement when we go through and deallocate all * the memory in a config-box structure. * * Yes, this does mean that any non-NULL value in this * field is expected to be dynamically allocated and * freeable. * * For CTRL_COLUMNS, this field MUST be NULL. */ char *label; /* * If `tabdelay' is non-zero, it indicates that this * particular control should not yet appear in the tab * order. A subsequent CTRL_TABDELAY entry will place it. */ bool tabdelay; /* * Indicate which column(s) this control occupies. This can * be unpacked into starting column and column span by the * COLUMN macros above. */ int column; /* * Most controls need to provide a function which gets * called when that control's setting is changed, or when * the control's setting needs initialising. * * The `data' parameter points to the writable data being * modified as a result of the configuration activity; for * example, the PuTTY `Conf' structure, although not * necessarily. * * The `dlg' parameter is passed back to the platform- * specific routines to read and write the actual control * state. */ handler_fn handler; /* * Almost all of the above functions will find it useful to * be able to store a piece of `void *' or `int' data. */ intorptr context; /* * For any control, we also allow the storage of a piece of * data for use by context-sensitive help. For example, on * Windows you can click the magic question mark and then * click a control, and help for that control should spring * up. Hence, here is a slot in which to store per-control * data that a particular platform-specific driver can use * to ensure it brings up the right piece of help text. */ intorptr helpctx; /* * Setting this to non-NULL coerces two controls to have their * y-coordinates adjusted so that they can sit alongside each * other and look nicely aligned, even if they're different * heights. * * Set this field on the _second_ control of the pair (in * terms of order in the data structure), so that when it's * instantiated, the first one is already there to be referred * to. */ union control *align_next_to; } generic; struct { STANDARD_PREFIX; union control *ctrl; } tabdelay; struct { STANDARD_PREFIX; } text; struct { STANDARD_PREFIX; char shortcut; /* keyboard shortcut */ /* * Percentage of the dialog-box width used by the edit box. * If this is set to 100, the label is on its own line; * otherwise the label is on the same line as the box * itself. */ int percentwidth; bool password; /* details of input are hidden */ /* * A special case of the edit box is the combo box, which * has a drop-down list built in. (Note that a _non_- * editable drop-down list is done as a special case of a * list box.) * * Don't try setting has_list and password on the same * control; front ends are not required to support that * combination. */ bool has_list; /* * Edit boxes tend to need two items of context, so here's * a spare. */ intorptr context2; } editbox; struct { STANDARD_PREFIX; /* * `shortcut' here is a single keyboard shortcut which is * expected to select the whole group of radio buttons. It * can be NO_SHORTCUT if required, and there is also a way * to place individual shortcuts on each button; see below. */ char shortcut; /* * There are separate fields for `ncolumns' and `nbuttons' * for several reasons. * * Firstly, we sometimes want the last of a set of buttons * to have a longer label than the rest; we achieve this by * setting `ncolumns' higher than `nbuttons', and the * layout code is expected to understand that the final * button should be given all the remaining space on the * line. This sounds like a ludicrously specific special * case (if we're doing this sort of thing, why not have * the general ability to have a particular button span * more than one column whether it's the last one or not?) * but actually it's reasonably common for the sort of * three-way control you get a lot of in PuTTY: `yes' * versus `no' versus `some more complex way to decide'. * * Secondly, setting `nbuttons' higher than `ncolumns' lets * us have more than one line of radio buttons for a single * setting. A very important special case of this is * setting `ncolumns' to 1, so that each button is on its * own line. */ int ncolumns; int nbuttons; /* * This points to a dynamically allocated array of `char *' * pointers, each of which points to a dynamically * allocated string. */ char **buttons; /* `nbuttons' button labels */ /* * This points to a dynamically allocated array of `char' * giving the individual keyboard shortcuts for each radio * button. The array may be NULL if none are required. */ char *shortcuts; /* `nbuttons' shortcuts; may be NULL */ /* * This points to a dynamically allocated array of * intorptr, giving helpful data for each button. */ intorptr *buttondata; /* `nbuttons' entries; may be NULL */ } radio; struct { STANDARD_PREFIX; char shortcut; } checkbox; struct { STANDARD_PREFIX; char shortcut; /* * At least Windows has the concept of a `default push * button', which gets implicitly pressed when you hit * Return even if it doesn't have the input focus. */ bool isdefault; /* * Also, the reverse of this: a default cancel-type button, * which is implicitly pressed when you hit Escape. */ bool iscancel; } button; struct { STANDARD_PREFIX; char shortcut; /* keyboard shortcut */ /* * Height of the list box, in approximate number of lines. * If this is zero, the list is a drop-down list. */ int height; /* height in lines */ /* * If this is set, the list elements can be reordered by * the user (by drag-and-drop or by Up and Down buttons, * whatever the per-platform implementation feels * comfortable with). This is not guaranteed to work on a * drop-down list, so don't try it! */ bool draglist; /* * If this is non-zero, the list can have more than one * element selected at a time. This is not guaranteed to * work on a drop-down list, so don't try it! * * Different non-zero values request slightly different * types of multi-selection (this may well be meaningful * only in GTK, so everyone else can ignore it if they * want). 1 means the list box expects to have individual * items selected, whereas 2 means it expects the user to * want to select a large contiguous range at a time. */ int multisel; /* * Percentage of the dialog-box width used by the list box. * If this is set to 100, the label is on its own line; * otherwise the label is on the same line as the box * itself. Setting this to anything other than 100 is not * guaranteed to work on a _non_-drop-down list, so don't * try it! */ int percentwidth; /* * Some list boxes contain strings that contain tab * characters. If `ncols' is greater than 0, then * `percentages' is expected to be non-zero and to contain * the respective widths of `ncols' columns, which together * will exactly fit the width of the list box. Otherwise * `percentages' must be NULL. * * There should never be more than one column in a * drop-down list (one with height==0), because front ends * may have to implement it as a special case of an * editable combo box. */ int ncols; /* number of columns */ int *percentages; /* % width of each column */ /* * Flag which can be set to false to suppress the horizontal * scroll bar if a list box entry goes off the right-hand * side. */ bool hscroll; } listbox; struct { STANDARD_PREFIX; char shortcut; /* * `filter' dictates what type of files will be selected by * default; for example, when selecting private key files * the file selector would do well to only show .PPK files * (on those systems where this is the chosen extension). * * The precise contents of `filter' are platform-defined, * unfortunately. The special value NULL means `all files' * and is always a valid fallback. * * Unlike almost all strings in this structure, this value * is NOT expected to require freeing (although of course * you can always use ctrl_alloc if you do need to create * one on the fly). This is because the likely mode of use * is to define string constants in a platform-specific * header file, and directly reference those. Or worse, a * particular platform might choose to cast integers into * this pointer type... */ char const *filter; /* * Some systems like to know whether a file selector is * choosing a file to read or one to write (and possibly * create). */ bool for_writing; /* * On at least some platforms, the file selector is a * separate dialog box, and contains a user-settable title. * * This value _is_ expected to require freeing. */ char *title; } fileselect; struct { /* In this variant, `label' MUST be NULL. */ STANDARD_PREFIX; int ncols; /* number of columns */ int *percentages; /* % width of each column */ /* * Every time this control type appears, exactly one of * `ncols' and the previous number of columns MUST be one. * Attempting to allow a seamless transition from a four- * to a five-column layout, for example, would be way more * trouble than it was worth. If you must lay things out * like that, define eight unevenly sized columns and use * column-spanning a lot. But better still, just don't. * * `percentages' may be NULL if ncols==1, to save space. */ } columns; struct { STANDARD_PREFIX; char shortcut; } fontselect; #ifdef MOD_ZMODEM struct { STANDARD_PREFIX; char shortcut; /* * On at least some platforms, the file selector is a * separate dialog box, and contains a user-settable title. * * This value _is_ expected to require freeing. */ char *title; } directoryselect; #endif }; #undef STANDARD_PREFIX /* * `controlset' is a container holding an array of `union control' * structures, together with a panel name and a title for the whole * set. In Windows and any similar-looking GUI, each `controlset' * in the config will be a container box within a panel. * * Special case: if `boxname' is NULL, the control set gives an * overall title for an entire panel of controls. */ struct controlset { char *pathname; /* panel path, e.g. "SSH/Tunnels" */ char *boxname; /* internal short name of controlset */ char *boxtitle; /* title of container box */ int ncolumns; /* current no. of columns at bottom */ size_t ncontrols; /* number of `union control' in array */ size_t ctrlsize; /* allocated size of array */ union control **ctrls; /* actual array */ }; typedef void (*ctrl_freefn_t)(void *); /* used by ctrl_alloc_with_free */ /* * This is the container structure which holds a complete set of * controls. */ struct controlbox { size_t nctrlsets; /* number of ctrlsets */ size_t ctrlsetsize; /* ctrlset size */ struct controlset **ctrlsets; /* actual array of ctrlsets */ size_t nfrees; size_t freesize; void **frees; /* array of aux data areas to free */ ctrl_freefn_t *freefuncs; /* parallel array of free functions */ }; struct controlbox *ctrl_new_box(void); void ctrl_free_box(struct controlbox *); /* * Standard functions used for populating a controlbox structure. */ /* Set up a panel title. */ struct controlset *ctrl_settitle(struct controlbox *, const char *path, const char *title); /* Retrieve a pointer to a controlset, creating it if absent. */ struct controlset *ctrl_getset(struct controlbox *, const char *path, const char *name, const char *boxtitle); void ctrl_free_set(struct controlset *); void ctrl_free(union control *); /* * This function works like `malloc', but the memory it returns * will be automatically freed when the controlbox is freed. Note * that a controlbox is a dialog-box _template_, not an instance, * and so data allocated through this function is better not used * to hold modifiable per-instance things. It's mostly here for * allocating structures to be passed as control handler params. * * ctrl_alloc_with_free also allows you to provide a function to free * the structure, in case there are other dynamically allocated bits * and pieces dangling off it. */ void *ctrl_alloc(struct controlbox *b, size_t size); void *ctrl_alloc_with_free(struct controlbox *b, size_t size, ctrl_freefn_t freefunc); /* * Individual routines to create `union control' structures in a controlset. * * Most of these routines allow the most common fields to be set * directly, and put default values in the rest. Each one returns a * pointer to the `union control' it created, so that final tweaks * can be made. */ /* `ncolumns' is followed by that many percentages, as integers. */ union control *ctrl_columns(struct controlset *, int ncolumns, ...); union control *ctrl_editbox(struct controlset *, const char *label, char shortcut, int percentage, intorptr helpctx, handler_fn handler, intorptr context, intorptr context2); union control *ctrl_combobox(struct controlset *, const char *label, char shortcut, int percentage, intorptr helpctx, handler_fn handler, intorptr context, intorptr context2); /* * `ncolumns' is followed by (alternately) radio button titles and * intorptrs, until a NULL in place of a title string is seen. Each * title is expected to be followed by a shortcut _iff_ `shortcut' * is NO_SHORTCUT. */ union control *ctrl_radiobuttons(struct controlset *, const char *label, char shortcut, int ncolumns, intorptr helpctx, handler_fn handler, intorptr context, ...); union control *ctrl_pushbutton(struct controlset *, const char *label, char shortcut, intorptr helpctx, handler_fn handler, intorptr context); union control *ctrl_listbox(struct controlset *, const char *label, char shortcut, intorptr helpctx, handler_fn handler, intorptr context); union control *ctrl_droplist(struct controlset *, const char *label, char shortcut, int percentage, intorptr helpctx, handler_fn handler, intorptr context); union control *ctrl_draglist(struct controlset *, const char *label, char shortcut, intorptr helpctx, handler_fn handler, intorptr context); union control *ctrl_filesel(struct controlset *, const char *label, char shortcut, const char *filter, bool write, const char *title, intorptr helpctx, handler_fn handler, intorptr context); union control *ctrl_fontsel(struct controlset *, const char *label, char shortcut, intorptr helpctx, handler_fn handler, intorptr context); union control *ctrl_text(struct controlset *, const char *text, intorptr helpctx); union control *ctrl_checkbox(struct controlset *, const char *label, char shortcut, intorptr helpctx, handler_fn handler, intorptr context); union control *ctrl_tabdelay(struct controlset *, union control *); #ifdef MOD_ZMODEM union control *ctrl_directorysel(struct controlset *,char *label,char shortcut, char *title, intorptr helpctx, handler_fn handler, intorptr context); #endif /* * Routines the platform-independent dialog code can call to read * and write the values of controls. */ void dlg_radiobutton_set(union control *ctrl, dlgparam *dp, int whichbutton); int dlg_radiobutton_get(union control *ctrl, dlgparam *dp); void dlg_checkbox_set(union control *ctrl, dlgparam *dp, bool checked); bool dlg_checkbox_get(union control *ctrl, dlgparam *dp); void dlg_editbox_set(union control *ctrl, dlgparam *dp, char const *text); char *dlg_editbox_get(union control *ctrl, dlgparam *dp); /* result must be freed by caller */ /* The `listbox' functions can also apply to combo boxes. */ void dlg_listbox_clear(union control *ctrl, dlgparam *dp); void dlg_listbox_del(union control *ctrl, dlgparam *dp, int index); void dlg_listbox_add(union control *ctrl, dlgparam *dp, char const *text); /* * Each listbox entry may have a numeric id associated with it. * Note that some front ends only permit a string to be stored at * each position, which means that _if_ you put two identical * strings in any listbox then you MUST not assign them different * IDs and expect to get meaningful results back. */ void dlg_listbox_addwithid(union control *ctrl, dlgparam *dp, char const *text, int id); int dlg_listbox_getid(union control *ctrl, dlgparam *dp, int index); /* dlg_listbox_index returns <0 if no single element is selected. */ int dlg_listbox_index(union control *ctrl, dlgparam *dp); bool dlg_listbox_issel(union control *ctrl, dlgparam *dp, int index); void dlg_listbox_select(union control *ctrl, dlgparam *dp, int index); void dlg_text_set(union control *ctrl, dlgparam *dp, char const *text); void dlg_filesel_set(union control *ctrl, dlgparam *dp, Filename *fn); Filename *dlg_filesel_get(union control *ctrl, dlgparam *dp); void dlg_fontsel_set(union control *ctrl, dlgparam *dp, FontSpec *fn); FontSpec *dlg_fontsel_get(union control *ctrl, dlgparam *dp); #ifdef MOD_ZMODEM void dlg_directorysel_set(union control *ctrl, void *dlg, Filename fn); void dlg_directorysel_get(union control *ctrl, void *dlg, Filename *fn); #endif /* * Bracketing a large set of updates in these two functions will * cause the front end (if possible) to delay updating the screen * until it's all complete, thus avoiding flicker. */ void dlg_update_start(union control *ctrl, dlgparam *dp); void dlg_update_done(union control *ctrl, dlgparam *dp); /* * Set input focus into a particular control. */ void dlg_set_focus(union control *ctrl, dlgparam *dp); /* * Change the label text on a control. */ void dlg_label_change(union control *ctrl, dlgparam *dp, char const *text); /* * Return the `ctrl' structure for the most recent control that had * the input focus apart from the one mentioned. This is NOT * GUARANTEED to work on all platforms, so don't base any critical * functionality on it! */ union control *dlg_last_focused(union control *ctrl, dlgparam *dp); /* * Find out whether a particular control is currently visible. */ bool dlg_is_visible(union control *ctrl, dlgparam *dp); /* * During event processing, you might well want to give an error * indication to the user. dlg_beep() is a quick and easy generic * error; dlg_error() puts up a message-box or equivalent. */ void dlg_beep(dlgparam *dp); void dlg_error_msg(dlgparam *dp, const char *msg); /* * This function signals to the front end that the dialog's * processing is completed, and passes an integer value (typically * a success status). */ void dlg_end(dlgparam *dp, int value); /* * Routines to manage a (per-platform) colour selector. * dlg_coloursel_start() is called in an event handler, and * schedules the running of a colour selector after the event * handler returns. The colour selector will send EVENT_CALLBACK to * the control that spawned it, when it's finished; * dlg_coloursel_results() fetches the results, as integers from 0 * to 255; it returns nonzero on success, or zero if the colour * selector was dismissed by hitting Cancel or similar. * * dlg_coloursel_start() accepts an RGB triple which is used to * initialise the colour selector to its starting value. */ void dlg_coloursel_start(union control *ctrl, dlgparam *dp, int r, int g, int b); bool dlg_coloursel_results(union control *ctrl, dlgparam *dp, int *r, int *g, int *b); /* * This routine is used by the platform-independent code to * indicate that the value of a particular control is likely to * have changed. It triggers a call of the handler for that control * with `event' set to EVENT_REFRESH. * * If `ctrl' is NULL, _all_ controls in the dialog get refreshed * (for loading or saving entire sets of settings). */ void dlg_refresh(union control *ctrl, dlgparam *dp); /* * Standard helper functions for reading a controlbox structure. */ /* * Find the index of next controlset in a controlbox for a given * path, or -1 if no such controlset exists. If -1 is passed as * input, finds the first. Intended usage is something like * * for (index=-1; (index=ctrl_find_path(ctrlbox, index, path)) >= 0 ;) { * ... process this controlset ... * } */ int ctrl_find_path(struct controlbox *b, const char *path, int index); int ctrl_path_elements(const char *path); /* Return the number of matching path elements at the starts of p1 and p2, * or INT_MAX if the paths are identical. */ int ctrl_path_compare(const char *p1, const char *p2); #ifdef MOD_ZMODEM /* * The standard directory-selector handler expects the main `context' * field to contain the `offsetof' a Filename field in the * structure pointed to by `data'. */ void conf_directorysel_handler(union control *ctrl, void *dlg, void *data, int event); #endif
0d178e8d3637726760d069819481d2f90278a40a
f7dc806f341ef5dbb0e11252a4693003a66853d5
/thirdparty/libwebp/src/mux/anim_encode.c
7078d9ae6b88dd1497811927a18d40007e91a77a
[ "BSD-3-Clause", "MIT", "OFL-1.1", "JSON", "LicenseRef-scancode-nvidia-2002", "Zlib", "MPL-2.0", "CC0-1.0", "BSL-1.0", "Libpng", "Apache-2.0", "LicenseRef-scancode-public-domain", "Unlicense", "LicenseRef-scancode-free-unknown", "CC-BY-4.0", "Bison-exception-2.2", "LicenseRef-scancode-other-permissive", "GPL-3.0-only", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-unicode", "BSD-2-Clause", "FTL", "GPL-3.0-or-later", "Bitstream-Vera", "MIT-Modern-Variant" ]
permissive
godotengine/godot
8a2419750f4851d1426a8f3bcb52cac5c86f23c2
970be7afdc111ccc7459d7ef3560de70e6d08c80
refs/heads/master
2023-08-21T14:37:00.262883
2023-08-21T06:26:15
2023-08-21T06:26:15
15,634,981
68,852
18,388
MIT
2023-09-14T21:42:16
2014-01-04T16:05:36
C++
UTF-8
C
false
false
58,650
c
anim_encode.c
// Copyright 2014 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // AnimEncoder implementation. // #include <assert.h> #include <limits.h> #include <math.h> // for pow() #include <stdio.h> #include <stdlib.h> // for abs() #include "src/mux/animi.h" #include "src/utils/utils.h" #include "src/webp/decode.h" #include "src/webp/encode.h" #include "src/webp/format_constants.h" #include "src/webp/mux.h" #if defined(_MSC_VER) && _MSC_VER < 1900 #define snprintf _snprintf #endif #define ERROR_STR_MAX_LENGTH 100 //------------------------------------------------------------------------------ // Internal structs. // Stores frame rectangle dimensions. typedef struct { int x_offset_, y_offset_, width_, height_; } FrameRectangle; // Used to store two candidates of encoded data for an animation frame. One of // the two will be chosen later. typedef struct { WebPMuxFrameInfo sub_frame_; // Encoded frame rectangle. WebPMuxFrameInfo key_frame_; // Encoded frame if it is a key-frame. int is_key_frame_; // True if 'key_frame' has been chosen. } EncodedFrame; struct WebPAnimEncoder { const int canvas_width_; // Canvas width. const int canvas_height_; // Canvas height. const WebPAnimEncoderOptions options_; // Global encoding options. FrameRectangle prev_rect_; // Previous WebP frame rectangle. WebPConfig last_config_; // Cached in case a re-encode is needed. WebPConfig last_config_reversed_; // If 'last_config_' uses lossless, then // this config uses lossy and vice versa; // only valid if 'options_.allow_mixed' // is true. WebPPicture* curr_canvas_; // Only pointer; we don't own memory. // Canvas buffers. WebPPicture curr_canvas_copy_; // Possibly modified current canvas. int curr_canvas_copy_modified_; // True if pixels in 'curr_canvas_copy_' // differ from those in 'curr_canvas_'. WebPPicture prev_canvas_; // Previous canvas. WebPPicture prev_canvas_disposed_; // Previous canvas disposed to background. // Encoded data. EncodedFrame* encoded_frames_; // Array of encoded frames. size_t size_; // Number of allocated frames. size_t start_; // Frame start index. size_t count_; // Number of valid frames. size_t flush_count_; // If >0, 'flush_count' frames starting from // 'start' are ready to be added to mux. // key-frame related. int64_t best_delta_; // min(canvas size - frame size) over the frames. // Can be negative in certain cases due to // transparent pixels in a frame. int keyframe_; // Index of selected key-frame relative to 'start_'. int count_since_key_frame_; // Frames seen since the last key-frame. int first_timestamp_; // Timestamp of the first frame. int prev_timestamp_; // Timestamp of the last added frame. int prev_candidate_undecided_; // True if it's not yet decided if previous // frame would be a sub-frame or a key-frame. // Misc. int is_first_frame_; // True if first frame is yet to be added/being added. int got_null_frame_; // True if WebPAnimEncoderAdd() has already been called // with a NULL frame. size_t in_frame_count_; // Number of input frames processed so far. size_t out_frame_count_; // Number of frames added to mux so far. This may be // different from 'in_frame_count_' due to merging. WebPMux* mux_; // Muxer to assemble the WebP bitstream. char error_str_[ERROR_STR_MAX_LENGTH]; // Error string. Empty if no error. }; // ----------------------------------------------------------------------------- // Life of WebPAnimEncoder object. #define DELTA_INFINITY (1ULL << 32) #define KEYFRAME_NONE (-1) // Reset the counters in the WebPAnimEncoder. static void ResetCounters(WebPAnimEncoder* const enc) { enc->start_ = 0; enc->count_ = 0; enc->flush_count_ = 0; enc->best_delta_ = DELTA_INFINITY; enc->keyframe_ = KEYFRAME_NONE; } static void DisableKeyframes(WebPAnimEncoderOptions* const enc_options) { enc_options->kmax = INT_MAX; enc_options->kmin = enc_options->kmax - 1; } #define MAX_CACHED_FRAMES 30 static void SanitizeEncoderOptions(WebPAnimEncoderOptions* const enc_options) { int print_warning = enc_options->verbose; if (enc_options->minimize_size) { DisableKeyframes(enc_options); } if (enc_options->kmax == 1) { // All frames will be key-frames. enc_options->kmin = 0; enc_options->kmax = 0; return; } else if (enc_options->kmax <= 0) { DisableKeyframes(enc_options); print_warning = 0; } if (enc_options->kmin >= enc_options->kmax) { enc_options->kmin = enc_options->kmax - 1; if (print_warning) { fprintf(stderr, "WARNING: Setting kmin = %d, so that kmin < kmax.\n", enc_options->kmin); } } else { const int kmin_limit = enc_options->kmax / 2 + 1; if (enc_options->kmin < kmin_limit && kmin_limit < enc_options->kmax) { // This ensures that enc.keyframe + kmin >= kmax is always true. So, we // can flush all the frames in the 'count_since_key_frame == kmax' case. enc_options->kmin = kmin_limit; if (print_warning) { fprintf(stderr, "WARNING: Setting kmin = %d, so that kmin >= kmax / 2 + 1.\n", enc_options->kmin); } } } // Limit the max number of frames that are allocated. if (enc_options->kmax - enc_options->kmin > MAX_CACHED_FRAMES) { enc_options->kmin = enc_options->kmax - MAX_CACHED_FRAMES; if (print_warning) { fprintf(stderr, "WARNING: Setting kmin = %d, so that kmax - kmin <= %d.\n", enc_options->kmin, MAX_CACHED_FRAMES); } } assert(enc_options->kmin < enc_options->kmax); } #undef MAX_CACHED_FRAMES static void DefaultEncoderOptions(WebPAnimEncoderOptions* const enc_options) { enc_options->anim_params.loop_count = 0; enc_options->anim_params.bgcolor = 0xffffffff; // White. enc_options->minimize_size = 0; DisableKeyframes(enc_options); enc_options->allow_mixed = 0; enc_options->verbose = 0; } int WebPAnimEncoderOptionsInitInternal(WebPAnimEncoderOptions* enc_options, int abi_version) { if (enc_options == NULL || WEBP_ABI_IS_INCOMPATIBLE(abi_version, WEBP_MUX_ABI_VERSION)) { return 0; } DefaultEncoderOptions(enc_options); return 1; } // This starting value is more fit to WebPCleanupTransparentAreaLossless(). #define TRANSPARENT_COLOR 0x00000000 static void ClearRectangle(WebPPicture* const picture, int left, int top, int width, int height) { int j; for (j = top; j < top + height; ++j) { uint32_t* const dst = picture->argb + j * picture->argb_stride; int i; for (i = left; i < left + width; ++i) { dst[i] = TRANSPARENT_COLOR; } } } static void WebPUtilClearPic(WebPPicture* const picture, const FrameRectangle* const rect) { if (rect != NULL) { ClearRectangle(picture, rect->x_offset_, rect->y_offset_, rect->width_, rect->height_); } else { ClearRectangle(picture, 0, 0, picture->width, picture->height); } } static void MarkNoError(WebPAnimEncoder* const enc) { enc->error_str_[0] = '\0'; // Empty string. } static void MarkError(WebPAnimEncoder* const enc, const char* str) { if (snprintf(enc->error_str_, ERROR_STR_MAX_LENGTH, "%s.", str) < 0) { assert(0); // FIX ME! } } static void MarkError2(WebPAnimEncoder* const enc, const char* str, int error_code) { if (snprintf(enc->error_str_, ERROR_STR_MAX_LENGTH, "%s: %d.", str, error_code) < 0) { assert(0); // FIX ME! } } WebPAnimEncoder* WebPAnimEncoderNewInternal( int width, int height, const WebPAnimEncoderOptions* enc_options, int abi_version) { WebPAnimEncoder* enc; if (WEBP_ABI_IS_INCOMPATIBLE(abi_version, WEBP_MUX_ABI_VERSION)) { return NULL; } if (width <= 0 || height <= 0 || (width * (uint64_t)height) >= MAX_IMAGE_AREA) { return NULL; } enc = (WebPAnimEncoder*)WebPSafeCalloc(1, sizeof(*enc)); if (enc == NULL) return NULL; MarkNoError(enc); // Dimensions and options. *(int*)&enc->canvas_width_ = width; *(int*)&enc->canvas_height_ = height; if (enc_options != NULL) { *(WebPAnimEncoderOptions*)&enc->options_ = *enc_options; SanitizeEncoderOptions((WebPAnimEncoderOptions*)&enc->options_); } else { DefaultEncoderOptions((WebPAnimEncoderOptions*)&enc->options_); } // Canvas buffers. if (!WebPPictureInit(&enc->curr_canvas_copy_) || !WebPPictureInit(&enc->prev_canvas_) || !WebPPictureInit(&enc->prev_canvas_disposed_)) { goto Err; } enc->curr_canvas_copy_.width = width; enc->curr_canvas_copy_.height = height; enc->curr_canvas_copy_.use_argb = 1; if (!WebPPictureAlloc(&enc->curr_canvas_copy_) || !WebPPictureCopy(&enc->curr_canvas_copy_, &enc->prev_canvas_) || !WebPPictureCopy(&enc->curr_canvas_copy_, &enc->prev_canvas_disposed_)) { goto Err; } WebPUtilClearPic(&enc->prev_canvas_, NULL); enc->curr_canvas_copy_modified_ = 1; // Encoded frames. ResetCounters(enc); // Note: one extra storage is for the previous frame. enc->size_ = enc->options_.kmax - enc->options_.kmin + 1; // We need space for at least 2 frames. But when kmin, kmax are both zero, // enc->size_ will be 1. So we handle that special case below. if (enc->size_ < 2) enc->size_ = 2; enc->encoded_frames_ = (EncodedFrame*)WebPSafeCalloc(enc->size_, sizeof(*enc->encoded_frames_)); if (enc->encoded_frames_ == NULL) goto Err; enc->mux_ = WebPMuxNew(); if (enc->mux_ == NULL) goto Err; enc->count_since_key_frame_ = 0; enc->first_timestamp_ = 0; enc->prev_timestamp_ = 0; enc->prev_candidate_undecided_ = 0; enc->is_first_frame_ = 1; enc->got_null_frame_ = 0; return enc; // All OK. Err: WebPAnimEncoderDelete(enc); return NULL; } // Release the data contained by 'encoded_frame'. static void FrameRelease(EncodedFrame* const encoded_frame) { if (encoded_frame != NULL) { WebPDataClear(&encoded_frame->sub_frame_.bitstream); WebPDataClear(&encoded_frame->key_frame_.bitstream); memset(encoded_frame, 0, sizeof(*encoded_frame)); } } void WebPAnimEncoderDelete(WebPAnimEncoder* enc) { if (enc != NULL) { WebPPictureFree(&enc->curr_canvas_copy_); WebPPictureFree(&enc->prev_canvas_); WebPPictureFree(&enc->prev_canvas_disposed_); if (enc->encoded_frames_ != NULL) { size_t i; for (i = 0; i < enc->size_; ++i) { FrameRelease(&enc->encoded_frames_[i]); } WebPSafeFree(enc->encoded_frames_); } WebPMuxDelete(enc->mux_); WebPSafeFree(enc); } } // ----------------------------------------------------------------------------- // Frame addition. // Returns cached frame at the given 'position'. static EncodedFrame* GetFrame(const WebPAnimEncoder* const enc, size_t position) { assert(enc->start_ + position < enc->size_); return &enc->encoded_frames_[enc->start_ + position]; } typedef int (*ComparePixelsFunc)(const uint32_t*, int, const uint32_t*, int, int, int); // Returns true if 'length' number of pixels in 'src' and 'dst' are equal, // assuming the given step sizes between pixels. // 'max_allowed_diff' is unused and only there to allow function pointer use. static WEBP_INLINE int ComparePixelsLossless(const uint32_t* src, int src_step, const uint32_t* dst, int dst_step, int length, int max_allowed_diff) { (void)max_allowed_diff; assert(length > 0); while (length-- > 0) { if (*src != *dst) { return 0; } src += src_step; dst += dst_step; } return 1; } // Helper to check if each channel in 'src' and 'dst' is at most off by // 'max_allowed_diff'. static WEBP_INLINE int PixelsAreSimilar(uint32_t src, uint32_t dst, int max_allowed_diff) { const int src_a = (src >> 24) & 0xff; const int src_r = (src >> 16) & 0xff; const int src_g = (src >> 8) & 0xff; const int src_b = (src >> 0) & 0xff; const int dst_a = (dst >> 24) & 0xff; const int dst_r = (dst >> 16) & 0xff; const int dst_g = (dst >> 8) & 0xff; const int dst_b = (dst >> 0) & 0xff; return (src_a == dst_a) && (abs(src_r - dst_r) * dst_a <= (max_allowed_diff * 255)) && (abs(src_g - dst_g) * dst_a <= (max_allowed_diff * 255)) && (abs(src_b - dst_b) * dst_a <= (max_allowed_diff * 255)); } // Returns true if 'length' number of pixels in 'src' and 'dst' are within an // error bound, assuming the given step sizes between pixels. static WEBP_INLINE int ComparePixelsLossy(const uint32_t* src, int src_step, const uint32_t* dst, int dst_step, int length, int max_allowed_diff) { assert(length > 0); while (length-- > 0) { if (!PixelsAreSimilar(*src, *dst, max_allowed_diff)) { return 0; } src += src_step; dst += dst_step; } return 1; } static int IsEmptyRect(const FrameRectangle* const rect) { return (rect->width_ == 0) || (rect->height_ == 0); } static int QualityToMaxDiff(float quality) { const double val = pow(quality / 100., 0.5); const double max_diff = 31 * (1 - val) + 1 * val; return (int)(max_diff + 0.5); } // Assumes that an initial valid guess of change rectangle 'rect' is passed. static void MinimizeChangeRectangle(const WebPPicture* const src, const WebPPicture* const dst, FrameRectangle* const rect, int is_lossless, float quality) { int i, j; const ComparePixelsFunc compare_pixels = is_lossless ? ComparePixelsLossless : ComparePixelsLossy; const int max_allowed_diff_lossy = QualityToMaxDiff(quality); const int max_allowed_diff = is_lossless ? 0 : max_allowed_diff_lossy; // Assumption/correctness checks. assert(src->width == dst->width && src->height == dst->height); assert(rect->x_offset_ + rect->width_ <= dst->width); assert(rect->y_offset_ + rect->height_ <= dst->height); // Left boundary. for (i = rect->x_offset_; i < rect->x_offset_ + rect->width_; ++i) { const uint32_t* const src_argb = &src->argb[rect->y_offset_ * src->argb_stride + i]; const uint32_t* const dst_argb = &dst->argb[rect->y_offset_ * dst->argb_stride + i]; if (compare_pixels(src_argb, src->argb_stride, dst_argb, dst->argb_stride, rect->height_, max_allowed_diff)) { --rect->width_; // Redundant column. ++rect->x_offset_; } else { break; } } if (rect->width_ == 0) goto NoChange; // Right boundary. for (i = rect->x_offset_ + rect->width_ - 1; i >= rect->x_offset_; --i) { const uint32_t* const src_argb = &src->argb[rect->y_offset_ * src->argb_stride + i]; const uint32_t* const dst_argb = &dst->argb[rect->y_offset_ * dst->argb_stride + i]; if (compare_pixels(src_argb, src->argb_stride, dst_argb, dst->argb_stride, rect->height_, max_allowed_diff)) { --rect->width_; // Redundant column. } else { break; } } if (rect->width_ == 0) goto NoChange; // Top boundary. for (j = rect->y_offset_; j < rect->y_offset_ + rect->height_; ++j) { const uint32_t* const src_argb = &src->argb[j * src->argb_stride + rect->x_offset_]; const uint32_t* const dst_argb = &dst->argb[j * dst->argb_stride + rect->x_offset_]; if (compare_pixels(src_argb, 1, dst_argb, 1, rect->width_, max_allowed_diff)) { --rect->height_; // Redundant row. ++rect->y_offset_; } else { break; } } if (rect->height_ == 0) goto NoChange; // Bottom boundary. for (j = rect->y_offset_ + rect->height_ - 1; j >= rect->y_offset_; --j) { const uint32_t* const src_argb = &src->argb[j * src->argb_stride + rect->x_offset_]; const uint32_t* const dst_argb = &dst->argb[j * dst->argb_stride + rect->x_offset_]; if (compare_pixels(src_argb, 1, dst_argb, 1, rect->width_, max_allowed_diff)) { --rect->height_; // Redundant row. } else { break; } } if (rect->height_ == 0) goto NoChange; if (IsEmptyRect(rect)) { NoChange: rect->x_offset_ = 0; rect->y_offset_ = 0; rect->width_ = 0; rect->height_ = 0; } } // Snap rectangle to even offsets (and adjust dimensions if needed). static WEBP_INLINE void SnapToEvenOffsets(FrameRectangle* const rect) { rect->width_ += (rect->x_offset_ & 1); rect->height_ += (rect->y_offset_ & 1); rect->x_offset_ &= ~1; rect->y_offset_ &= ~1; } typedef struct { int should_try_; // Should try this set of parameters. int empty_rect_allowed_; // Frame with empty rectangle can be skipped. FrameRectangle rect_ll_; // Frame rectangle for lossless compression. WebPPicture sub_frame_ll_; // Sub-frame pic for lossless compression. FrameRectangle rect_lossy_; // Frame rectangle for lossy compression. // Could be smaller than rect_ll_ as pixels // with small diffs can be ignored. WebPPicture sub_frame_lossy_; // Sub-frame pic for lossless compression. } SubFrameParams; static int SubFrameParamsInit(SubFrameParams* const params, int should_try, int empty_rect_allowed) { params->should_try_ = should_try; params->empty_rect_allowed_ = empty_rect_allowed; if (!WebPPictureInit(&params->sub_frame_ll_) || !WebPPictureInit(&params->sub_frame_lossy_)) { return 0; } return 1; } static void SubFrameParamsFree(SubFrameParams* const params) { WebPPictureFree(&params->sub_frame_ll_); WebPPictureFree(&params->sub_frame_lossy_); } // Given previous and current canvas, picks the optimal rectangle for the // current frame based on 'is_lossless' and other parameters. Assumes that the // initial guess 'rect' is valid. static int GetSubRect(const WebPPicture* const prev_canvas, const WebPPicture* const curr_canvas, int is_key_frame, int is_first_frame, int empty_rect_allowed, int is_lossless, float quality, FrameRectangle* const rect, WebPPicture* const sub_frame) { if (!is_key_frame || is_first_frame) { // Optimize frame rectangle. // Note: This behaves as expected for first frame, as 'prev_canvas' is // initialized to a fully transparent canvas in the beginning. MinimizeChangeRectangle(prev_canvas, curr_canvas, rect, is_lossless, quality); } if (IsEmptyRect(rect)) { if (empty_rect_allowed) { // No need to get 'sub_frame'. return 1; } else { // Force a 1x1 rectangle. rect->width_ = 1; rect->height_ = 1; assert(rect->x_offset_ == 0); assert(rect->y_offset_ == 0); } } SnapToEvenOffsets(rect); return WebPPictureView(curr_canvas, rect->x_offset_, rect->y_offset_, rect->width_, rect->height_, sub_frame); } // Picks optimal frame rectangle for both lossless and lossy compression. The // initial guess for frame rectangles will be the full canvas. static int GetSubRects(const WebPPicture* const prev_canvas, const WebPPicture* const curr_canvas, int is_key_frame, int is_first_frame, float quality, SubFrameParams* const params) { // Lossless frame rectangle. params->rect_ll_.x_offset_ = 0; params->rect_ll_.y_offset_ = 0; params->rect_ll_.width_ = curr_canvas->width; params->rect_ll_.height_ = curr_canvas->height; if (!GetSubRect(prev_canvas, curr_canvas, is_key_frame, is_first_frame, params->empty_rect_allowed_, 1, quality, &params->rect_ll_, &params->sub_frame_ll_)) { return 0; } // Lossy frame rectangle. params->rect_lossy_ = params->rect_ll_; // seed with lossless rect. return GetSubRect(prev_canvas, curr_canvas, is_key_frame, is_first_frame, params->empty_rect_allowed_, 0, quality, &params->rect_lossy_, &params->sub_frame_lossy_); } static WEBP_INLINE int clip(int v, int min_v, int max_v) { return (v < min_v) ? min_v : (v > max_v) ? max_v : v; } int WebPAnimEncoderRefineRect( const WebPPicture* const prev_canvas, const WebPPicture* const curr_canvas, int is_lossless, float quality, int* const x_offset, int* const y_offset, int* const width, int* const height) { FrameRectangle rect; const int right = clip(*x_offset + *width, 0, curr_canvas->width); const int left = clip(*x_offset, 0, curr_canvas->width - 1); const int bottom = clip(*y_offset + *height, 0, curr_canvas->height); const int top = clip(*y_offset, 0, curr_canvas->height - 1); if (prev_canvas == NULL || curr_canvas == NULL || prev_canvas->width != curr_canvas->width || prev_canvas->height != curr_canvas->height || !prev_canvas->use_argb || !curr_canvas->use_argb) { return 0; } rect.x_offset_ = left; rect.y_offset_ = top; rect.width_ = clip(right - left, 0, curr_canvas->width - rect.x_offset_); rect.height_ = clip(bottom - top, 0, curr_canvas->height - rect.y_offset_); MinimizeChangeRectangle(prev_canvas, curr_canvas, &rect, is_lossless, quality); SnapToEvenOffsets(&rect); *x_offset = rect.x_offset_; *y_offset = rect.y_offset_; *width = rect.width_; *height = rect.height_; return 1; } static void DisposeFrameRectangle(int dispose_method, const FrameRectangle* const rect, WebPPicture* const curr_canvas) { assert(rect != NULL); if (dispose_method == WEBP_MUX_DISPOSE_BACKGROUND) { WebPUtilClearPic(curr_canvas, rect); } } static uint32_t RectArea(const FrameRectangle* const rect) { return (uint32_t)rect->width_ * rect->height_; } static int IsLosslessBlendingPossible(const WebPPicture* const src, const WebPPicture* const dst, const FrameRectangle* const rect) { int i, j; assert(src->width == dst->width && src->height == dst->height); assert(rect->x_offset_ + rect->width_ <= dst->width); assert(rect->y_offset_ + rect->height_ <= dst->height); for (j = rect->y_offset_; j < rect->y_offset_ + rect->height_; ++j) { for (i = rect->x_offset_; i < rect->x_offset_ + rect->width_; ++i) { const uint32_t src_pixel = src->argb[j * src->argb_stride + i]; const uint32_t dst_pixel = dst->argb[j * dst->argb_stride + i]; const uint32_t dst_alpha = dst_pixel >> 24; if (dst_alpha != 0xff && src_pixel != dst_pixel) { // In this case, if we use blending, we can't attain the desired // 'dst_pixel' value for this pixel. So, blending is not possible. return 0; } } } return 1; } static int IsLossyBlendingPossible(const WebPPicture* const src, const WebPPicture* const dst, const FrameRectangle* const rect, float quality) { const int max_allowed_diff_lossy = QualityToMaxDiff(quality); int i, j; assert(src->width == dst->width && src->height == dst->height); assert(rect->x_offset_ + rect->width_ <= dst->width); assert(rect->y_offset_ + rect->height_ <= dst->height); for (j = rect->y_offset_; j < rect->y_offset_ + rect->height_; ++j) { for (i = rect->x_offset_; i < rect->x_offset_ + rect->width_; ++i) { const uint32_t src_pixel = src->argb[j * src->argb_stride + i]; const uint32_t dst_pixel = dst->argb[j * dst->argb_stride + i]; const uint32_t dst_alpha = dst_pixel >> 24; if (dst_alpha != 0xff && !PixelsAreSimilar(src_pixel, dst_pixel, max_allowed_diff_lossy)) { // In this case, if we use blending, we can't attain the desired // 'dst_pixel' value for this pixel. So, blending is not possible. return 0; } } } return 1; } // For pixels in 'rect', replace those pixels in 'dst' that are same as 'src' by // transparent pixels. // Returns true if at least one pixel gets modified. static int IncreaseTransparency(const WebPPicture* const src, const FrameRectangle* const rect, WebPPicture* const dst) { int i, j; int modified = 0; assert(src != NULL && dst != NULL && rect != NULL); assert(src->width == dst->width && src->height == dst->height); for (j = rect->y_offset_; j < rect->y_offset_ + rect->height_; ++j) { const uint32_t* const psrc = src->argb + j * src->argb_stride; uint32_t* const pdst = dst->argb + j * dst->argb_stride; for (i = rect->x_offset_; i < rect->x_offset_ + rect->width_; ++i) { if (psrc[i] == pdst[i] && pdst[i] != TRANSPARENT_COLOR) { pdst[i] = TRANSPARENT_COLOR; modified = 1; } } } return modified; } #undef TRANSPARENT_COLOR // Replace similar blocks of pixels by a 'see-through' transparent block // with uniform average color. // Assumes lossy compression is being used. // Returns true if at least one pixel gets modified. static int FlattenSimilarBlocks(const WebPPicture* const src, const FrameRectangle* const rect, WebPPicture* const dst, float quality) { const int max_allowed_diff_lossy = QualityToMaxDiff(quality); int i, j; int modified = 0; const int block_size = 8; const int y_start = (rect->y_offset_ + block_size) & ~(block_size - 1); const int y_end = (rect->y_offset_ + rect->height_) & ~(block_size - 1); const int x_start = (rect->x_offset_ + block_size) & ~(block_size - 1); const int x_end = (rect->x_offset_ + rect->width_) & ~(block_size - 1); assert(src != NULL && dst != NULL && rect != NULL); assert(src->width == dst->width && src->height == dst->height); assert((block_size & (block_size - 1)) == 0); // must be a power of 2 // Iterate over each block and count similar pixels. for (j = y_start; j < y_end; j += block_size) { for (i = x_start; i < x_end; i += block_size) { int cnt = 0; int avg_r = 0, avg_g = 0, avg_b = 0; int x, y; const uint32_t* const psrc = src->argb + j * src->argb_stride + i; uint32_t* const pdst = dst->argb + j * dst->argb_stride + i; for (y = 0; y < block_size; ++y) { for (x = 0; x < block_size; ++x) { const uint32_t src_pixel = psrc[x + y * src->argb_stride]; const int alpha = src_pixel >> 24; if (alpha == 0xff && PixelsAreSimilar(src_pixel, pdst[x + y * dst->argb_stride], max_allowed_diff_lossy)) { ++cnt; avg_r += (src_pixel >> 16) & 0xff; avg_g += (src_pixel >> 8) & 0xff; avg_b += (src_pixel >> 0) & 0xff; } } } // If we have a fully similar block, we replace it with an // average transparent block. This compresses better in lossy mode. if (cnt == block_size * block_size) { const uint32_t color = (0x00 << 24) | ((avg_r / cnt) << 16) | ((avg_g / cnt) << 8) | ((avg_b / cnt) << 0); for (y = 0; y < block_size; ++y) { for (x = 0; x < block_size; ++x) { pdst[x + y * dst->argb_stride] = color; } } modified = 1; } } } return modified; } static int EncodeFrame(const WebPConfig* const config, WebPPicture* const pic, WebPMemoryWriter* const memory) { pic->use_argb = 1; pic->writer = WebPMemoryWrite; pic->custom_ptr = memory; if (!WebPEncode(config, pic)) { return 0; } return 1; } // Struct representing a candidate encoded frame including its metadata. typedef struct { WebPMemoryWriter mem_; WebPMuxFrameInfo info_; FrameRectangle rect_; int evaluate_; // True if this candidate should be evaluated. } Candidate; // Generates a candidate encoded frame given a picture and metadata. static WebPEncodingError EncodeCandidate(WebPPicture* const sub_frame, const FrameRectangle* const rect, const WebPConfig* const encoder_config, int use_blending, Candidate* const candidate) { WebPConfig config = *encoder_config; WebPEncodingError error_code = VP8_ENC_OK; assert(candidate != NULL); memset(candidate, 0, sizeof(*candidate)); // Set frame rect and info. candidate->rect_ = *rect; candidate->info_.id = WEBP_CHUNK_ANMF; candidate->info_.x_offset = rect->x_offset_; candidate->info_.y_offset = rect->y_offset_; candidate->info_.dispose_method = WEBP_MUX_DISPOSE_NONE; // Set later. candidate->info_.blend_method = use_blending ? WEBP_MUX_BLEND : WEBP_MUX_NO_BLEND; candidate->info_.duration = 0; // Set in next call to WebPAnimEncoderAdd(). // Encode picture. WebPMemoryWriterInit(&candidate->mem_); if (!config.lossless && use_blending) { // Disable filtering to avoid blockiness in reconstructed frames at the // time of decoding. config.autofilter = 0; config.filter_strength = 0; } if (!EncodeFrame(&config, sub_frame, &candidate->mem_)) { error_code = sub_frame->error_code; goto Err; } candidate->evaluate_ = 1; return error_code; Err: WebPMemoryWriterClear(&candidate->mem_); return error_code; } static void CopyCurrentCanvas(WebPAnimEncoder* const enc) { if (enc->curr_canvas_copy_modified_) { WebPCopyPixels(enc->curr_canvas_, &enc->curr_canvas_copy_); enc->curr_canvas_copy_.progress_hook = enc->curr_canvas_->progress_hook; enc->curr_canvas_copy_.user_data = enc->curr_canvas_->user_data; enc->curr_canvas_copy_modified_ = 0; } } enum { LL_DISP_NONE = 0, LL_DISP_BG, LOSSY_DISP_NONE, LOSSY_DISP_BG, CANDIDATE_COUNT }; #define MIN_COLORS_LOSSY 31 // Don't try lossy below this threshold. #define MAX_COLORS_LOSSLESS 194 // Don't try lossless above this threshold. // Generates candidates for a given dispose method given pre-filled sub-frame // 'params'. static WebPEncodingError GenerateCandidates( WebPAnimEncoder* const enc, Candidate candidates[CANDIDATE_COUNT], WebPMuxAnimDispose dispose_method, int is_lossless, int is_key_frame, SubFrameParams* const params, const WebPConfig* const config_ll, const WebPConfig* const config_lossy) { WebPEncodingError error_code = VP8_ENC_OK; const int is_dispose_none = (dispose_method == WEBP_MUX_DISPOSE_NONE); Candidate* const candidate_ll = is_dispose_none ? &candidates[LL_DISP_NONE] : &candidates[LL_DISP_BG]; Candidate* const candidate_lossy = is_dispose_none ? &candidates[LOSSY_DISP_NONE] : &candidates[LOSSY_DISP_BG]; WebPPicture* const curr_canvas = &enc->curr_canvas_copy_; const WebPPicture* const prev_canvas = is_dispose_none ? &enc->prev_canvas_ : &enc->prev_canvas_disposed_; int use_blending_ll, use_blending_lossy; int evaluate_ll, evaluate_lossy; CopyCurrentCanvas(enc); use_blending_ll = !is_key_frame && IsLosslessBlendingPossible(prev_canvas, curr_canvas, &params->rect_ll_); use_blending_lossy = !is_key_frame && IsLossyBlendingPossible(prev_canvas, curr_canvas, &params->rect_lossy_, config_lossy->quality); // Pick candidates to be tried. if (!enc->options_.allow_mixed) { evaluate_ll = is_lossless; evaluate_lossy = !is_lossless; } else if (enc->options_.minimize_size) { evaluate_ll = 1; evaluate_lossy = 1; } else { // Use a heuristic for trying lossless and/or lossy compression. const int num_colors = WebPGetColorPalette(&params->sub_frame_ll_, NULL); evaluate_ll = (num_colors < MAX_COLORS_LOSSLESS); evaluate_lossy = (num_colors >= MIN_COLORS_LOSSY); } // Generate candidates. if (evaluate_ll) { CopyCurrentCanvas(enc); if (use_blending_ll) { enc->curr_canvas_copy_modified_ = IncreaseTransparency(prev_canvas, &params->rect_ll_, curr_canvas); } error_code = EncodeCandidate(&params->sub_frame_ll_, &params->rect_ll_, config_ll, use_blending_ll, candidate_ll); if (error_code != VP8_ENC_OK) return error_code; } if (evaluate_lossy) { CopyCurrentCanvas(enc); if (use_blending_lossy) { enc->curr_canvas_copy_modified_ = FlattenSimilarBlocks(prev_canvas, &params->rect_lossy_, curr_canvas, config_lossy->quality); } error_code = EncodeCandidate(&params->sub_frame_lossy_, &params->rect_lossy_, config_lossy, use_blending_lossy, candidate_lossy); if (error_code != VP8_ENC_OK) return error_code; enc->curr_canvas_copy_modified_ = 1; } return error_code; } #undef MIN_COLORS_LOSSY #undef MAX_COLORS_LOSSLESS static void GetEncodedData(const WebPMemoryWriter* const memory, WebPData* const encoded_data) { encoded_data->bytes = memory->mem; encoded_data->size = memory->size; } // Sets dispose method of the previous frame to be 'dispose_method'. static void SetPreviousDisposeMethod(WebPAnimEncoder* const enc, WebPMuxAnimDispose dispose_method) { const size_t position = enc->count_ - 2; EncodedFrame* const prev_enc_frame = GetFrame(enc, position); assert(enc->count_ >= 2); // As current and previous frames are in enc. if (enc->prev_candidate_undecided_) { assert(dispose_method == WEBP_MUX_DISPOSE_NONE); prev_enc_frame->sub_frame_.dispose_method = dispose_method; prev_enc_frame->key_frame_.dispose_method = dispose_method; } else { WebPMuxFrameInfo* const prev_info = prev_enc_frame->is_key_frame_ ? &prev_enc_frame->key_frame_ : &prev_enc_frame->sub_frame_; prev_info->dispose_method = dispose_method; } } static int IncreasePreviousDuration(WebPAnimEncoder* const enc, int duration) { const size_t position = enc->count_ - 1; EncodedFrame* const prev_enc_frame = GetFrame(enc, position); int new_duration; assert(enc->count_ >= 1); assert(!prev_enc_frame->is_key_frame_ || prev_enc_frame->sub_frame_.duration == prev_enc_frame->key_frame_.duration); assert(prev_enc_frame->sub_frame_.duration == (prev_enc_frame->sub_frame_.duration & (MAX_DURATION - 1))); assert(duration == (duration & (MAX_DURATION - 1))); new_duration = prev_enc_frame->sub_frame_.duration + duration; if (new_duration >= MAX_DURATION) { // Special case. // Separate out previous frame from earlier merged frames to avoid overflow. // We add a 1x1 transparent frame for the previous frame, with blending on. const FrameRectangle rect = { 0, 0, 1, 1 }; const uint8_t lossless_1x1_bytes[] = { 0x52, 0x49, 0x46, 0x46, 0x14, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38, 0x4c, 0x08, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x10, 0x88, 0x88, 0x08 }; const WebPData lossless_1x1 = { lossless_1x1_bytes, sizeof(lossless_1x1_bytes) }; const uint8_t lossy_1x1_bytes[] = { 0x52, 0x49, 0x46, 0x46, 0x40, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38, 0x58, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x4c, 0x50, 0x48, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x50, 0x38, 0x20, 0x18, 0x00, 0x00, 0x00, 0x30, 0x01, 0x00, 0x9d, 0x01, 0x2a, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x34, 0x25, 0xa4, 0x00, 0x03, 0x70, 0x00, 0xfe, 0xfb, 0xfd, 0x50, 0x00 }; const WebPData lossy_1x1 = { lossy_1x1_bytes, sizeof(lossy_1x1_bytes) }; const int can_use_lossless = (enc->last_config_.lossless || enc->options_.allow_mixed); EncodedFrame* const curr_enc_frame = GetFrame(enc, enc->count_); curr_enc_frame->is_key_frame_ = 0; curr_enc_frame->sub_frame_.id = WEBP_CHUNK_ANMF; curr_enc_frame->sub_frame_.x_offset = 0; curr_enc_frame->sub_frame_.y_offset = 0; curr_enc_frame->sub_frame_.dispose_method = WEBP_MUX_DISPOSE_NONE; curr_enc_frame->sub_frame_.blend_method = WEBP_MUX_BLEND; curr_enc_frame->sub_frame_.duration = duration; if (!WebPDataCopy(can_use_lossless ? &lossless_1x1 : &lossy_1x1, &curr_enc_frame->sub_frame_.bitstream)) { return 0; } ++enc->count_; ++enc->count_since_key_frame_; enc->flush_count_ = enc->count_ - 1; enc->prev_candidate_undecided_ = 0; enc->prev_rect_ = rect; } else { // Regular case. // Increase duration of the previous frame by 'duration'. prev_enc_frame->sub_frame_.duration = new_duration; prev_enc_frame->key_frame_.duration = new_duration; } return 1; } // Pick the candidate encoded frame with smallest size and release other // candidates. // TODO(later): Perhaps a rough SSIM/PSNR produced by the encoder should // also be a criteria, in addition to sizes. static void PickBestCandidate(WebPAnimEncoder* const enc, Candidate* const candidates, int is_key_frame, EncodedFrame* const encoded_frame) { int i; int best_idx = -1; size_t best_size = ~0; for (i = 0; i < CANDIDATE_COUNT; ++i) { if (candidates[i].evaluate_) { const size_t candidate_size = candidates[i].mem_.size; if (candidate_size < best_size) { best_idx = i; best_size = candidate_size; } } } assert(best_idx != -1); for (i = 0; i < CANDIDATE_COUNT; ++i) { if (candidates[i].evaluate_) { if (i == best_idx) { WebPMuxFrameInfo* const dst = is_key_frame ? &encoded_frame->key_frame_ : &encoded_frame->sub_frame_; *dst = candidates[i].info_; GetEncodedData(&candidates[i].mem_, &dst->bitstream); if (!is_key_frame) { // Note: Previous dispose method only matters for non-keyframes. // Also, we don't want to modify previous dispose method that was // selected when a non key-frame was assumed. const WebPMuxAnimDispose prev_dispose_method = (best_idx == LL_DISP_NONE || best_idx == LOSSY_DISP_NONE) ? WEBP_MUX_DISPOSE_NONE : WEBP_MUX_DISPOSE_BACKGROUND; SetPreviousDisposeMethod(enc, prev_dispose_method); } enc->prev_rect_ = candidates[i].rect_; // save for next frame. } else { WebPMemoryWriterClear(&candidates[i].mem_); candidates[i].evaluate_ = 0; } } } } // Depending on the configuration, tries different compressions // (lossy/lossless), dispose methods, blending methods etc to encode the current // frame and outputs the best one in 'encoded_frame'. // 'frame_skipped' will be set to true if this frame should actually be skipped. static WebPEncodingError SetFrame(WebPAnimEncoder* const enc, const WebPConfig* const config, int is_key_frame, EncodedFrame* const encoded_frame, int* const frame_skipped) { int i; WebPEncodingError error_code = VP8_ENC_OK; const WebPPicture* const curr_canvas = &enc->curr_canvas_copy_; const WebPPicture* const prev_canvas = &enc->prev_canvas_; Candidate candidates[CANDIDATE_COUNT]; const int is_lossless = config->lossless; const int consider_lossless = is_lossless || enc->options_.allow_mixed; const int consider_lossy = !is_lossless || enc->options_.allow_mixed; const int is_first_frame = enc->is_first_frame_; // First frame cannot be skipped as there is no 'previous frame' to merge it // to. So, empty rectangle is not allowed for the first frame. const int empty_rect_allowed_none = !is_first_frame; // Even if there is exact pixel match between 'disposed previous canvas' and // 'current canvas', we can't skip current frame, as there may not be exact // pixel match between 'previous canvas' and 'current canvas'. So, we don't // allow empty rectangle in this case. const int empty_rect_allowed_bg = 0; // If current frame is a key-frame, dispose method of previous frame doesn't // matter, so we don't try dispose to background. // Also, if key-frame insertion is on, and previous frame could be picked as // either a sub-frame or a key-frame, then we can't be sure about what frame // rectangle would be disposed. In that case too, we don't try dispose to // background. const int dispose_bg_possible = !is_key_frame && !enc->prev_candidate_undecided_; SubFrameParams dispose_none_params; SubFrameParams dispose_bg_params; WebPConfig config_ll = *config; WebPConfig config_lossy = *config; config_ll.lossless = 1; config_lossy.lossless = 0; enc->last_config_ = *config; enc->last_config_reversed_ = config->lossless ? config_lossy : config_ll; *frame_skipped = 0; if (!SubFrameParamsInit(&dispose_none_params, 1, empty_rect_allowed_none) || !SubFrameParamsInit(&dispose_bg_params, 0, empty_rect_allowed_bg)) { return VP8_ENC_ERROR_INVALID_CONFIGURATION; } memset(candidates, 0, sizeof(candidates)); // Change-rectangle assuming previous frame was DISPOSE_NONE. if (!GetSubRects(prev_canvas, curr_canvas, is_key_frame, is_first_frame, config_lossy.quality, &dispose_none_params)) { error_code = VP8_ENC_ERROR_INVALID_CONFIGURATION; goto Err; } if ((consider_lossless && IsEmptyRect(&dispose_none_params.rect_ll_)) || (consider_lossy && IsEmptyRect(&dispose_none_params.rect_lossy_))) { // Don't encode the frame at all. Instead, the duration of the previous // frame will be increased later. assert(empty_rect_allowed_none); *frame_skipped = 1; goto End; } if (dispose_bg_possible) { // Change-rectangle assuming previous frame was DISPOSE_BACKGROUND. WebPPicture* const prev_canvas_disposed = &enc->prev_canvas_disposed_; WebPCopyPixels(prev_canvas, prev_canvas_disposed); DisposeFrameRectangle(WEBP_MUX_DISPOSE_BACKGROUND, &enc->prev_rect_, prev_canvas_disposed); if (!GetSubRects(prev_canvas_disposed, curr_canvas, is_key_frame, is_first_frame, config_lossy.quality, &dispose_bg_params)) { error_code = VP8_ENC_ERROR_INVALID_CONFIGURATION; goto Err; } assert(!IsEmptyRect(&dispose_bg_params.rect_ll_)); assert(!IsEmptyRect(&dispose_bg_params.rect_lossy_)); if (enc->options_.minimize_size) { // Try both dispose methods. dispose_bg_params.should_try_ = 1; dispose_none_params.should_try_ = 1; } else if ((is_lossless && RectArea(&dispose_bg_params.rect_ll_) < RectArea(&dispose_none_params.rect_ll_)) || (!is_lossless && RectArea(&dispose_bg_params.rect_lossy_) < RectArea(&dispose_none_params.rect_lossy_))) { dispose_bg_params.should_try_ = 1; // Pick DISPOSE_BACKGROUND. dispose_none_params.should_try_ = 0; } } if (dispose_none_params.should_try_) { error_code = GenerateCandidates( enc, candidates, WEBP_MUX_DISPOSE_NONE, is_lossless, is_key_frame, &dispose_none_params, &config_ll, &config_lossy); if (error_code != VP8_ENC_OK) goto Err; } if (dispose_bg_params.should_try_) { assert(!enc->is_first_frame_); assert(dispose_bg_possible); error_code = GenerateCandidates( enc, candidates, WEBP_MUX_DISPOSE_BACKGROUND, is_lossless, is_key_frame, &dispose_bg_params, &config_ll, &config_lossy); if (error_code != VP8_ENC_OK) goto Err; } PickBestCandidate(enc, candidates, is_key_frame, encoded_frame); goto End; Err: for (i = 0; i < CANDIDATE_COUNT; ++i) { if (candidates[i].evaluate_) { WebPMemoryWriterClear(&candidates[i].mem_); } } End: SubFrameParamsFree(&dispose_none_params); SubFrameParamsFree(&dispose_bg_params); return error_code; } // Calculate the penalty incurred if we encode given frame as a key frame // instead of a sub-frame. static int64_t KeyFramePenalty(const EncodedFrame* const encoded_frame) { return ((int64_t)encoded_frame->key_frame_.bitstream.size - encoded_frame->sub_frame_.bitstream.size); } static int CacheFrame(WebPAnimEncoder* const enc, const WebPConfig* const config) { int ok = 0; int frame_skipped = 0; WebPEncodingError error_code = VP8_ENC_OK; const size_t position = enc->count_; EncodedFrame* const encoded_frame = GetFrame(enc, position); ++enc->count_; if (enc->is_first_frame_) { // Add this as a key-frame. error_code = SetFrame(enc, config, 1, encoded_frame, &frame_skipped); if (error_code != VP8_ENC_OK) goto End; assert(frame_skipped == 0); // First frame can't be skipped, even if empty. assert(position == 0 && enc->count_ == 1); encoded_frame->is_key_frame_ = 1; enc->flush_count_ = 0; enc->count_since_key_frame_ = 0; enc->prev_candidate_undecided_ = 0; } else { ++enc->count_since_key_frame_; if (enc->count_since_key_frame_ <= enc->options_.kmin) { // Add this as a frame rectangle. error_code = SetFrame(enc, config, 0, encoded_frame, &frame_skipped); if (error_code != VP8_ENC_OK) goto End; if (frame_skipped) goto Skip; encoded_frame->is_key_frame_ = 0; enc->flush_count_ = enc->count_ - 1; enc->prev_candidate_undecided_ = 0; } else { int64_t curr_delta; FrameRectangle prev_rect_key, prev_rect_sub; // Add this as a frame rectangle to enc. error_code = SetFrame(enc, config, 0, encoded_frame, &frame_skipped); if (error_code != VP8_ENC_OK) goto End; if (frame_skipped) goto Skip; prev_rect_sub = enc->prev_rect_; // Add this as a key-frame to enc, too. error_code = SetFrame(enc, config, 1, encoded_frame, &frame_skipped); if (error_code != VP8_ENC_OK) goto End; assert(frame_skipped == 0); // Key-frame cannot be an empty rectangle. prev_rect_key = enc->prev_rect_; // Analyze size difference of the two variants. curr_delta = KeyFramePenalty(encoded_frame); if (curr_delta <= enc->best_delta_) { // Pick this as the key-frame. if (enc->keyframe_ != KEYFRAME_NONE) { EncodedFrame* const old_keyframe = GetFrame(enc, enc->keyframe_); assert(old_keyframe->is_key_frame_); old_keyframe->is_key_frame_ = 0; } encoded_frame->is_key_frame_ = 1; enc->prev_candidate_undecided_ = 1; enc->keyframe_ = (int)position; enc->best_delta_ = curr_delta; enc->flush_count_ = enc->count_ - 1; // We can flush previous frames. } else { encoded_frame->is_key_frame_ = 0; enc->prev_candidate_undecided_ = 0; } // Note: We need '>=' below because when kmin and kmax are both zero, // count_since_key_frame will always be > kmax. if (enc->count_since_key_frame_ >= enc->options_.kmax) { enc->flush_count_ = enc->count_ - 1; enc->count_since_key_frame_ = 0; enc->keyframe_ = KEYFRAME_NONE; enc->best_delta_ = DELTA_INFINITY; } if (!enc->prev_candidate_undecided_) { enc->prev_rect_ = encoded_frame->is_key_frame_ ? prev_rect_key : prev_rect_sub; } } } // Update previous to previous and previous canvases for next call. WebPCopyPixels(enc->curr_canvas_, &enc->prev_canvas_); enc->is_first_frame_ = 0; Skip: ok = 1; ++enc->in_frame_count_; End: if (!ok || frame_skipped) { FrameRelease(encoded_frame); // We reset some counters, as the frame addition failed/was skipped. --enc->count_; if (!enc->is_first_frame_) --enc->count_since_key_frame_; if (!ok) { MarkError2(enc, "ERROR adding frame. WebPEncodingError", error_code); } } enc->curr_canvas_->error_code = error_code; // report error_code assert(ok || error_code != VP8_ENC_OK); return ok; } static int FlushFrames(WebPAnimEncoder* const enc) { while (enc->flush_count_ > 0) { WebPMuxError err; EncodedFrame* const curr = GetFrame(enc, 0); const WebPMuxFrameInfo* const info = curr->is_key_frame_ ? &curr->key_frame_ : &curr->sub_frame_; assert(enc->mux_ != NULL); err = WebPMuxPushFrame(enc->mux_, info, 1); if (err != WEBP_MUX_OK) { MarkError2(enc, "ERROR adding frame. WebPMuxError", err); return 0; } if (enc->options_.verbose) { fprintf(stderr, "INFO: Added frame. offset:%d,%d dispose:%d blend:%d\n", info->x_offset, info->y_offset, info->dispose_method, info->blend_method); } ++enc->out_frame_count_; FrameRelease(curr); ++enc->start_; --enc->flush_count_; --enc->count_; if (enc->keyframe_ != KEYFRAME_NONE) --enc->keyframe_; } if (enc->count_ == 1 && enc->start_ != 0) { // Move enc->start to index 0. const int enc_start_tmp = (int)enc->start_; EncodedFrame temp = enc->encoded_frames_[0]; enc->encoded_frames_[0] = enc->encoded_frames_[enc_start_tmp]; enc->encoded_frames_[enc_start_tmp] = temp; FrameRelease(&enc->encoded_frames_[enc_start_tmp]); enc->start_ = 0; } return 1; } #undef DELTA_INFINITY #undef KEYFRAME_NONE int WebPAnimEncoderAdd(WebPAnimEncoder* enc, WebPPicture* frame, int timestamp, const WebPConfig* encoder_config) { WebPConfig config; int ok; if (enc == NULL) { return 0; } MarkNoError(enc); if (!enc->is_first_frame_) { // Make sure timestamps are non-decreasing (integer wrap-around is OK). const uint32_t prev_frame_duration = (uint32_t)timestamp - enc->prev_timestamp_; if (prev_frame_duration >= MAX_DURATION) { if (frame != NULL) { frame->error_code = VP8_ENC_ERROR_INVALID_CONFIGURATION; } MarkError(enc, "ERROR adding frame: timestamps must be non-decreasing"); return 0; } if (!IncreasePreviousDuration(enc, (int)prev_frame_duration)) { return 0; } // IncreasePreviousDuration() may add a frame to avoid exceeding // MAX_DURATION which could cause CacheFrame() to over read encoded_frames_ // before the next flush. if (enc->count_ == enc->size_ && !FlushFrames(enc)) { return 0; } } else { enc->first_timestamp_ = timestamp; } if (frame == NULL) { // Special: last call. enc->got_null_frame_ = 1; enc->prev_timestamp_ = timestamp; return 1; } if (frame->width != enc->canvas_width_ || frame->height != enc->canvas_height_) { frame->error_code = VP8_ENC_ERROR_INVALID_CONFIGURATION; MarkError(enc, "ERROR adding frame: Invalid frame dimensions"); return 0; } if (!frame->use_argb) { // Convert frame from YUV(A) to ARGB. if (enc->options_.verbose) { fprintf(stderr, "WARNING: Converting frame from YUV(A) to ARGB format; " "this incurs a small loss.\n"); } if (!WebPPictureYUVAToARGB(frame)) { MarkError(enc, "ERROR converting frame from YUV(A) to ARGB"); return 0; } } if (encoder_config != NULL) { if (!WebPValidateConfig(encoder_config)) { MarkError(enc, "ERROR adding frame: Invalid WebPConfig"); return 0; } config = *encoder_config; } else { WebPConfigInit(&config); config.lossless = 1; } assert(enc->curr_canvas_ == NULL); enc->curr_canvas_ = frame; // Store reference. assert(enc->curr_canvas_copy_modified_ == 1); CopyCurrentCanvas(enc); ok = CacheFrame(enc, &config) && FlushFrames(enc); enc->curr_canvas_ = NULL; enc->curr_canvas_copy_modified_ = 1; if (ok) { enc->prev_timestamp_ = timestamp; } return ok; } // ----------------------------------------------------------------------------- // Bitstream assembly. static int DecodeFrameOntoCanvas(const WebPMuxFrameInfo* const frame, WebPPicture* const canvas) { const WebPData* const image = &frame->bitstream; WebPPicture sub_image; WebPDecoderConfig config; WebPInitDecoderConfig(&config); WebPUtilClearPic(canvas, NULL); if (WebPGetFeatures(image->bytes, image->size, &config.input) != VP8_STATUS_OK) { return 0; } if (!WebPPictureView(canvas, frame->x_offset, frame->y_offset, config.input.width, config.input.height, &sub_image)) { return 0; } config.output.is_external_memory = 1; config.output.colorspace = MODE_BGRA; config.output.u.RGBA.rgba = (uint8_t*)sub_image.argb; config.output.u.RGBA.stride = sub_image.argb_stride * 4; config.output.u.RGBA.size = config.output.u.RGBA.stride * sub_image.height; if (WebPDecode(image->bytes, image->size, &config) != VP8_STATUS_OK) { return 0; } return 1; } static int FrameToFullCanvas(WebPAnimEncoder* const enc, const WebPMuxFrameInfo* const frame, WebPData* const full_image) { WebPPicture* const canvas_buf = &enc->curr_canvas_copy_; WebPMemoryWriter mem1, mem2; WebPMemoryWriterInit(&mem1); WebPMemoryWriterInit(&mem2); if (!DecodeFrameOntoCanvas(frame, canvas_buf)) goto Err; if (!EncodeFrame(&enc->last_config_, canvas_buf, &mem1)) goto Err; GetEncodedData(&mem1, full_image); if (enc->options_.allow_mixed) { if (!EncodeFrame(&enc->last_config_reversed_, canvas_buf, &mem2)) goto Err; if (mem2.size < mem1.size) { GetEncodedData(&mem2, full_image); WebPMemoryWriterClear(&mem1); } else { WebPMemoryWriterClear(&mem2); } } return 1; Err: WebPMemoryWriterClear(&mem1); WebPMemoryWriterClear(&mem2); return 0; } // Convert a single-frame animation to a non-animated image if appropriate. // TODO(urvang): Can we pick one of the two heuristically (based on frame // rectangle and/or presence of alpha)? static WebPMuxError OptimizeSingleFrame(WebPAnimEncoder* const enc, WebPData* const webp_data) { WebPMuxError err = WEBP_MUX_OK; int canvas_width, canvas_height; WebPMuxFrameInfo frame; WebPData full_image; WebPData webp_data2; WebPMux* const mux = WebPMuxCreate(webp_data, 0); if (mux == NULL) return WEBP_MUX_BAD_DATA; assert(enc->out_frame_count_ == 1); WebPDataInit(&frame.bitstream); WebPDataInit(&full_image); WebPDataInit(&webp_data2); err = WebPMuxGetFrame(mux, 1, &frame); if (err != WEBP_MUX_OK) goto End; if (frame.id != WEBP_CHUNK_ANMF) goto End; // Non-animation: nothing to do. err = WebPMuxGetCanvasSize(mux, &canvas_width, &canvas_height); if (err != WEBP_MUX_OK) goto End; if (!FrameToFullCanvas(enc, &frame, &full_image)) { err = WEBP_MUX_BAD_DATA; goto End; } err = WebPMuxSetImage(mux, &full_image, 1); if (err != WEBP_MUX_OK) goto End; err = WebPMuxAssemble(mux, &webp_data2); if (err != WEBP_MUX_OK) goto End; if (webp_data2.size < webp_data->size) { // Pick 'webp_data2' if smaller. WebPDataClear(webp_data); *webp_data = webp_data2; WebPDataInit(&webp_data2); } End: WebPDataClear(&frame.bitstream); WebPDataClear(&full_image); WebPMuxDelete(mux); WebPDataClear(&webp_data2); return err; } int WebPAnimEncoderAssemble(WebPAnimEncoder* enc, WebPData* webp_data) { WebPMux* mux; WebPMuxError err; if (enc == NULL) { return 0; } MarkNoError(enc); if (webp_data == NULL) { MarkError(enc, "ERROR assembling: NULL input"); return 0; } if (enc->in_frame_count_ == 0) { MarkError(enc, "ERROR: No frames to assemble"); return 0; } if (!enc->got_null_frame_ && enc->in_frame_count_ > 1 && enc->count_ > 0) { // set duration of the last frame to be avg of durations of previous frames. const double delta_time = (uint32_t)enc->prev_timestamp_ - enc->first_timestamp_; const int average_duration = (int)(delta_time / (enc->in_frame_count_ - 1)); if (!IncreasePreviousDuration(enc, average_duration)) { return 0; } } // Flush any remaining frames. enc->flush_count_ = enc->count_; if (!FlushFrames(enc)) { return 0; } // Set definitive canvas size. mux = enc->mux_; err = WebPMuxSetCanvasSize(mux, enc->canvas_width_, enc->canvas_height_); if (err != WEBP_MUX_OK) goto Err; err = WebPMuxSetAnimationParams(mux, &enc->options_.anim_params); if (err != WEBP_MUX_OK) goto Err; // Assemble into a WebP bitstream. err = WebPMuxAssemble(mux, webp_data); if (err != WEBP_MUX_OK) goto Err; if (enc->out_frame_count_ == 1) { err = OptimizeSingleFrame(enc, webp_data); if (err != WEBP_MUX_OK) goto Err; } return 1; Err: MarkError2(enc, "ERROR assembling WebP", err); return 0; } const char* WebPAnimEncoderGetError(WebPAnimEncoder* enc) { if (enc == NULL) return NULL; return enc->error_str_; } // -----------------------------------------------------------------------------
4e7f7e979cbad4a2f1b6fc16b076ee8cad3731ef
9ceacf33fd96913cac7ef15492c126d96cae6911
/sys/arch/sparc64/dev/schizoreg.h
629747d63d9c5cefc0ee266afa5685ffb90256c5
[]
no_license
openbsd/src
ab97ef834fd2d5a7f6729814665e9782b586c130
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
refs/heads/master
2023-09-02T18:54:56.624627
2023-09-02T15:16:12
2023-09-02T15:16:12
66,966,208
3,394
1,235
null
2023-08-08T02:42:25
2016-08-30T18:18:25
C
UTF-8
C
false
false
11,765
h
schizoreg.h
/* $OpenBSD: schizoreg.h,v 1.21 2008/12/16 22:27:34 kettenis Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) * All rights reserved. * * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. */ struct schizo_pbm_regs { volatile u_int64_t _unused1[64]; /* 0x0000 - 0x01ff */ struct iommureg iommu; /* 0x0200 - 0x03ff */ volatile u_int64_t _unused2[384]; volatile u_int64_t imap[64]; volatile u_int64_t _unused3[64]; volatile u_int64_t iclr[64]; volatile u_int64_t _unused4[320]; volatile u_int64_t ctrl; volatile u_int64_t __unused0; volatile u_int64_t afsr; volatile u_int64_t afar; volatile u_int64_t _unused5[252]; struct iommu_strbuf strbuf; volatile u_int64_t strbuf_ctxflush; volatile u_int64_t _unused6[4012]; volatile u_int64_t iommu_tag; volatile u_int64_t _unused7[15]; volatile u_int64_t iommu_data; volatile u_int64_t _unused8[63]; volatile u_int64_t istat[2]; volatile u_int64_t _unused9[2814]; volatile u_int64_t strbuf_ctxmatch; volatile u_int64_t _unused10[122879]; }; struct schizo_regs { volatile u_int64_t _unused0[8]; volatile u_int64_t pcia_mem_match; volatile u_int64_t pcia_mem_mask; volatile u_int64_t pcia_io_match; volatile u_int64_t pcia_io_mask; volatile u_int64_t pcib_mem_match; volatile u_int64_t pcib_mem_mask; volatile u_int64_t pcib_io_match; volatile u_int64_t pcib_io_mask; volatile u_int64_t _unused1[8176]; volatile u_int64_t control_status; volatile u_int64_t error_control; volatile u_int64_t interrupt_control; volatile u_int64_t safari_errlog; volatile u_int64_t eccctrl; volatile u_int64_t _unused3[1]; volatile u_int64_t ue_afsr; volatile u_int64_t ue_afar; volatile u_int64_t ce_afsr; volatile u_int64_t ce_afar; volatile u_int64_t _unused4[253942]; struct schizo_pbm_regs pbm_a; struct schizo_pbm_regs pbm_b; }; #define SCZ_PCIA_MEM_MATCH 0x00040 #define SCZ_PCIA_MEM_MASK 0x00048 #define SCZ_PCIA_IO_MATCH 0x00050 #define SCZ_PCIA_IO_MASK 0x00058 #define SCZ_PCIB_MEM_MATCH 0x00060 #define SCZ_PCIB_MEM_MASK 0x00068 #define SCZ_PCIB_IO_MATCH 0x00070 #define SCZ_PCIB_IO_MASK 0x00078 #define SCZ_CONTROL_STATUS 0x10000 #define SCZ_SAFARI_INTCTRL 0x10010 #define SCZ_SAFARI_ERRLOG 0x10018 #define SCZ_ECCCTRL 0x10020 #define SCZ_UE_AFSR 0x10030 #define SCZ_UE_AFAR 0x10038 #define SCZ_CE_AFSR 0x10040 #define SCZ_CE_AFAR 0x10048 #define TOM_RESET_GEN 0x17010 /* These are relative to the PBM */ #define SCZ_PCI_IOMMU_CTRL 0x00200 #define SCZ_PCI_IOMMU_TSBBASE 0x00208 #define SCZ_PCI_IOMMU_FLUSH 0x00210 #define SCZ_PCI_IOMMU_CTXFLUSH 0x00218 #define TOM_PCI_IOMMU_TFAR 0x00220 #define SCZ_PCI_IMAP_BASE 0x01000 #define SCZ_PCI_ICLR_BASE 0x01400 #define SCZ_PCI_INTR_RETRY 0x01a00 /* interrupt retry */ #define SCZ_PCI_DMA_FLUSH 0x01a08 /* pci consistent dma flush */ #define SCZ_PCI_CTRL 0x02000 #define SCZ_PCI_AFSR 0x02010 #define SCZ_PCI_AFAR 0x02018 #define SCZ_PCI_DIAG 0x02020 #define SCZ_PCI_ESTAR 0x02028 #define SCZ_PCI_STRBUF_CTRL 0x02800 #define SCZ_PCI_STRBUF_FLUSH 0x02808 #define SCZ_PCI_STRBUF_FSYNC 0x02810 #define SCZ_PCI_STRBUF_CTXFLUSH 0x02818 #define SCZ_PCI_IOMMU_TAG 0x0a580 #define SCZ_PCI_IOMMU_DATA 0x0a600 #define SCZ_PCI_STRBUF_CTXMATCH 0x10000 #define SCZ_ECCCTRL_EE_INTEN 0x8000000000000000UL #define SCZ_ECCCTRL_UE_INTEN 0x4000000000000000UL #define SCZ_ECCCTRL_CE_INTEN 0x2000000000000000UL #define SCZ_UEAFSR_PPIO 0x8000000000000000UL #define SCZ_UEAFSR_PDRD 0x4000000000000000UL #define SCZ_UEAFSR_PDWR 0x2000000000000000UL #define SCZ_UEAFSR_SPIO 0x1000000000000000UL #define SCZ_UEAFSR_SDMA 0x0800000000000000UL #define SCZ_UEAFSR_ERRPNDG 0x0300000000000000UL #define SCZ_UEAFSR_BMSK 0x000003ff00000000UL #define SCZ_UEAFSR_QOFF 0x00000000c0000000UL #define SCZ_UEAFSR_AID 0x000000001f000000UL #define SCZ_UEAFSR_PARTIAL 0x0000000000800000UL #define SCZ_UEAFSR_OWNEDIN 0x0000000000400000UL #define SCZ_UEAFSR_MTAGSYND 0x00000000000f0000UL #define SCZ_UEAFSR_MTAG 0x000000000000e000UL #define SCZ_UEAFSR_ECCSYND 0x00000000000001ffUL #define SCZ_UEAFAR_PIO 0x0000080000000000UL /* 0=pio, 1=memory */ #define SCZ_UEAFAR_PIO_TYPE 0x0000078000000000UL /* pio type: */ #define SCZ_UEAFAR_PIO_UPA 0x0000078000000000UL /* upa */ #define SZC_UEAFAR_PIO_SAFARI 0x0000060000000000UL /* safari/upa64s */ #define SCZ_UEAFAR_PIO_NLAS 0x0000058000000000UL /* newlink alt space */ #define SCZ_UEAFAR_PIO_NLS 0x0000050000000000UL /* newlink space */ #define SCZ_UEAFAR_PIO_NLI 0x0000040000000000UL /* newlink interface */ #define SCZ_UEAFAR_PIO_PCIAM 0x0000030000000000UL /* pcia: memory */ #define SCZ_UEAFAR_PIO_PCIAI 0x0000020000000000UL /* pcia: interface */ #define SZC_UEAFAR_PIO_PCIBC 0x0000018000000000UL /* pcia: config / i/o */ #define SZC_UEAFAR_PIO_PCIBM 0x0000010000000000UL /* pcib: memory */ #define SZC_UEAFAR_PIO_PCIBI 0x0000000000000000UL /* pcib: interface */ #define SCZ_UEAFAR_PIO_PCIAC 0x0000038000000000UL /* pcib: config / i/o */ #define SCZ_UEAFAR_MEMADDR 0x000007fffffffff0UL /* memory address */ #define SCZ_CEAFSR_PPIO 0x8000000000000000UL #define SCZ_CEAFSR_PDRD 0x4000000000000000UL #define SCZ_CEAFSR_PDWR 0x2000000000000000UL #define SCZ_CEAFSR_SPIO 0x1000000000000000UL #define SCZ_CEAFSR_SDMA 0x0800000000000000UL #define SCZ_CEAFSR_ERRPNDG 0x0300000000000000UL #define SCZ_CEAFSR_BMSK 0x000003ff00000000UL #define SCZ_CEAFSR_QOFF 0x00000000c0000000UL #define SCZ_CEAFSR_AID 0x000000001f000000UL #define SCZ_CEAFSR_PARTIAL 0x0000000000800000UL #define SCZ_CEAFSR_OWNEDIN 0x0000000000400000UL #define SCZ_CEAFSR_MTAGSYND 0x00000000000f0000UL #define SCZ_CEAFSR_MTAG 0x000000000000e000UL #define SCZ_CEAFSR_ECCSYND 0x00000000000001ffUL #define SCZ_CEAFAR_PIO 0x0000080000000000UL /* 0=pio, 1=memory */ #define SCZ_CEAFAR_PIO_TYPE 0x0000078000000000UL /* pio type: */ #define SCZ_CEAFAR_PIO_UPA 0x0000078000000000UL /* upa */ #define SZC_CEAFAR_PIO_SAFARI 0x0000060000000000UL /* safari/upa64s */ #define SCZ_CEAFAR_PIO_NLAS 0x0000058000000000UL /* newlink alt space */ #define SCZ_CEAFAR_PIO_NLS 0x0000050000000000UL /* newlink space */ #define SCZ_CEAFAR_PIO_NLI 0x0000040000000000UL /* newlink interface */ #define SCZ_CEAFAR_PIO_PCIAM 0x0000030000000000UL /* pcia: memory */ #define SCZ_CEAFAR_PIO_PCIAI 0x0000020000000000UL /* pcia: interface */ #define SZC_CEAFAR_PIO_PCIBC 0x0000018000000000UL /* pcia: config / i/o */ #define SZC_CEAFAR_PIO_PCIBM 0x0000010000000000UL /* pcib: memory */ #define SZC_CEAFAR_PIO_PCIBI 0x0000000000000000UL /* pcib: interface */ #define SCZ_CEAFAR_PIO_PCIAC 0x0000038000000000UL /* pcib: config / i/o */ #define SCZ_CEAFAR_MEMADDR 0x000007fffffffff0UL /* memory address */ #define TOM_RESET_GEN_XIR 0x00000000000000002L #define SCZ_PCICTRL_BUS_UNUS (1UL << 63UL) /* bus unusable */ #define TOM_PCICTRL_DTO_ERR (1UL << 62UL) /* pci discard timeout */ #define TOM_PCICTRL_DTO_INT (1UL << 61UL) /* discard intr en */ #define SCZ_PCICTRL_ESLCK (1UL << 51UL) /* error slot locked */ #define SCZ_PCICTRL_ERRSLOT (7UL << 48UL) /* error slot */ #define SCZ_PCICTRL_TTO_ERR (1UL << 38UL) /* pci trdy# timeout */ #define SCZ_PCICTRL_RTRY_ERR (1UL << 37UL) /* pci rtry# timeout */ #define SCZ_PCICTRL_MMU_ERR (1UL << 36UL) /* pci mmu error */ #define SCZ_PCICTRL_SBH_ERR (1UL << 35UL) /* pci strm hole */ #define SCZ_PCICTRL_SERR (1UL << 34UL) /* pci serr# sampled */ #define SCZ_PCICTRL_PCISPD (1UL << 33UL) /* speed (0=clk/2,1=clk) */ #define SCZ_PCICTRL_PTO (3UL << 24UL) /* pci timeout interval */ #define SCZ_PCICTRL_MMU_INT (1UL << 19UL) /* mmu intr en */ #define SCZ_PCICTRL_SBH_INT (1UL << 18UL) /* strm byte hole intr en */ #define SCZ_PCICTRL_EEN (1UL << 17UL) /* error intr en */ #define SCZ_PCICTRL_PARK (1UL << 16UL) /* bus parked */ #define SCZ_PCICTRL_PCIRST (1UL << 8UL) /* pci reset */ #define SCZ_PCICTRL_ARB (0x3fUL << 0UL) /* dma arb enables */ #define SCZ_PCICTRL_BITS "\20\277UNUS\276DTO\275DTO_INT\263ESLCK\246TTO\245RTRY\244MMU\243SBH\242SERR\241SPD\223MMU_INT\222SBH_INT\221EEN\220PARK\210PCIRST" #define SCZ_PCIAFSR_PMA 0x8000000000000000UL #define SCZ_PCIAFSR_PTA 0x4000000000000000UL #define SCZ_PCIAFSR_PRTRY 0x2000000000000000UL #define SCZ_PCIAFSR_PPERR 0x1000000000000000UL #define SCZ_PCIAFSR_PTTO 0x0800000000000000UL #define SCZ_PCIAFSR_PUNUS 0x0400000000000000UL #define SCZ_PCIAFSR_SMA 0x0200000000000000UL #define SCZ_PCIAFSR_STA 0x0100000000000000UL #define SCZ_PCIAFSR_SRTRY 0x0080000000000000UL #define SCZ_PCIAFSR_SPERR 0x0040000000000000UL #define SCZ_PCIAFSR_STTO 0x0020000000000000UL #define SCZ_PCIAFSR_SUNUS 0x0010000000000000UL #define SCZ_PCIAFSR_BMSK 0x000003ff00000000UL #define SCZ_PCIAFSR_BLK 0x0000000080000000UL #define SCZ_PCIAFSR_CFG 0x0000000040000000UL #define SCZ_PCIAFSR_MEM 0x0000000020000000UL #define SCZ_PCIAFSR_IO 0x0000000010000000UL #define SCZ_PCIAFSR_BITS "\20\277PMA\276PTA\275PRTRY\274PPERR\273PTTO\272PUNUS\271SMA\270STA\267SRTRY\266SPERR\265STTO\264SUNUS\237BLK\236CFG\235MEM\234IO" #define SCZ_PCIDIAG_D_BADECC (1UL << 10UL) /* disable bad ecc */ #define SCZ_PCIDIAG_D_BYPASS (1UL << 9UL) /* disable mmu bypass */ #define SCZ_PCIDIAG_D_TTO (1UL << 8UL) /* disable trdy# timeout */ #define SCZ_PCIDIAG_D_RTRYARB (1UL << 7UL) /* disable retry arb */ #define SCZ_PCIDIAG_D_RETRY (1UL << 6UL) /* disable retry lim */ #define SCZ_PCIDIAG_D_INTSYNC (1UL << 5UL) /* disable write sync */ #define SCZ_PCIDIAG_I_DMADPAR (1UL << 3UL) /* invert dma parity */ #define SCZ_PCIDIAG_I_PIODPAR (1UL << 2UL) /* invert pio data parity */ #define SCZ_PCIDIAG_I_PIOAPAR (1UL << 1UL) /* invert pio addr parity */ #define TOM_IOMMU_ERR (1UL << 24) #define TOM_IOMMU_ERR_MASK (3UL << 25) #define TOM_IOMMU_PROT_ERR (0UL << 25) #define TOM_IOMMU_INV_ERR (1UL << 25) #define TOM_IOMMU_TO_ERR (2UL << 25) #define TOM_IOMMU_ECC_ERR (3UL << 25) #define TOM_IOMMU_ILLTSBTBW_ERR (1UL << 27) #define TOM_IOMMU_BADVA_ERR (1UL << 28) #define SCZ_PBM_A_REGS (0x600000UL - 0x400000UL) #define SCZ_PBM_B_REGS (0x700000UL - 0x400000UL) #define SCZ_UE_INO 0x30 /* uncorrectable error */ #define SCZ_CE_INO 0x31 /* correctable ecc error */ #define SCZ_PCIERR_A_INO 0x32 /* PCI A bus error */ #define SCZ_PCIERR_B_INO 0x33 /* PCI B bus error */ #define SCZ_SERR_INO 0x34 /* safari interface error */ struct schizo_range { u_int32_t cspace; u_int32_t child_hi; u_int32_t child_lo; u_int32_t phys_hi; u_int32_t phys_lo; u_int32_t size_hi; u_int32_t size_lo; };
92fc08e4a8eb054771eb5210a9540b4d599ad0ba
e73547787354afd9b717ea57fe8dd0695d161821
/src/world/area_kkj/kkj_15/kkj_15_6_chapter2.c
e2f2201f155731c8c0c5b1466a530523b74e2667
[]
no_license
pmret/papermario
8b514b19653cef8d6145e47499b3636b8c474a37
9774b26d93f1045dd2a67e502b6efc9599fb6c31
refs/heads/main
2023-08-31T07:09:48.951514
2023-08-21T18:07:08
2023-08-21T18:07:08
287,151,133
904
139
null
2023-09-14T02:44:23
2020-08-13T01:22:57
C
UTF-8
C
false
false
935
c
kkj_15_6_chapter2.c
#include "kkj_15.h" EvtScript N(EVS_ExtiDoor_Chapter2) = { EVT_IF_EQ(AF_KKJ_06, FALSE) EVT_CALL(DisablePlayerInput, TRUE) EVT_CALL(DisablePartnerAI, 1) EVT_CALL(SpeakToPlayer, NPC_PARTNER, ANIM_Twink_Talk, ANIM_Twink_Idle, 0, MSG_Peach_006B) EVT_CALL(EnablePartnerAI) EVT_CALL(DisablePlayerInput, FALSE) EVT_END_IF EVT_SET(LVar0, kkj_15_ENTRY_0) EVT_SET(LVar1, COLLIDER_tte) EVT_SET(LVar2, MODEL_o2) EVT_SET(LVar3, DOOR_SWING_IN) EVT_EXEC(ExitSingleDoor) EVT_WAIT(17) EVT_IF_EQ(AF_KKJ_06, FALSE) EVT_CALL(GotoMap, EVT_PTR("kkj_11"), kkj_11_ENTRY_7) EVT_ELSE EVT_CALL(GotoMap, EVT_PTR("kkj_11"), kkj_11_ENTRY_3) EVT_END_IF EVT_WAIT(100) EVT_RETURN EVT_END }; EvtScript N(EVS_SetupChapter2) = { EVT_BIND_TRIGGER(EVT_PTR(N(EVS_ExtiDoor_Chapter2)), TRIGGER_WALL_PRESS_A, COLLIDER_tte, 1, 0) EVT_RETURN EVT_END };
11545566451267559714aebbd51ca09b1d869078
c6759b857e55991fea3ef0b465dbcee53fa38714
/tools/autotiler_v3/CNN_Generators_fp16/RNN_Generators_fp16.c
5c84afac5d3f61def8659aa08a78e3edb4335ee9
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
GreenWaves-Technologies/gap_sdk
1b343bba97b7a5ce62a24162bd72eef5cc67e269
3fea306d52ee33f923f2423c5a75d9eb1c07e904
refs/heads/master
2023-09-01T14:38:34.270427
2023-08-10T09:04:44
2023-08-10T09:04:44
133,324,605
145
96
Apache-2.0
2023-08-27T19:03:52
2018-05-14T07:50:29
C
UTF-8
C
false
false
61,719
c
RNN_Generators_fp16.c
#include <stdint.h> #include <stdio.h> #include "AutoTilerLib.h" #include "Gap.h" #include "RNN_Generators_fp16.h" #define D0 KER_ITER_D0 #define D1 KER_ITER_D1 #define D2 KER_ITER_D2 #define D3 KER_ITER_D3 #define T0 KER_ITER_TILE0 #define T1 KER_ITER_TILE1 #define T2 KER_ITER_TILE2 void LoadRNN_fp16_Library() { LoadCNN_Copy_Library(); LibKernelTemplate("KerRNN_fp16_T", CArgs(13, TCArg("F16 *__restrict__", "StateInOut"), TCArg("F16 *__restrict__", "State"), TCArg("F16 *__restrict__", "Xin"), TCArg("unsigned short int", "DimState"), TCArg("unsigned short int", "DimIn"), TCArg("F16 *__restrict__", "Wf"), TCArg("F16 * __restrict__", "Bf"), TCArg("F16 *__restrict__", "Hout"), TCArg("unsigned short int", "Nout"), TCArg("unsigned short int", "OutBase"), TCArg("char", "FirstCell"), TCArg("char", "FirstOut"), TCArg("char", "Reset") ) ); LibKernel("RNN_Ker_fp16", CALL_PARALLEL|CALL_FLOAT_KER, 0, "KerRNN_fp16_T", 0); LibKernel("RNN_ParKer_fp16", CALL_PARALLEL|CALL_FLOAT_KER, 0, "KerRNN_fp16_T", 0); LibKernelTemplate("KerLSTM_fp16_T", CArgs(19, TCArg("F16 *__restrict__", "StateInOut"), TCArg("F16 *__restrict__", "State"), TCArg("F16 *__restrict__", "Xin"), TCArg("unsigned short int", "DimState"), TCArg("unsigned short int", "DimIn"), TCArg("F16 *__restrict__", "Wf"), TCArg("F16 * __restrict__", "Bf"), TCArg("F16 *__restrict__", "Wi"), TCArg("F16 * __restrict__", "Bi"), TCArg("F16 *__restrict__", "Wg"), TCArg("F16 * __restrict__", "Bg"), TCArg("F16 *__restrict__", "Wo"), TCArg("F16 * __restrict__", "Bo"), TCArg("F16 *__restrict__", "Hout"), TCArg("unsigned short int", "Nout"), TCArg("unsigned short int", "OutBase"), TCArg("char", "FirstCell"), TCArg("char", "FirstOut"), TCArg("char", "Reset") ) ); LibKernel("LSTM_Ker_fp16", CALL_PARALLEL|CALL_FLOAT_KER, 0, "KerLSTM_fp16_T", 0); LibKernel("LSTM_ParKer_fp16", CALL_PARALLEL|CALL_FLOAT_KER, 0, "KerLSTM_fp16_T", 0); LibKernelTemplate("KerGRU_fp16_T", CArgs(18, TCArg("F16 *__restrict__", "StateInOut"), TCArg("F16 *__restrict__", "State"), TCArg("F16 *__restrict__", "Xin"), TCArg("unsigned short int", "DimState"), TCArg("unsigned short int", "DimIn"), TCArg("F16 *__restrict__", "Wr"), TCArg("F16 * __restrict__", "Br"), TCArg("F16 *__restrict__", "Wz"), TCArg("F16 * __restrict__", "Bz"), TCArg("F16 *__restrict__", "Wh"), TCArg("F16 * __restrict__", "Bwh"), TCArg("F16 * __restrict__", "Brh"), TCArg("F16 *__restrict__", "Hout"), TCArg("unsigned short int", "Nout"), TCArg("unsigned short int", "OutBase"), TCArg("char", "FirstCell"), TCArg("char", "FirstOut"), TCArg("char", "Reset") ) ); LibKernel("GRU_Ker_fp16", CALL_PARALLEL|CALL_FLOAT_KER, 0, "KerGRU_fp16_T", 0); LibKernel("GRU_ParKer_fp16", CALL_PARALLEL|CALL_FLOAT_KER, 0, "KerGRU_fp16_T", 0); } int RNN_Sequence_fp16(int Nc, int K0, int K1, int *n1, int *n2, int *n3, int *n2_io) { int N1 = Min(K0, Nc-K1); int N3 = Nc - Max(K0, Nc-K1); int N2 = Nc - (N1 + N3); int N2_IO = ((N2>0)&&(K0+K1>=Nc)); if (n1) *n1 = N1; if (n2) *n2 = N2; if (n3) *n3 = N3; if (n2_io) *n2_io = N2_IO; return ((N1!=0) + (N2!=0) + (N3!=0)); } static int RNN_Stack_Seq_fp16_Internal( char *Name, CNN_GenControl_T *Ctrl, char *RNNKerName, int AlwaysReset, int NCells, int DimState, int DimIn, int UseIn, int ExposeSequence, int Buffer, int FirstSeq, int LastSeq, int Revert, int Dynamic ) { /* Sequences In: DimIn!=0, ExposeSequence==0 InOut: DimIn!=0, ExposeSequence!=0 None: DimIn==0, ExposeSequence==0 Out: DimIn==0, ExposeSequence!=0 */ int BiasDataSize = 2; int FeatDataSize = 2; int ParFeat = 1; int PerCell = 0; int PerChanQuant = 0; Tile_Orientation_T TileOrientation = TILE_HOR; int TileCons=0; unsigned long long int LayerOp = 0; unsigned long long int LayerBandwidth = 0; unsigned int Si_Attr = O_IN|((!FirstSeq||AlwaysReset)?O_NO_LOAD:0); unsigned int So_Attr = O_OUT|((!LastSeq||AlwaysReset)?O_NO_STORE:0); int RD0 = Revert?SPACE_PROP(D0, SPACE_PROP_REVERT):D0; if (Dynamic && (Si_Attr==O_IN)) Si_Attr |= O_ALWAYS_LOAD; if (Ctrl) { if (Ctrl->ParallelFeatures != -1) ParFeat = Ctrl->ParallelFeatures; } if (ParFeat) TileCons = 8; int Din = UseIn?DimIn:0; int DimOut = PerCell?NCells:1; LayerOp = NCells*((DimState + (UseIn?DimIn:0))*DimState + DimState); LayerBandwidth = NCells*((DimState + DimIn) + (DimState + DimIn)*DimState*1 + (DimState)*BiasDataSize + DimState); Kernel_T *Kernel = UserKernel(Name, KernelIterSpace(2, Dynamic?IterFixedSpaceDynBound(D0, NCells, "NCells"):IterFixedSpace(D0, NCells), IterTiledSpace(T0)), TileOrientation, CArgs(8, (Dynamic)? TCArg(CNN_ArgDataType (4,0,0), "NCells"):AT_NO_C_ARG, (!(FirstSeq&&AlwaysReset))? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Sin"):AT_NO_C_ARG, (!(LastSeq&&AlwaysReset))? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Sout"):AT_NO_C_ARG, (UseIn)? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Xin"):AT_NO_C_ARG, TCArg(CNN_ArgDataTypeF(2,1,1), "Wf"), TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bf"), (ExposeSequence)? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Hout"):AT_NO_C_ARG, (!AlwaysReset)? TCArg(CNN_ArgDataType (1,0,0), "Reset"):AT_NO_C_ARG ), Calls(1, Call(RNNKerName, LOC_LOOP, Bindings(13, (!(FirstSeq&&AlwaysReset))?K_Arg("Sin", KER_ARG_TILE):((!(LastSeq&&AlwaysReset))?K_Arg("Sout", KER_ARG_TILE):Imm(0)), K_Arg("State", KER_ARG_TILE), UseIn?K_Arg("Xin", KER_ARG_TILE):Imm(0), Imm(DimState), Imm(DimIn), K_Arg("Wf", KER_ARG_TILE), K_Arg("Bf", KER_ARG_TILE), (ExposeSequence)?K_Arg("Hout", KER_ARG_TILE):Imm(0), K_Arg("Bf", KER_ARG_TILE_H), K_Arg("Bf", KER_ARG_TILE_BASE), K_ArgPred("Wf", KER_ARG_TILEFIRST, D0), K_ArgPred("Wf", KER_ARG_TILEFIRST, T0), AlwaysReset?(FirstSeq?Imm(1):Imm(0)):C_Arg("Reset") ) ) ), KerArgs(7, KerArg("State", KerArgSpace(1,T0), O_BUFF|O_NTILED, DimState+DimIn, 1, FeatDataSize, 0, 0, 0, ""), (!(FirstSeq&&AlwaysReset))? KerArg("Sin", KerArgSpace(1,T0), Si_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "Sin"):AT_NO_KER_ARG, (!(LastSeq&&AlwaysReset))? ((!(FirstSeq&&AlwaysReset))? KerArgAliased("Sout", KerArgSpace(1,T0),1, So_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "Sout"): KerArg("Sout", KerArgSpace(1,T0), So_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "Sout")):AT_NO_KER_ARG, (UseIn)? KerArg("Xin", KerArgSpace(1,RD0), O_IN|O_DB, DimIn, 1, FeatDataSize, 0, 0, 0, "Xin"):AT_NO_KER_ARG, (PerCell)? KerArg("Wf", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST|Buffer, DimIn+DimState, DimState, 2, 0, 0, TileCons, "Wf"): KerArg("Wf", KerArgSpace(1,T0), O_IN|O_DB|O_CONST|Buffer, DimIn+DimState, DimState, 2, 0, 0, 0, "Wf"), (PerCell)? KerArg("Bf", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST|Buffer, 1, DimState, BiasDataSize, 0, 0, 0, "Bf"): KerArg("Bf", KerArgSpace(1,T0), O_IN|O_DB|O_CONST|Buffer, 1, DimState, BiasDataSize, 0, 0, 0, "Bf"), (ExposeSequence)? KerArg("Hout", KerArgSpace(2,RD0,T0),O_OUT|O_DB, 1, DimState, FeatDataSize, 0, 0, 0, "Hout"):AT_NO_KER_ARG ) ); if (Kernel) { AddKernelInfos(Name, AT_KERINFO_OPER, LayerOp, 0); AddKernelInfos(Name, AT_KERINFO_BANDWIDTH, LayerBandwidth, 0); if (!(FirstSeq&&AlwaysReset)) AddKernelFloatArgDim(Name, "Sin", 2, DimState, FeatDataSize); if (!(LastSeq&&AlwaysReset)) AddKernelFloatArgDim(Name, "Sout", 2, DimState, FeatDataSize); if (UseIn) AddKernelFloatArgDim(Name, "Xin", 3, NCells, DimIn, FeatDataSize); AddKernelFloatArgDim(Name, "Wf", 4, DimOut, DimState, DimIn+DimState, 2); AddKernelFloatArgDim(Name, "Bf", 3, DimOut, DimState, BiasDataSize); if (ExposeSequence) AddKernelFloatArgDim(Name, "Hout", 3, NCells, DimState, FeatDataSize); } return (Kernel!=0); } static int RNN_Stack_Seq_fp16( char *Name, CNN_GenControl_T *Ctrl, char *RNNKerName, int AlwaysReset, int NCells, int DimState, int DimIn, int UseIn, int ExposeSequence, int Buffer, int FirstSeq, int LastSeq, int Revert, int Dynamic) { int Ker = 0; AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); Ker = RNN_Stack_Seq_fp16_Internal(Name, Ctrl, RNNKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, Buffer, FirstSeq, LastSeq, Revert, Dynamic); if (Ker) return 1; AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); GenTilingDebug("\n\n=============================== Solution not found for %s: Trying PARALLELFEATURES=0 ===============================\n\n", Name); /* If solution not found try with ParallelFeature = 0 */ CNN_GenControl_T InternalCtrl; if (!Ctrl) CNN_InitGenCtrl(&InternalCtrl); else InternalCtrl = *Ctrl; CNN_SetGenCtrl(&InternalCtrl, "PARALLELFEATURES", AT_OPT_VAL(0)); Ker = RNN_Stack_Seq_fp16_Internal(Name, &InternalCtrl, RNNKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, Buffer, FirstSeq, LastSeq, Revert, Dynamic); return Ker; } int RNN_Stack_fp16( char *Name, CNN_GenControl_T *Ctrl, int NCells, int K0, int K1, int DimState, int DimIn, int AlwaysReset, int Revert ) { int Log = 1; int BiasDataSize = 2; int FeatDataSize = 2; if (K0<1) GenTilingError("RNN_Stack_fp16, %s, K0, At least one input is expected\n", Name, K0); if (K1<1) GenTilingError("RNN_Stack_fp16, %s, K1, At least one output is expected\n", Name, K1); if (K0>NCells) GenTilingError("RNN_Stack_fp16, %s, K0, Number of input should be in [1,NCells]\n", Name, K0); if (K1>NCells) GenTilingError("RNN_Stack_fp16, %s, K1, Number of ouput should be in [1,NCells]\n", Name, K1); int ParFeat = 1; int PerCell = 0; int PerChanQuant = 0; unsigned S_Attr = 0 | ((!AlwaysReset)?O_IN:0) | ((!AlwaysReset)?O_OUT:0); char *RNNKerName = ParFeat?"RNN_ParKer_fp16":"RNN_Ker_fp16"; char *G1_Name=0, *G2_Name=0, *G3_Name=0; int N1, N2, N3, N2_IO, Seq = RNN_Sequence_fp16(NCells, K0, K1, &N1, &N2, &N3, &N2_IO); int DimOut = PerCell?NCells:1; /* If dynamic cell count we accept only All IN all OUT e.g NC=K0=K1 => N1=N3=0, N2=NC => Single sequence All IN single OUT e.g NC=K0, K1=1 => N1=NC-1, N2=1 => Two sequences */ int Dynamic = 0; if (Ctrl) { if (Ctrl->DynamicIter) Dynamic = 1; } if (Log) { GenTilingDebug("RNN, %d Cells%s, DimState: %d, DimIn: %d, Input Cells: %d, Output Cells: %d, Order: %s\n", NCells, Dynamic?" Dynamic":"", DimState, DimIn, K0, K1, Revert?"Reverse":"Regular"); GenTilingDebug("Basic Kernel: %s\n", RNNKerName); GenTilingDebug("In Seq: %d, %s Seq: %d, Out Seq: %d\n", N1, N2_IO?"In/Out":"void", N2, N3); } int Ok = 1; if (Dynamic && !((NCells==K0 && NCells==K1) || (NCells==K0 && K1==1))) GenTilingError("RNN with dynamic cell count is valid only for NC=K0=K1 (all in and out) or NC=K0,K1=1 (all in, single out)"); OpenKernelGroup(Name); if (Dynamic) UserSymbols(3, US_Int("Revert", Revert), US_Int("DimIn", DimIn), US_Type("pFeatType", CNN_ArgDataTypeF(FeatDataSize,1,1))); if (N1==0 && N3==0) { AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); Ok = Ok && RNN_Stack_Seq_fp16(G2_Name = AppendNames(Name, "G2"), Ctrl, RNNKerName, AlwaysReset, N2, DimState, DimIn, N2_IO, N2_IO, O_BUFF, 1, 1, Revert, Dynamic); AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); if (Ok==0) { if (Log) GenTilingDebug("Failed to map with all coeffs promoted to buffer, reverting to tile based\n"); Ok = 1; Ok = Ok && RNN_Stack_Seq_fp16(G2_Name = AppendNames(Name, "G2"), Ctrl, RNNKerName, AlwaysReset, N2, DimState, DimIn, N2_IO, N2_IO, 0, 1, 1, Revert, Dynamic); } } else { if (N1>0) Ok = Ok && RNN_Stack_Seq_fp16(G1_Name = AppendNames(Name, "G1"), Ctrl, RNNKerName, AlwaysReset, N1, DimState, DimIn, 1, 0, 0, 1, 0, Revert, Dynamic); if (N2>0) Ok = Ok && RNN_Stack_Seq_fp16(G2_Name = AppendNames(Name, "G2"), Ctrl, RNNKerName, AlwaysReset, N2, DimState, DimIn, N2_IO, N2_IO, 0, (N1==0), (N3==0), Revert, Dynamic && (N1==0)); if (N3>0) Ok = Ok && RNN_Stack_Seq_fp16(G3_Name = AppendNames(Name, "G3"), Ctrl, RNNKerName, AlwaysReset, N3, DimState, DimIn, 0, 1, 0, 0, 1, Revert, 0); } CloseKernelGroupNoMerge(); if (Ok==0) return 0; CKernel_Arg_T **GroupCArgs; CKernelCall_T **GroupCCalls; Object_T **GroupKerArgs; GroupCArgs = AllocateCArgs(4 + 2*(AlwaysReset==0) + (N1!=0) + (N2!=0 && N3!=0) + (Dynamic!=0)); int A= 0; if (Dynamic) GroupCArgs[A++] = TCArg(CNN_ArgDataType (4,0,0), "NCells"); if (!AlwaysReset) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Hinout"); if (N1!=0) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "G1O"); if (N2!=0 && N3!=0) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "G2O"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Xin"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(2,1,1), "Wf"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bf"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Hout"); if (!AlwaysReset) GroupCArgs[A++] = TCArg(CNN_ArgDataType (1,0,0), "Reset"); GroupCCalls = AllocateCalls((N1!=0)+(N2!=0)+(N3!=0)); A=0; if (Dynamic) { if (N1>0) GroupCCalls[A++] = UserKernelCall(G1_Name, LOC_GROUP, Bindings(7, BindKGExpr("CArg(NCells)-1"), (!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING, C_Arg("G1O"), BindKGExpr("((pFeatType)CArg(Xin))+(Revert?(DimIn*(CArg(NCells)-1)):0)"), C_Arg("Wf"), C_Arg("Bf"), (AlwaysReset==0)?C_Arg("Reset"):AT_NO_ARG_BINDING)); if (N2>0&&N2_IO) GroupCCalls[A++] = UserKernelCall(G2_Name, LOC_GROUP, Bindings(8, (N1==0)?BindKGExpr("CArg(NCells)"):AT_NO_ARG_BINDING, (N1)?C_Arg("G1O"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), (N3)?C_Arg("G2O"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), BindKGExpr("((pFeatType)CArg(Xin))+(Revert?0:(DimIn*(CArg(NCells)-1)))"), KG_ArgOper("Wf", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bf", '+', PerCell*N1*DimState), C_Arg("Hout"), (!AlwaysReset)?((N1==0)?C_Arg("Reset"):Imm(0)):AT_NO_ARG_BINDING ) ); } else { if (N1>0) GroupCCalls[A++] = UserKernelCall(G1_Name, LOC_GROUP, Bindings(6, (!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING, C_Arg("G1O"), Revert?KG_ArgOper("Xin", '+', (N2_IO?N2:0)*DimIn):C_Arg("Xin"), C_Arg("Wf"), C_Arg("Bf"), (AlwaysReset==0)?C_Arg("Reset"):AT_NO_ARG_BINDING)); if (N2>0&&N2_IO) GroupCCalls[A++] = UserKernelCall(G2_Name, LOC_GROUP, Bindings(7, (N1)?C_Arg("G1O"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), (N3)?C_Arg("G2O"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), Revert?C_Arg("Xin"):KG_ArgOper("Xin", '+', N1*DimIn), KG_ArgOper("Wf", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bf", '+', PerCell*N1*DimState), C_Arg("Hout"), (!AlwaysReset)?((N1==0)?C_Arg("Reset"):Imm(0)):AT_NO_ARG_BINDING ) ); if (N2>0&&!N2_IO) GroupCCalls[A++] = UserKernelCall(G2_Name, LOC_GROUP, Bindings(5, C_Arg("G1O"), C_Arg("G2O"), KG_ArgOper("Wf", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bf", '+', PerCell*N1*DimState), (!AlwaysReset)?Imm(0):AT_NO_ARG_BINDING ) ); if (N3>0) GroupCCalls[A++] = UserKernelCall(G3_Name, LOC_GROUP, Bindings(6, (N2)?C_Arg("G2O"):C_Arg("G1O"), (!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING, KG_ArgOper("Wf", '+', PerCell*(N1+N2)*(DimState+DimIn)*DimState), KG_ArgOper("Bf", '+', PerCell*(N1+N2)*DimState), KG_ArgOper("Hout", '+', N2_IO?(N2*DimState):0), (!AlwaysReset)?Imm(0):AT_NO_ARG_BINDING ) ); } GroupKerArgs = AllocateKerArgs(4+ (Dynamic!=0) + (N1!=0) + (N2!=0 && N3!=0)+ 2*(AlwaysReset==0)); A = 0; if (Dynamic) GroupKerArgs[A++] = KerGroupArg("NCells", O_IN, 1, 4, "NCells"); if (AlwaysReset==0) GroupKerArgs[A++] = KerGroupArg("Hinout", O_IN|O_OUT, DimState, FeatDataSize, "Hinout"); if (N1!=0) GroupKerArgs[A++] = KerGroupArg("G1O", O_IN|O_OUT|O_BUFF, DimState, FeatDataSize, "G1O"); if (N2!=0 && N3!=0) GroupKerArgs[A++] = KerGroupArg("G2O", O_IN|O_OUT|O_BUFF, DimState, FeatDataSize, "G2O"); GroupKerArgs[A++] = KerGroupArg("Xin", O_IN, DimIn*K0, FeatDataSize, "Xin"); GroupKerArgs[A++] = KerGroupArg("Wf", O_IN, DimOut*(DimState + DimIn)*DimState, 2, "Wf"); GroupKerArgs[A++] = KerGroupArg("Bf", O_IN, DimOut*DimState, BiasDataSize, "Bf"); GroupKerArgs[A++] = KerGroupArg("Hout", O_OUT, DimState*K1, FeatDataSize, "Hout"); if (!AlwaysReset) GroupKerArgs[A++] = KerGroupArg("Reset", O_IN, 1, 1, "Reset"); KernelGroup_T *UKGroup = UserKernelGroupK( Name, 1, GroupCArgs, 0, GroupCCalls, GroupKerArgs ); return (UKGroup!=0); } static int LSTM_Stack_Seq_fp16_Internal( char *Name, CNN_GenControl_T *Ctrl, char *LSTMKerName, int AlwaysReset, int NCells, int DimState, int DimIn, int UseIn, int ExposeSequence, int FirstSeq, int LastSeq, int Revert, int Dynamic ) { /* Sequences In: DimIn!=0, ExposeSequence==0 InOut: DimIn!=0, ExposeSequence!=0 None: DimIn==0, ExposeSequence==0 Out: DimIn==0, ExposeSequence!=0 */ int BiasDataSize = 2; int FeatDataSize = 2; int RD0 = Revert?SPACE_PROP(D0, SPACE_PROP_REVERT):D0; int ParFeat = 1; int PerCell = 0; int PerChanQuant = 0; Tile_Orientation_T TileOrientation = TILE_HOR; int TileCons=0; unsigned long long int LayerOp = 0; unsigned long long int LayerBandwidth = 0; unsigned int Si_Attr = O_IN|((!FirstSeq||AlwaysReset)?O_NO_LOAD:0); unsigned int So_Attr = O_OUT|((!LastSeq||AlwaysReset)?O_NO_STORE:0); if (Dynamic && (Si_Attr==O_IN)) Si_Attr |= O_ALWAYS_LOAD; if (Ctrl) { if (Ctrl->ParallelFeatures != -1) ParFeat = Ctrl->ParallelFeatures; } if (ParFeat) TileCons = 8; int Din = UseIn?DimIn:0; int DimOut = PerCell?NCells:1; LayerOp = NCells*((DimState + (UseIn?DimIn:0))*DimState*4 + DimState*4 + DimState*4); LayerBandwidth = NCells*((DimState + DimIn) + 4*(DimState + DimIn)*DimState*1 + 4*(DimState)*BiasDataSize + DimState); Kernel_T *Kernel = UserKernel(Name, KernelIterSpace(2, Dynamic?IterFixedSpaceDynBound(D0, NCells, "NCells"):IterFixedSpace(D0, NCells), IterTiledSpace(T0)), TileOrientation, CArgs(16, (Dynamic)? TCArg(CNN_ArgDataType (4,0,0), "NCells"):AT_NO_C_ARG, (!(FirstSeq&&AlwaysReset))? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "SCin"):AT_NO_C_ARG, (!(FirstSeq&&AlwaysReset))? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "SHin"):AT_NO_C_ARG, (!(LastSeq&&AlwaysReset))? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "SCout"):AT_NO_C_ARG, (!(LastSeq&&AlwaysReset))? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "SHout"):AT_NO_C_ARG, (UseIn)? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Xin"):AT_NO_C_ARG, TCArg(CNN_ArgDataTypeF(2,1,1), "Wf"), TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bf"), TCArg(CNN_ArgDataTypeF(2,1,1), "Wi"), TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bi"), TCArg(CNN_ArgDataTypeF(2,1,1), "Wg"), TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bg"), TCArg(CNN_ArgDataTypeF(2,1,1), "Wo"), TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bo"), (ExposeSequence)? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Hout"):AT_NO_C_ARG, (AlwaysReset==0)? TCArg(CNN_ArgDataType(1,0,0), "Reset"):AT_NO_C_ARG ), Calls(1, Call(LSTMKerName, LOC_LOOP, Bindings(19, (!(FirstSeq&&AlwaysReset))?K_Arg("SCin", KER_ARG_TILE):((!(LastSeq&&AlwaysReset))?K_Arg("SCout", KER_ARG_TILE):Imm(0)), K_Arg("State", KER_ARG_TILE), UseIn?K_Arg("Xin", KER_ARG_TILE):Imm(0), Imm(DimState), Imm(DimIn), K_Arg("Wf", KER_ARG_TILE), K_Arg("Bf", KER_ARG_TILE), K_Arg("Wi", KER_ARG_TILE), K_Arg("Bi", KER_ARG_TILE), K_Arg("Wg", KER_ARG_TILE), K_Arg("Bg", KER_ARG_TILE), K_Arg("Wo", KER_ARG_TILE), K_Arg("Bo", KER_ARG_TILE), (ExposeSequence)?K_Arg("Hout", KER_ARG_TILE):Imm(0), K_Arg("Bo", KER_ARG_TILE_H), K_Arg("Bo", KER_ARG_TILE_BASE), K_ArgPred("Wf", KER_ARG_TILEFIRST, D0), K_ArgPred("Wf", KER_ARG_TILEFIRST, T0), AlwaysReset?(FirstSeq?Imm(1):Imm(0)):C_Arg("Reset") ) ) ), KerArgs(15, KerArg("State", KerArgSpace(1,T0), O_BUFF|O_NTILED, 2*DimState+DimIn, 1, FeatDataSize, 0, 0, 0, ""), (!(FirstSeq&&AlwaysReset))? KerArg("SCin", KerArgSpace(1,T0), Si_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "SCin"):AT_NO_KER_ARG, (!(FirstSeq&&AlwaysReset))? KerArg("SHin", KerArgSpace(1,T0), Si_Attr|O_BUFF|O_NTILED|O_STACK_PRED, DimState, 1, FeatDataSize, 0, 0, 0, "SHin"):AT_NO_KER_ARG, (!(LastSeq&&AlwaysReset))? ((!(FirstSeq&&AlwaysReset))? KerArgAliased("SCout", KerArgSpace(1,T0), 1, So_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "SCout"): KerArg("SCout", KerArgSpace(1,T0), So_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "SCout")):AT_NO_KER_ARG, (!(LastSeq&&AlwaysReset))? ((!(FirstSeq&&AlwaysReset))? KerArgAliased("SHout", KerArgSpace(1,T0), 2, So_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "SHout"): KerArg("SHout", KerArgSpace(1,T0), So_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "SHout")):AT_NO_KER_ARG, (UseIn)? KerArg("Xin", KerArgSpace(1,RD0), O_IN|O_DB, DimIn, 1, FeatDataSize, 0, 0, 0, "Xin"):AT_NO_KER_ARG, (PerCell)? KerArg("Wf", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, TileCons, "Wf"): KerArg("Wf", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, TileCons, "Wf"), (PerCell)? KerArg("Bf", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bf"): KerArg("Bf", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bf"), (PerCell)? KerArg("Wi", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, 0, "Wi"): KerArg("Wi", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, 0, "Wi"), (PerCell)? KerArg("Bi", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bi"): KerArg("Bi", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bi"), (PerCell)? KerArg("Wg", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, 0, "Wg"): KerArg("Wg", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, 0, "Wg"), (PerCell)? KerArg("Bg", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bg"): KerArg("Bg", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bg"), (PerCell)? KerArg("Wo", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, 0, "Wo"): KerArg("Wo", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, 0, "Wo"), (PerCell)? KerArg("Bo", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bo"): KerArg("Bo", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bo"), (ExposeSequence)? KerArg("Hout", KerArgSpace(2,RD0,T0),O_OUT|O_DB, 1, DimState, FeatDataSize, 0, 0, 0, "Hout"):AT_NO_KER_ARG ) ); if (Kernel) { AddKernelInfos(Name, AT_KERINFO_OPER, LayerOp, 0); AddKernelInfos(Name, AT_KERINFO_BANDWIDTH, LayerBandwidth, 0); if (!(FirstSeq&&AlwaysReset)) AddKernelFloatArgDim(Name, "SCin", 2, DimState, FeatDataSize); if (!(FirstSeq&&AlwaysReset)) AddKernelFloatArgDim(Name, "SHin", 2, DimState, FeatDataSize); if (!(LastSeq&&AlwaysReset)) AddKernelFloatArgDim(Name, "SCout", 2, DimState, FeatDataSize); if (!(LastSeq&&AlwaysReset)) AddKernelFloatArgDim(Name, "SHout", 2, DimState, FeatDataSize); if (UseIn) AddKernelFloatArgDim(Name, "Xin", 3, NCells, DimIn, FeatDataSize); AddKernelFloatArgDim(Name, "Wf", 4, DimOut, DimState, DimIn+DimState, 2); AddKernelFloatArgDim(Name, "Bf", 3, DimOut, DimState, BiasDataSize); AddKernelFloatArgDim(Name, "Wi", 4, DimOut, DimState, DimIn+DimState, 2); AddKernelFloatArgDim(Name, "Bi", 3, DimOut, DimState, BiasDataSize); AddKernelFloatArgDim(Name, "Wg", 4, DimOut, DimState, DimIn+DimState, 2); AddKernelFloatArgDim(Name, "Bg", 3, DimOut, DimState, BiasDataSize); AddKernelFloatArgDim(Name, "Wo", 4, DimOut, DimState, DimIn+DimState, 2); AddKernelFloatArgDim(Name, "Bo", 3, DimOut, DimState, BiasDataSize); if (ExposeSequence) AddKernelFloatArgDim(Name, "Hout", 3, NCells, DimState, FeatDataSize); } return (Kernel!=0); } static int LSTM_Stack_Seq_fp16( char *Name, CNN_GenControl_T *Ctrl, char *LSTMKerName, int AlwaysReset, int NCells, int DimState, int DimIn, int UseIn, int ExposeSequence, int FirstSeq, int LastSeq, int Revert, int Dynamic) { int Ker = 0; AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); Ker = LSTM_Stack_Seq_fp16_Internal(Name, Ctrl, LSTMKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); if (Ker) return 1; AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); GenTilingDebug("\n\n=============================== Solution not found for %s: Trying PARALLELFEATURES=0 ===============================\n\n", Name); /* If solution not found try with ParallelFeature = 0 */ CNN_GenControl_T InternalCtrl; if (!Ctrl) CNN_InitGenCtrl(&InternalCtrl); else InternalCtrl = *Ctrl; CNN_SetGenCtrl(&InternalCtrl, "PARALLELFEATURES", AT_OPT_VAL(0)); Ker = LSTM_Stack_Seq_fp16_Internal(Name, &InternalCtrl, LSTMKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); return Ker; } int LSTM_Stack_fp16( char *Name, CNN_GenControl_T *Ctrl, int NCells, int K0, int K1, int DimState, int DimIn, int AlwaysReset, int Revert ) { int Log = 1; int BiasDataSize = 2; int FeatDataSize = 2; if (K0<1) GenTilingError("LSTM_Stack_fp16, %s, K0, At least one input is expected\n", Name, K0); if (K1<1) GenTilingError("LSTM_Stack_fp16, %s, K1, At least one output is expected\n", Name, K1); if (K0>NCells) GenTilingError("LSTM_Stack_fp16, %s, K0, Number of input should be in [1,NCells]\n", Name, K0); if (K1>NCells) GenTilingError("LSTM_Stack_fp16, %s, K1, Number of ouput should be in [1,NCells]\n", Name, K1); int ParFeat = 1; int PerCell = 0; int PerChanQuant = 0; char *LSTMKerName = ParFeat?"LSTM_ParKer_fp16":"LSTM_Ker_fp16"; char *G1_Name=0, *G2_Name=0, *G3_Name=0; int N1, N2, N3, N2_IO, Seq = RNN_Sequence_fp16(NCells, K0, K1, &N1, &N2, &N3, &N2_IO); int DimOut = PerCell?NCells:1; int Dynamic = 0; if (Ctrl) { if (Ctrl->DynamicIter) Dynamic = 1; } if (Log) { GenTilingDebug("LSTM, %d Cells%s, DimState: %d, DimIn: %d, Input Cells: %d, Output Cells: %d\n", NCells, Dynamic?" Dynamic":"", DimState, DimIn, K0, K1); GenTilingDebug("Basic Kernel: %s\n", LSTMKerName); GenTilingDebug("In Seq: %d, %s Seq: %d, Out Seq: %d\n", N1, N2_IO?"In/Out":"void", N2, N3); } int Ok = 1; if (Dynamic && !((NCells==K0 && NCells==K1) || (NCells==K0 && K1==1))) GenTilingError("LSTM with dynamic cell count is valid only for NC=K0=K1 (all in and out) or NC=K0,K1=1 (all in, single out)"); OpenKernelGroup(Name); if (Dynamic) UserSymbols(3, US_Int("Revert", Revert), US_Int("DimIn", DimIn), US_Type("pFeatType", CNN_ArgDataTypeF(FeatDataSize,1,1))); if (N1>0) Ok = Ok && LSTM_Stack_Seq_fp16(G1_Name = AppendNames(Name, "G1"), Ctrl, LSTMKerName, AlwaysReset, N1, DimState, DimIn, 1, 0, 1, 0, Revert, Dynamic); if (N2>0) Ok = Ok && LSTM_Stack_Seq_fp16(G2_Name = AppendNames(Name, "G2"), Ctrl, LSTMKerName, AlwaysReset, N2, DimState, DimIn, N2_IO, N2_IO, (N1==0), (N3==0), Revert, Dynamic && (N1==0)); if (N3>0) Ok = Ok && LSTM_Stack_Seq_fp16(G3_Name = AppendNames(Name, "G3"), Ctrl, LSTMKerName, AlwaysReset, N3, DimState, DimIn, 0, 1, 0, 1, Revert, 0); CloseKernelGroupNoMerge(); if (Ok==0) return 0; CKernel_Arg_T **GroupCArgs; CKernelCall_T **GroupCCalls; Object_T **GroupKerArgs; GroupCArgs = AllocateCArgs(10 + 3*(AlwaysReset==0)+ 2*(N1!=0) + 2*(N2!=0 && N3!=0) + (Dynamic!=0)); int A= 0; if (Dynamic) GroupCArgs[A++] = TCArg(CNN_ArgDataType (4,0,0), "NCells"); if (!AlwaysReset) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Cinout"); if (!AlwaysReset) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Hinout"); if (N1!=0) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "G1O0"); if (N1!=0) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "G1O1"); if (N2!=0 && N3!=0) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "G2O0"); if (N2!=0 && N3!=0) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "G2O1"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Xin"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(2,1,1), "Wf"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bf"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(2,1,1), "Wi"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bi"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(2,1,1), "Wg"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bg"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(2,1,1), "Wo"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bo"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Hout"); if (AlwaysReset==0) GroupCArgs[A++] = TCArg(CNN_ArgDataType (1,0,0), "Reset"); GroupCCalls = AllocateCalls((N1!=0)+(N2!=0)+(N3!=0)); A=0; if (Dynamic) { if (N1>0) GroupCCalls[A++] = UserKernelCall(G1_Name, LOC_GROUP, Bindings(15,BindKGExpr("CArg(NCells)-1"), (!AlwaysReset)?C_Arg("Cinout"):AT_NO_ARG_BINDING, (!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING, C_Arg("G1O0"), C_Arg("G1O1"), BindKGExpr("((pFeatType)CArg(Xin))+(Revert?(DimIn*(CArg(NCells)-1)):0)"), C_Arg("Wf"), C_Arg("Bf"), C_Arg("Wi"), C_Arg("Bi"), C_Arg("Wg"), C_Arg("Bg"), C_Arg("Wo"), C_Arg("Bo"), (!AlwaysReset)?C_Arg("Reset"):AT_IGNORE_ARG_BINDING ) ); if (N2>0&&N2_IO) GroupCCalls[A++] = UserKernelCall(G2_Name, LOC_GROUP, Bindings(16,(N1==0)?BindKGExpr("CArg(NCells)"):AT_NO_ARG_BINDING, (N1)?C_Arg("G1O0"):((!AlwaysReset)?C_Arg("Cinout"):AT_NO_ARG_BINDING), (N1)?C_Arg("G1O1"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), (N3)?C_Arg("G2O0"):((!AlwaysReset)?C_Arg("Cinout"):AT_NO_ARG_BINDING), (N3)?C_Arg("G2O1"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), BindKGExpr("((pFeatType)CArg(Xin))+(Revert?0:(DimIn*(CArg(NCells)-1)))"), KG_ArgOper("Wf", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bf", '+', PerCell*N1*DimState), KG_ArgOper("Wi", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bi", '+', PerCell*N1*DimState), KG_ArgOper("Wg", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bg", '+', PerCell*N1*DimState), KG_ArgOper("Wo", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bo", '+', PerCell*N1*DimState), C_Arg("Hout"), (!AlwaysReset)?((N1==0)?C_Arg("Reset"):Imm(0)):AT_IGNORE_ARG_BINDING ) ); } else { if (N1>0) GroupCCalls[A++] = UserKernelCall(G1_Name, LOC_GROUP, Bindings(14,(!AlwaysReset)?C_Arg("Cinout"):AT_NO_ARG_BINDING, (!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING, C_Arg("G1O0"), C_Arg("G1O1"), Revert?KG_ArgOper("Xin", '+', (N2_IO?N2:0)*DimIn):C_Arg("Xin"), C_Arg("Wf"), C_Arg("Bf"), C_Arg("Wi"), C_Arg("Bi"), C_Arg("Wg"), C_Arg("Bg"), C_Arg("Wo"), C_Arg("Bo"), (!AlwaysReset)?C_Arg("Reset"):AT_IGNORE_ARG_BINDING ) ); if (N2>0&&N2_IO) GroupCCalls[A++] = UserKernelCall(G2_Name, LOC_GROUP, Bindings(15,(N1)?C_Arg("G1O0"):((!AlwaysReset)?C_Arg("Cinout"):AT_NO_ARG_BINDING), (N1)?C_Arg("G1O1"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), (N3)?C_Arg("G2O0"):((!AlwaysReset)?C_Arg("Cinout"):AT_NO_ARG_BINDING), (N3)?C_Arg("G2O1"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), Revert?C_Arg("Xin"):KG_ArgOper("Xin", '+', N1*DimIn), KG_ArgOper("Wf", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bf", '+', PerCell*N1*DimState), KG_ArgOper("Wi", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bi", '+', PerCell*N1*DimState), KG_ArgOper("Wg", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bg", '+', PerCell*N1*DimState), KG_ArgOper("Wo", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bo", '+', PerCell*N1*DimState), C_Arg("Hout"), (!AlwaysReset)?((N1==0)?C_Arg("Reset"):Imm(0)):AT_IGNORE_ARG_BINDING ) ); if (N2>0&&!N2_IO) GroupCCalls[A++] = UserKernelCall(G2_Name, LOC_GROUP, Bindings(13,C_Arg("G1O0"), C_Arg("G1O1"), C_Arg("G2O0"), C_Arg("G2O1"), KG_ArgOper("Wf", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bf", '+', PerCell*N1*DimState), KG_ArgOper("Wi", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bi", '+', PerCell*N1*DimState), KG_ArgOper("Wg", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bg", '+', PerCell*N1*DimState), KG_ArgOper("Wo", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bo", '+', PerCell*N1*DimState), (AlwaysReset==0)?Imm(0):AT_IGNORE_ARG_BINDING ) ); if (N3>0) GroupCCalls[A++] = UserKernelCall(G3_Name, LOC_GROUP, Bindings(14,(N2)?C_Arg("G2O0"):C_Arg("G1O0"), (N2)?C_Arg("G2O1"):C_Arg("G1O1"), (!AlwaysReset)?C_Arg("Cinout"):AT_NO_ARG_BINDING, (!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING, KG_ArgOper("Wf", '+', PerCell*(N1+N2)*(DimState+DimIn)*DimState), KG_ArgOper("Bf", '+', PerCell*(N1+N2)*DimState), KG_ArgOper("Wi", '+', PerCell*(N1+N2)*(DimState+DimIn)*DimState), KG_ArgOper("Bi", '+', PerCell*(N1+N2)*DimState), KG_ArgOper("Wg", '+', PerCell*(N1+N2)*(DimState+DimIn)*DimState), KG_ArgOper("Bg", '+', PerCell*(N1+N2)*DimState), KG_ArgOper("Wo", '+', PerCell*(N1+N2)*(DimState+DimIn)*DimState), KG_ArgOper("Bo", '+', PerCell*(N1+N2)*DimState), KG_ArgOper("Hout", '+', N2_IO?N2*DimState:0), (!AlwaysReset)?Imm(0):AT_IGNORE_ARG_BINDING ) ); } GroupKerArgs = AllocateKerArgs(10 + (Dynamic!=0) + 3*(AlwaysReset==0) + 2*(N1!=0) + 2*(N2!=0 && N3!=0)); A = 0; if (Dynamic) GroupKerArgs[A++] = KerGroupArg("NCells", O_IN, 1, 4, "NCells"); if (!AlwaysReset) GroupKerArgs[A++] = KerGroupArg("Cinout", O_IN|O_OUT, DimState, FeatDataSize, "Cinout"); if (!AlwaysReset) GroupKerArgs[A++] = KerGroupArg("Hinout", O_IN|O_OUT, DimState, FeatDataSize, "Hinout"); if (N1!=0) GroupKerArgs[A++] = KerGroupArg("G1O0", O_IN|O_OUT|O_BUFF, DimState, FeatDataSize, "G1O0"); if (N1!=0) GroupKerArgs[A++] = KerGroupArg("G1O1", O_IN|O_OUT|O_BUFF, DimState, FeatDataSize, "G1O1"); if (N2!=0 && N3!=0) GroupKerArgs[A++] = KerGroupArg("G2O0", O_IN|O_OUT|O_BUFF, DimState, FeatDataSize, "G2O0"); if (N2!=0 && N3!=0) GroupKerArgs[A++] = KerGroupArg("G2O1", O_IN|O_OUT|O_BUFF, DimState, FeatDataSize, "G2O1"); GroupKerArgs[A++] = KerGroupArg("Xin", O_IN, DimIn*K0, FeatDataSize, "Xin"); GroupKerArgs[A++] = KerGroupArg("Wf", O_IN, DimOut*(DimState + DimIn)*DimState, 2, "Wf"); GroupKerArgs[A++] = KerGroupArg("Bf", O_IN, DimOut*DimState, BiasDataSize, "Bf"); GroupKerArgs[A++] = KerGroupArg("Wi", O_IN, DimOut*(DimState + DimIn)*DimState, 2, "Wi"); GroupKerArgs[A++] = KerGroupArg("Bi", O_IN, DimOut*DimState, BiasDataSize, "Bi"); GroupKerArgs[A++] = KerGroupArg("Wg", O_IN, DimOut*(DimState + DimIn)*DimState, 2, "Wg"); GroupKerArgs[A++] = KerGroupArg("Bg", O_IN, DimOut*DimState, BiasDataSize, "Bg"); GroupKerArgs[A++] = KerGroupArg("Wo", O_IN, DimOut*(DimState + DimIn)*DimState, 2, "Wo"); GroupKerArgs[A++] = KerGroupArg("Bo", O_IN, DimOut*DimState, BiasDataSize, "Bo"); GroupKerArgs[A++] = KerGroupArg("Hout", O_OUT, K1*DimState, FeatDataSize, "Hout"); if (!AlwaysReset) GroupKerArgs[A++] = KerGroupArg("Reset", O_IN, 1, 1, "Reset"); KernelGroup_T *UKGroup = UserKernelGroupK( Name, 1, GroupCArgs, 0, GroupCCalls, GroupKerArgs ); return (UKGroup!=0); } static int GRU_Stack_Seq_fp16_Internal( char *Name, CNN_GenControl_T *Ctrl, char *GRUKerName, int AlwaysReset, int NCells, int DimState, int DimIn, int UseIn, int ExposeSequence, int FirstSeq, int LastSeq, int Revert, int Dynamic ) { /* Sequences In: DimIn!=0, ExposeSequence==0 InOut: DimIn!=0, ExposeSequence!=0 None: DimIn==0, ExposeSequence==0 Out: DimIn==0, ExposeSequence!=0 */ int BiasDataSize = 2; int FeatDataSize = 2; int RD0 = Revert?SPACE_PROP(D0, SPACE_PROP_REVERT):D0; int ParFeat = 1; int PerCell = 0; int PerChanQuant = 0; Tile_Orientation_T TileOrientation = TILE_HOR; int TileCons=0; unsigned long long int LayerOp = 0; unsigned long long int LayerBandwidth = 0; unsigned int Si_Attr = O_IN|((!FirstSeq||AlwaysReset)?O_NO_LOAD:0); unsigned int So_Attr = O_OUT|((!LastSeq||AlwaysReset)?O_NO_STORE:0); if (Dynamic && (Si_Attr==O_IN)) Si_Attr |= O_ALWAYS_LOAD; if (Ctrl) { if (Ctrl->ParallelFeatures != -1) ParFeat = Ctrl->ParallelFeatures; } if (ParFeat) TileCons = 8; int Din = UseIn?DimIn:0; int DimOut = PerCell?NCells:1; LayerOp = NCells*((DimState + (UseIn?DimIn:0))*DimState*3 + DimState*3 + DimState*3); LayerBandwidth = NCells*((DimState + DimIn) + 3*(DimState + DimIn)*DimState*1 + 3*(DimState)*BiasDataSize + DimState); Kernel_T *Kernel = UserKernel(Name, KernelIterSpace(2, Dynamic?IterFixedSpaceDynBound(D0, NCells, "NCells"):IterFixedSpace(D0, NCells), IterTiledSpace(T0)), TileOrientation, CArgs(13, (Dynamic)? TCArg(CNN_ArgDataType (4,0,0), "NCells"):AT_NO_C_ARG, (!(FirstSeq&&AlwaysReset))? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Sin"):AT_NO_C_ARG, (!(LastSeq&&AlwaysReset))? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Sout"):AT_NO_C_ARG, (UseIn)? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Xin"):AT_NO_C_ARG, TCArg(CNN_ArgDataTypeF(2,1,1), "Wr"), TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Br"), TCArg(CNN_ArgDataTypeF(2,1,1), "Wz"), TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bz"), TCArg(CNN_ArgDataTypeF(2,1,1), "Wh"), TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bwh"), TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Brh"), (ExposeSequence)? TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Hout"):AT_NO_C_ARG, (!AlwaysReset)? TCArg(CNN_ArgDataType (1,0,0), "Reset"):AT_NO_C_ARG ), Calls(1, Call(GRUKerName, LOC_LOOP, Bindings(18, (!(FirstSeq&&AlwaysReset))?K_Arg("Sin", KER_ARG_TILE):((!(LastSeq&&AlwaysReset))?K_Arg("Sout", KER_ARG_TILE):Imm(0)), K_Arg("State", KER_ARG_TILE), UseIn?K_Arg("Xin", KER_ARG_TILE):Imm(0), Imm(DimState), Imm(DimIn), K_Arg("Wr", KER_ARG_TILE), K_Arg("Br", KER_ARG_TILE), K_Arg("Wz", KER_ARG_TILE), K_Arg("Bz", KER_ARG_TILE), K_Arg("Wh", KER_ARG_TILE), K_Arg("Bwh", KER_ARG_TILE), K_Arg("Brh", KER_ARG_TILE), (ExposeSequence)?K_Arg("Hout", KER_ARG_TILE):Imm(0), K_Arg("Bwh", KER_ARG_TILE_H), K_Arg("Bwh", KER_ARG_TILE_BASE), K_ArgPred("Wr", KER_ARG_TILEFIRST, D0), K_ArgPred("Wr", KER_ARG_TILEFIRST, T0), AlwaysReset?(FirstSeq?Imm(1):Imm(0)):C_Arg("Reset") ) ) ), KerArgs(12, KerArg("State", KerArgSpace(1,T0), O_BUFF|O_NTILED, DimState+DimIn, 1, FeatDataSize, 0, 0, 0, ""), (!(FirstSeq&&AlwaysReset))? KerArg("Sin", KerArgSpace(1,T0), Si_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "Sin"):AT_NO_KER_ARG, (!(LastSeq&&AlwaysReset))? ((!(FirstSeq&&AlwaysReset))? KerArgAliased("Sout", KerArgSpace(1,T0),1, So_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "Sout"): KerArg("Sout", KerArgSpace(1,T0), So_Attr|O_BUFF|O_NTILED, DimState, 1, FeatDataSize, 0, 0, 0, "Sout")):AT_NO_KER_ARG, (UseIn)? KerArg("Xin", KerArgSpace(1,RD0), O_IN|O_DB, DimIn, 1, FeatDataSize, 0, 0, 0, "Xin"):AT_NO_KER_ARG, (PerCell)? KerArg("Wr", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, TileCons, "Wr"): KerArg("Wr", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, TileCons, "Wr"), (PerCell)? KerArg("Br", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Br"): KerArg("Br", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Br"), (PerCell)? KerArg("Wz", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, 0, "Wz"): KerArg("Wz", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, 0, "Wz"), (PerCell)? KerArg("Bz", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bz"): KerArg("Bz", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bz"), (PerCell)? KerArg("Wh", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, 0, "Wh"): KerArg("Wh", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, DimIn+DimState, DimState, 2, 0, 0, 0, "Wh"), (PerCell)? KerArg("Bwh", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bwh"): KerArg("Bwh", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Bwh"), (PerCell)? KerArg("Brh", KerArgSpace(2,D0,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Brh"): KerArg("Brh", KerArgSpace(1,T0), O_IN|O_DB|O_CONST, 1, DimState, BiasDataSize, 0, 0, 0, "Brh"), (ExposeSequence)? KerArg("Hout", KerArgSpace(2,RD0,T0),O_OUT|O_DB, 1, DimState, FeatDataSize, 0, 0, 0, "Hout"):AT_NO_KER_ARG ) ); if (Kernel) { AddKernelInfos(Name, AT_KERINFO_OPER, LayerOp, 0); AddKernelInfos(Name, AT_KERINFO_BANDWIDTH, LayerBandwidth, 0); if (!(FirstSeq&&AlwaysReset)) AddKernelFloatArgDim(Name, "Sin", 2, DimState, FeatDataSize); if (!(LastSeq&&AlwaysReset)) AddKernelFloatArgDim(Name, "Sout", 2, DimState, FeatDataSize); if (UseIn) AddKernelFloatArgDim(Name, "Xin", 3, NCells, DimIn, FeatDataSize); AddKernelFloatArgDim(Name, "Wr", 4, DimOut, DimState, DimIn+DimState, 2); AddKernelFloatArgDim(Name, "Br", 3, DimOut, DimState, BiasDataSize); AddKernelFloatArgDim(Name, "Wz", 4, DimOut, DimState, DimIn+DimState, 2); AddKernelFloatArgDim(Name, "Bz", 3, DimOut, DimState, BiasDataSize); AddKernelFloatArgDim(Name, "Wh", 4, DimOut, DimState, DimIn+DimState, 2); AddKernelFloatArgDim(Name, "Bwh", 3, DimOut, DimState, BiasDataSize); AddKernelFloatArgDim(Name, "Brh", 3, DimOut, DimState, BiasDataSize); if (ExposeSequence) AddKernelFloatArgDim(Name, "Hout", 3, NCells, DimState, FeatDataSize); if (Ctrl && (Ctrl->Filter_L3)) { SetKerArgInL3(Name, "Wr"); SetKerArgInL3(Name, "Wz"); SetKerArgInL3(Name, "Wh"); } } return (Kernel!=0); } static int GRU_Stack_Seq_fp16( char *Name, CNN_GenControl_T *Ctrl, char *GRUKerName, int AlwaysReset, int NCells, int DimState, int DimIn, int UseIn, int ExposeSequence, int FirstSeq, int LastSeq, int Revert, int Dynamic) { int Ker = 0; AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_OFF); Ker = GRU_Stack_Seq_fp16_Internal(Name, Ctrl, GRUKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); if (Ker) return 1; AT_SetKernelCtrl(AT_KERNEL_NOSOLUTION_ERROR, AT_OPT_ON); GenTilingDebug("\n\n=============================== Solution not found for %s: Trying PARALLELFEATURES=0 ===============================\n\n", Name); /* If solution not found try with ParallelFeature = 0 */ CNN_GenControl_T InternalCtrl; if (!Ctrl) CNN_InitGenCtrl(&InternalCtrl); else InternalCtrl = *Ctrl; CNN_SetGenCtrl(&InternalCtrl, "PARALLELFEATURES", AT_OPT_VAL(0)); Ker = GRU_Stack_Seq_fp16_Internal(Name, &InternalCtrl, GRUKerName, AlwaysReset, NCells, DimState, DimIn, UseIn, ExposeSequence, FirstSeq, LastSeq, Revert, Dynamic); return Ker; } int GRU_Stack_fp16( char *Name, CNN_GenControl_T *Ctrl, int NCells, int K0, int K1, int DimState, int DimIn, int AlwaysReset, int Revert ) { int Log = 1; int BiasDataSize = 2; int FeatDataSize = 2; if (K0<1) GenTilingError("GRU_Stack_fp16, %s, K0, At least one input is expected\n", Name, K0); if (K1<1) GenTilingError("GRU_Stack_fp16, %s, K1, At least one output is expected\n", Name, K1); if (K0>NCells) GenTilingError("GRU_Stack_fp16, %s, K0, Number of input should be in [1,NCells]\n", Name, K0); if (K1>NCells) GenTilingError("GRU_Stack_fp16, %s, K1, Number of ouput should be in [1,NCells]\n", Name, K1); int ParFeat = 1; int PerCell = 0; int PerChanQuant = 0; char *GRUKerName = ParFeat?"GRU_ParKer_fp16":"GRU_Ker_fp16"; char *G1_Name=0, *G2_Name=0, *G3_Name=0; int N1, N2, N3, N2_IO, Seq = RNN_Sequence_fp16(NCells, K0, K1, &N1, &N2, &N3, &N2_IO); int DimOut = PerCell?NCells:1; int Dynamic = 0; if (Ctrl) { if (Ctrl->DynamicIter) Dynamic = 1; } if (Log) { GenTilingDebug("GRU, %d Cells%s, DimState: %d, DimIn: %d, Input Cells: %d, Output Cells: %d\n", NCells, Dynamic?" Dynamic":"", DimState, DimIn, K0, K1); GenTilingDebug("Basic Kernel: %s\n", GRUKerName); GenTilingDebug("In Seq: %d, %s Seq: %d, Out Seq: %d\n", N1, N2_IO?"In/Out":"void", N2, N3); } int Ok = 1; if (Dynamic && !((NCells==K0 && NCells==K1) || (NCells==K0 && K1==1))) GenTilingError("GRU with dynamic cell count is valid only for NC=K0=K1 (all in and out) or NC=K0,K1=1 (all in, single out)"); OpenKernelGroup(Name); if (Dynamic) UserSymbols(3, US_Int("Revert", Revert), US_Int("DimIn", DimIn), US_Type("pFeatType", CNN_ArgDataTypeF(FeatDataSize,1,1))); if (N1>0) Ok = Ok && GRU_Stack_Seq_fp16(G1_Name = AppendNames(Name, "G1"), Ctrl, GRUKerName, AlwaysReset, N1, DimState, DimIn, 1, 0, 1, 0, Revert, Dynamic); if (N2>0) Ok = Ok && GRU_Stack_Seq_fp16(G2_Name = AppendNames(Name, "G2"), Ctrl, GRUKerName, AlwaysReset, N2, DimState, DimIn, N2_IO, N2_IO, (N1==0), (N3==0), Revert, Dynamic && (N1==0)); if (N3>0) Ok = Ok && GRU_Stack_Seq_fp16(G3_Name = AppendNames(Name, "G3"), Ctrl, GRUKerName, AlwaysReset, N3, DimState, DimIn, 0, 1, 0, 1, Revert, 0); CloseKernelGroupNoMerge(); if (Ok==0) return 0; CKernel_Arg_T **GroupCArgs; CKernelCall_T **GroupCCalls; Object_T **GroupKerArgs; GroupCArgs = AllocateCArgs(9 + (N1!=0) + (N2!=0 && N3!=0) + 2*(AlwaysReset==0) + (Dynamic!=0)); int A= 0; if (Dynamic) GroupCArgs[A++] = TCArg(CNN_ArgDataType (4,0,0), "NCells"); if (!AlwaysReset) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Hinout"); if (N1!=0) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "G1O"); if (N2!=0 && N3!=0) GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "G2O"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(2,1,1), "Xin"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(2,1,1), "Wr"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Br"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(2,1,1), "Wz"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bz"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(2,1,1), "Wh"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Bwh"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(BiasDataSize,1,1), "Brh"); GroupCArgs[A++] = TCArg(CNN_ArgDataTypeF(FeatDataSize,1,1), "Hout"); if (!AlwaysReset) GroupCArgs[A++] = TCArg(CNN_ArgDataType (1,0,0), "Reset"); GroupCCalls = AllocateCalls((N1!=0)+(N2!=0)+(N3!=0)); A=0; if (Dynamic) { if (N1>0) GroupCCalls[A++] = UserKernelCall(G1_Name, LOC_GROUP, Bindings(12,BindKGExpr("CArg(NCells)-1"), (!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING, C_Arg("G1O"), BindKGExpr("((pFeatType)CArg(Xin))+(Revert?(DimIn*(CArg(NCells)-1)):0)"), C_Arg("Wr"), C_Arg("Br"), C_Arg("Wz"), C_Arg("Bz"), C_Arg("Wh"), C_Arg("Bwh"), C_Arg("Brh"), (AlwaysReset==0)?C_Arg("Reset"):AT_IGNORE_ARG_BINDING ) ); if (N2>0&&N2_IO) GroupCCalls[A++] = UserKernelCall(G2_Name, LOC_GROUP, Bindings(13,(N1==0)?BindKGExpr("CArg(NCells)"):AT_NO_ARG_BINDING, (N1)?C_Arg("G1O"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), (N3)?C_Arg("G2O"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), BindKGExpr("((pFeatType)CArg(Xin))+(Revert?0:(DimIn*(CArg(NCells)-1)))"), KG_ArgOper("Wr", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Br", '+', PerCell*N1*DimState), KG_ArgOper("Wz", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bz", '+', PerCell*N1*DimState), KG_ArgOper("Wh", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bwh", '+', PerCell*N1*DimState), KG_ArgOper("Brh", '+', PerCell*N1*DimState), C_Arg("Hout"), (!AlwaysReset)?((N1==0)?C_Arg("Reset"):Imm(0)):AT_NO_ARG_BINDING ) ); } else { if (N1>0) GroupCCalls[A++] = UserKernelCall(G1_Name, LOC_GROUP, Bindings(11,(!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING, C_Arg("G1O"), Revert?KG_ArgOper("Xin", '+', (N2_IO?N2:0)*DimIn):C_Arg("Xin"), C_Arg("Wr"), C_Arg("Br"), C_Arg("Wz"), C_Arg("Bz"), C_Arg("Wh"), C_Arg("Bwh"), C_Arg("Brh"), (AlwaysReset==0)?C_Arg("Reset"):AT_IGNORE_ARG_BINDING ) ); if (N2>0&&N2_IO) GroupCCalls[A++] = UserKernelCall(G2_Name, LOC_GROUP, Bindings(12,(N1)?C_Arg("G1O"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), (N3)?C_Arg("G2O"):((!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING), Revert?C_Arg("Xin"):KG_ArgOper("Xin", '+', N1*DimIn), KG_ArgOper("Wr", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Br", '+', PerCell*N1*DimState), KG_ArgOper("Wz", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bz", '+', PerCell*N1*DimState), KG_ArgOper("Wh", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bwh", '+', PerCell*N1*DimState), KG_ArgOper("Brh", '+', PerCell*N1*DimState), C_Arg("Hout"), (!AlwaysReset)?((N1==0)?C_Arg("Reset"):Imm(0)):AT_NO_ARG_BINDING ) ); if (N2>0&&!N2_IO) GroupCCalls[A++] = UserKernelCall(G2_Name, LOC_GROUP, Bindings(10,C_Arg("G1O"), C_Arg("G2O"), KG_ArgOper("Wr", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Br", '+', PerCell*N1*DimState), KG_ArgOper("Wz", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bz", '+', PerCell*N1*DimState), KG_ArgOper("Wh", '+', PerCell*N1*(DimState+DimIn)*DimState), KG_ArgOper("Bwh", '+', PerCell*N1*DimState), KG_ArgOper("Brh", '+', PerCell*N1*DimState), (!AlwaysReset)?Imm(0):AT_NO_ARG_BINDING ) ); if (N3>0) GroupCCalls[A++] = UserKernelCall(G3_Name, LOC_GROUP, Bindings(11,(N2)?C_Arg("G2O"):C_Arg("G1O"), (!AlwaysReset)?C_Arg("Hinout"):AT_NO_ARG_BINDING, KG_ArgOper("Wr", '+', PerCell*(N1+N2)*(DimState+DimIn)*DimState), KG_ArgOper("Br", '+', PerCell*(N1+N2)*DimState), KG_ArgOper("Wz", '+', PerCell*(N1+N2)*(DimState+DimIn)*DimState), KG_ArgOper("Bz", '+', PerCell*(N1+N2)*DimState), KG_ArgOper("Wh", '+', PerCell*(N1+N2)*(DimState+DimIn)*DimState), KG_ArgOper("Bwh", '+', PerCell*(N1+N2)*DimState), KG_ArgOper("Brh", '+', PerCell*(N1+N2)*DimState), KG_ArgOper("Hout", '+', N2_IO?N2*DimState:0), (!AlwaysReset)?Imm(0):AT_NO_ARG_BINDING ) ); } GroupKerArgs = AllocateKerArgs(10 + (Dynamic!=0) + (N1!=0) + (N2!=0 && N3!=0) + 2*(AlwaysReset==0)); A = 0; if (Dynamic) GroupKerArgs[A++] = KerGroupArg("NCells", O_IN, 1, 4, "NCells"); if (!AlwaysReset) GroupKerArgs[A++] = KerGroupArg("Hinout", O_IN|O_OUT, DimState, FeatDataSize, "Hinout"); if (N1!=0) GroupKerArgs[A++] = KerGroupArg("G1O", O_IN|O_OUT|O_BUFF, DimState, FeatDataSize, "G1O"); if (N2!=0 && N3!=0) GroupKerArgs[A++] = KerGroupArg("G2O", O_IN|O_OUT|O_BUFF, DimState, FeatDataSize, "G2O"); GroupKerArgs[A++] = KerGroupArg("Xin", O_IN, DimIn*K0, FeatDataSize, "Xin"); GroupKerArgs[A++] = KerGroupArg("Wr", O_IN, DimOut*(DimState + DimIn)*DimState, 2, "Wr"); GroupKerArgs[A++] = KerGroupArg("Br", O_IN, DimOut*DimState, BiasDataSize, "Br"); GroupKerArgs[A++] = KerGroupArg("Wz", O_IN, DimOut*(DimState + DimIn)*DimState, 2, "Wz"); GroupKerArgs[A++] = KerGroupArg("Bz", O_IN, DimOut*DimState, BiasDataSize, "Bz"); GroupKerArgs[A++] = KerGroupArg("Wh", O_IN, DimOut*(DimState + DimIn)*DimState, 2, "Wh"); GroupKerArgs[A++] = KerGroupArg("Bwh", O_IN, DimOut*DimState, BiasDataSize, "Bwh"); GroupKerArgs[A++] = KerGroupArg("Brh", O_IN, DimOut*DimState, BiasDataSize, "Brh"); GroupKerArgs[A++] = KerGroupArg("Hout", O_OUT, DimState*K1, FeatDataSize, "Hout"); if (!AlwaysReset) GroupKerArgs[A++] = KerGroupArg("Reset", O_IN, 1, 1, "Reset"); KernelGroup_T *UKGroup = UserKernelGroupK( Name, 1, GroupCArgs, 0, GroupCCalls, GroupKerArgs ); if (UKGroup) { if (Ctrl && (Ctrl->Filter_L3)) { SetKerArgInL3(Name, "Wr"); SetKerArgInL3(Name, "Wz"); SetKerArgInL3(Name, "Wh"); } } return (UKGroup!=0); }
42614f8dc98b2dfbc8492f64fe5830328b62eb76
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/graphics/MesaLib/patches/patch-src_mapi_entry__x86__tls.h
c618f8b753e3ab61616eb70e6a1999e9a389b958
[]
no_license
NetBSD/pkgsrc
a0732c023519650ef821ab89c23ab6ab59e25bdb
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
refs/heads/trunk
2023-09-01T07:40:12.138283
2023-09-01T05:25:19
2023-09-01T05:25:19
88,439,572
321
138
null
2023-07-12T22:34:14
2017-04-16T20:04:15
null
UTF-8
C
false
false
1,723
h
patch-src_mapi_entry__x86__tls.h
$NetBSD: patch-src_mapi_entry__x86__tls.h,v 1.7 2022/03/13 15:50:05 tnn Exp $ NetBSD only supports zero-initialized initial-exec tls variables in conjuction with dlopen(3) at the moment. --- src/mapi/entry_x86_tls.h.orig 2021-07-14 20:04:57.805030000 +0000 +++ src/mapi/entry_x86_tls.h @@ -51,6 +51,25 @@ __asm__("x86_current_tls:\n\t" "movl " ENTRY_CURRENT_TABLE "@GOTNTPOFF(%eax), %eax\n\t" "ret"); +#if defined(__NetBSD__) +__asm__("x86_current_table_helper:\n\t" + "call 1f\n\t" + "1:\n\t" + "popl %eax\n\t" + "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t" + "movl " ENTRY_CURRENT_TABLE "@GOTNTPOFF(%eax), %eax\n\t" + "movl %gs:(%eax), %eax\n\t" + "testl %eax, %eax\n\t" + "je 2f\n\t" + "ret\n\t" + "2:\n\t" + "call 3f\n\t" + "3:\n\t" + "popl %eax\n\t" + "addl $_GLOBAL_OFFSET_TABLE_+[.-3b], %eax\n\t" + "jmp *" ENTRY_CURRENT_TABLE_GET "@GOT(%eax)"); +#endif + #ifndef GLX_X86_READONLY_TEXT __asm__(".section wtext, \"awx\", @progbits"); #endif /* GLX_X86_READONLY_TEXT */ @@ -64,6 +83,11 @@ __asm__(".balign 16\n" ".balign 16\n" \ func ":" +#if defined(__NetBSD__) +#define STUB_ASM_CODE(slot) \ + "call x86_current_table_helper\n\t" \ + "jmp *(4 * " slot ")(%eax)" +#else #define STUB_ASM_CODE(slot) \ ENDBR \ "call 1f\n" \ @@ -73,6 +97,7 @@ __asm__(".balign 16\n" "movl " ENTRY_CURRENT_TABLE "@GOTNTPOFF(%eax), %eax\n\t" \ "movl %gs:(%eax), %eax\n\t" \ "jmp *(4 * " slot ")(%eax)" +#endif #define MAPI_TMP_STUB_ASM_GCC #include "mapi_tmp.h"
399dcdfac6d9737e528312b87d63621265af54d8
fb47ab6337a71029dee71933e449cf7f6805fc0f
/external/platform/stm32f4xx/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dcmi.c
9de667645db0887b1ccb19079fef1fd1b00fdf0e
[ "MIT" ]
permissive
littlekernel/lk
7e7ba50b87b1f2e0b6e2f052c59249825c91975b
30dc320054f70910e1c1ee40a6948ee99672acec
refs/heads/master
2023-09-02T00:47:52.203963
2023-06-21T22:42:35
2023-06-21T22:42:35
3,058,456
3,077
618
MIT
2023-08-30T09:41:31
2011-12-27T19:19:36
C
UTF-8
C
false
false
17,773
c
stm32f4xx_dcmi.c
/** ****************************************************************************** * @file stm32f4xx_dcmi.c * @author MCD Application Team * @version V1.8.1 * @date 27-January-2022 * @brief This file provides firmware functions to manage the following * functionalities of the DCMI peripheral: * + Initialization and Configuration * + Image capture functions * + Interrupts and flags management * @verbatim =============================================================================== ##### How to use this driver ##### =============================================================================== [..] The sequence below describes how to use this driver to capture image from a camera module connected to the DCMI Interface. This sequence does not take into account the configuration of the camera module, which should be made before to configure and enable the DCMI to capture images. (#) Enable the clock for the DCMI and associated GPIOs using the following functions: RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_DCMI, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE); (#) DCMI pins configuration (++) Connect the involved DCMI pins to AF13 using the following function GPIO_PinAFConfig(GPIOx, GPIO_PinSourcex, GPIO_AF_DCMI); (++) Configure these DCMI pins in alternate function mode by calling the function GPIO_Init(); (#) Declare a DCMI_InitTypeDef structure, for example: DCMI_InitTypeDef DCMI_InitStructure; and fill the DCMI_InitStructure variable with the allowed values of the structure member. (#) Initialize the DCMI interface by calling the function DCMI_Init(&DCMI_InitStructure); (#) Configure the DMA2_Stream1 channel1 to transfer Data from DCMI DR register to the destination memory buffer. (#) Enable DCMI interface using the function DCMI_Cmd(ENABLE); (#) Start the image capture using the function DCMI_CaptureCmd(ENABLE); (#) At this stage the DCMI interface waits for the first start of frame, then a DMA request is generated continuously/once (depending on the mode used, Continuous/Snapshot) to transfer the received data into the destination memory. -@- If you need to capture only a rectangular window from the received image, you have to use the DCMI_CROPConfig() function to configure the coordinates and size of the window to be captured, then enable the Crop feature using DCMI_CROPCmd(ENABLE); In this case, the Crop configuration should be made before to enable and start the DCMI interface. @endverbatim ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_dcmi.h" #include "stm32f4xx_rcc.h" /** @addtogroup STM32F4xx_StdPeriph_Driver * @{ */ /** @defgroup DCMI * @brief DCMI driver modules * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** @defgroup DCMI_Private_Functions * @{ */ /** @defgroup DCMI_Group1 Initialization and Configuration functions * @brief Initialization and Configuration functions * @verbatim =============================================================================== ##### Initialization and Configuration functions ##### =============================================================================== @endverbatim * @{ */ /** * @brief Deinitializes the DCMI registers to their default reset values. * @param None * @retval None */ void DCMI_DeInit(void) { DCMI->CR = 0x0; DCMI->IER = 0x0; DCMI->ICR = 0x1F; DCMI->ESCR = 0x0; DCMI->ESUR = 0x0; DCMI->CWSTRTR = 0x0; DCMI->CWSIZER = 0x0; } /** * @brief Initializes the DCMI according to the specified parameters in the DCMI_InitStruct. * @param DCMI_InitStruct: pointer to a DCMI_InitTypeDef structure that contains * the configuration information for the DCMI. * @retval None */ void DCMI_Init(DCMI_InitTypeDef* DCMI_InitStruct) { uint32_t temp = 0x0; /* Check the parameters */ assert_param(IS_DCMI_CAPTURE_MODE(DCMI_InitStruct->DCMI_CaptureMode)); assert_param(IS_DCMI_SYNCHRO(DCMI_InitStruct->DCMI_SynchroMode)); assert_param(IS_DCMI_PCKPOLARITY(DCMI_InitStruct->DCMI_PCKPolarity)); assert_param(IS_DCMI_VSPOLARITY(DCMI_InitStruct->DCMI_VSPolarity)); assert_param(IS_DCMI_HSPOLARITY(DCMI_InitStruct->DCMI_HSPolarity)); assert_param(IS_DCMI_CAPTURE_RATE(DCMI_InitStruct->DCMI_CaptureRate)); assert_param(IS_DCMI_EXTENDED_DATA(DCMI_InitStruct->DCMI_ExtendedDataMode)); /* The DCMI configuration registers should be programmed correctly before enabling the CR_ENABLE Bit and the CR_CAPTURE Bit */ DCMI->CR &= ~(DCMI_CR_ENABLE | DCMI_CR_CAPTURE); /* Reset the old DCMI configuration */ temp = DCMI->CR; temp &= ~((uint32_t)DCMI_CR_CM | DCMI_CR_ESS | DCMI_CR_PCKPOL | DCMI_CR_HSPOL | DCMI_CR_VSPOL | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_EDM_0 | DCMI_CR_EDM_1); /* Sets the new configuration of the DCMI peripheral */ temp |= ((uint32_t)DCMI_InitStruct->DCMI_CaptureMode | DCMI_InitStruct->DCMI_SynchroMode | DCMI_InitStruct->DCMI_PCKPolarity | DCMI_InitStruct->DCMI_VSPolarity | DCMI_InitStruct->DCMI_HSPolarity | DCMI_InitStruct->DCMI_CaptureRate | DCMI_InitStruct->DCMI_ExtendedDataMode); DCMI->CR = temp; } /** * @brief Fills each DCMI_InitStruct member with its default value. * @param DCMI_InitStruct : pointer to a DCMI_InitTypeDef structure which will * be initialized. * @retval None */ void DCMI_StructInit(DCMI_InitTypeDef* DCMI_InitStruct) { /* Set the default configuration */ DCMI_InitStruct->DCMI_CaptureMode = DCMI_CaptureMode_Continuous; DCMI_InitStruct->DCMI_SynchroMode = DCMI_SynchroMode_Hardware; DCMI_InitStruct->DCMI_PCKPolarity = DCMI_PCKPolarity_Falling; DCMI_InitStruct->DCMI_VSPolarity = DCMI_VSPolarity_Low; DCMI_InitStruct->DCMI_HSPolarity = DCMI_HSPolarity_Low; DCMI_InitStruct->DCMI_CaptureRate = DCMI_CaptureRate_All_Frame; DCMI_InitStruct->DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b; } /** * @brief Initializes the DCMI peripheral CROP mode according to the specified * parameters in the DCMI_CROPInitStruct. * @note This function should be called before to enable and start the DCMI interface. * @param DCMI_CROPInitStruct: pointer to a DCMI_CROPInitTypeDef structure that * contains the configuration information for the DCMI peripheral CROP mode. * @retval None */ void DCMI_CROPConfig(DCMI_CROPInitTypeDef* DCMI_CROPInitStruct) { /* Sets the CROP window coordinates */ DCMI->CWSTRTR = (uint32_t)((uint32_t)DCMI_CROPInitStruct->DCMI_HorizontalOffsetCount | ((uint32_t)DCMI_CROPInitStruct->DCMI_VerticalStartLine << 16)); /* Sets the CROP window size */ DCMI->CWSIZER = (uint32_t)(DCMI_CROPInitStruct->DCMI_CaptureCount | ((uint32_t)DCMI_CROPInitStruct->DCMI_VerticalLineCount << 16)); } /** * @brief Enables or disables the DCMI Crop feature. * @note This function should be called before to enable and start the DCMI interface. * @param NewState: new state of the DCMI Crop feature. * This parameter can be: ENABLE or DISABLE. * @retval None */ void DCMI_CROPCmd(FunctionalState NewState) { /* Check the parameters */ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { /* Enable the DCMI Crop feature */ DCMI->CR |= (uint32_t)DCMI_CR_CROP; } else { /* Disable the DCMI Crop feature */ DCMI->CR &= ~(uint32_t)DCMI_CR_CROP; } } /** * @brief Sets the embedded synchronization codes * @param DCMI_CodesInitTypeDef: pointer to a DCMI_CodesInitTypeDef structure that * contains the embedded synchronization codes for the DCMI peripheral. * @retval None */ void DCMI_SetEmbeddedSynchroCodes(DCMI_CodesInitTypeDef* DCMI_CodesInitStruct) { DCMI->ESCR = (uint32_t)(DCMI_CodesInitStruct->DCMI_FrameStartCode | ((uint32_t)DCMI_CodesInitStruct->DCMI_LineStartCode << 8)| ((uint32_t)DCMI_CodesInitStruct->DCMI_LineEndCode << 16)| ((uint32_t)DCMI_CodesInitStruct->DCMI_FrameEndCode << 24)); } /** * @brief Enables or disables the DCMI JPEG format. * @note The Crop and Embedded Synchronization features cannot be used in this mode. * @param NewState: new state of the DCMI JPEG format. * This parameter can be: ENABLE or DISABLE. * @retval None */ void DCMI_JPEGCmd(FunctionalState NewState) { /* Check the parameters */ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { /* Enable the DCMI JPEG format */ DCMI->CR |= (uint32_t)DCMI_CR_JPEG; } else { /* Disable the DCMI JPEG format */ DCMI->CR &= ~(uint32_t)DCMI_CR_JPEG; } } /** * @} */ /** @defgroup DCMI_Group2 Image capture functions * @brief Image capture functions * @verbatim =============================================================================== ##### Image capture functions ##### =============================================================================== @endverbatim * @{ */ /** * @brief Enables or disables the DCMI interface. * @param NewState: new state of the DCMI interface. * This parameter can be: ENABLE or DISABLE. * @retval None */ void DCMI_Cmd(FunctionalState NewState) { /* Check the parameters */ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { /* Enable the DCMI by setting ENABLE bit */ DCMI->CR |= (uint32_t)DCMI_CR_ENABLE; } else { /* Disable the DCMI by clearing ENABLE bit */ DCMI->CR &= ~(uint32_t)DCMI_CR_ENABLE; } } /** * @brief Enables or disables the DCMI Capture. * @param NewState: new state of the DCMI capture. * This parameter can be: ENABLE or DISABLE. * @retval None */ void DCMI_CaptureCmd(FunctionalState NewState) { /* Check the parameters */ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { /* Enable the DCMI Capture */ DCMI->CR |= (uint32_t)DCMI_CR_CAPTURE; } else { /* Disable the DCMI Capture */ DCMI->CR &= ~(uint32_t)DCMI_CR_CAPTURE; } } /** * @brief Reads the data stored in the DR register. * @param None * @retval Data register value */ uint32_t DCMI_ReadData(void) { return DCMI->DR; } /** * @} */ /** @defgroup DCMI_Group3 Interrupts and flags management functions * @brief Interrupts and flags management functions * @verbatim =============================================================================== ##### Interrupts and flags management functions ##### =============================================================================== @endverbatim * @{ */ /** * @brief Enables or disables the DCMI interface interrupts. * @param DCMI_IT: specifies the DCMI interrupt sources to be enabled or disabled. * This parameter can be any combination of the following values: * @arg DCMI_IT_FRAME: Frame capture complete interrupt mask * @arg DCMI_IT_OVF: Overflow interrupt mask * @arg DCMI_IT_ERR: Synchronization error interrupt mask * @arg DCMI_IT_VSYNC: VSYNC interrupt mask * @arg DCMI_IT_LINE: Line interrupt mask * @param NewState: new state of the specified DCMI interrupts. * This parameter can be: ENABLE or DISABLE. * @retval None */ void DCMI_ITConfig(uint16_t DCMI_IT, FunctionalState NewState) { /* Check the parameters */ assert_param(IS_DCMI_CONFIG_IT(DCMI_IT)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { /* Enable the Interrupt sources */ DCMI->IER |= DCMI_IT; } else { /* Disable the Interrupt sources */ DCMI->IER &= (uint16_t)(~DCMI_IT); } } /** * @brief Checks whether the DCMI interface flag is set or not. * @param DCMI_FLAG: specifies the flag to check. * This parameter can be one of the following values: * @arg DCMI_FLAG_FRAMERI: Frame capture complete Raw flag mask * @arg DCMI_FLAG_OVFRI: Overflow Raw flag mask * @arg DCMI_FLAG_ERRRI: Synchronization error Raw flag mask * @arg DCMI_FLAG_VSYNCRI: VSYNC Raw flag mask * @arg DCMI_FLAG_LINERI: Line Raw flag mask * @arg DCMI_FLAG_FRAMEMI: Frame capture complete Masked flag mask * @arg DCMI_FLAG_OVFMI: Overflow Masked flag mask * @arg DCMI_FLAG_ERRMI: Synchronization error Masked flag mask * @arg DCMI_FLAG_VSYNCMI: VSYNC Masked flag mask * @arg DCMI_FLAG_LINEMI: Line Masked flag mask * @arg DCMI_FLAG_HSYNC: HSYNC flag mask * @arg DCMI_FLAG_VSYNC: VSYNC flag mask * @arg DCMI_FLAG_FNE: Fifo not empty flag mask * @retval The new state of DCMI_FLAG (SET or RESET). */ FlagStatus DCMI_GetFlagStatus(uint16_t DCMI_FLAG) { FlagStatus bitstatus = RESET; uint32_t dcmireg, tempreg = 0; /* Check the parameters */ assert_param(IS_DCMI_GET_FLAG(DCMI_FLAG)); /* Get the DCMI register index */ dcmireg = (((uint16_t)DCMI_FLAG) >> 12); if (dcmireg == 0x00) /* The FLAG is in RISR register */ { tempreg= DCMI->RISR; } else if (dcmireg == 0x02) /* The FLAG is in SR register */ { tempreg = DCMI->SR; } else /* The FLAG is in MISR register */ { tempreg = DCMI->MISR; } if ((tempreg & DCMI_FLAG) != (uint16_t)RESET ) { bitstatus = SET; } else { bitstatus = RESET; } /* Return the DCMI_FLAG status */ return bitstatus; } /** * @brief Clears the DCMI's pending flags. * @param DCMI_FLAG: specifies the flag to clear. * This parameter can be any combination of the following values: * @arg DCMI_FLAG_FRAMERI: Frame capture complete Raw flag mask * @arg DCMI_FLAG_OVFRI: Overflow Raw flag mask * @arg DCMI_FLAG_ERRRI: Synchronization error Raw flag mask * @arg DCMI_FLAG_VSYNCRI: VSYNC Raw flag mask * @arg DCMI_FLAG_LINERI: Line Raw flag mask * @retval None */ void DCMI_ClearFlag(uint16_t DCMI_FLAG) { /* Check the parameters */ assert_param(IS_DCMI_CLEAR_FLAG(DCMI_FLAG)); /* Clear the flag by writing in the ICR register 1 in the corresponding Flag position*/ DCMI->ICR = DCMI_FLAG; } /** * @brief Checks whether the DCMI interrupt has occurred or not. * @param DCMI_IT: specifies the DCMI interrupt source to check. * This parameter can be one of the following values: * @arg DCMI_IT_FRAME: Frame capture complete interrupt mask * @arg DCMI_IT_OVF: Overflow interrupt mask * @arg DCMI_IT_ERR: Synchronization error interrupt mask * @arg DCMI_IT_VSYNC: VSYNC interrupt mask * @arg DCMI_IT_LINE: Line interrupt mask * @retval The new state of DCMI_IT (SET or RESET). */ ITStatus DCMI_GetITStatus(uint16_t DCMI_IT) { ITStatus bitstatus = RESET; uint32_t itstatus = 0; /* Check the parameters */ assert_param(IS_DCMI_GET_IT(DCMI_IT)); itstatus = DCMI->MISR & DCMI_IT; /* Only masked interrupts are checked */ if ((itstatus != (uint16_t)RESET)) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; } /** * @brief Clears the DCMI's interrupt pending bits. * @param DCMI_IT: specifies the DCMI interrupt pending bit to clear. * This parameter can be any combination of the following values: * @arg DCMI_IT_FRAME: Frame capture complete interrupt mask * @arg DCMI_IT_OVF: Overflow interrupt mask * @arg DCMI_IT_ERR: Synchronization error interrupt mask * @arg DCMI_IT_VSYNC: VSYNC interrupt mask * @arg DCMI_IT_LINE: Line interrupt mask * @retval None */ void DCMI_ClearITPendingBit(uint16_t DCMI_IT) { /* Clear the interrupt pending Bit by writing in the ICR register 1 in the corresponding pending Bit position*/ DCMI->ICR = DCMI_IT; } /** * @} */ /** * @} */ /** * @} */ /** * @} */
c877696bb4bbd7a74286c13dbcb8c2a6209a810b
fcc9b5cb92607deaac4b097776ed0490789d8c3e
/src/runtime/stringspace.c
be5c68fff127db987086fe8a01ab1e90ffbcbced
[ "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-warranty-disclaimer", "BSD-3-Clause", "LicenseRef-scancode-mit-specification-disclaimer", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "UPL-1.0" ]
permissive
sbcl/sbcl
ef248b5e8614ba7f0a1132c4f2cfcb000a074400
85003adf60ef659082c244972e816ea62240b9cb
refs/heads/master
2023-09-01T05:14:15.225083
2023-08-31T20:09:49
2023-08-31T20:09:49
1,890,957
1,737
408
NOASSERTION
2023-08-28T13:05:04
2011-06-13T20:33:25
Common Lisp
UTF-8
C
false
false
14,748
c
stringspace.c
/* * This software is part of the SBCL system. See the README file for * more information. * * This software is derived from the CMU CL system, which was * written at Carnegie Mellon University and released into the * public domain. The software is in the public domain and is * provided with absolutely no warranty. See the COPYING and CREDITS * files for more information. */ #include "code.h" #include "gc.h" #include "genesis/gc-tables.h" #include "genesis/instance.h" #include "genesis/static-symbols.h" #include "genesis/symbol.h" #include "genesis/vector.h" #include "globals.h" #include "validate.h" #include <stdio.h> #include <stdlib.h> #ifdef LISP_FEATURE_DARWIN_JIT void prepare_readonly_space(__attribute__((unused)) int purify, __attribute__((unused)) int print) {} void move_rospace_to_dynamic(__attribute__((unused)) int print) {} #else /* This visitor is mostly like all the others, but only bothers with words that * can possibly be adjusted to point to or from readonly space. * So there's no dealing with fdefns at all, or closure-fun, funcallable-instance-fun, * or a few other things. */ static void visit_pointer_words(lispobj* object, lispobj (*func)(lispobj, uword_t), uword_t arg) { #define FIX(what) { lispobj ptr = what; \ if (is_lisp_pointer(ptr) && gc_managed_heap_space_p(ptr)) { lispobj new = func(ptr, arg); if (new != ptr) what = new; } } if (is_cons_half(*object)) { FIX(object[0]); FIX(object[1]); return; } int widetag = widetag_of(object); if (leaf_obj_widetag_p(widetag)) return; if (instanceoid_widetag_p(widetag)) { lispobj layout = layout_of(object); if (layout) { struct bitmap bitmap = get_layout_bitmap(LAYOUT(layout)); int nslots = instanceoid_length(*object), i; for (i=0; i<nslots; ++i) if (bitmap_logbitp(i, bitmap)) FIX(object[i+1]); } } else if (widetag == SIMPLE_VECTOR_WIDETAG) { struct vector* v = (void*)object; sword_t len = vector_len(v), i; int rehash = 0; for (i=0; i<len; ++i) { lispobj old = v->data[i]; if (!(is_lisp_pointer(old) && gc_managed_heap_space_p(old))) continue; lispobj new = func(old, arg); if (new != old) v->data[i] = new, rehash = 1; } // The 'rehash' bit on address-sensitive hashing vectors needs to be set if // an address-sensitive key moved, because it won't move again in final GC. if (vector_flagp(*object, VectorAddrHashing) && rehash) v->data[1] = make_fixnum(1); } else if (widetag == SYMBOL_WIDETAG) { struct symbol*s = (void*)object; FIX(s->value); FIX(s->info); lispobj name = decode_symbol_name(s->name); gc_assert(is_lisp_pointer(name)); set_symbol_name(s, func(name, arg)); } else if (widetag == CODE_HEADER_WIDETAG) { int boxedlen = code_header_words((struct code*)object), i; // first 4 slots are header, boxedlen, fixups, debuginfo for (i=2; i<boxedlen; ++i) FIX(object[i]); } else { sword_t len = object_size(object), i; for (i=1; i<len; ++i) FIX(object[i]); } #undef FIX } static int readonly_unboxed_obj_p(lispobj* obj) { if (is_cons_half(*obj)) return 0; int widetag = widetag_of(obj); switch (widetag) { case BIGNUM_WIDETAG: case DOUBLE_FLOAT_WIDETAG: case COMPLEX_SINGLE_FLOAT_WIDETAG: case COMPLEX_DOUBLE_FLOAT_WIDETAG: case SAP_WIDETAG: case SIMPLE_ARRAY_NIL_WIDETAG: return 1; case RATIO_WIDETAG: case COMPLEX_WIDETAG: return fixnump(obj[1]) && fixnump(obj[2]); #ifdef LISP_FEATURE_SIMD_PACK case SIMD_PACK_WIDETAG: #endif } if ((widetag > SIMPLE_VECTOR_WIDETAG && widetag < COMPLEX_BASE_STRING_WIDETAG)) { if (!vector_len((struct vector*)obj)) return 1; // length 0 vectors can't be stored into // any vector marked shareable is a winner if (*obj & (VECTOR_SHAREABLE|VECTOR_SHAREABLE_NONSTD)<<ARRAY_FLAGS_POSITION) return 1; } if (widetag == SIMPLE_VECTOR_WIDETAG) { struct vector*v = (void*)obj; sword_t length = vector_len(v); if (!length) return 1; // length 0 vectors can't be stored into if (*obj & (VECTOR_SHAREABLE|VECTOR_SHAREABLE_NONSTD)<<ARRAY_FLAGS_POSITION) { // If every element is non-pointer, then it can go in readonly space sword_t i; for (i=0; i<length; ++i) if (v->data[i] != NIL && is_lisp_pointer(v->data[i])) return 0; return 1; } } return 0; } // CAUTION: don't think you can use this generally. It can only compute sizes // of objects that do not change when forwarded. Instances can grow when forwarded // by gencgc due to adding a stable hash slot. static sword_t careful_object_size(lispobj* obj) { return object_size(forwarding_pointer_p(obj) ? native_pointer(forwarding_pointer_value(obj)) : obj); } static void walk_range(lispobj* start, lispobj* end, void (*func)(lispobj*,uword_t), uword_t arg) { lispobj* where = next_object(start, 0, end); while (where) { func(where, arg); where = next_object(where, careful_object_size(where), end); } } static void walk_all_spaces(void (*fun)(lispobj*,uword_t), uword_t arg) { walk_range((lispobj*)NIL_SYMBOL_SLOTS_START, (lispobj*)NIL_SYMBOL_SLOTS_END, fun, arg); walk_range((lispobj*)STATIC_SPACE_OBJECTS_START, static_space_free_pointer, fun, arg); #ifdef LISP_FEATURE_IMMOBILE_SPACE walk_range((lispobj*)FIXEDOBJ_SPACE_START, fixedobj_free_pointer, fun, arg); walk_range((lispobj*)TEXT_SPACE_START, text_space_highwatermark, fun, arg); #endif page_index_t first, last; for ( first = 0 ; first < next_free_page ; first = 1+last ) { last = contiguous_block_final_page(first); walk_range((lispobj*)page_address(first), page_limit(last), fun, arg); } } static void ensure_forwarded(lispobj* obj) { if (forwarding_pointer_p(obj)) return; sword_t nwords = object_size(obj); lispobj* copy = read_only_space_free_pointer; read_only_space_free_pointer += nwords; gc_assert((uword_t)read_only_space_free_pointer <= READ_ONLY_SPACE_END); memcpy(copy, obj, nwords << WORD_SHIFT); set_forwarding_pointer(obj, make_lispobj(copy, OTHER_POINTER_LOWTAG)); } // We have to take the unused arg for function signature compatibility. // Lambdas in C are so crappy. static void ensure_symbol_name_forwarded(lispobj* obj, __attribute__((unused)) uword_t arg) { if (widetag_of(obj) == SYMBOL_WIDETAG) { struct symbol* s = (void*)obj; ensure_forwarded(native_pointer(decode_symbol_name(s->name))); } } static lispobj follow_ro_fp(lispobj ptr, __attribute__((unused)) uword_t arg) { return follow_fp(ptr); // just ignore arg } static void follow_rospace_ptrs(lispobj* obj, __attribute__((unused)) uword_t arg) { if (*obj != FORWARDING_HEADER) visit_pointer_words(obj, follow_ro_fp, 0); } static void insert_filler(lispobj* obj, __attribute__((unused)) uword_t arg) { if (*obj == FORWARDING_HEADER) { sword_t nwords = object_size(native_pointer(forwarding_pointer_value(obj))); // TODO: huge fillers aren't really used elsewhere. Can this exceed the // bits allotted for the size field? Insert more than one filler if needed. *obj = make_filler_header(nwords); } } void prepare_readonly_space(int purify, int print) { gc_assert((uword_t)read_only_space_free_pointer == READ_ONLY_SPACE_START); if (!purify) { // I guess some of the architectures need a readonly page now because reasons, // even though we're somewhat more careful in coreparse to avoid reading memory // at READ_ONLY_SPACE_START if the free_pointer isn't higher than the start. int string_space_size = BACKEND_PAGE_BYTES; READ_ONLY_SPACE_START = (uword_t)os_alloc_gc_space(READ_ONLY_CORE_SPACE_ID, MOVABLE, (char*)DYNAMIC_SPACE_START - string_space_size, string_space_size); READ_ONLY_SPACE_END = READ_ONLY_SPACE_START + string_space_size; read_only_space_free_pointer = (lispobj*)READ_ONLY_SPACE_START; return; } int sum_sizes = 2; // 1. Sum of the sizes of immutable objects, which can only be in dynamic space if (print) fprintf(stderr, "purify: calculating size ... "); page_index_t first, last; for ( first = 0; first < next_free_page; first = 1+last ) { last = contiguous_block_final_page(first); lispobj* where = (lispobj*)page_address(first); lispobj* limit = (lispobj*)page_limit(last); where = next_object(where, 0, limit); uword_t nwords; while (where) { nwords = object_size(where); if ( readonly_unboxed_obj_p(where) ) sum_sizes += nwords; where = next_object(where, nwords, limit); } } #ifdef LISP_FEATURE_IMMOBILE_SPACE extern int compute_codeblob_offsets_nwords(int*); sum_sizes += compute_codeblob_offsets_nwords(NULL); #endif sum_sizes <<= WORD_SHIFT; if (print) fprintf(stderr, "%d bytes\n", sum_sizes); int string_space_size = ALIGN_UP(sum_sizes, BACKEND_PAGE_BYTES); // Try to place readonly just below dynamic space, but it doesn't really matter where READ_ONLY_SPACE_START = (uword_t)os_alloc_gc_space(READ_ONLY_CORE_SPACE_ID, MOVABLE, (char*)DYNAMIC_SPACE_START - string_space_size, string_space_size); READ_ONLY_SPACE_END = READ_ONLY_SPACE_START + string_space_size; read_only_space_free_pointer = (lispobj*)READ_ONLY_SPACE_START; // 2. Forward all symbol names so that they're placed contiguously // Could be even more clever and sort lexicographically for determistic core if (print) fprintf(stderr, "purify: forwarding symbol names\n"); walk_all_spaces(ensure_symbol_name_forwarded, 0); // Add a random delimiter object between symbol-names and everything else. // APROPOS-LIST uses this to detect the end of the strings. *read_only_space_free_pointer = SIMPLE_VECTOR_WIDETAG; // length 0 read_only_space_free_pointer += 2; // 3. Forward everything else if (print) fprintf(stderr, "purify: forwarding other data\n"); for ( first = 0; first < next_free_page; first = 1+last ) { last = contiguous_block_final_page(first); lispobj* where = (lispobj*)page_address(first); lispobj* limit = page_limit(last); where = next_object(where, 0, limit); while (where) { if (readonly_unboxed_obj_p(where)) ensure_forwarded(where); where = next_object(where, careful_object_size(where), limit); } } // 4. Update all objects in all spaces to point to r/o copy of anything that moved if (print) fprintf(stderr, "purify: fixing all pointers\n"); walk_all_spaces(follow_rospace_ptrs, 0); walk_all_spaces(insert_filler, 0); } /* Now for the opposite of 'purify' - moving back from R/O to dynamic */ static lispobj follow_shadow_fp(lispobj ptr, uword_t arg) { if (!readonly_space_p(ptr)) return ptr; lispobj* shadow_space = (lispobj*)arg; lispobj* base = native_pointer(ptr); int displacement = base - (lispobj*)READ_ONLY_SPACE_START; return shadow_space[displacement]; } static void undo_rospace_ptrs(lispobj* obj, uword_t arg) { visit_pointer_words(obj, follow_shadow_fp, arg); } void move_rospace_to_dynamic(__attribute__((unused)) int print) { #ifdef LISP_FEATURE_IMMOBILE_SPACE extern void deport_codeblob_offsets_from_heap(); deport_codeblob_offsets_from_heap(); #endif int space_usage = (uword_t)read_only_space_free_pointer - READ_ONLY_SPACE_START; if (!space_usage) return; lispobj* shadow_base = calloc(space_usage, 1); gc_assert(shadow_base); lispobj* shadow_cursor = shadow_base; // Forward everything in R/O to dynamic space. Record FPs outside of the objects // since the space is not writable and we're about to unmap. lispobj *where = (lispobj*)READ_ONLY_SPACE_START; sword_t nwords; for ( ; where < read_only_space_free_pointer ; where += nwords, shadow_cursor += nwords ) { nwords = headerobj_size(where); lispobj *new = gc_general_alloc(unboxed_region, nwords*N_WORD_BYTES, PAGE_TYPE_BOXED); SET_ALLOCATED_BIT(new); memcpy(new, where, nwords*N_WORD_BYTES); *shadow_cursor = make_lispobj(new, OTHER_POINTER_LOWTAG); } ensure_region_closed(unboxed_region, PAGE_TYPE_BOXED); os_deallocate((void*)READ_ONLY_SPACE_START, READ_ONLY_SPACE_END - READ_ONLY_SPACE_START); walk_all_spaces(undo_rospace_ptrs, (uword_t)shadow_base); // Set it empty read_only_space_free_pointer = (lispobj*)READ_ONLY_SPACE_START; } /* This kludge is only for the hide-packages test after it invokes move_rospace_to_dynamic(). * I wish there were a better way to write that test than to hack up the GC * so badly that it can't run with its heap verifications enabled. */ void test_dirty_all_gc_cards() { #ifdef LISP_FEATURE_IMMOBILE_SPACE int n_text_pages = text_space_size / IMMOBILE_CARD_BYTES; int n_bitmap_elts = ALIGN_UP(n_text_pages, 32) / 32; memset(text_page_touched_bits, 0xFF, sizeof (int)*n_bitmap_elts); lispobj* where = (lispobj*)TEXT_SPACE_START; // OBJ_WRITTEN_FLAG is confusing. The '<<24' puts it in the generation byte. for ( ; where < text_space_highwatermark ; where += object_size(where) ) if (widetag_of(where) == CODE_HEADER_WIDETAG) *where |= (OBJ_WRITTEN_FLAG << 24); #endif #ifdef LISP_FEATURE_SOFT_CARD_MARKS // just touch all mark bits, no harm done memset(gc_card_mark, 0, 1<<gc_card_table_nbits); #endif page_index_t first = 0; while (first < next_free_page) { page_index_t last = contiguous_block_final_page(first); lispobj* where = (lispobj*)page_address(first); lispobj* limit = page_limit(last); for (where = next_object(where, 0, limit) ; where ; where = next_object(where, object_size(where), limit) ) if (widetag_of(where) == CODE_HEADER_WIDETAG) { #ifndef LISP_FEATURE_SOFT_CARD_MARKS // only touch code pages, others got WP faults gc_card_mark[addr_to_card_index(where)] = 1; #endif *where |= (OBJ_WRITTEN_FLAG << 24); } first = 1+last; } pre_verify_gen_0 = 1; } #endif
9d7338a2948564a8553e9baf38a2d9bf36a8fa72
c0bfd93cd7f26a271268e504959256f1e02c6806
/components/wpa_supplicant/src/common/ieee802_11_defs.h
32e2ca92f7bdba03d668d7104bdb540a4e5ba96b
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
espressif/ESP8266_RTOS_SDK
606f396e92d2675d9854f0fabd88587fbbbaf267
af0cdc36fa2600033d0a09301c754008cf1503c1
refs/heads/master
2023-08-24T22:40:15.373553
2023-05-06T02:04:24
2023-05-06T02:04:24
27,584,181
3,163
1,749
Apache-2.0
2023-08-09T10:48:13
2014-12-05T09:27:12
C
UTF-8
C
false
false
31,158
h
ieee802_11_defs.h
/* * IEEE 802.11 Frame type definitions * Copyright (c) 2002-2019, Jouni Malinen <j@w1.fi> * Copyright (c) 2007-2008 Intel Corporation * * This software may be distributed under the terms of the BSD license. * See README for more details. */ #ifndef IEEE802_11_DEFS_H #define IEEE802_11_DEFS_H #include <utils/common.h> /* IEEE 802.11 defines */ #define WLAN_FC_PVER 0x0003 #define WLAN_FC_TODS 0x0100 #define WLAN_FC_FROMDS 0x0200 #define WLAN_FC_MOREFRAG 0x0400 #define WLAN_FC_RETRY 0x0800 #define WLAN_FC_PWRMGT 0x1000 #define WLAN_FC_MOREDATA 0x2000 #define WLAN_FC_ISWEP 0x4000 #define WLAN_FC_ORDER 0x8000 #define WLAN_FC_GET_TYPE(fc) (((fc) & 0x000c) >> 2) #define WLAN_FC_GET_STYPE(fc) (((fc) & 0x00f0) >> 4) #define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0))) #define WLAN_GET_SEQ_SEQ(seq) \ (((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4) #define WLAN_FC_TYPE_MGMT 0 #define WLAN_FC_TYPE_CTRL 1 #define WLAN_FC_TYPE_DATA 2 /* management */ #define WLAN_FC_STYPE_ASSOC_REQ 0 #define WLAN_FC_STYPE_ASSOC_RESP 1 #define WLAN_FC_STYPE_REASSOC_REQ 2 #define WLAN_FC_STYPE_REASSOC_RESP 3 #define WLAN_FC_STYPE_PROBE_REQ 4 #define WLAN_FC_STYPE_PROBE_RESP 5 #define WLAN_FC_STYPE_BEACON 8 #define WLAN_FC_STYPE_ATIM 9 #define WLAN_FC_STYPE_DISASSOC 10 #define WLAN_FC_STYPE_AUTH 11 #define WLAN_FC_STYPE_DEAUTH 12 #define WLAN_FC_STYPE_ACTION 13 /* control */ #define WLAN_FC_STYPE_PSPOLL 10 #define WLAN_FC_STYPE_RTS 11 #define WLAN_FC_STYPE_CTS 12 #define WLAN_FC_STYPE_ACK 13 #define WLAN_FC_STYPE_CFEND 14 #define WLAN_FC_STYPE_CFENDACK 15 /* data */ #define WLAN_FC_STYPE_DATA 0 #define WLAN_FC_STYPE_DATA_CFACK 1 #define WLAN_FC_STYPE_DATA_CFPOLL 2 #define WLAN_FC_STYPE_DATA_CFACKPOLL 3 #define WLAN_FC_STYPE_NULLFUNC 4 #define WLAN_FC_STYPE_CFACK 5 #define WLAN_FC_STYPE_CFPOLL 6 #define WLAN_FC_STYPE_CFACKPOLL 7 #define WLAN_FC_STYPE_QOS_DATA 8 /* Authentication algorithms */ #define WLAN_AUTH_OPEN 0 #define WLAN_AUTH_SHARED_KEY 1 #define WLAN_AUTH_FT 2 #define WLAN_AUTH_LEAP 128 #define WLAN_AUTH_CHALLENGE_LEN 128 #define WLAN_CAPABILITY_ESS BIT(0) #define WLAN_CAPABILITY_IBSS BIT(1) #define WLAN_CAPABILITY_CF_POLLABLE BIT(2) #define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3) #define WLAN_CAPABILITY_PRIVACY BIT(4) #define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5) #define WLAN_CAPABILITY_PBCC BIT(6) #define WLAN_CAPABILITY_CHANNEL_AGILITY BIT(7) #define WLAN_CAPABILITY_SPECTRUM_MGMT BIT(8) #define WLAN_CAPABILITY_QOS BIT(9) #define WLAN_CAPABILITY_SHORT_SLOT_TIME BIT(10) #define WLAN_CAPABILITY_APSD BIT(11) #define WLAN_CAPABILITY_RADIO_MEASUREMENT BIT(12) #define WLAN_CAPABILITY_DSSS_OFDM BIT(13) #define WLAN_CAPABILITY_DELAYED_BLOCK_ACK BIT(14) #define WLAN_CAPABILITY_IMM_BLOCK_ACK BIT(15) /* Status codes (IEEE Std 802.11-2016, 9.4.1.9, Table 9-46) */ #define WLAN_STATUS_SUCCESS 0 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1 #define WLAN_STATUS_CAPS_UNSUPPORTED 10 #define WLAN_STATUS_REASSOC_NO_ASSOC 11 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 #define WLAN_STATUS_CHALLENGE_FAIL 15 #define WLAN_STATUS_AUTH_TIMEOUT 16 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 #define WLAN_STATUS_ASSOC_DENIED_RATES 18 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 #define WLAN_STATUS_SPEC_MGMT_REQUIRED 22 #define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23 #define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24 #define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25 #define WLAN_STATUS_ASSOC_DENIED_NO_HT 27 #define WLAN_STATUS_R0KH_UNREACHABLE 28 #define WLAN_STATUS_ASSOC_DENIED_NO_PCO 29 #define WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY 30 #define WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION 31 #define WLAN_STATUS_UNSPECIFIED_QOS_FAILURE 32 #define WLAN_STATUS_DENIED_INSUFFICIENT_BANDWIDTH 33 #define WLAN_STATUS_DENIED_POOR_CHANNEL_CONDITIONS 34 #define WLAN_STATUS_DENIED_QOS_NOT_SUPPORTED 35 #define WLAN_STATUS_REQUEST_DECLINED 37 #define WLAN_STATUS_INVALID_PARAMETERS 38 #define WLAN_STATUS_REJECTED_WITH_SUGGESTED_CHANGES 39 #define WLAN_STATUS_INVALID_IE 40 #define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41 #define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42 #define WLAN_STATUS_AKMP_NOT_VALID 43 #define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44 #define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45 #define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46 #define WLAN_STATUS_TS_NOT_CREATED 47 #define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48 #define WLAN_STATUS_DEST_STA_NOT_PRESENT 49 #define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50 #define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51 #define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52 #define WLAN_STATUS_INVALID_PMKID 53 #define WLAN_STATUS_INVALID_MDIE 54 #define WLAN_STATUS_INVALID_FTIE 55 #define WLAN_STATUS_GAS_ADV_PROTO_NOT_SUPPORTED 59 #define WLAN_STATUS_NO_OUTSTANDING_GAS_REQ 60 #define WLAN_STATUS_GAS_RESP_NOT_RECEIVED 61 #define WLAN_STATUS_STA_TIMED_OUT_WAITING_FOR_GAS_RESP 62 #define WLAN_STATUS_GAS_RESP_LARGER_THAN_LIMIT 63 #define WLAN_STATUS_REQ_REFUSED_HOME 64 #define WLAN_STATUS_ADV_SRV_UNREACHABLE 65 #define WLAN_STATUS_REQ_REFUSED_SSPN 67 #define WLAN_STATUS_REQ_REFUSED_UNAUTH_ACCESS 68 #define WLAN_STATUS_INVALID_RSNIE 72 #define WLAN_STATUS_ANTI_CLOGGING_TOKEN_REQ 76 #define WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED 77 #define WLAN_STATUS_TRANSMISSION_FAILURE 79 #define WLAN_STATUS_REJECTED_WITH_SUGGESTED_BSS_TRANSITION 82 #define WLAN_STATUS_PENDING_ADMITTING_FST_SESSION 86 #define WLAN_STATUS_QUERY_RESP_OUTSTANDING 95 #define WLAN_STATUS_DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL 99 #define WLAN_STATUS_ASSOC_DENIED_NO_VHT 104 #define WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER 123 /* Reason codes (IEEE Std 802.11-2016, 9.4.1.7, Table 9-45) */ #define WLAN_REASON_UNSPECIFIED 1 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2 #define WLAN_REASON_DEAUTH_LEAVING 3 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 #define WLAN_REASON_DISASSOC_AP_BUSY 5 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 #define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10 #define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11 #define WLAN_REASON_BSS_TRANSITION_DISASSOC 12 #define WLAN_REASON_INVALID_IE 13 #define WLAN_REASON_MICHAEL_MIC_FAILURE 14 #define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15 #define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16 #define WLAN_REASON_IE_IN_4WAY_DIFFERS 17 #define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18 #define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19 #define WLAN_REASON_AKMP_NOT_VALID 20 #define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21 #define WLAN_REASON_INVALID_RSN_IE_CAPAB 22 #define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23 #define WLAN_REASON_CIPHER_SUITE_REJECTED 24 /* Information Element IDs (IEEE Std 802.11-2016, 9.4.2.1, Table 9-77) */ #define WLAN_EID_SSID 0 #define WLAN_EID_SUPP_RATES 1 #define WLAN_EID_DS_PARAMS 3 #define WLAN_EID_CF_PARAMS 4 #define WLAN_EID_TIM 5 #define WLAN_EID_IBSS_PARAMS 6 #define WLAN_EID_COUNTRY 7 #define WLAN_EID_CHALLENGE 16 #define WLAN_EID_PWR_CONSTRAINT 32 #define WLAN_EID_PWR_CAPABILITY 33 #define WLAN_EID_TPC_REQUEST 34 #define WLAN_EID_TPC_REPORT 35 #define WLAN_EID_SUPPORTED_CHANNELS 36 #define WLAN_EID_CHANNEL_SWITCH 37 #define WLAN_EID_MEASURE_REQUEST 38 #define WLAN_EID_MEASURE_REPORT 39 #define WLAN_EID_QUIET 40 #define WLAN_EID_IBSS_DFS 41 #define WLAN_EID_ERP_INFO 42 #define WLAN_EID_HT_CAP 45 #define WLAN_EID_RSN 48 #define WLAN_EID_EXT_SUPP_RATES 50 #define WLAN_EID_NEIGHBOR_REPORT 52 #define WLAN_EID_MOBILITY_DOMAIN 54 #define WLAN_EID_FAST_BSS_TRANSITION 55 #define WLAN_EID_TIMEOUT_INTERVAL 56 #define WLAN_EID_RIC_DATA 57 #define WLAN_EID_HT_OPERATION 61 #define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62 #define WLAN_EID_RRM_ENABLED_CAPABILITIES 70 #define WLAN_EID_20_40_BSS_COEXISTENCE 72 #define WLAN_EID_20_40_BSS_INTOLERANT 73 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74 #define WLAN_EID_MMIE 76 #define WLAN_EID_EXT_CAPAB 127 #define WLAN_EID_VENDOR_SPECIFIC 221 #define WLAN_EID_CAG_NUMBER 237 #define WLAN_EID_AP_CSN 239 #define WLAN_EID_FILS_INDICATION 240 #define WLAN_EID_DILS 241 #define WLAN_EID_FRAGMENT 242 #define WLAN_EID_EXTENSION 255 /* Element ID Extension (EID 255) values */ #define WLAN_EID_EXT_ASSOC_DELAY_INFO 1 #define WLAN_EID_EXT_FILS_REQ_PARAMS 2 #define WLAN_EID_EXT_FILS_KEY_CONFIRM 3 #define WLAN_EID_EXT_FILS_SESSION 4 #define WLAN_EID_EXT_FILS_HLP_CONTAINER 5 #define WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN 6 #define WLAN_EID_EXT_KEY_DELIVERY 7 #define WLAN_EID_EXT_WRAPPED_DATA 8 #define WLAN_EID_EXT_FTM_SYNC_INFO 9 #define WLAN_EID_EXT_EXTENDED_REQUEST 10 #define WLAN_EID_EXT_ESTIMATED_SERVICE_PARAMS 11 #define WLAN_EID_EXT_FILS_PUBLIC_KEY 12 #define WLAN_EID_EXT_FILS_NONCE 13 #define WLAN_EID_EXT_FUTURE_CHANNEL_GUIDANCE 14 #define WLAN_EID_EXT_OWE_DH_PARAM 32 #define WLAN_EID_EXT_PASSWORD_IDENTIFIER 33 #define WLAN_EID_EXT_HE_CAPABILITIES 35 #define WLAN_EID_EXT_HE_OPERATION 36 /* Action frame categories (IEEE Std 802.11-2016, 9.4.1.11, Table 9-76) */ #define WLAN_ACTION_SPECTRUM_MGMT 0 #define WLAN_ACTION_QOS 1 #define WLAN_ACTION_DLS 2 #define WLAN_ACTION_BLOCK_ACK 3 #define WLAN_ACTION_PUBLIC 4 #define WLAN_ACTION_RADIO_MEASUREMENT 5 #define WLAN_ACTION_FT 6 #define WLAN_ACTION_HT 7 #define WLAN_ACTION_SA_QUERY 8 #define WLAN_ACTION_WNM 10 #define WLAN_ACTION_UNPROTECTED_WNM 11 #define WLAN_ACTION_WMM 17 /* WMM Specification 1.1 */ /* SA Query Action frame (IEEE 802.11w/D8.0, 7.4.9) */ #define WLAN_SA_QUERY_REQUEST 0 #define WLAN_SA_QUERY_RESPONSE 1 #define WLAN_SA_QUERY_TR_ID_LEN 2 /* Timeout Interval Type */ #define WLAN_TIMEOUT_REASSOC_DEADLINE 1 #define WLAN_TIMEOUT_KEY_LIFETIME 2 #define WLAN_TIMEOUT_ASSOC_COMEBACK 3 #ifdef _MSC_VER #pragma pack(push, 1) #endif /* _MSC_VER */ struct ieee80211_hdr { le16 frame_control; le16 duration_id; u8 addr1[6]; u8 addr2[6]; u8 addr3[6]; le16 seq_ctrl; /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame */ } STRUCT_PACKED; #define IEEE80211_DA_FROMDS addr1 #define IEEE80211_BSSID_FROMDS addr2 #define IEEE80211_SA_FROMDS addr3 #define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr)) #define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4)) /* Radio Measurement Action codes */ #define WLAN_RRM_RADIO_MEASUREMENT_REQUEST 0 #define WLAN_RRM_RADIO_MEASUREMENT_REPORT 1 #define WLAN_RRM_LINK_MEASUREMENT_REQUEST 2 #define WLAN_RRM_LINK_MEASUREMENT_REPORT 3 #define WLAN_RRM_NEIGHBOR_REPORT_REQUEST 4 #define WLAN_RRM_NEIGHBOR_REPORT_RESPONSE 5 /* Radio Measurement capabilities (from RM Enabled Capabilities element) * IEEE Std 802.11-2016, 9.4.2.45, Table 9-157 */ /* byte 1 (out of 5) */ #define WLAN_RRM_CAPS_LINK_MEASUREMENT BIT(0) #define WLAN_RRM_CAPS_NEIGHBOR_REPORT BIT(1) #define WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE BIT(4) #define WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE BIT(5) #define WLAN_RRM_CAPS_BEACON_REPORT_TABLE BIT(6) /* * IEEE P802.11-REVmc/D5.0 Table 9-81 - Measurement type definitions for * measurement requests */ enum measure_type { MEASURE_TYPE_RPI_HIST = 2, MEASURE_TYPE_BEACON = 5, MEASURE_TYPE_LCI = 8, MEASURE_TYPE_LOCATION_CIVIC = 11, MEASURE_TYPE_MEASURE_PAUSE = 255, }; /* IEEE Std 802.11-2012 Table 8-71 - Location subject definition */ enum location_subject { LOCATION_SUBJECT_LOCAL = 0, LOCATION_SUBJECT_REMOTE = 1, LOCATION_SUBJECT_3RD_PARTY = 2, }; /* * IEEE P802.11-REVmc/D5.0 Table 9-94 - Optional subelement IDs for LCI request */ enum lci_req_subelem { LCI_REQ_SUBELEM_AZIMUTH_REQ = 1, LCI_REQ_SUBELEM_ORIGINATOR_MAC_ADDR = 2, LCI_REQ_SUBELEM_TARGET_MAC_ADDR = 3, LCI_REQ_SUBELEM_MAX_AGE = 4, }; struct ieee80211_mgmt { le16 frame_control; le16 duration; u8 da[6]; u8 sa[6]; u8 bssid[6]; le16 seq_ctrl; union { struct { le16 auth_alg; le16 auth_transaction; le16 status_code; /* possibly followed by Challenge text */ u8 variable[0]; } STRUCT_PACKED auth; struct { le16 reason_code; } STRUCT_PACKED deauth; struct { le16 capab_info; le16 listen_interval; /* followed by SSID and Supported rates */ u8 variable[0]; } STRUCT_PACKED assoc_req; struct { le16 capab_info; le16 status_code; le16 aid; /* followed by Supported rates */ u8 variable[0]; } STRUCT_PACKED assoc_resp, reassoc_resp; struct { le16 capab_info; le16 listen_interval; u8 current_ap[6]; /* followed by SSID and Supported rates */ u8 variable[0]; } STRUCT_PACKED reassoc_req; struct { le16 reason_code; } STRUCT_PACKED disassoc; struct { u8 timestamp[8]; le16 beacon_int; le16 capab_info; /* followed by some of SSID, Supported rates, * FH Params, DS Params, CF Params, IBSS Params, TIM */ u8 variable[0]; } STRUCT_PACKED beacon; struct { /* only variable items: SSID, Supported rates */ u8 variable[0]; } STRUCT_PACKED probe_req; struct { u8 timestamp[8]; le16 beacon_int; le16 capab_info; /* followed by some of SSID, Supported rates, * FH Params, DS Params, CF Params, IBSS Params */ u8 variable[0]; } STRUCT_PACKED probe_resp; struct { u8 category; union { struct { u8 action_code; u8 dialog_token; u8 status_code; u8 variable[0]; } STRUCT_PACKED wmm_action; struct{ u8 action_code; u8 element_id; u8 length; u8 switch_mode; u8 new_chan; u8 switch_count; } STRUCT_PACKED chan_switch; struct { u8 action; u8 sta_addr[ETH_ALEN]; u8 target_ap_addr[ETH_ALEN]; u8 variable[0]; /* FT Request */ } STRUCT_PACKED ft_action_req; struct { u8 action; u8 sta_addr[ETH_ALEN]; u8 target_ap_addr[ETH_ALEN]; le16 status_code; u8 variable[0]; /* FT Request */ } STRUCT_PACKED ft_action_resp; struct { u8 action; u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN]; } STRUCT_PACKED sa_query_req; struct { u8 action; /* */ u8 trans_id[WLAN_SA_QUERY_TR_ID_LEN]; } STRUCT_PACKED sa_query_resp; } u; } STRUCT_PACKED action; } u; } STRUCT_PACKED; #define IEEE80211_MAX_MMPDU_SIZE 2304 struct ieee80211_ht_capabilities { le16 ht_capabilities_info; u8 a_mpdu_params; u8 supported_mcs_set[16]; le16 ht_extended_capabilities; le32 tx_bf_capability_info; u8 asel_capabilities; } STRUCT_PACKED; /* HT Operation element */ struct ieee80211_ht_operation { u8 primary_chan; /* Five octets of HT Operation Information */ u8 ht_param; /* B0..B7 */ le16 operation_mode; /* B8..B23 */ le16 param; /* B24..B39 */ u8 basic_mcs_set[16]; } STRUCT_PACKED; #ifdef _MSC_VER #pragma pack(pop) #endif /* _MSC_VER */ #define ERP_INFO_NON_ERP_PRESENT BIT(0) #define ERP_INFO_USE_PROTECTION BIT(1) #define ERP_INFO_BARKER_PREAMBLE_MODE BIT(2) #define OVERLAPPING_BSS_TRANS_DELAY_FACTOR 5 /* HT Capabilities Info field within HT Capabilities element */ #define HT_CAP_INFO_LDPC_CODING_CAP ((u16) BIT(0)) #define HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET ((u16) BIT(1)) #define HT_CAP_INFO_SMPS_MASK ((u16) (BIT(2) | BIT(3))) #define HT_CAP_INFO_SMPS_STATIC ((u16) 0) #define HT_CAP_INFO_SMPS_DYNAMIC ((u16) BIT(2)) #define HT_CAP_INFO_SMPS_DISABLED ((u16) (BIT(2) | BIT(3))) #define HT_CAP_INFO_GREEN_FIELD ((u16) BIT(4)) #define HT_CAP_INFO_SHORT_GI20MHZ ((u16) BIT(5)) #define HT_CAP_INFO_SHORT_GI40MHZ ((u16) BIT(6)) #define HT_CAP_INFO_TX_STBC ((u16) BIT(7)) #define HT_CAP_INFO_RX_STBC_MASK ((u16) (BIT(8) | BIT(9))) #define HT_CAP_INFO_RX_STBC_1 ((u16) BIT(8)) #define HT_CAP_INFO_RX_STBC_12 ((u16) BIT(9)) #define HT_CAP_INFO_RX_STBC_123 ((u16) (BIT(8) | BIT(9))) #define HT_CAP_INFO_DELAYED_BA ((u16) BIT(10)) #define HT_CAP_INFO_MAX_AMSDU_SIZE ((u16) BIT(11)) #define HT_CAP_INFO_DSSS_CCK40MHZ ((u16) BIT(12)) /* B13 - Reserved (was PSMP support during P802.11n development) */ #define HT_CAP_INFO_40MHZ_INTOLERANT ((u16) BIT(14)) #define HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT ((u16) BIT(15)) /* HT Extended Capabilities field within HT Capabilities element */ #define EXT_HT_CAP_INFO_PCO ((u16) BIT(0)) #define EXT_HT_CAP_INFO_PCO_TRANS_TIME_MASK ((u16) (BIT(1) | BIT(2))) #define EXT_HT_CAP_INFO_TRANS_TIME_OFFSET 1 /* B3..B7 - Reserved */ #define EXT_HT_CAP_INFO_MCS_FEEDBACK_MASK ((u16) (BIT(8) | BIT(9))) #define EXT_HT_CAP_INFO_MCS_FEEDBACK_OFFSET 8 #define EXT_HT_CAP_INFO_HTC_SUPPORT ((u16) BIT(10)) #define EXT_HT_CAP_INFO_RD_RESPONDER ((u16) BIT(11)) /* B12..B15 - Reserved */ /* Transmit Beanforming Capabilities within HT Capabilities element */ #define TX_BF_CAP_IMPLICIT_TXBF_RX_CAP ((u32) BIT(0)) #define TX_BF_CAP_RX_STAGGERED_SOUNDING_CAP ((u32) BIT(1)) #define TX_BF_CAP_TX_STAGGERED_SOUNDING_CAP ((u32) BIT(2)) #define TX_BF_CAP_RX_NDP_CAP ((u32) BIT(3)) #define TX_BF_CAP_TX_NDP_CAP ((u32) BIT(4)) #define TX_BF_CAP_IMPLICIT_TX_BF_CAP ((u32) BIT(5)) #define TX_BF_CAP_CALIBRATION_MASK ((u32) (BIT(6) | BIT(7)) #define TX_BF_CAP_CALIB_OFFSET 6 #define TX_BF_CAP_EXPLICIT_CSI_TXBF_CAP ((u32) BIT(8)) #define TX_BF_CAP_EXPLICIT_NONCOMPR_STEERING_CAP ((u32) BIT(9)) #define TX_BF_CAP_EXPLICIT_COMPR_STEERING_CAP ((u32) BIT(10)) #define TX_BF_CAP_EXPLICIT_TX_BF_CSI_FEEDBACK_MASK ((u32) (BIT(10) | BIT(11))) #define TX_BF_CAP_EXPLICIT_BF_CSI_FEEDBACK_OFFSET 11 #define TX_BF_CAP_EXPLICIT_UNCOMPR_STEERING_MATRIX_FEEDBACK_OFFSET 13 #define TX_BF_CAP_EXPLICIT_COMPRESSED_STEERING_MATRIX_FEEDBACK_OFFSET 15 #define TX_BF_CAP_MINIMAL_GROUPING_OFFSET 17 #define TX_BF_CAP_CSI_NUM_BEAMFORMER_ANT_OFFSET 19 #define TX_BF_CAP_UNCOMPRESSED_STEERING_MATRIX_BEAMFORMER_ANT_OFFSET 21 #define TX_BF_CAP_COMPRESSED_STEERING_MATRIX_BEAMFORMER_ANT_OFFSET 23 #define TX_BF_CAP_SCI_MAX_OF_ROWS_BEANFORMER_SUPPORTED_OFFSET 25 #define TX_BF_CAP_CHANNEL_ESTIMATION_CAP_MASK ((u32) (BIT(27) | BIT(28))) #define TX_BF_CAP_CHANNEL_ESTIMATION_CAP_OFFSET 27 /* B29..B31 - Reserved */ /* ASEL Capability field within HT Capabilities element */ #define ASEL_CAP_ASEL_CAPABLE ((u8) BIT(0)) #define ASEL_CAP_EXPLICIT_CSI_FEEDBACK_BASED_TX_AS_CAP ((u8) BIT(1)) #define ASEL_CAP_ANT_INDICES_FEEDBACK_BASED_TX_AS_CAP ((u8) BIT(2)) #define ASEL_CAP_EXPLICIT_CSI_FEEDBACK_CAP ((u8) BIT(3)) #define ASEL_CAP_ANT_INDICES_FEEDBACK_CAP ((u8) BIT(4)) #define ASEL_CAP_RX_AS_CAP ((u8) BIT(5)) #define ASEL_CAP_TX_SOUNDING_PPDUS_CAP ((u8) BIT(6)) /* B7 - Reserved */ /* First octet of HT Operation Information within HT Operation element */ #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1)) #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0)) #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1)) #define HT_INFO_HT_PARAM_STA_CHNL_WIDTH ((u8) BIT(2)) #define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3)) /* B4..B7 - Reserved */ /* HT Protection (B8..B9 of HT Operation Information) */ #define HT_PROT_NO_PROTECTION 0 #define HT_PROT_NONMEMBER_PROTECTION 1 #define HT_PROT_20MHZ_PROTECTION 2 #define HT_PROT_NON_HT_MIXED 3 /* Bits within ieee80211_ht_operation::operation_mode (BIT(0) maps to B8 in * HT Operation Information) */ #define HT_OPER_OP_MODE_HT_PROT_MASK ((u16) (BIT(0) | BIT(1))) /* B8..B9 */ #define HT_OPER_OP_MODE_NON_GF_HT_STAS_PRESENT ((u16) BIT(2)) /* B10 */ /* BIT(3), i.e., B11 in HT Operation Information field - Reserved */ #define HT_OPER_OP_MODE_OBSS_NON_HT_STAS_PRESENT ((u16) BIT(4)) /* B12 */ /* BIT(5)..BIT(15), i.e., B13..B23 - Reserved */ /* Last two octets of HT Operation Information (BIT(0) = B24) */ /* B24..B29 - Reserved */ #define HT_OPER_PARAM_DUAL_BEACON ((u16) BIT(6)) #define HT_OPER_PARAM_DUAL_CTS_PROTECTION ((u16) BIT(7)) #define HT_OPER_PARAM_STBC_BEACON ((u16) BIT(8)) #define HT_OPER_PARAM_LSIG_TXOP_PROT_FULL_SUPP ((u16) BIT(9)) #define HT_OPER_PARAM_PCO_ACTIVE ((u16) BIT(10)) #define HT_OPER_PARAM_PCO_PHASE ((u16) BIT(11)) /* B36..B39 - Reserved */ #define WMM_OUI_TYPE 2 #define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0 #define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1 #define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2 #define WMM_VERSION 1 #define WMM_ACTION_CODE_ADDTS_REQ 0 #define WMM_ACTION_CODE_ADDTS_RESP 1 #define WMM_ACTION_CODE_DELTS 2 #define WMM_ADDTS_STATUS_ADMISSION_ACCEPTED 0 #define WMM_ADDTS_STATUS_INVALID_PARAMETERS 1 /* 2 - Reserved */ #define WMM_ADDTS_STATUS_REFUSED 3 /* 4-255 - Reserved */ /* WMM TSPEC Direction Field Values */ #define WMM_TSPEC_DIRECTION_UPLINK 0 #define WMM_TSPEC_DIRECTION_DOWNLINK 1 /* 2 - Reserved */ #define WMM_TSPEC_DIRECTION_BI_DIRECTIONAL 3 /* * WMM Information Element (used in (Re)Association Request frames; may also be * used in Beacon frames) */ struct wmm_information_element { /* Element ID: 221 (0xdd); Length: 7 */ /* required fields for WMM version 1 */ u8 oui[3]; /* 00:50:f2 */ u8 oui_type; /* 2 */ u8 oui_subtype; /* 0 */ u8 version; /* 1 for WMM version 1.0 */ u8 qos_info; /* AP/STA specific QoS info */ } STRUCT_PACKED; #define WMM_AC_AIFSN_MASK 0x0f #define WMM_AC_AIFNS_SHIFT 0 #define WMM_AC_ACM 0x10 #define WMM_AC_ACI_MASK 0x60 #define WMM_AC_ACI_SHIFT 5 #define WMM_AC_ECWMIN_MASK 0x0f #define WMM_AC_ECWMIN_SHIFT 0 #define WMM_AC_ECWMAX_MASK 0xf0 #define WMM_AC_ECWMAX_SHIFT 4 struct wmm_ac_parameter { u8 aci_aifsn; /* AIFSN, ACM, ACI */ u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */ le16 txop_limit; } STRUCT_PACKED; /* * WMM Parameter Element (used in Beacon, Probe Response, and (Re)Association * Response frmaes) */ struct wmm_parameter_element { /* Element ID: 221 (0xdd); Length: 24 */ /* required fields for WMM version 1 */ u8 oui[3]; /* 00:50:f2 */ u8 oui_type; /* 2 */ u8 oui_subtype; /* 1 */ u8 version; /* 1 for WMM version 1.0 */ u8 qos_info; /* AP/STA specific QoS info */ u8 reserved; /* 0 */ struct wmm_ac_parameter ac[4]; /* AC_BE, AC_BK, AC_VI, AC_VO */ } STRUCT_PACKED; /* WMM TSPEC Element */ struct wmm_tspec_element { u8 eid; /* 221 = 0xdd */ u8 length; /* 6 + 55 = 61 */ u8 oui[3]; /* 00:50:f2 */ u8 oui_type; /* 2 */ u8 oui_subtype; /* 2 */ u8 version; /* 1 */ /* WMM TSPEC body (55 octets): */ u8 ts_info[3]; le16 nominal_msdu_size; le16 maximum_msdu_size; le32 minimum_service_interval; le32 maximum_service_interval; le32 inactivity_interval; le32 suspension_interval; le32 service_start_time; le32 minimum_data_rate; le32 mean_data_rate; le32 peak_data_rate; le32 maximum_burst_size; le32 delay_bound; le32 minimum_phy_rate; le16 surplus_bandwidth_allowance; le16 medium_time; } STRUCT_PACKED; /* Access Categories / ACI to AC coding */ enum wmm_ac { WMM_AC_BE = 0 /* Best Effort */, WMM_AC_BK = 1 /* Background */, WMM_AC_VI = 2 /* Video */, WMM_AC_VO = 3 /* Voice */, WMM_AC_NUM = 4 }; /* MBO v0.0_r19, 4.2.7: Transition Rejection Reason Code Attribute */ /* Table 4-21: Transition Rejection Reason Code Field Values */ enum mbo_transition_reject_reason { MBO_TRANSITION_REJECT_REASON_UNSPECIFIED = 0, MBO_TRANSITION_REJECT_REASON_FRAME_LOSS = 1, MBO_TRANSITION_REJECT_REASON_DELAY = 2, MBO_TRANSITION_REJECT_REASON_QOS_CAPACITY = 3, MBO_TRANSITION_REJECT_REASON_RSSI = 4, MBO_TRANSITION_REJECT_REASON_INTERFERENCE = 5, MBO_TRANSITION_REJECT_REASON_SERVICES = 6, }; /* IEEE 802.11v - WNM Action field values */ enum wnm_action { WNM_EVENT_REQ = 0, WNM_EVENT_REPORT = 1, WNM_DIAGNOSTIC_REQ = 2, WNM_DIAGNOSTIC_REPORT = 3, WNM_LOCATION_CFG_REQ = 4, WNM_LOCATION_CFG_RESP = 5, WNM_BSS_TRANS_MGMT_QUERY = 6, WNM_BSS_TRANS_MGMT_REQ = 7, WNM_BSS_TRANS_MGMT_RESP = 8, WNM_FMS_REQ = 9, WNM_FMS_RESP = 10, WNM_COLLOCATED_INTERFERENCE_REQ = 11, WNM_COLLOCATED_INTERFERENCE_REPORT = 12, WNM_TFS_REQ = 13, WNM_TFS_RESP = 14, WNM_TFS_NOTIFY = 15, WNM_SLEEP_MODE_REQ = 16, WNM_SLEEP_MODE_RESP = 17, WNM_TIM_BROADCAST_REQ = 18, WNM_TIM_BROADCAST_RESP = 19, WNM_QOS_TRAFFIC_CAPAB_UPDATE = 20, WNM_CHANNEL_USAGE_REQ = 21, WNM_CHANNEL_USAGE_RESP = 22, WNM_DMS_REQ = 23, WNM_DMS_RESP = 24, WNM_TIMING_MEASUREMENT_REQ = 25, WNM_NOTIFICATION_REQ = 26, WNM_NOTIFICATION_RESP = 27 }; /* IEEE 802.11v - BSS Transition Management Request - Request Mode */ #define WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED BIT(0) #define WNM_BSS_TM_REQ_ABRIDGED BIT(1) #define WNM_BSS_TM_REQ_DISASSOC_IMMINENT BIT(2) #define WNM_BSS_TM_REQ_BSS_TERMINATION_INCLUDED BIT(3) #define WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT BIT(4) /* IEEE Std 802.11-2012 - Table 8-253 */ enum bss_trans_mgmt_status_code { WNM_BSS_TM_ACCEPT = 0, WNM_BSS_TM_REJECT_UNSPECIFIED = 1, WNM_BSS_TM_REJECT_INSUFFICIENT_BEACON = 2, WNM_BSS_TM_REJECT_INSUFFICIENT_CAPABITY = 3, WNM_BSS_TM_REJECT_UNDESIRED = 4, WNM_BSS_TM_REJECT_DELAY_REQUEST = 5, WNM_BSS_TM_REJECT_STA_CANDIDATE_LIST_PROVIDED = 6, WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES = 7, WNM_BSS_TM_REJECT_LEAVING_ESS = 8 }; /* * IEEE P802.11-REVmc/D5.0 Table 9-150 - Optional subelement IDs for * neighbor report */ #define WNM_NEIGHBOR_TSF 1 #define WNM_NEIGHBOR_CONDENSED_COUNTRY_STRING 2 #define WNM_NEIGHBOR_BSS_TRANSITION_CANDIDATE 3 #define WNM_NEIGHBOR_BSS_TERMINATION_DURATION 4 #define WNM_NEIGHBOR_BEARING 5 #define WNM_NEIGHBOR_MEASUREMENT_REPORT 39 #define WNM_NEIGHBOR_MEASUREMENT_PILOT 66 #define WNM_NEIGHBOR_RRM_ENABLED_CAPABILITIES 70 #define WNM_NEIGHBOR_MULTIPLE_BSSID 71 struct tpc_report { u8 eid; u8 len; u8 tx_power; u8 link_margin; } STRUCT_PACKED; #define RRM_CAPABILITIES_IE_LEN 5 /* IEEE Std 802.11-2012, 8.5.7.4 - Link Measurement Request frame format */ struct rrm_link_measurement_request { u8 dialog_token; s8 tx_power; s8 max_tp; u8 variable[0]; } STRUCT_PACKED; /* IEEE Std 802.11-2012, 8.5.7.5 - Link Measurement Report frame format */ struct rrm_link_measurement_report { u8 dialog_token; struct tpc_report tpc; u8 rx_ant_id; u8 tx_ant_id; u8 rcpi; u8 rsni; u8 variable[0]; } STRUCT_PACKED; /* IEEE Std 802.11-2016, 9.4.2.21 - Measurement Request element */ struct rrm_measurement_request_element { u8 eid; /* Element ID */ u8 len; /* Length */ u8 token; /* Measurement Token */ u8 mode; /* Measurement Request Mode */ u8 type; /* Measurement Type */ u8 variable[0]; /* Measurement Request */ } STRUCT_PACKED; /* IEEE Std 802.11-2016, Figure 9-148 - Measurement Request Mode field */ #define MEASUREMENT_REQUEST_MODE_PARALLEL BIT(0) #define MEASUREMENT_REQUEST_MODE_ENABLE BIT(1) #define MEASUREMENT_REQUEST_MODE_REQUEST BIT(2) #define MEASUREMENT_REQUEST_MODE_REPORT BIT(3) #define MEASUREMENT_REQUEST_MODE_DURATION_MANDATORY BIT(4) /* IEEE Std 802.11-2016, 9.4.2.21.7 - Beacon request */ struct rrm_measurement_beacon_request { u8 oper_class; /* Operating Class */ u8 channel; /* Channel Number */ le16 rand_interval; /* Randomization Interval (in TUs) */ le16 duration; /* Measurement Duration (in TUs) */ u8 mode; /* Measurement Mode */ u8 bssid[ETH_ALEN]; /* BSSID */ u8 variable[0]; /* Optional Subelements */ } STRUCT_PACKED; /* * IEEE Std 802.11-2016, Table 9-87 - Measurement Mode definitions for Beacon * request */ enum beacon_report_mode { BEACON_REPORT_MODE_PASSIVE = 0, BEACON_REPORT_MODE_ACTIVE = 1, BEACON_REPORT_MODE_TABLE = 2, }; /* IEEE Std 802.11-2016, Table 9-88 - Beacon Request subelement IDs */ /* IEEE P802.11-REVmd/D2.0, Table 9-106 - Optional subelement IDs for * Beacon request */ #define WLAN_BEACON_REQUEST_SUBELEM_SSID 0 #define WLAN_BEACON_REQUEST_SUBELEM_INFO 1 /* Beacon Reporting */ #define WLAN_BEACON_REQUEST_SUBELEM_DETAIL 2 /* Reporting Detail */ #define WLAN_BEACON_REQUEST_SUBELEM_REQUEST 10 #define WLAN_BEACON_REQUEST_SUBELEM_AP_CHANNEL 51 /* AP Channel Report */ #define WLAN_BEACON_REQUEST_SUBELEM_LAST_INDICATION 164 #define WLAN_BEACON_REQUEST_SUBELEM_VENDOR 221 /* * IEEE Std 802.11-2016, Table 9-90 - Reporting Detail values */ enum beacon_report_detail { /* No fixed-length fields or elements */ BEACON_REPORT_DETAIL_NONE = 0, /* All fixed-length fields and any requested elements in the Request * element if present */ BEACON_REPORT_DETAIL_REQUESTED_ONLY = 1, /* All fixed-length fields and elements (default, used when Reporting * Detail subelement is not included in a Beacon request) */ BEACON_REPORT_DETAIL_ALL_FIELDS_AND_ELEMENTS = 2, }; /* IEEE Std 802.11-2016, 9.4.2.22 - Measurement Report element */ struct rrm_measurement_report_element { u8 eid; /* Element ID */ u8 len; /* Length */ u8 token; /* Measurement Token */ u8 mode; /* Measurement Report Mode */ u8 type; /* Measurement Type */ u8 variable[0]; /* Measurement Report */ } STRUCT_PACKED; /* IEEE Std 802.11-2016, Figure 9-192 - Measurement Report Mode field */ #define MEASUREMENT_REPORT_MODE_ACCEPT 0 #define MEASUREMENT_REPORT_MODE_REJECT_LATE BIT(0) #define MEASUREMENT_REPORT_MODE_REJECT_INCAPABLE BIT(1) #define MEASUREMENT_REPORT_MODE_REJECT_REFUSED BIT(2) /* IEEE Std 802.11-2016, 9.4.2.22.7 - Beacon report */ struct rrm_measurement_beacon_report { u8 op_class; /* Operating Class */ u8 channel; /* Channel Number */ le64 start_time; /* Actual Measurement Start Time * (in TSF of the BSS requesting the measurement) */ le16 duration; /* in TUs */ u8 report_info; /* Reported Frame Information */ u8 rcpi; /* RCPI */ u8 rsni; /* RSNI */ u8 bssid[ETH_ALEN]; /* BSSID */ u8 antenna_id; /* Antenna ID */ le32 parent_tsf; /* Parent TSF */ u8 variable[0]; /* Optional Subelements */ } STRUCT_PACKED; /* IEEE Std 802.11-2016, Table 9-112 - Beacon report Subelement IDs */ /* IEEE P802.11-REVmd/D2.0, Table 9-130 - Optional subelement IDs for * Beacon report */ #define WLAN_BEACON_REPORT_SUBELEM_FRAME_BODY 1 #define WLAN_BEACON_REPORT_SUBELEM_FRAME_BODY_FRAGMENT_ID 2 #define WLAN_BEACON_REPORT_SUBELEM_LAST_INDICATION 164 /* IEEE P802.11-REVmd/D2.0, Table 9-232 - Data field format of the * Reported Frame Body Fragment ID subelement */ #define REPORTED_FRAME_BODY_SUBELEM_LEN 4 #define REPORTED_FRAME_BODY_MORE_FRAGMENTS BIT(7) /* IEEE P802.11-REVmd/D2.0, 9.4.2.21.7 - Beacon report */ #define BEACON_REPORT_LAST_INDICATION_SUBELEM_LEN 3 /* IEEE Std 802.11ac-2013, Annex C - dot11PHYType */ enum phy_type { PHY_TYPE_UNSPECIFIED = 0, PHY_TYPE_FHSS = 1, PHY_TYPE_DSSS = 2, PHY_TYPE_IRBASEBAND = 3, PHY_TYPE_OFDM = 4, PHY_TYPE_HRDSSS = 5, PHY_TYPE_ERP = 6, PHY_TYPE_HT = 7, PHY_TYPE_DMG = 8, PHY_TYPE_VHT = 9, }; /* IEEE P802.11-REVmc/D5.0, 9.4.2.37 - Neighbor Report element */ /* BSSID Information Field */ #define NEI_REP_BSSID_INFO_AP_NOT_REACH BIT(0) #define NEI_REP_BSSID_INFO_AP_UNKNOWN_REACH BIT(1) #define NEI_REP_BSSID_INFO_AP_REACHABLE (BIT(0) | BIT(1)) #define NEI_REP_BSSID_INFO_SECURITY BIT(2) #define NEI_REP_BSSID_INFO_KEY_SCOPE BIT(3) #define NEI_REP_BSSID_INFO_SPECTRUM_MGMT BIT(4) #define NEI_REP_BSSID_INFO_QOS BIT(5) #define NEI_REP_BSSID_INFO_APSD BIT(6) #define NEI_REP_BSSID_INFO_RM BIT(7) #define NEI_REP_BSSID_INFO_DELAYED_BA BIT(8) #define NEI_REP_BSSID_INFO_IMM_BA BIT(9) #define NEI_REP_BSSID_INFO_MOBILITY_DOMAIN BIT(10) #define NEI_REP_BSSID_INFO_HT BIT(11) #define NEI_REP_BSSID_INFO_VHT BIT(12) #define NEI_REP_BSSID_INFO_FTM BIT(13) #endif /* IEEE802_11_DEFS_H */
6eb6e6565f72adf4af7b78caf28babf7c8b5f50e
cf56b5fcf51fddb219c47f5f006d8595a4483c57
/src/utils/ucc_sys.h
7ee1ecc2c4af83c1b52c06a704e0e03b34034d33
[ "BSD-3-Clause" ]
permissive
openucx/ucc
3b39fbd849a7850c559b60eaec7882292f8a5eca
f89cd7557e6ebb19b4c6ebd529647d8b42c30657
refs/heads/master
2023-08-18T03:18:54.072899
2023-08-17T18:05:44
2023-08-17T18:05:44
282,490,868
150
57
BSD-3-Clause
2023-09-12T09:49:18
2020-07-25T17:18:51
C
UTF-8
C
false
false
671
h
ucc_sys.h
/** * Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * See file LICENSE for terms. */ #ifndef UCC_SYS_H_ #define UCC_SYS_H_ #include "ucc/api/ucc_status.h" #include "utils/ucc_compiler_def.h" #include "utils/ucc_log.h" #include <stddef.h> #include <unistd.h> #include <assert.h> ucc_status_t ucc_sysv_alloc(size_t *size, void **addr, int *shm_id); ucc_status_t ucc_sysv_free(void *addr); const char* ucc_sys_get_lib_path(); ucc_status_t ucc_sys_dirname(const char *path, char **out); ucc_status_t ucc_sys_path_join(const char *path1, const char *path2, char **out); size_t ucc_get_page_size(); #endif
86da2fc86992fd1b0312d576b07940e1b6358be5
d2e0fb3fdad7fc2cb70894591d358f40d8db13d2
/libc/include/tar.h
8cb994dc1d9afc7fbb4b4a96d8ad54c08b22a506
[ "ISC", "MIT" ]
permissive
dennis95/dennix
54c568485862a0799664033eb0717abb028d3924
f898bb2d27346f6257df1650a002ee929e66e7fa
refs/heads/master
2023-08-17T06:54:17.274650
2023-07-10T16:06:35
2023-07-10T16:06:35
55,073,371
168
15
null
null
null
null
UTF-8
C
false
false
1,393
h
tar.h
/* Copyright (c) 2016, 2020 Dennis Wölfing * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* libc/include/tar.h * Unix tar format. */ #ifndef _TAR_H #define _TAR_H #include <sys/cdefs.h> #define TMAGIC "ustar" #define TMAGLEN 6 #define TVERSION "00" #define TVERSLEN 2 #define REGTYPE '0' #define AREGTYPE '\0' #define LNKTYPE '1' #define SYMTYPE '2' #define CHRTYPE '3' #define BLKTYPE '4' #define DIRTYPE '5' #define FIFOTYPE '6' #define CONTTYPE '7' #define TSUID 04000 #define TSGID 02000 #define TSVTX 01000 #define TUREAD 0400 #define TUWRITE 0200 #define TUEXEC 0100 #define TGREAD 040 #define TGWRITE 020 #define TGEXEC 010 #define TOREAD 04 #define TOWRITE 02 #define TOEXEC 01 #endif
ac2e2ad9860152a4b83f1d586cd70a2394e81963
d9e96244515264268d6078650fa707f34d94ee7a
/Working/Game/xleres/Lighting/ImageBased.h
cdb7f631ebcbb0d914c1479d351e62f1430b9ba4
[ "MIT" ]
permissive
xlgames-inc/XLE
45c89537c10561e216367a2e3bcd7d1c92b1b039
69cc4f2aa4faf12ed15bb4291c6992c83597899c
refs/heads/master
2022-06-29T17:16:11.491925
2022-05-04T00:29:28
2022-05-04T00:29:28
29,281,799
396
102
null
2016-01-04T13:35:59
2015-01-15T05:07:55
C++
UTF-8
C
false
false
12,753
h
ImageBased.h
// Copyright 2015 XLGAMES Inc. // // Distributed under the MIT License (See // accompanying file "LICENSE" or the website // http://www.opensource.org/licenses/mit-license.php) #if !defined(IMAGE_BASED_H) #define IMAGE_BASED_H #if !defined(SPECULAR_METHOD) #define SPECULAR_METHOD 1 #endif #include "SpecularMethods.h" #include "../CommonResources.h" #include "IBL/IBLAlgorithm.h" #include "IBL/IBLRef.h" #include "../Utility/Misc.h" // for DitherPatternInt #include "../Transform.h" // for GlobalSamplingPassCount, GlobalSamplingPassIndex TextureCube DiffuseIBL : register(t19); TextureCube SpecularIBL : register(t20); Texture2D<float2> GlossLUT : register(t21); // this is the look up table used in the split-sum IBL glossy reflections Texture2DArray<float> GlossTransLUT : register(t22); #if MAT_SEPARATE_REFRACTION_MAP TextureCube SpecularTransIBL : register(t30); #endif // #define RECALC_SPLIT_TERM // #define RECALC_FILTERED_TEXTURE // #define REF_IBL float3 IBLPrecalc_SampleInputTexture(float3 direction) { return ReadSkyReflectionTexture(InvAdjSkyCubeMapCoords(direction), 0.f); } #include "IBL/IBLPrecalc.h" float3 SampleDiffuseIBL(float3 worldSpaceNormal, LightScreenDest lsd) { // note -- in the same way that we apply the specular BRDF when for // the gloss reflections, we could also apply the diffuse BRDF // to the diffuse reflections (including the view dependent part) // Currently we'll just get lambert response... #if defined(REF_IBL) uint dither = DitherPatternInt(lsd.pixelCoords)&0xf; dither = dither*GlobalSamplingPassCount+GlobalSamplingPassIndex; const uint sampleCount = 64; return SampleDiffuseIBL_Ref(worldSpaceNormal, SkyReflectionTexture, sampleCount, dither, 16*GlobalSamplingPassCount); #elif HAS_DIFFUSE_IBL==1 float3 result = DiffuseIBL.SampleLevel(DefaultSampler, AdjSkyCubeMapCoords(worldSpaceNormal), 0).rgb; // note -- our pipeline doesn't currently factor the 1.0f / pi normalization factor into // the texture. We could burn this, rather than having to multiply here const float normalizationFactor = 1.0f / pi; result *= normalizationFactor; return result; #else return 0.0.xxx; #endif } float3 SplitSumIBL_PrefilterEnvMap(float roughness, float3 reflection, uint dither) { // Roughness is mapped on to a linear progression through // the mipmaps. Because of the way SampleLevel works, we // need to know how many mipmaps there are in the texture! // For a cubemap with 512x512 faces, there should be 9 mipmaps. // Ideally this value would not be hard-coded...! // We should also use a trilinear sampler, so that we get // interpolation through the mipmap levels. // Also note that the tool that filters the texture must // use the same mapping for roughness that we do -- otherwise // we need to apply the mapping there. #if !defined(RECALC_FILTERED_TEXTURE) return SpecularIBL.SampleLevel( DefaultSampler, AdjSkyCubeMapCoords(reflection), RoughnessToMipmap(roughness)).rgb; #else const uint sampleCount = 64; return GenerateFilteredSpecular( AdjSkyCubeMapCoords(reflection), roughness, sampleCount, dither&0xf, 16); #endif } float2 SplitSumIBL_IntegrateBRDF(float roughness, float NdotV, uint dither) { // Note that we can also use an analytical approximation for // this term. See: // https://knarkowicz.wordpress.com/2014/12/27/analytical-dfg-term-for-ibl/ // That would avoid using a lookup table, and replace it with // just a few shader instructions. // This lookup table should have at least 16 bit of precision, and // the values are all in the range [0, 1] (so we can use UNORM format) // note -- it may be ok to use PointClampSampler here...? is it better to // use a small texture and bilinear filtering, or a large texture // and no filtering? #if !defined(RECALC_SPLIT_TERM) return GlossLUT.SampleLevel(ClampingSampler, float2(NdotV, 1.f - roughness), 0).xy; #else const uint sampleCount = 64; return GenerateSplitTerm(saturate(NdotV), saturate(roughness), sampleCount, dither&0xf, 16); #endif } float3 SampleSpecularIBL_SplitSum(float3 normal, float3 viewDirection, SpecularParameters specParam, uint dither) { // This is the split-sum approximation for glossy specular reflections from // Brian Karis for Unreal. // // This is a useful method for us, because we can use some existing tools for // generating the input textures for this. // For example, see IBL Baker: // https://github.com/derkreature/IBLBaker // // See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf // for more details. // // Note that when we prefilter the environment map, we assume that N = V = R. // This removes the distortion to the GGX specular shape that should occur at grazing // angles. But Karis suggests that the error is minor. The advantage is the blurring // we apply to the reflection cubemap now only depends on roughness. float NdotV = saturate(dot(normal, viewDirection)); float3 R = 2.f * dot(viewDirection, normal) * normal - viewDirection; // reflection vector float3 prefilteredColor = SplitSumIBL_PrefilterEnvMap(specParam.roughness, R, dither); float2 envBRDF = SplitSumIBL_IntegrateBRDF(specParam.roughness, NdotV, dither); return prefilteredColor * (specParam.F0 * envBRDF.x + envBRDF.y); } float3 SampleSpecularIBL(float3 normal, float3 viewDirection, SpecularParameters specParam, LightScreenDest lsd) { uint dither = DitherPatternInt(lsd.pixelCoords); #if defined(REF_IBL) const uint sampleCount = 64; return SampleSpecularIBL_Ref(normal, viewDirection, specParam, SkyReflectionTexture, sampleCount, dither&0xf, 16); #else return SampleSpecularIBL_SplitSum(normal, viewDirection, specParam, dither); #endif } /////////////////// T R A N S M I T T E D S P E C U L A R /////////////////// float SplitSumIBLTrans_IntegrateBTDF(float roughness, float NdotV, float F0, float iorIncident, float iorOutgoing, uint dither) { #if !defined(RECALC_SPLIT_TERM) // Currently our split term solution for specular transmission uses a 3D texture. It's seems // reasonably ok, but there is an easy way to switch it to 2D -- by just fixing the IOR to a single // value for all objects. // We could also try to find a parametric simplification... But the surface in 3D space is fairly complex. // I think we can afford to be much less accuracy for refraction (when compared to reflections) because it's // a somewhat less important effect. const float minF0 = RefractiveIndexToF0(RefractiveIndexMin); const float maxF0 = RefractiveIndexToF0(RefractiveIndexMax); float specular = (F0 - minF0) / (maxF0 - minF0); // Note -- // Fixed array count for GlossTransLUT here // Also, we're not doing any linear interpolation on "arrayIndex" -- that's probably // ok, but it may cause banding if "specular" varies greatly across an object (though that // would probably also cause some very wierd refractions) float arrayIndex = 32.f * specular; return GlossTransLUT.SampleLevel(ClampingSampler, float3(NdotV, 1.f - roughness, arrayIndex), 0); #else const uint sampleCount = 64; return GenerateSplitTermTrans(NdotV, roughness, iorIncident, iorOutgoing, sampleCount, dither&0xf, 16); #endif } float3 SplitSumIBLTrans_PrefilterEnvMap2( float roughness, float3 dir, float3 viewDirection, float3 normal, float iorIncident, float iorOutgoing, uint dither) { // This is an approximation that attempts to calculate the correct blurriness for // the refracted image. The blurriness is based on the roughness and the derivative // of the incident ray (with respect to the microfacet normal). This has the effect of // making the image more blurry in areas where the image is shrunk, and more sharp in // areas where the image is expanded. // The calculations below aren't based on any physical theory; but they are just balanced // by eye. // This causes the refracted image on the edges of a sphere to appear more blurry; which // helps it blend more nicely into the reflection (because the impression of the refraction // is lessened in those areas). It's a subtle effect, but the end result is a big improvement // over having just a constant blurriness over the whole sphere. float angularBlurriness = RefractionIncidentAngleDerivative2( dot(viewDirection, normal), iorIncident, iorOutgoing); float A = 2.f * roughness * pow(angularBlurriness, 1.5f); return SpecularIBL.SampleLevel( DefaultSampler, AdjSkyCubeMapCoords(dir), RoughnessToMipmap(saturate(A))).rgb; } float3 SplitSumIBLTrans_PrefilterEnvMap( float roughness, float3 dir, float3 viewDirection, float3 normal, float iorIncident, float iorOutgoing, uint dither) { #if !defined(RECALC_FILTERED_TEXTURE) #if MAT_SEPARATE_REFRACTION_MAP return SpecularTransIBL.SampleLevel( DefaultSampler, AdjSkyCubeMapCoords(dir), RoughnessToMipmap(roughness)).rgb; #else return SplitSumIBLTrans_PrefilterEnvMap2( roughness, dir, viewDirection, normal, iorIncident, iorOutgoing, dither); #endif #else const uint sampleCount = 64; return CalculateFilteredTextureTrans( AdjSkyCubeMapCoords(dir), roughness, iorIncident, iorOutgoing, sampleCount, dither&0xf, 16); #endif } float3 SampleSpecularIBLTrans_SplitSum( float3 normal, float3 viewDirection, SpecularParameters specParam, float iorIncident, float iorOutgoing, uint dither) { float NdotV = saturate(dot(normal, viewDirection)); // This is a little tricky because we are performing refraction based on // the surface normal here, and we will consider refraction based on microfacet // detail later. // Our microfacet simulation will take into account focusing of light and // brighten the refraction appropriately. But we're not simulating that same // focusing when it comes to the surface normal refraction. // It's a little strange because we're doing 2 separate refraction simulations. // Also, the index of refraction we use here will vary depending on the material, // while the refraction we do on the microfacet level uses a fixed ior. float3 i; if (!CalculateTransmissionIncident(i, viewDirection, normal, iorIncident, iorOutgoing)) return 0.0.xxx; float3 prefilteredColor = SplitSumIBLTrans_PrefilterEnvMap( specParam.roughness, i, viewDirection, normal, iorIncident, iorOutgoing, dither); float envBTDF = SplitSumIBLTrans_IntegrateBTDF(specParam.roughness, NdotV, specParam.F0.g, iorIncident, iorOutgoing, dither); return prefilteredColor * ((1.f - specParam.F0.g) * envBTDF); } float3 SampleSpecularIBLTrans( float3 normal, float3 viewDirection, SpecularParameters specParam, LightScreenDest lsd) { // In our scheme, the camera is always within the substance with ior=iorOutgoing // Also, the normal should point towards the substance with the lower ior (usually air) // So, depending on the type of refraction we want to achieve, we must sometimes // flip the normal. float surfaceIOR = F0ToRefractiveIndex(specParam.F0.g); float iorIncident, iorOutgoing; if (dot(normal, viewDirection) > 0) { // viewer is outside of the object, incident light is coming from behind the interface iorIncident = surfaceIOR; iorOutgoing = 1.f; } else { // viewer is inside the object iorIncident = 1.f; iorOutgoing = surfaceIOR; } uint dither = DitherPatternInt(lsd.pixelCoords); #if defined(REF_IBL) const uint sampleCount = 64; return specParam.transmission * SampleTransmittedSpecularIBL_Ref( normal, viewDirection, specParam, iorIncident, iorOutgoing, SkyReflectionTexture, sampleCount, dither&0xf, 16); #else return specParam.transmission * SampleSpecularIBLTrans_SplitSum( normal, viewDirection, specParam, iorIncident, iorOutgoing, dither); #endif } #endif
3bd63ada5fe7daa77bfd9dcb5ddc72074b2233bf
7d2667eb56489d7d36ae377b00ef2cf1569aa3b6
/external/libcrt/src/ctype/toupper.c
aa55481963bf79017a6e21515d03783f0b0a45a8
[ "MIT" ]
permissive
AMDESE/linux-svsm
e0eef44ef407b47a1d029e4cb0e25a4a53522bff
7f286b506bb969a919c01a9d852177493397da27
refs/heads/main
2023-07-06T14:41:42.392149
2023-04-28T16:30:15
2023-04-28T16:30:15
515,643,561
102
36
MIT
2023-06-22T16:03:54
2022-07-19T15:34:24
Rust
UTF-8
C
false
false
124
c
toupper.c
/* SPDX-License-Identifier: MIT */ #include <ctype.h> int toupper(int c) { if (islower(c)) return c & 0x5f; return c; }
314bcd851ec8d27f2cea37147a77b553422a9b07
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/arch/powerpc/cpu/mpc85xx/t4240_ids.c
1a3cb33987426878d718b24cd1f15bf9fd499dc9
[ "GPL-2.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
5,211
c
t4240_ids.c
/* * Copyright 2012 Freescale Semiconductor, Inc. * * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> #include <asm/fsl_portals.h> #include <asm/fsl_liodn.h> #ifdef CONFIG_SYS_DPAA_QBMAN struct qportal_info qp_info[CONFIG_SYS_QMAN_NUM_PORTALS] = { /* dqrr liodn, frame data liodn, liodn off, sdest */ SET_QP_INFO(1, 27, 1, 0), SET_QP_INFO(2, 28, 1, 0), SET_QP_INFO(3, 29, 1, 1), SET_QP_INFO(4, 30, 1, 1), SET_QP_INFO(5, 31, 1, 2), SET_QP_INFO(6, 32, 1, 2), SET_QP_INFO(7, 33, 1, 3), SET_QP_INFO(8, 34, 1, 3), SET_QP_INFO(9, 35, 1, 4), SET_QP_INFO(10, 36, 1, 4), SET_QP_INFO(11, 37, 1, 5), SET_QP_INFO(12, 38, 1, 5), SET_QP_INFO(13, 39, 1, 6), SET_QP_INFO(14, 40, 1, 6), SET_QP_INFO(15, 41, 1, 7), SET_QP_INFO(16, 42, 1, 7), SET_QP_INFO(17, 43, 1, 8), SET_QP_INFO(18, 44, 1, 8), SET_QP_INFO(19, 45, 1, 9), SET_QP_INFO(20, 46, 1, 9), SET_QP_INFO(21, 47, 1, 10), SET_QP_INFO(22, 48, 1, 10), SET_QP_INFO(23, 49, 1, 11), SET_QP_INFO(24, 50, 1, 11), SET_QP_INFO(65, 89, 1, 0), SET_QP_INFO(66, 90, 1, 0), SET_QP_INFO(67, 91, 1, 1), SET_QP_INFO(68, 92, 1, 1), SET_QP_INFO(69, 93, 1, 2), SET_QP_INFO(70, 94, 1, 2), SET_QP_INFO(71, 95, 1, 3), SET_QP_INFO(72, 96, 1, 3), SET_QP_INFO(73, 97, 1, 4), SET_QP_INFO(74, 98, 1, 4), SET_QP_INFO(75, 99, 1, 5), SET_QP_INFO(76, 100, 1, 5), SET_QP_INFO(77, 101, 1, 6), SET_QP_INFO(78, 102, 1, 6), SET_QP_INFO(79, 103, 1, 7), SET_QP_INFO(80, 104, 1, 7), SET_QP_INFO(81, 105, 1, 8), SET_QP_INFO(82, 106, 1, 8), SET_QP_INFO(83, 107, 1, 9), SET_QP_INFO(84, 108, 1, 9), SET_QP_INFO(85, 109, 1, 10), SET_QP_INFO(86, 110, 1, 10), SET_QP_INFO(87, 111, 1, 11), SET_QP_INFO(88, 112, 1, 11), SET_QP_INFO(25, 51, 1, 0), SET_QP_INFO(26, 52, 1, 0), }; #endif #ifdef CONFIG_SYS_SRIO struct srio_liodn_id_table srio_liodn_tbl[] = { SET_SRIO_LIODN_BASE(1, 307), SET_SRIO_LIODN_BASE(2, 387), }; int srio_liodn_tbl_sz = ARRAY_SIZE(srio_liodn_tbl); #endif struct liodn_id_table liodn_tbl[] = { #ifdef CONFIG_SYS_DPAA_QBMAN SET_QMAN_LIODN(62), SET_BMAN_LIODN(63), #endif SET_SDHC_LIODN(1, 552), SET_PME_LIODN(117), SET_USB_LIODN(1, "fsl-usb2-mph", 553), SET_USB_LIODN(2, "fsl-usb2-dr", 554), SET_SATA_LIODN(1, 555), SET_SATA_LIODN(2, 556), SET_PCI_LIODN_BASE(CONFIG_SYS_FSL_PCIE_COMPAT, 1, 148), SET_PCI_LIODN_BASE(CONFIG_SYS_FSL_PCIE_COMPAT, 2, 228), SET_PCI_LIODN_BASE(CONFIG_SYS_FSL_PCIE_COMPAT, 3, 308), SET_PCI_LIODN_BASE(CONFIG_SYS_FSL_PCIE_COMPAT, 4, 388), SET_DMA_LIODN(1, 147), SET_DMA_LIODN(2, 227), SET_GUTS_LIODN("fsl,rapidio-delta", 199, rio1liodnr, 0), SET_GUTS_LIODN(NULL, 200, rio2liodnr, 0), SET_GUTS_LIODN(NULL, 201, rio1maintliodnr, 0), SET_GUTS_LIODN(NULL, 202, rio2maintliodnr, 0), #ifdef CONFIG_SYS_PMAN SET_PMAN_LIODN(1, 513), SET_PMAN_LIODN(2, 514), SET_PMAN_LIODN(3, 515), #endif /* SET_NEXUS_LIODN(557), -- not yet implemented */ }; int liodn_tbl_sz = ARRAY_SIZE(liodn_tbl); #ifdef CONFIG_SYS_DPAA_FMAN struct liodn_id_table fman1_liodn_tbl[] = { SET_FMAN_RX_1G_LIODN(1, 0, 88), SET_FMAN_RX_1G_LIODN(1, 1, 89), SET_FMAN_RX_1G_LIODN(1, 2, 90), SET_FMAN_RX_1G_LIODN(1, 3, 91), SET_FMAN_RX_1G_LIODN(1, 4, 92), SET_FMAN_RX_1G_LIODN(1, 5, 93), SET_FMAN_RX_10G_LIODN(1, 0, 94), SET_FMAN_RX_10G_LIODN(1, 1, 95), }; int fman1_liodn_tbl_sz = ARRAY_SIZE(fman1_liodn_tbl); #if (CONFIG_SYS_NUM_FMAN == 2) struct liodn_id_table fman2_liodn_tbl[] = { SET_FMAN_RX_1G_LIODN(2, 0, 88), SET_FMAN_RX_1G_LIODN(2, 1, 89), SET_FMAN_RX_1G_LIODN(2, 2, 90), SET_FMAN_RX_1G_LIODN(2, 3, 91), SET_FMAN_RX_1G_LIODN(2, 4, 92), SET_FMAN_RX_1G_LIODN(2, 5, 93), SET_FMAN_RX_10G_LIODN(2, 0, 94), SET_FMAN_RX_10G_LIODN(2, 1, 95), }; int fman2_liodn_tbl_sz = ARRAY_SIZE(fman2_liodn_tbl); #endif #endif struct liodn_id_table sec_liodn_tbl[] = { SET_SEC_JR_LIODN_ENTRY(0, 454, 458), SET_SEC_JR_LIODN_ENTRY(1, 455, 459), SET_SEC_JR_LIODN_ENTRY(2, 456, 460), SET_SEC_JR_LIODN_ENTRY(3, 457, 461), SET_SEC_RTIC_LIODN_ENTRY(a, 453), SET_SEC_RTIC_LIODN_ENTRY(b, 549), SET_SEC_RTIC_LIODN_ENTRY(c, 550), SET_SEC_RTIC_LIODN_ENTRY(d, 551), SET_SEC_DECO_LIODN_ENTRY(0, 541, 610), SET_SEC_DECO_LIODN_ENTRY(1, 542, 611), SET_SEC_DECO_LIODN_ENTRY(2, 543, 612), SET_SEC_DECO_LIODN_ENTRY(3, 544, 613), SET_SEC_DECO_LIODN_ENTRY(4, 545, 614), SET_SEC_DECO_LIODN_ENTRY(5, 546, 615), SET_SEC_DECO_LIODN_ENTRY(6, 547, 616), SET_SEC_DECO_LIODN_ENTRY(7, 548, 617), }; int sec_liodn_tbl_sz = ARRAY_SIZE(sec_liodn_tbl); #ifdef CONFIG_SYS_DPAA_RMAN struct liodn_id_table rman_liodn_tbl[] = { /* Set RMan block 0-3 liodn offset */ SET_RMAN_LIODN(0, 6), SET_RMAN_LIODN(1, 7), SET_RMAN_LIODN(2, 8), SET_RMAN_LIODN(3, 9), }; int rman_liodn_tbl_sz = ARRAY_SIZE(rman_liodn_tbl); #endif struct liodn_id_table liodn_bases[] = { #ifdef CONFIG_SYS_DPAA_DCE [FSL_HW_PORTAL_DCE] = SET_LIODN_BASE_2(618, 694), #endif [FSL_HW_PORTAL_SEC] = SET_LIODN_BASE_2(462, 558), #ifdef CONFIG_SYS_DPAA_FMAN [FSL_HW_PORTAL_FMAN1] = SET_LIODN_BASE_1(973), #if (CONFIG_SYS_NUM_FMAN == 2) [FSL_HW_PORTAL_FMAN2] = SET_LIODN_BASE_1(1069), #endif #endif #ifdef CONFIG_SYS_DPAA_PME [FSL_HW_PORTAL_PME] = SET_LIODN_BASE_2(770, 846), #endif #ifdef CONFIG_SYS_DPAA_RMAN [FSL_HW_PORTAL_RMAN] = SET_LIODN_BASE_1(922), #endif };
7aa0bdd0f188b9df2c946e09bf5e94e93a814307
1a1ad4757a9e6792ed459fcdb6f0bb81952956f0
/kernel/utils/misc.h
5cf08f307af3660d803d38fb2928b3409e7963c2
[]
no_license
david942j/kvm-kernel-example
79db75ce34ae0874e4e3e0bc7b4144fa72751728
226367cae6dd1ab431f7f615d15eb06f18d1107b
refs/heads/master
2023-09-01T21:45:27.822193
2023-02-05T09:50:03
2023-02-05T09:50:07
151,266,327
300
55
null
2023-09-03T09:05:41
2018-10-02T14:15:25
C
UTF-8
C
false
false
227
h
misc.h
#ifndef MISC_H #define MISC_H #define aligndown(v) ((uint64_t) (v) & -0x1000) #define alignup(v) (((uint64_t) (v) & 0xfff) ? aligndown(v) + 0x1000 : (uint64_t) (v)) #define alignok(v) ((uint64_t) (v) == aligndown(v)) #endif
c53bd94074902ce393980f818fd4314ee8078083
010279e2ba272d09e9d2c4e903722e5faba2cf7a
/contrib/python/numpy/py3/numpy/core/src/umath/loops.h
11f3dc253c16940ce3e02183cc1f15a2f4d071a1
[ "Apache-2.0", "BSD-3-Clause", "Zlib", "MIT" ]
permissive
catboost/catboost
854c1a1f439a96f1ae6b48e16644be20aa04dba2
f5042e35b945aded77b23470ead62d7eacefde92
refs/heads/master
2023-09-01T12:14:14.174108
2023-09-01T10:01:01
2023-09-01T10:22:12
97,556,265
8,012
1,425
Apache-2.0
2023-09-11T03:32:32
2017-07-18T05:29:04
Python
UTF-8
C
false
false
154,945
h
loops.h
#line 1 "numpy/core/src/umath/loops.h.src" /* ***************************************************************************** ** This file was autogenerated from a template DO NOT EDIT!!!! ** ** Changes should be made to the original source (.src) file ** ***************************************************************************** */ #line 1 /* -*- c -*- */ /* * vim:syntax=c */ #ifndef _NPY_UMATH_LOOPS_H_ #define _NPY_UMATH_LOOPS_H_ #ifndef NPY_NO_EXPORT #define NPY_NO_EXPORT NPY_VISIBILITY_HIDDEN #endif #define BOOL_invert BOOL_logical_not #define BOOL_add BOOL_logical_or #define BOOL_bitwise_and BOOL_logical_and #define BOOL_bitwise_or BOOL_logical_or #define BOOL_logical_xor BOOL_not_equal #define BOOL_bitwise_xor BOOL_logical_xor #define BOOL_multiply BOOL_logical_and #define BOOL_maximum BOOL_logical_or #define BOOL_minimum BOOL_logical_and #define BOOL_fmax BOOL_maximum #define BOOL_fmin BOOL_minimum /* ***************************************************************************** ** BOOLEAN LOOPS ** ***************************************************************************** */ #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_comparison.dispatch.h" #endif #line 38 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BOOL_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 38 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BOOL_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 38 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BOOL_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 38 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BOOL_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 38 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BOOL_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 38 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BOOL_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 45 NPY_NO_EXPORT void BOOL_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 45 NPY_NO_EXPORT void BOOL_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 45 NPY_NO_EXPORT void BOOL_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 45 NPY_NO_EXPORT void BOOL_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BOOL__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); #line 55 NPY_NO_EXPORT void BOOL_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 55 NPY_NO_EXPORT void BOOL_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 55 NPY_NO_EXPORT void BOOL_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); /* ***************************************************************************** ** INTEGER LOOPS ***************************************************************************** */ #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_arithmetic.dispatch.h" #endif #line 73 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 73 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 73 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 73 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 73 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 73 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 73 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 73 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 73 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 73 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_modulo.dispatch.h" #endif #line 85 #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_divmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_fmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_remainder, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 85 #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_divmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_fmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_remainder, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 85 #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_divmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_fmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_remainder, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 85 #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_divmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_fmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_remainder, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 85 #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_divmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_fmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_remainder, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 85 #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_divmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_fmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_remainder, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 85 #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_divmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_fmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_remainder, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 85 #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_divmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_fmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_remainder, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 85 #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_divmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_fmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_remainder, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 85 #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_divmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_fmod, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 88 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_remainder, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_comparison.dispatch.h" #endif #line 101 #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 101 #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 101 #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 101 #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 101 #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 101 #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 101 #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 101 #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 101 #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 101 #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_not_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_greater, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_greater_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_less, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 104 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_less_equal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 112 #line 118 #define BYTE_floor_divide BYTE_divide #define BYTE_fmax BYTE_maximum #define BYTE_fmin BYTE_minimum NPY_NO_EXPORT void BYTE__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void BYTE_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void BYTE_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void BYTE_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void BYTE_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_invert(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_bitwise_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_bitwise_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_bitwise_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_left_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_right_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void BYTE_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void BYTE_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void BYTE_square_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void BYTE_reciprocal_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void BYTE_conjugate_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_negative_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_logical_not_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_invert_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_add_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_subtract_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_multiply_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_bitwise_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_bitwise_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_bitwise_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_left_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void BYTE_right_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void BYTE_logical_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void BYTE_logical_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_logical_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void BYTE_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void BYTE_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_power(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_gcd(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void BYTE_lcm(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void BYTE_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void BYTE_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void BYTE_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 118 #define UBYTE_floor_divide UBYTE_divide #define UBYTE_fmax UBYTE_maximum #define UBYTE_fmin UBYTE_minimum NPY_NO_EXPORT void UBYTE__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void UBYTE_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void UBYTE_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void UBYTE_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void UBYTE_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_invert(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_bitwise_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_bitwise_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_bitwise_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_left_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_right_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void UBYTE_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void UBYTE_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void UBYTE_square_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void UBYTE_reciprocal_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void UBYTE_conjugate_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_negative_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_logical_not_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_invert_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_add_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_subtract_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_multiply_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_bitwise_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_bitwise_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_bitwise_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_left_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UBYTE_right_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void UBYTE_logical_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void UBYTE_logical_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_logical_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void UBYTE_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void UBYTE_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_power(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_gcd(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UBYTE_lcm(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void UBYTE_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void UBYTE_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void UBYTE_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 112 #line 118 #define SHORT_floor_divide SHORT_divide #define SHORT_fmax SHORT_maximum #define SHORT_fmin SHORT_minimum NPY_NO_EXPORT void SHORT__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void SHORT_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void SHORT_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void SHORT_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void SHORT_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_invert(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_bitwise_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_bitwise_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_bitwise_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_left_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_right_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void SHORT_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void SHORT_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void SHORT_square_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void SHORT_reciprocal_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void SHORT_conjugate_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_negative_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_logical_not_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_invert_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_add_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_subtract_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_multiply_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_bitwise_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_bitwise_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_bitwise_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_left_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void SHORT_right_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void SHORT_logical_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void SHORT_logical_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_logical_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void SHORT_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void SHORT_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_power(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_gcd(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void SHORT_lcm(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void SHORT_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void SHORT_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void SHORT_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 118 #define USHORT_floor_divide USHORT_divide #define USHORT_fmax USHORT_maximum #define USHORT_fmin USHORT_minimum NPY_NO_EXPORT void USHORT__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void USHORT_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void USHORT_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void USHORT_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void USHORT_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_invert(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_bitwise_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_bitwise_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_bitwise_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_left_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_right_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void USHORT_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void USHORT_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void USHORT_square_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void USHORT_reciprocal_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void USHORT_conjugate_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_negative_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_logical_not_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_invert_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_add_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_subtract_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_multiply_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_bitwise_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_bitwise_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_bitwise_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_left_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void USHORT_right_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void USHORT_logical_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void USHORT_logical_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_logical_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void USHORT_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void USHORT_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_power(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_gcd(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void USHORT_lcm(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void USHORT_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void USHORT_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void USHORT_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 112 #line 118 #define INT_floor_divide INT_divide #define INT_fmax INT_maximum #define INT_fmin INT_minimum NPY_NO_EXPORT void INT__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void INT_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void INT_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void INT_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void INT_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_invert(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_bitwise_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_bitwise_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_bitwise_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_left_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_right_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void INT_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void INT_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void INT_square_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void INT_reciprocal_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void INT_conjugate_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_negative_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_logical_not_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_invert_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_add_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_subtract_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_multiply_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_bitwise_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_bitwise_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_bitwise_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_left_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void INT_right_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void INT_logical_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void INT_logical_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_logical_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void INT_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void INT_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_power(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_gcd(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void INT_lcm(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void INT_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void INT_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void INT_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 118 #define UINT_floor_divide UINT_divide #define UINT_fmax UINT_maximum #define UINT_fmin UINT_minimum NPY_NO_EXPORT void UINT__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void UINT_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void UINT_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void UINT_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void UINT_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_invert(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_bitwise_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_bitwise_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_bitwise_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_left_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_right_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void UINT_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void UINT_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void UINT_square_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void UINT_reciprocal_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void UINT_conjugate_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_negative_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_logical_not_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_invert_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_add_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_subtract_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_multiply_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_bitwise_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_bitwise_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_bitwise_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_left_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void UINT_right_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void UINT_logical_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void UINT_logical_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_logical_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void UINT_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void UINT_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_power(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_gcd(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void UINT_lcm(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void UINT_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void UINT_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void UINT_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 112 #line 118 #define LONG_floor_divide LONG_divide #define LONG_fmax LONG_maximum #define LONG_fmin LONG_minimum NPY_NO_EXPORT void LONG__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONG_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void LONG_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONG_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONG_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_invert(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_bitwise_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_bitwise_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_bitwise_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_left_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_right_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void LONG_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void LONG_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void LONG_square_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONG_reciprocal_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONG_conjugate_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_negative_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_logical_not_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_invert_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_add_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_subtract_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_multiply_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_bitwise_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_bitwise_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_bitwise_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_left_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONG_right_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void LONG_logical_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void LONG_logical_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_logical_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void LONG_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void LONG_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_power(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_gcd(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONG_lcm(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void LONG_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void LONG_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void LONG_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 118 #define ULONG_floor_divide ULONG_divide #define ULONG_fmax ULONG_maximum #define ULONG_fmin ULONG_minimum NPY_NO_EXPORT void ULONG__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void ULONG_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void ULONG_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void ULONG_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void ULONG_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_invert(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_bitwise_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_bitwise_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_bitwise_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_left_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_right_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void ULONG_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void ULONG_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void ULONG_square_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void ULONG_reciprocal_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void ULONG_conjugate_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_negative_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_logical_not_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_invert_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_add_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_subtract_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_multiply_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_bitwise_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_bitwise_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_bitwise_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_left_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONG_right_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void ULONG_logical_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void ULONG_logical_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_logical_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void ULONG_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void ULONG_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_power(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_gcd(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONG_lcm(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void ULONG_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void ULONG_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void ULONG_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 112 #line 118 #define LONGLONG_floor_divide LONGLONG_divide #define LONGLONG_fmax LONGLONG_maximum #define LONGLONG_fmin LONGLONG_minimum NPY_NO_EXPORT void LONGLONG__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONGLONG_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void LONGLONG_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONGLONG_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONGLONG_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_invert(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_bitwise_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_bitwise_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_bitwise_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_left_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_right_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void LONGLONG_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void LONGLONG_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void LONGLONG_square_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONGLONG_reciprocal_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONGLONG_conjugate_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_negative_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_logical_not_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_invert_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_add_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_subtract_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_multiply_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_bitwise_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_bitwise_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_bitwise_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_left_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void LONGLONG_right_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void LONGLONG_logical_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void LONGLONG_logical_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_logical_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void LONGLONG_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void LONGLONG_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_power(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_gcd(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGLONG_lcm(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void LONGLONG_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void LONGLONG_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void LONGLONG_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 118 #define ULONGLONG_floor_divide ULONGLONG_divide #define ULONGLONG_fmax ULONGLONG_maximum #define ULONGLONG_fmin ULONGLONG_minimum NPY_NO_EXPORT void ULONGLONG__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void ULONGLONG_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void ULONGLONG_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void ULONGLONG_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void ULONGLONG_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_invert(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_bitwise_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_bitwise_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_bitwise_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_left_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_right_shift(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void ULONGLONG_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void ULONGLONG_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 132 NPY_NO_EXPORT void ULONGLONG_square_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void ULONGLONG_reciprocal_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void ULONGLONG_conjugate_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_negative_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_logical_not_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_invert_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_add_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_subtract_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_multiply_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_bitwise_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_bitwise_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_bitwise_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_left_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 157 NPY_NO_EXPORT void ULONGLONG_right_shift_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void ULONGLONG_logical_and_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 166 NPY_NO_EXPORT void ULONGLONG_logical_or_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_logical_xor_avx2(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void ULONGLONG_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 179 NPY_NO_EXPORT void ULONGLONG_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_power(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_gcd(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void ULONGLONG_lcm(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void ULONGLONG_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void ULONGLONG_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 201 NPY_NO_EXPORT void ULONGLONG_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); /* ***************************************************************************** ** FLOAT LOOPS ** ***************************************************************************** */ #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_unary_fp.dispatch.h" #endif #line 220 #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_rint, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_floor, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_trunc, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_ceil, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_sqrt, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_absolute, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_square, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_reciprocal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 220 #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_rint, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_floor, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_trunc, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_ceil, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_sqrt, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_absolute, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_square, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 223 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_reciprocal, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_arithm_fp.dispatch.h" #endif #line 234 #line 239 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_add, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 239 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_subtract, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 239 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_multiply, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 239 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 234 #line 239 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_add, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 239 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_subtract, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 239 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_multiply, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 239 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_divide, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_hyperbolic.dispatch.h" #endif #line 250 #line 253 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_tanh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 250 #line 253 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_tanh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) // SVML #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_umath_fp.dispatch.h" #endif #line 266 #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_tanh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_exp2, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_log2, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_log10, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_expm1, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_log1p, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_cbrt, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_tan, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_arcsin, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_arccos, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_arctan, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_sinh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_cosh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_arcsinh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_arccosh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_arctanh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 266 #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_tanh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_exp2, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_log2, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_log10, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_expm1, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_log1p, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_cbrt, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_tan, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_arcsin, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_arccos, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_arctan, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_sinh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_cosh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_arcsinh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_arccosh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 269 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_arctanh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_sin, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_cos, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_tan, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_exp, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_exp2, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_log, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_log2, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_log10, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_expm1, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_log1p, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_cbrt, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_arcsin, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_arccos, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_arctan, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_sinh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_cosh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_tanh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_arcsinh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_arccosh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 279 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void HALF_arctanh, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 288 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_sin, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 288 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_cos, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 297 #line 300 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_power, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 300 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_arctan2, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 297 #line 300 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_power, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 300 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_arctan2, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func))) #line 310 #line 313 NPY_NO_EXPORT void FLOAT_maximum_avx512f(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 313 NPY_NO_EXPORT void FLOAT_minimum_avx512f(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 310 #line 313 NPY_NO_EXPORT void DOUBLE_maximum_avx512f(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 313 NPY_NO_EXPORT void DOUBLE_minimum_avx512f(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_trigonometric.dispatch.h" #endif #line 325 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_sin, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 325 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_cos, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_exponent_log.dispatch.h" #endif #line 336 #line 339 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_exp, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 339 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_log, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 339 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_frexp, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 339 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_ldexp, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 336 #line 339 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_exp, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 339 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_log, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 339 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_frexp, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 339 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_ldexp, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_comparison.dispatch.h" #endif #line 351 #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_equal, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_not_equal, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_less, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_less_equal, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_greater, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_greater_equal, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 351 #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_equal, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_not_equal, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_less, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_less_equal, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_greater, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 354 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_greater_equal, ( char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func) )) #line 366 #line 372 NPY_NO_EXPORT void HALF_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void HALF_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void HALF_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void HALF_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 380 NPY_NO_EXPORT void HALF_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 380 NPY_NO_EXPORT void HALF_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void HALF_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void HALF_isnan_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void HALF_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void HALF_isinf_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void HALF_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void HALF_isfinite_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void HALF_signbit(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void HALF_signbit_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void HALF_copysign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void HALF_copysign_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void HALF_nextafter(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void HALF_nextafter_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void HALF_spacing(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void HALF_spacing_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 407 NPY_NO_EXPORT void HALF_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 407 NPY_NO_EXPORT void HALF_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 415 NPY_NO_EXPORT void HALF_fmax(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 415 NPY_NO_EXPORT void HALF_fmin(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_floor_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_remainder(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_divmod(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void HALF_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void HALF__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void HALF_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_modf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_frexp(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_ldexp(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void HALF_ldexp_long(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 366 #line 372 NPY_NO_EXPORT void FLOAT_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void FLOAT_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void FLOAT_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void FLOAT_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 380 NPY_NO_EXPORT void FLOAT_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 380 NPY_NO_EXPORT void FLOAT_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void FLOAT_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void FLOAT_isnan_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void FLOAT_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void FLOAT_isinf_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void FLOAT_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void FLOAT_isfinite_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void FLOAT_signbit(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void FLOAT_signbit_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void FLOAT_copysign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void FLOAT_copysign_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void FLOAT_nextafter(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void FLOAT_nextafter_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void FLOAT_spacing(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void FLOAT_spacing_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 407 NPY_NO_EXPORT void FLOAT_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 407 NPY_NO_EXPORT void FLOAT_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 415 NPY_NO_EXPORT void FLOAT_fmax(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 415 NPY_NO_EXPORT void FLOAT_fmin(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_floor_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_remainder(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_divmod(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void FLOAT_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void FLOAT__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void FLOAT_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_modf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_frexp(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_ldexp(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void FLOAT_ldexp_long(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 366 #line 372 NPY_NO_EXPORT void DOUBLE_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void DOUBLE_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void DOUBLE_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void DOUBLE_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 380 NPY_NO_EXPORT void DOUBLE_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 380 NPY_NO_EXPORT void DOUBLE_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void DOUBLE_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void DOUBLE_isnan_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void DOUBLE_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void DOUBLE_isinf_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void DOUBLE_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void DOUBLE_isfinite_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void DOUBLE_signbit(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void DOUBLE_signbit_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void DOUBLE_copysign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void DOUBLE_copysign_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void DOUBLE_nextafter(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void DOUBLE_nextafter_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void DOUBLE_spacing(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void DOUBLE_spacing_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 407 NPY_NO_EXPORT void DOUBLE_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 407 NPY_NO_EXPORT void DOUBLE_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 415 NPY_NO_EXPORT void DOUBLE_fmax(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 415 NPY_NO_EXPORT void DOUBLE_fmin(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_floor_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_remainder(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_divmod(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void DOUBLE_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void DOUBLE__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void DOUBLE_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_modf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_frexp(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_ldexp(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DOUBLE_ldexp_long(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 366 #line 372 NPY_NO_EXPORT void LONGDOUBLE_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void LONGDOUBLE_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void LONGDOUBLE_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 372 NPY_NO_EXPORT void LONGDOUBLE_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 380 NPY_NO_EXPORT void LONGDOUBLE_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 380 NPY_NO_EXPORT void LONGDOUBLE_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void LONGDOUBLE_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void LONGDOUBLE_isnan_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void LONGDOUBLE_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void LONGDOUBLE_isinf_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void LONGDOUBLE_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void LONGDOUBLE_isfinite_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void LONGDOUBLE_signbit(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void LONGDOUBLE_signbit_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void LONGDOUBLE_copysign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void LONGDOUBLE_copysign_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void LONGDOUBLE_nextafter(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void LONGDOUBLE_nextafter_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 394 #line 398 NPY_NO_EXPORT void LONGDOUBLE_spacing(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 398 NPY_NO_EXPORT void LONGDOUBLE_spacing_avx512_skx(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 407 NPY_NO_EXPORT void LONGDOUBLE_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 407 NPY_NO_EXPORT void LONGDOUBLE_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 415 NPY_NO_EXPORT void LONGDOUBLE_fmax(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 415 NPY_NO_EXPORT void LONGDOUBLE_fmin(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_floor_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_remainder(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_divmod(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_square(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONGDOUBLE_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONGDOUBLE__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void LONGDOUBLE_conjugate(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_modf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_frexp(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_ldexp(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void LONGDOUBLE_ldexp_long(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 468 #line 471 NPY_NO_EXPORT void HALF_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 471 NPY_NO_EXPORT void HALF_not_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 471 NPY_NO_EXPORT void HALF_less(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 471 NPY_NO_EXPORT void HALF_less_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 471 NPY_NO_EXPORT void HALF_greater(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 471 NPY_NO_EXPORT void HALF_greater_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 468 #line 471 NPY_NO_EXPORT void LONGDOUBLE_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 471 NPY_NO_EXPORT void LONGDOUBLE_not_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 471 NPY_NO_EXPORT void LONGDOUBLE_less(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 471 NPY_NO_EXPORT void LONGDOUBLE_less_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 471 NPY_NO_EXPORT void LONGDOUBLE_greater(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 471 NPY_NO_EXPORT void LONGDOUBLE_greater_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); /* ***************************************************************************** ** COMPLEX LOOPS ** ***************************************************************************** */ #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_arithm_fp.dispatch.h" #endif #line 487 #line 490 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void CFLOAT_add, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 490 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void CFLOAT_subtract, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 490 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void CFLOAT_multiply, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 487 #line 490 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void CDOUBLE_add, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 490 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void CDOUBLE_subtract, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 490 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void CDOUBLE_multiply, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #define CGE(xr,xi,yr,yi) (xr > yr || (xr == yr && xi >= yi)); #define CLE(xr,xi,yr,yi) (xr < yr || (xr == yr && xi <= yi)); #define CGT(xr,xi,yr,yi) (xr > yr || (xr == yr && xi > yi)); #define CLT(xr,xi,yr,yi) (xr < yr || (xr == yr && xi < yi)); #define CEQ(xr,xi,yr,yi) (xr == yr && xi == yi); #define CNE(xr,xi,yr,yi) (xr != yr || xi != yi); #line 508 #line 513 NPY_NO_EXPORT void CFLOAT_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 513 NPY_NO_EXPORT void CFLOAT_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 513 NPY_NO_EXPORT void CFLOAT_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CFLOAT_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CFLOAT_greater(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CFLOAT_greater_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CFLOAT_less(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CFLOAT_less_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CFLOAT_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CFLOAT_not_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 533 NPY_NO_EXPORT void CFLOAT_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 533 NPY_NO_EXPORT void CFLOAT_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CFLOAT_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CFLOAT_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 547 NPY_NO_EXPORT void CFLOAT_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 547 NPY_NO_EXPORT void CFLOAT_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 547 NPY_NO_EXPORT void CFLOAT_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CFLOAT_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void CFLOAT__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); #line 560 NPY_NO_EXPORT void CFLOAT_conjugate(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CFLOAT_absolute(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CFLOAT_square(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(data)); #line 560 NPY_NO_EXPORT void CFLOAT_conjugate_avx512f(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CFLOAT_absolute_avx512f(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CFLOAT_square_avx512f(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void CFLOAT__arg(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CFLOAT_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 581 NPY_NO_EXPORT void CFLOAT_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 581 NPY_NO_EXPORT void CFLOAT_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 589 NPY_NO_EXPORT void CFLOAT_fmax(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 589 NPY_NO_EXPORT void CFLOAT_fmin(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 508 #line 513 NPY_NO_EXPORT void CDOUBLE_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 513 NPY_NO_EXPORT void CDOUBLE_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 513 NPY_NO_EXPORT void CDOUBLE_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CDOUBLE_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CDOUBLE_greater(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CDOUBLE_greater_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CDOUBLE_less(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CDOUBLE_less_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CDOUBLE_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CDOUBLE_not_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 533 NPY_NO_EXPORT void CDOUBLE_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 533 NPY_NO_EXPORT void CDOUBLE_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CDOUBLE_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CDOUBLE_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 547 NPY_NO_EXPORT void CDOUBLE_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 547 NPY_NO_EXPORT void CDOUBLE_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 547 NPY_NO_EXPORT void CDOUBLE_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CDOUBLE_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void CDOUBLE__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); #line 560 NPY_NO_EXPORT void CDOUBLE_conjugate(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CDOUBLE_absolute(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CDOUBLE_square(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(data)); #line 560 NPY_NO_EXPORT void CDOUBLE_conjugate_avx512f(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CDOUBLE_absolute_avx512f(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CDOUBLE_square_avx512f(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void CDOUBLE__arg(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CDOUBLE_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 581 NPY_NO_EXPORT void CDOUBLE_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 581 NPY_NO_EXPORT void CDOUBLE_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 589 NPY_NO_EXPORT void CDOUBLE_fmax(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 589 NPY_NO_EXPORT void CDOUBLE_fmin(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 508 #line 513 NPY_NO_EXPORT void CLONGDOUBLE_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 513 NPY_NO_EXPORT void CLONGDOUBLE_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 513 NPY_NO_EXPORT void CLONGDOUBLE_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CLONGDOUBLE_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CLONGDOUBLE_greater(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CLONGDOUBLE_greater_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CLONGDOUBLE_less(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CLONGDOUBLE_less_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CLONGDOUBLE_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 524 NPY_NO_EXPORT void CLONGDOUBLE_not_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 533 NPY_NO_EXPORT void CLONGDOUBLE_logical_and(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 533 NPY_NO_EXPORT void CLONGDOUBLE_logical_or(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CLONGDOUBLE_logical_xor(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CLONGDOUBLE_logical_not(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 547 NPY_NO_EXPORT void CLONGDOUBLE_isnan(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 547 NPY_NO_EXPORT void CLONGDOUBLE_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 547 NPY_NO_EXPORT void CLONGDOUBLE_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CLONGDOUBLE_reciprocal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void CLONGDOUBLE__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); #line 560 NPY_NO_EXPORT void CLONGDOUBLE_conjugate(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CLONGDOUBLE_absolute(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CLONGDOUBLE_square(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(data)); #line 560 NPY_NO_EXPORT void CLONGDOUBLE_conjugate_avx512f(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CLONGDOUBLE_absolute_avx512f(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CLONGDOUBLE_square_avx512f(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void CLONGDOUBLE__arg(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void CLONGDOUBLE_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 581 NPY_NO_EXPORT void CLONGDOUBLE_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 581 NPY_NO_EXPORT void CLONGDOUBLE_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 589 NPY_NO_EXPORT void CLONGDOUBLE_fmax(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 589 NPY_NO_EXPORT void CLONGDOUBLE_fmin(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #undef CGE #undef CLE #undef CGT #undef CLT #undef CEQ #undef CNE /* ***************************************************************************** ** DATETIME LOOPS ** ***************************************************************************** */ NPY_NO_EXPORT void TIMEDELTA_negative(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_positive(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_absolute(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 623 NPY_NO_EXPORT void DATETIME_isnat(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DATETIME_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DATETIME_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #define DATETIME_isnan DATETIME_isnat NPY_NO_EXPORT void DATETIME__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); #line 642 NPY_NO_EXPORT void DATETIME_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 642 NPY_NO_EXPORT void DATETIME_not_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 642 NPY_NO_EXPORT void DATETIME_greater(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 642 NPY_NO_EXPORT void DATETIME_greater_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 642 NPY_NO_EXPORT void DATETIME_less(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 642 NPY_NO_EXPORT void DATETIME_less_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 649 NPY_NO_EXPORT void DATETIME_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 649 NPY_NO_EXPORT void DATETIME_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 649 NPY_NO_EXPORT void DATETIME_fmin(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 649 NPY_NO_EXPORT void DATETIME_fmax(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 623 NPY_NO_EXPORT void TIMEDELTA_isnat(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_isfinite(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_isinf(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #define TIMEDELTA_isnan TIMEDELTA_isnat NPY_NO_EXPORT void TIMEDELTA__ones_like(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); #line 642 NPY_NO_EXPORT void TIMEDELTA_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 642 NPY_NO_EXPORT void TIMEDELTA_not_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 642 NPY_NO_EXPORT void TIMEDELTA_greater(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 642 NPY_NO_EXPORT void TIMEDELTA_greater_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 642 NPY_NO_EXPORT void TIMEDELTA_less(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 642 NPY_NO_EXPORT void TIMEDELTA_less_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 649 NPY_NO_EXPORT void TIMEDELTA_maximum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 649 NPY_NO_EXPORT void TIMEDELTA_minimum(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 649 NPY_NO_EXPORT void TIMEDELTA_fmin(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 649 NPY_NO_EXPORT void TIMEDELTA_fmax(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DATETIME_Mm_M_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data)); NPY_NO_EXPORT void DATETIME_mM_M_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_mm_m_add(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DATETIME_Mm_M_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void DATETIME_MM_m_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_mm_m_subtract(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_mq_m_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_qm_m_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_md_m_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_dm_m_multiply(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_mq_m_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_md_m_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_mm_d_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_mm_q_floor_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_mm_m_remainder(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void TIMEDELTA_mm_qm_divmod(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); /* Special case equivalents to above functions */ #define TIMEDELTA_mq_m_floor_divide TIMEDELTA_mq_m_divide #define TIMEDELTA_md_m_floor_divide TIMEDELTA_md_m_divide /* #define TIMEDELTA_mm_d_floor_divide TIMEDELTA_mm_d_divide */ /* ***************************************************************************** ** OBJECT LOOPS ** ***************************************************************************** */ #line 718 #line 721 NPY_NO_EXPORT void OBJECT_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 721 NPY_NO_EXPORT void OBJECT_OO_O_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 718 #line 721 NPY_NO_EXPORT void OBJECT_not_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 721 NPY_NO_EXPORT void OBJECT_OO_O_not_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 718 #line 721 NPY_NO_EXPORT void OBJECT_greater(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 721 NPY_NO_EXPORT void OBJECT_OO_O_greater(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 718 #line 721 NPY_NO_EXPORT void OBJECT_greater_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 721 NPY_NO_EXPORT void OBJECT_OO_O_greater_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 718 #line 721 NPY_NO_EXPORT void OBJECT_less(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 721 NPY_NO_EXPORT void OBJECT_OO_O_less(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 718 #line 721 NPY_NO_EXPORT void OBJECT_less_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); #line 721 NPY_NO_EXPORT void OBJECT_OO_O_less_equal(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void OBJECT_sign(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); NPY_NO_EXPORT void PyUFunc_OOO_O(char **args, npy_intp const *dimensions, npy_intp const *steps, void *func); /* ***************************************************************************** ** MIN/MAX LOOPS ** ***************************************************************************** */ #ifndef NPY_DISABLE_OPTIMIZATION #include "loops_minmax.dispatch.h" #endif //---------- Integers ---------- #line 748 #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void BYTE_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 748 #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UBYTE_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 748 #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void SHORT_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 748 #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void USHORT_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 748 #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void INT_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 748 #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void UINT_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 748 #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONG_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 748 #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONG_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 748 #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGLONG_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 748 #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 751 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void ULONGLONG_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) //---------- Float ---------- #line 761 #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_fmax, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void FLOAT_fmin, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 761 #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_fmax, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void DOUBLE_fmin, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 761 #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGDOUBLE_maximum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGDOUBLE_minimum, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGDOUBLE_fmax, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) #line 764 NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT void LONGDOUBLE_fmin, (char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(data))) /* ***************************************************************************** ** END LOOPS ** ***************************************************************************** */ #endif
877663a6071319b7ef45d68ea8da1628dea157ce
1af43c4ba32d78c60f007a4d068136ce575d917f
/system/apps/test17_official/source/Analyze.h
b6e06373c182aec2bfd281c77f5666712b91776c
[ "MIT" ]
permissive
gabonator/LA104
a4f1cdf2b3e513300d61c50fff091c5717abda9e
27d0eece7302c479da2cf86e881b6a51a535f93d
refs/heads/master
2023-08-31T22:09:36.272616
2023-08-27T20:08:08
2023-08-27T20:08:08
155,659,451
500
69
MIT
2023-08-17T08:44:32
2018-11-01T03:54:21
C
UTF-8
C
false
false
647
h
Analyze.h
#ifndef __ANALYZE_H #define __ANALYZE_H #define ASCII_WIDTH 7 // 6 #define DEX_WIDTH 21 // 18 #define HEX_WIDTH 28 // 24 #define ASCII 0 #define DEX 1 #define HEX 2 #define LSB 0 // #define MSB 1 // void SPI_AnalyzeFrame(void); void IIC_AnalyzeFrame(void); void UART_AnalyzeFrame(void); void Show_UART_AnalyzeData(void); void Show_SPI_AnalyzeData(void); void Show_I2C_AnalyzeData(void); void AnalyzeFrame(u8 Type); void Show_AnalyzeData(u8 Type); u16 SPI_AnalyzeDataStartCnt(u64 StartTime); u16 I2C_AnalyzeStartCnt(u64 StartTime); #endif
97efcf85c38056bb29bd72fdf120d7ec8b8dc32a
a7557f4e8413259be724646f4b542a550e5baf5e
/usr/include/autoopts/options.h
61f7bc2f5d8e85d9469f9ebf179a01d155a9c38d
[]
no_license
git-for-windows/git-sdk-64
cb5558b693ac508417f7503be9e7a149daf973fa
25f0f24eaff909ace7960515a055da2c2fb2aeac
refs/heads/main
2023-08-31T05:40:42.358892
2023-08-30T11:37:51
2023-08-30T11:37:51
87,077,328
195
202
null
2023-08-25T06:33:10
2017-04-03T13:30:02
null
UTF-8
C
false
false
44,064
h
options.h
/* -*- buffer-read-only: t -*- vi: set ro: * * DO NOT EDIT THIS FILE (options.h) * * It has been AutoGen-ed * From the definitions funcs.def * and the template file options_h * * This file defines all the global structures and special values * used in the automated option processing library. * * Automated Options Copyright (C) 1992-2018 by Bruce Korb * * This file is part of AutoOpts, a companion to AutoGen. * AutoOpts is free software. * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved * * AutoOpts is available under any one of two licenses. The license * in use must be one of these two and the choice is under the control * of the user of the license. * * The GNU Lesser General Public License, version 3 or later * See the files "COPYING.lgplv3" and "COPYING.gplv3" * * The Modified Berkeley Software Distribution License * See the file "COPYING.mbsd" * * These files have the following sha256 sums: * * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3 * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3 * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd */ #ifndef AUTOOPTS_OPTIONS_H_GUARD #define AUTOOPTS_OPTIONS_H_GUARD 1 /** \file options.h * * @addtogroup autoopts * @{ */ #include <sys/types.h> #include <stdio.h> #include <stdint.h> #include <limits.h> #include <stdbool.h> /** * Defined to abnormal value of EX_USAGE. Used to indicate that paged usage * was requested. It is used to distinguish a --usage from a --help request. * --usage is abbreviated and --help gives as much help as possible. */ #define AO_EXIT_REQ_USAGE 10064 #undef VOIDP /** * Coerce a value into a void pointer with no const or volatile attributes. * Somewhere along the line, the above set of includes need to set up * the "uintptr_t" type. */ #define VOIDP(_a) ((void *)(uintptr_t)(_a)) /** * PUBLIC DEFINES * * The following defines may be used in applications that need to test the * state of an option. To test against these masks and values, a pointer * to an option descriptor must be obtained. There are two ways: * * 1. inside an option processing procedure, it is the second argument, * conventionally "tOptDesc * pOD". * * 2. Outside of an option procedure (or to reference a different option * descriptor), use either "&DESC( opt_name )" or "&pfx_DESC( opt_name )". * * See the relevant generated header file to determine which and what * values for "opt_name" are available. * @group version * @{ */ /// autoopts structure version #define OPTIONS_STRUCT_VERSION 172033 /// autoopts structure version string #define OPTIONS_VERSION_STRING "42:1:17" /// minimum version the autoopts library supports #define OPTIONS_MINIMUM_VERSION 102400 /// minimum version the autoopts library supports as a string #define OPTIONS_MIN_VER_STRING "25:0:0" /// the display version of the autoopts library, as a string #define OPTIONS_DOTTED_VERSION "42.1" /// convert a version/release number pair to an integer value #define OPTIONS_VER_TO_NUM(_v, _r) (((_v) * 4096) + (_r)) /// @} /** * Option argument types. This must fit in the OPTST_ARG_TYPE_MASK * field of the fOptState field of an option descriptor (tOptDesc). * It will be a problem to extend beyond 4 bits. */ typedef enum { OPARG_TYPE_NONE = 0, ///< does not take an argument OPARG_TYPE_STRING = 1, ///< default type/ vanilla string OPARG_TYPE_ENUMERATION = 2, ///< opt arg is an enum (keyword list) OPARG_TYPE_BOOLEAN = 3, ///< opt arg is boolean-valued OPARG_TYPE_MEMBERSHIP = 4, ///< opt arg sets set membership bits OPARG_TYPE_NUMERIC = 5, ///< opt arg is a long int OPARG_TYPE_HIERARCHY = 6, ///< option arg is hierarchical value OPARG_TYPE_FILE = 7, ///< option arg names a file OPARG_TYPE_TIME = 8, ///< opt arg is a time duration OPARG_TYPE_FLOAT = 9, ///< opt arg is a floating point num OPARG_TYPE_DOUBLE = 10, ///< opt arg is a double prec. float OPARG_TYPE_LONG_DOUBLE = 11, ///< opt arg is a long double prec. OPARG_TYPE_LONG_LONG = 12, ///< opt arg is a long long int OPARG_TYPE_STATIC = 13 ///< } teOptArgType; /** * value descriptor for sub options */ typedef struct optionValue { teOptArgType valType; ///< which argument type char * pzName; ///< name of the sub-option union { char strVal[1]; ///< OPARG_TYPE_STRING unsigned int enumVal; ///< OPARG_TYPE_ENUMERATION unsigned int boolVal; ///< OPARG_TYPE_BOOLEAN unsigned long setVal; ///< OPARG_TYPE_MEMBERSHIP long longVal; ///< OPARG_TYPE_NUMERIC void * nestVal; ///< OPARG_TYPE_HIERARCHY } v; } tOptionValue; /** * file argument state and handling. */ typedef enum { FTYPE_MODE_MAY_EXIST = 0x00, ///< may or may not exist FTYPE_MODE_MUST_EXIST = 0x01, ///< must pre-exist FTYPE_MODE_MUST_NOT_EXIST = 0x02, ///< must *not* pre-exist FTYPE_MODE_EXIST_MASK = 0x03, ///< mask for these bits FTYPE_MODE_NO_OPEN = 0x00, ///< leave file closed FTYPE_MODE_OPEN_FD = 0x10, ///< call open(2) FTYPE_MODE_FOPEN_FP = 0x20, ///< call fopen(3) FTYPE_MODE_OPEN_MASK = 0x30 ///< open/fopen/not open } teOptFileType; /** * the open flag bits or the mode string, depending on the open type. */ typedef union { int file_flags; ///< open(2) flag bits char const * file_mode; ///< fopen(3) mode string } tuFileMode; /// initial number of option argument holders to allocate #define MIN_ARG_ALLOC_CT 6 /// amount by which to increment the argument holder allocation. #define INCR_ARG_ALLOC_CT 8 /** * an argument list. When an option appears multiple times and * the values get "stacked". \a apzArgs holds 8 pointers initially * and is incremented by \a INCR_ARG_ALLOC_CT as needed. */ typedef struct { int useCt; ///< elements in use /// allocated elements, mininum \a MIN_ARG_ALLOC_CT /// steps by \a INCR_ARG_ALLOC_CT int allocCt; char const * apzArgs[MIN_ARG_ALLOC_CT]; ///< element array } tArgList; /** * Bits in the fOptState option descriptor field. * @{ */ /** integral type for holding opt_state masks */ typedef uint32_t opt_state_mask_t; #define OPTST_ARG_TYPE_SHIFT 12 /** bits defined for opt_state_mask_t */ /** Set via the "SET_OPT()" macro */ #define OPTST_SET 0x0000001U /** Set via an RC/INI file */ #define OPTST_PRESET 0x0000002U /** Set via a command line option */ #define OPTST_DEFINED 0x0000004U /** Reset via command line option */ #define OPTST_RESET 0x0000008U /** selected by equiv'ed option */ #define OPTST_EQUIVALENCE 0x0000010U /** option is in disabled state */ #define OPTST_DISABLED 0x0000020U /** pzOptArg was allocated */ #define OPTST_ALLOC_ARG 0x0000040U /** option cannot be preset */ #define OPTST_NO_INIT 0x0000100U /** opt value (flag) is any digit */ #define OPTST_NUMBER_OPT 0x0000200U /** opt uses optionStackArg proc */ #define OPTST_STACKED 0x0000400U /** option defaults to enabled */ #define OPTST_INITENABLED 0x0000800U /** bit 1 of arg type enum */ #define OPTST_ARG_TYPE_1 0x0001000U /** bit 2 of arg type enum */ #define OPTST_ARG_TYPE_2 0x0002000U /** bit 3 of arg type enum */ #define OPTST_ARG_TYPE_3 0x0004000U /** bit 4 of arg type enum */ #define OPTST_ARG_TYPE_4 0x0008000U /** the option arg not required */ #define OPTST_ARG_OPTIONAL 0x0010000U /** process opt on first pass */ #define OPTST_IMM 0x0020000U /** process disablement immed. */ #define OPTST_DISABLE_IMM 0x0040000U /** compiled out of program */ #define OPTST_OMITTED 0x0080000U /** must be set or pre-set */ #define OPTST_MUST_SET 0x0100000U /** opt is for doc only */ #define OPTST_DOCUMENT 0x0200000U /** process opt twice - imm + reg */ #define OPTST_TWICE 0x0400000U /** process disabled option twice */ #define OPTST_DISABLE_TWICE 0x0800000U /** scaled integer value */ #define OPTST_SCALED_NUM 0x1000000U /** disable from cmd line */ #define OPTST_NO_COMMAND 0x2000000U /** support is being removed */ #define OPTST_DEPRECATED 0x4000000U /** alias for other option */ #define OPTST_ALIAS 0x8000000U /** bits in SET mask: * set preset reset defined */ #define OPTST_SET_MASK 0x000000FU /** bits in MUTABLE mask: * set preset reset defined equivalence disabled * alloc_arg */ #define OPTST_MUTABLE_MASK 0x000007FU /** bits omitted from PERSISTENT mask: * mutable_mask */ #define OPTST_PERSISTENT_MASK 0xFFFFF00U /** bits in SELECTED mask: * set defined */ #define OPTST_SELECTED_MASK 0x0000005U /** bits in ARG_TYPE mask: * arg_type_1 arg_type_2 arg_type_3 arg_type_4 */ #define OPTST_ARG_TYPE_MASK 0x000F000U /** bits in NO_USAGE mask: * omitted no_command deprecated */ #define OPTST_NO_USAGE_MASK 0x6080000U /** bits in IMMUTABLE mask: * document omitted */ #define OPTST_IMMUTABLE_MASK 0x0280000U /** bits in DO_NOT_SAVE mask: * document omitted no_init */ #define OPTST_DO_NOT_SAVE_MASK 0x0280100U /** bits in NO_OUTPUT mask: * document omitted alias */ #define OPTST_NO_OUTPUT_MASK 0x8280000U /** all bits in opt_state_mask_t masks */ #define OPTST_MASK_ALL 0xFFFFF7FU /** no bits in opt_state_mask_t */ #define OPTST_INIT 0x0000000U /** @} */ #ifdef NO_OPTIONAL_OPT_ARGS # undef OPTST_ARG_OPTIONAL # define OPTST_ARG_OPTIONAL 0 #endif #define VENDOR_OPTION_VALUE 'W' #define SELECTED_OPT(_od) ((_od)->fOptState & OPTST_SELECTED_MASK) #define UNUSED_OPT( _od) (((_od)->fOptState & OPTST_SET_MASK) == 0) #define DISABLED_OPT(_od) ((_od)->fOptState & OPTST_DISABLED) #define OPTION_STATE(_od) ((_od)->fOptState) #define OPTST_SET_ARGTYPE(_n) ((_n) << OPTST_ARG_TYPE_SHIFT) #define OPTST_GET_ARGTYPE(_f) \ (((_f)&OPTST_ARG_TYPE_MASK) >> OPTST_ARG_TYPE_SHIFT) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * PRIVATE INTERFACES * * The following values are used in the generated code to communicate * with the option library procedures. They are not for public use * and may be subject to change. */ /** * Define the processing state flags * @{ */ /** integral type for holding proc_state masks */ typedef uint32_t proc_state_mask_t; /** bits defined for proc_state_mask_t */ /** Process long style options */ #define OPTPROC_LONGOPT 0x000001U /** Process short style "flags" */ #define OPTPROC_SHORTOPT 0x000002U /** Stop on argument errors */ #define OPTPROC_ERRSTOP 0x000004U /** Current option is disabled */ #define OPTPROC_DISABLEDOPT 0x000008U /** no options are required */ #define OPTPROC_NO_REQ_OPT 0x000010U /** there is a number option */ #define OPTPROC_NUM_OPT 0x000020U /** have inits been done? */ #define OPTPROC_INITDONE 0x000040U /** any negation options? */ #define OPTPROC_NEGATIONS 0x000080U /** check environment? */ #define OPTPROC_ENVIRON 0x000100U /** Disallow remaining arguments */ #define OPTPROC_NO_ARGS 0x000200U /** Require args after options */ #define OPTPROC_ARGS_REQ 0x000400U /** reorder operands after opts */ #define OPTPROC_REORDER 0x000800U /** emit usage in GNU style */ #define OPTPROC_GNUUSAGE 0x001000U /** Translate strings in tOptions */ #define OPTPROC_TRANSLATE 0x002000U /** no usage on usage error */ #define OPTPROC_MISUSE 0x004000U /** immediate options active */ #define OPTPROC_IMMEDIATE 0x008000U /** suppress for config only */ #define OPTPROC_NXLAT_OPT_CFG 0x010000U /** suppress xlation always */ #define OPTPROC_NXLAT_OPT 0x020000U /** vendor options active */ #define OPTPROC_VENDOR_OPT 0x040000U /** opt processing in preset state */ #define OPTPROC_PRESETTING 0x080000U /** Ignore pzFullUsage, compute usage text */ #define OPTPROC_COMPUTE 0x100000U /** Program outputs digested option state for shell scripts. Usage text * always written to stderr */ #define OPTPROC_SHELL_OUTPUT 0x200000U /** bits in NO_XLAT mask: * nxlat_opt_cfg nxlat_opt */ #define OPTPROC_NO_XLAT_MASK 0x030000U /** all bits in proc_state_mask_t masks */ #define OPTPROC_MASK_ALL 0x3FFFFFU /** no bits in proc_state_mask_t */ #define OPTPROC_NONE 0x000000U /** @} */ #define STMTS(s) do { s; } while (false) /** * Abbreviation for const memory character. */ #define tCC char const /** * Magical values for the program's option pointer * @{ */ typedef enum { OP_VAL_EMIT_USAGE = 1, ///< request for usage OP_VAL_EMIT_SHELL = 2, ///< emit value for Bourne shell evaluation OP_VAL_RETURN_VALNAME = 3, ///< return the value as a string OP_VAL_EMIT_LIMIT = 15 ///< limit for magic values } opt_proc_vals_t; /// \a OPT_VAL_EMIT_USAGE cast as a pointer #define OPTPROC_EMIT_USAGE ((tOptions *)OP_VAL_EMIT_USAGE) /// \a OPT_VAL_EMIT_SHELL cast as a pointer #define OPTPROC_EMIT_SHELL ((tOptions *)OP_VAL_EMIT_SHELL) /// \a OPT_VAL_RETURN_VALNAME cast as a pointer #define OPTPROC_RETURN_VALNAME ((tOptions *)OP_VAL_RETURN_VALNAME) /// \a OPT_VAL_EMIT_LIMIT cast as a pointer #define OPTPROC_EMIT_LIMIT ((tOptions *)OP_VAL_EMIT_LIMIT) /** @} */ /** group option processing procedure types * @{ */ /** forward declaration for tOptDesc */ typedef struct opt_desc tOptDesc; /** forward declaration for tOptiond */ typedef struct options tOptions; /** * The option procedures do the special processing for each * option flag that needs it. */ typedef void (tOptProc)(tOptions * pOpts, tOptDesc * pOptDesc); /** * a pointer to an option processing procedure */ typedef tOptProc * tpOptProc; /** * The usage procedure will never return. It calls "exit(2)" * with the "exitCode" argument passed to it. */ // coverity[+kill] typedef void (tUsageProc)(tOptions * pOpts, int exitCode); /** * a pointer to a procedure that prints usage and exits. */ typedef tUsageProc * tpUsageProc; /** @} */ /** * Special definitions. "NOLIMIT" is the 'max' value to use when * a flag may appear multiple times without limit. "NO_EQUIVALENT" * is an illegal value for 'optIndex' (option description index). * @{ */ #define NOLIMIT USHRT_MAX ///< no occurrance count limit #define OPTION_LIMIT SHRT_MAX ///< maximum number of option types /// option index to indicate no equivalance or alias #define NO_EQUIVALENT (OPTION_LIMIT+1) /** @} */ /** * Option argument value. Which is valid is determined by: * (fOptState & OPTST_ARG_TYPE_MASK) >> OPTST_ARG_TYPE_SHIFT * which will yield one of the teOptArgType values. */ typedef union { char const * argString; ///< as a string uintptr_t argEnum; ///< as an enumeration value uintptr_t argIntptr; ///< as an integer big enough to hold pointer long argInt; ///< as a long integer unsigned long argUint; ///< as an unsigned long ingeger unsigned int argBool; ///< as a boolean value FILE * argFp; ///< as a FILE * pointer int argFd; ///< as a file descriptor (int) } opt_arg_union_t; /// Compatibility define: \a pzLastArg is now \a optArg.argString #define pzLastArg optArg.argString /// The old amorphous argument bucket is now the opt_arg_union_t union. #define optArgBucket_t opt_arg_union_t /** * Enumeration of AutoOpts defined options. The enumeration is used in * marking each option that is defined by AutoOpts so libopts can find * the correct descriptor. This renders \a option_spec_idx_t redundant. */ typedef enum { AOUSE_USER_DEFINED = 0, ///< user specified option AOUSE_RESET_OPTION, ///< reset option state option AOUSE_VERSION, ///< request version AOUSE_HELP, ///< request usage help AOUSE_MORE_HELP, ///< request paged usage AOUSE_USAGE, ///< request short usage AOUSE_SAVE_OPTS, ///< save option state AOUSE_LOAD_OPTS, ///< load options from file AOUSE_VENDOR_OPT ///< specify a vendor option } opt_usage_t; /** * Descriptor structure for each option. * Only the fields marked "PUBLIC" are for public use. */ struct opt_desc { /// Public, the index of this descriptor uint16_t const optIndex; /// Public, the flag character (value) uint16_t const optValue; /// Public, the index of the option used to activate option uint16_t optActualIndex; /// Public, the flag character of the activating option uint16_t optActualValue; /// Public, the index of the equivalenced-to option. /// This is NO_EQUIVALENT unless activated. uint16_t const optEquivIndex; /// Private, the minimum occurrance count uint16_t const optMinCt; /// Private, the maximum occurrance count (NOLIMIT, if unlimited) uint16_t const optMaxCt; /// Public, the actual occurrance count uint16_t optOccCt; /// Public, the option processing state opt_state_mask_t fOptState; /// Private, how the option is used (opt_usage_t) uint32_t optUsage; /// Public, The current option argument value opt_arg_union_t optArg; /// Public, data that is actually private to the code that handles /// this particular option. It is public IFF you have your own /// handling function. void * optCookie; /// Private, a list of options that must be specified when this option /// has been specified int const * const pOptMust; /// Private, a list of options that cannot be specified when this option /// has been specified int const * const pOptCant; /// Private, the function to call for handling this option tpOptProc const pOptProc; /// Private, usage information about this option char const * const pzText; /// Public, the UPPER CASE, shell variable name syntax name of the option char const * const pz_NAME; /// the unmodified name of the option char const * const pz_Name; /// the option name to use to disable the option. Long options names /// must be active. char const * const pz_DisableName; /// the special prefix that makes the normal option name become the /// disablement name. char const * const pz_DisablePfx; }; /** * Some options need special processing, so we store their * indexes in a known place. */ typedef struct { uint16_t const more_help; ///< passes help text through pager uint16_t const save_opts; ///< stores option state to a file uint16_t const number_option; ///< the option "name" is an integer /// all arguments are options, this is the default option that must /// take an argument. That argument is the unrecognized option. uint16_t const default_opt; } option_spec_idx_t; /** * The procedure generated for translating option text */ typedef void (tOptionXlateProc)(void); /** * Everything marked "PUBLIC" is also marked "const". Public access is not * a license to modify. Other fields are used and modified by the library. * They are also subject to change without any notice. * Do not even look at these outside of libopts. */ struct options { int const structVersion; ///< The version of this struct unsigned int origArgCt; ///< program argument count char ** origArgVect; ///< program argument vector proc_state_mask_t fOptSet; ///< option proc. state flags unsigned int curOptIdx; ///< current option index char * pzCurOpt; ///< current option text /// Public, the full path of the program char const * const pzProgPath; /// Public, the name of the executable, without any path char const * const pzProgName; /// Public, the upper-cased, shell variable syntax-ed program name char const * const pzPROGNAME; /// the name of the "rc file" (configuration file) char const * const pzRcName; /// the copyright text char const * const pzCopyright; /// the full copyright notice char const * const pzCopyNotice; /// a string with the program name, project name and version char const * const pzFullVersion; /// a list of pointers to directories to search for the config file char const * const * const papzHomeList; /// the title line for usage char const * const pzUsageTitle; /// some added explanation for what this program is trying to do char const * const pzExplain; /// a detailed explanation of the program's purpose, for use when /// full help has been requested char const * const pzDetail; /// The public array of option descriptors tOptDesc * const pOptDesc; /// the email address for reporting bugs char const * const pzBugAddr; /// Reserved for future use void * pExtensions; /// A copy of the option state when optionSaveState was called. void * pSavedState; /// The procedure to call to print usage text /* __attribute__((__noreturn__)) */ // coverity[+kill] tpUsageProc pUsageProc; /// The procedure to call to translate translatable option messages tOptionXlateProc * pTransProc; /// Special option indexes. option_spec_idx_t specOptIdx; /// the total number of options for the program int const optCt; /// The number of "presettable" options, though some may be marked /// "no-preset". Includes all user specified options, plus a few /// that are specified by AutoOpts. int const presetOptCt; /// user specified full usage text char const * pzFullUsage; /// user specifed short usage (usage error triggered) message char const * pzShortUsage; /// The option argument settings active when optionSaveState was called opt_arg_union_t const * const originalOptArgArray; /// any saved cookie value void * const * const originalOptArgCookie; /// the package data directory (e.g. global configuration files) char const * const pzPkgDataDir; /// email address of the project packager char const * const pzPackager; }; /* * Versions where in various fields first appear: * ($AO_CURRENT * 4096 + $AO_REVISION, but $AO_REVISION must be zero) */ /** * The version that first stored the original argument vector */ #define originalOptArgArray_STRUCT_VERSION 0x20000 /* AO_CURRENT = 32 */ #define HAS_originalOptArgArray(_opt) \ ((_opt)->structVersion >= originalOptArgArray_STRUCT_VERSION) /** * The version that first stored the package data directory */ #define pzPkgDataDir_STRUCT_VERSION 0x22000 /* AO_CURRENT = 34 */ #define HAS_pzPkgDataDir(_opt) \ ((_opt)->structVersion >= pzPkgDataDir_STRUCT_VERSION) /** * The version that first stored the option usage in each option descriptor */ #define opt_usage_t_STRUCT_VERSION 0x26000 /* AO_CURRENT = 38 */ #define HAS_opt_usage_t(_opt) \ ((_opt)->structVersion >= opt_usage_t_STRUCT_VERSION) /** * "token list" structure returned by "string_tokenize()" */ typedef struct { unsigned long tkn_ct; ///< number of tokens found unsigned char * tkn_list[1]; ///< array of pointers to tokens } token_list_t; /* * Hide the interface - it pollutes a POSIX claim, but leave it for * anyone #include-ing this header */ #define strneqvcmp option_strneqvcmp #define streqvcmp option_streqvcmp #define streqvmap option_streqvmap #define strequate option_strequate #define strtransform option_strtransform /** * Everything needed to be known about an mmap-ed file. * * This is an output only structure used by text_mmap and text_munmap. * Clients must not alter the contents and must provide it to both * the text_mmap and text_munmap procedures. BE ADVISED: if you are * mapping the file with PROT_WRITE the NUL byte at the end MIGHT NOT * BE WRITABLE. In any event, that byte is not be written back * to the source file. ALSO: if "txt_data" is valid and "txt_errno" * is not zero, then there *may* not be a terminating NUL. */ typedef struct { void * txt_data; ///< text file data size_t txt_size; ///< actual file size size_t txt_full_size; ///< mmaped mem size int txt_fd; ///< file descriptor int txt_zero_fd; ///< fd for /dev/zero int txt_errno; ///< warning code int txt_prot; ///< "prot" flags int txt_flags; ///< mapping type } tmap_info_t; /** * mmap result wrapper that yields "true" when mmap has failed. */ #define TEXT_MMAP_FAILED_ADDR(a) (VOIDP(a) == VOIDP(MAP_FAILED)) #ifdef __cplusplus #define CPLUSPLUS_OPENER extern "C" { CPLUSPLUS_OPENER #define CPLUSPLUS_CLOSER } #else #define CPLUSPLUS_CLOSER #endif /** * The following routines may be coded into AutoOpts client code: */ /** * ao_string_tokenize - tokenize an input string * * This function will convert one input string into a list of strings. * The list of strings is derived by separating the input based on * white space separation. However, if the input contains either single * or double quote characters, then the text after that character up to * a matching quote will become the string in the list. * * The returned pointer should be deallocated with @code{free(3C)} when * are done using the data. The data are placed in a single block of * allocated memory. Do not deallocate individual token/strings. * * The structure pointed to will contain at least these two fields: * @table @samp * @item tkn_ct * The number of tokens found in the input string. * @item tok_list * An array of @code{tkn_ct + 1} pointers to substring tokens, with * the last pointer set to NULL. * @end table * * There are two types of quoted strings: single quoted (@code{'}) and * double quoted (@code{"}). Singly quoted strings are fairly raw in that * escape characters (@code{\\}) are simply another character, except when * preceding the following characters: * @example * @code{\\} double backslashes reduce to one * @code{'} incorporates the single quote into the string * @code{\n} suppresses both the backslash and newline character * @end example * * Double quote strings are formed according to the rules of string * constants in ANSI-C programs. * * @param string string to be tokenized * * @return token_list_t * - pointer to a structure that lists each token */ extern token_list_t * ao_string_tokenize(char const *); /** * configFileLoad - parse a configuration file * * This routine will load a named configuration file and parse the * text as a hierarchically valued option. The option descriptor * created from an option definition file is not used via this interface. * The returned value is "named" with the input file name and is of * type "@code{OPARG_TYPE_HIERARCHY}". It may be used in calls to * @code{optionGetValue()}, @code{optionNextValue()} and * @code{optionUnloadNested()}. * * @param fname the file to load * * @return const tOptionValue * - An allocated, compound value structure */ extern const tOptionValue * configFileLoad(char const *); /** * optionFileLoad - Load the locatable config files, in order * * This function looks in all the specified directories for a configuration * file ("rc" file or "ini" file) and processes any found twice. The first * time through, they are processed in reverse order (last file first). At * that time, only "immediate action" configurables are processed. For * example, if the last named file specifies not processing any more * configuration files, then no more configuration files will be processed. * Such an option in the @strong{first} named directory will have no effect. * * Once the immediate action configurables have been handled, then the * directories are handled in normal, forward order. In that way, later * config files can override the settings of earlier config files. * * See the AutoOpts documentation for a thorough discussion of the * config file format. * * Configuration files not found or not decipherable are simply ignored. * * @param opts program options descriptor * @param prog program name * * @return int - 0 -> SUCCESS, -1 -> FAILURE */ extern int optionFileLoad(tOptions *, char const *); /** * optionFindNextValue - find a hierarcicaly valued option instance * * This routine will find the next entry in a nested value option or * configurable. It will search through the list and return the next entry * that matches the criteria. * * @param odesc an option with a nested arg type * @param pPrevVal the last entry * @param name name of value to find * @param value the matching value * * @return const tOptionValue * - a compound value structure */ extern const tOptionValue * optionFindNextValue(const tOptDesc *, const tOptionValue *, char const *, char const *); /** * optionFindValue - find a hierarcicaly valued option instance * * This routine will find an entry in a nested value option or configurable. * It will search through the list and return a matching entry. * * @param odesc an option with a nested arg type * @param name name of value to find * @param val the matching value * * @return const tOptionValue * - a compound value structure */ extern const tOptionValue * optionFindValue(const tOptDesc *, char const *, char const *); /** * optionFree - free allocated option processing memory * * AutoOpts sometimes allocates memory and puts pointers to it in the * option state structures. This routine deallocates all such memory. * * @param pOpts program options descriptor */ extern void optionFree(tOptions *); /** * optionGetValue - get a specific value from a hierarcical list * * This routine will find an entry in a nested value option or configurable. * If "valueName" is NULL, then the first entry is returned. Otherwise, * the first entry with a name that exactly matches the argument will be * returned. If there is no matching value, NULL is returned and errno is * set to ENOENT. If the provided option value is not a hierarchical value, * NULL is also returned and errno is set to EINVAL. * * @param pOptValue a hierarchcal value * @param valueName name of value to get * * @return const tOptionValue * - a compound value structure */ extern const tOptionValue * optionGetValue(const tOptionValue *, char const *); /** * optionLoadLine - process a string for an option name and value * * This is a client program callable routine for setting options from, for * example, the contents of a file that they read in. Only one option may * appear in the text. It will be treated as a normal (non-preset) option. * * When passed a pointer to the option struct and a string, it will find * the option named by the first token on the string and set the option * argument to the remainder of the string. The caller must NUL terminate * the string. The caller need not skip over any introductory hyphens. * Any embedded new lines will be included in the option * argument. If the input looks like one or more quoted strings, then the * input will be "cooked". The "cooking" is identical to the string * formation used in AutoGen definition files (@pxref{basic expression}), * except that you may not use backquotes. * * @param opts program options descriptor * @param line NUL-terminated text */ extern void optionLoadLine(tOptions *, char const *); /** * optionMemberList - Get the list of members of a bit mask set * * This converts the OPT_VALUE_name mask value to a allocated string. * It is the caller's responsibility to free the string. * * @param od the set membership option description * * @return char * - the names of the set bits */ extern char * optionMemberList(tOptDesc *); /** * optionNextValue - get the next value from a hierarchical list * * This routine will return the next entry after the entry passed in. At the * end of the list, NULL will be returned. If the entry is not found on the * list, NULL will be returned and "@var{errno}" will be set to EINVAL. * The "@var{pOldValue}" must have been gotten from a prior call to this * routine or to "@code{opitonGetValue()}". * * @param pOptValue a hierarchcal list value * @param pOldValue a value from this list * * @return const tOptionValue * - a compound value structure */ extern const tOptionValue * optionNextValue(const tOptionValue *, const tOptionValue *); /** * optionOnlyUsage - Print usage text for just the options * * This routine will print only the usage for each option. * This function may be used when the emitted usage must incorporate * information not available to AutoOpts. * * @param pOpts program options descriptor * @param ex_code exit code for calling exit(3) */ extern void optionOnlyUsage(tOptions *, int); /** * optionPrintVersion - Print the program version * * This routine will print the version to stdout. * * @param opts program options descriptor * @param od the descriptor for this arg */ extern void optionPrintVersion(tOptions *, tOptDesc *); /** * optionPrintVersionAndReturn - Print the program version * * This routine will print the version to stdout and return * instead of exiting. Please see the source for the * @code{print_ver} funtion for details on selecting how * verbose to be after this function returns. * * @param opts program options descriptor * @param od the descriptor for this arg */ extern void optionPrintVersionAndReturn(tOptions *, tOptDesc *); /** * optionProcess - this is the main option processing routine * * This is the main entry point for processing options. It is intended * that this procedure be called once at the beginning of the execution of * a program. Depending on options selected earlier, it is sometimes * necessary to stop and restart option processing, or to select completely * different sets of options. This can be done easily, but you generally * do not want to do this. * * The number of arguments processed always includes the program name. * If one of the arguments is "--", then it is counted and the processing * stops. If an error was encountered and errors are to be tolerated, then * the returned value is the index of the argument causing the error. * A hyphen by itself ("-") will also cause processing to stop and will * @emph{not} be counted among the processed arguments. A hyphen by itself * is treated as an operand. Encountering an operand stops option * processing. * * @param opts program options descriptor * @param a_ct program arg count * @param a_v program arg vector * * @return int - the count of the arguments processed */ extern int optionProcess(tOptions *, int, char **); /** * optionRestore - restore option state from memory copy * * Copy back the option state from saved memory. * The allocated memory is left intact, so this routine can be * called repeatedly without having to call optionSaveState again. * If you are restoring a state that was saved before the first call * to optionProcess(3AO), then you may change the contents of the * argc/argv parameters to optionProcess. * * @param pOpts program options descriptor */ extern void optionRestore(tOptions *); /** * optionSaveFile - saves the option state to a file * * This routine will save the state of option processing to a file. The name * of that file can be specified with the argument to the @code{--save-opts} * option, or by appending the @code{rcfile} attribute to the last * @code{homerc} attribute. If no @code{rcfile} attribute was specified, it * will default to @code{.@i{programname}rc}. If you wish to specify another * file, you should invoke the @code{SET_OPT_SAVE_OPTS(@i{filename})} macro. * * The recommend usage is as follows: * @example * optionProcess(&progOptions, argc, argv); * if (i_want_a_non_standard_place_for_this) * SET_OPT_SAVE_OPTS("myfilename"); * optionSaveFile(&progOptions); * @end example * * @param opts program options descriptor */ extern void optionSaveFile(tOptions *); /** * optionSaveState - saves the option state to memory * * This routine will allocate enough memory to save the current option * processing state. If this routine has been called before, that memory * will be reused. You may only save one copy of the option state. This * routine may be called before optionProcess(3AO). If you do call it * before the first call to optionProcess, then you may also change the * contents of argc/argv after you call optionRestore(3AO) * * In fact, more strongly put: it is safest to only use this function * before having processed any options. In particular, the saving and * restoring of stacked string arguments and hierarchical values is * disabled. The values are not saved. * * @param pOpts program options descriptor */ extern void optionSaveState(tOptions *); /** * optionUnloadNested - Deallocate the memory for a nested value * * A nested value needs to be deallocated. The pointer passed in should * have been gotten from a call to @code{configFileLoad()} (See * @pxref{libopts-configFileLoad}). * * @param pOptVal the hierarchical value */ extern void optionUnloadNested(tOptionValue const *); /** * optionVersion - return the compiled AutoOpts version number * * Returns the full version string compiled into the library. * The returned string cannot be modified. * * @return char const * - the version string in constant memory */ extern char const * optionVersion(void); /** * strequate - map a list of characters to the same value * * Each character in the input string get mapped to the first character * in the string. * This function name is mapped to option_strequate so as to not conflict * with the POSIX name space. * * @param ch_list characters to equivalence */ extern void strequate(char const *); /** * streqvcmp - compare two strings with an equivalence mapping * * Using a character mapping, two strings are compared for "equivalence". * Each input character is mapped to a comparison character and the * mapped-to characters are compared for the two NUL terminated input strings. * This function name is mapped to option_streqvcmp so as to not conflict * with the POSIX name space. * * @param str1 first string * @param str2 second string * * @return int - the difference between two differing characters */ extern int streqvcmp(char const *, char const *); /** * streqvmap - Set the character mappings for the streqv functions * * Set the character mapping. If the count (@code{ct}) is set to zero, then * the map is cleared by setting all entries in the map to their index * value. Otherwise, the "@code{From}" character is mapped to the "@code{To}" * character. If @code{ct} is greater than 1, then @code{From} and @code{To} * are incremented and the process repeated until @code{ct} entries have been * set. For example, * @example * streqvmap('a', 'A', 26); * @end example * @noindent * will alter the mapping so that all English lower case letters * will map to upper case. * * This function name is mapped to option_streqvmap so as to not conflict * with the POSIX name space. * * @param from Input character * @param to Mapped-to character * @param ct compare length */ extern void streqvmap(char, char, int); /** * strneqvcmp - compare two strings with an equivalence mapping * * Using a character mapping, two strings are compared for "equivalence". * Each input character is mapped to a comparison character and the * mapped-to characters are compared for the two NUL terminated input strings. * The comparison is limited to @code{ct} bytes. * This function name is mapped to option_strneqvcmp so as to not conflict * with the POSIX name space. * * @param str1 first string * @param str2 second string * @param ct compare length * * @return int - the difference between two differing characters */ extern int strneqvcmp(char const *, char const *, int); /** * strtransform - convert a string into its mapped-to value * * Each character in the input string is mapped and the mapped-to * character is put into the output. * This function name is mapped to option_strtransform so as to not conflict * with the POSIX name space. * * The source and destination may be the same. * * @param dest output string * @param src input string */ extern void strtransform(char *, char const *); /* AutoOpts PRIVATE FUNCTIONS: */ tOptProc optionStackArg, optionUnstackArg, optionBooleanVal, optionNumericVal; extern char * ao_string_cook(char *, int *); extern unsigned int ao_string_cook_escape_char(char const *, char *, unsigned int); extern void genshelloptUsage(tOptions *, int); extern int optionAlias(tOptions *, tOptDesc *, unsigned int); extern void optionBooleanVal(tOptions *, tOptDesc *); extern uintptr_t optionEnumerationVal(tOptions *, tOptDesc *, char const * const *, unsigned int); extern void optionFileCheck(tOptions *, tOptDesc *, teOptFileType, tuFileMode); extern char const * optionKeywordName(tOptDesc *, unsigned int); extern void optionLoadOpt(tOptions *, tOptDesc *); extern bool optionMakePath(char *, int, char const *, char const *); extern void optionNestedVal(tOptions *, tOptDesc *); extern void optionNumericVal(tOptions *, tOptDesc *); extern void optionPagedUsage(tOptions *, tOptDesc *); extern void optionParseShell(tOptions *); extern void optionPrintParagraphs(char const *, bool, FILE *); extern void optionPutShell(tOptions *); extern char const * optionQuoteString(char const *, char const *); extern void optionResetOpt(tOptions *, tOptDesc *); extern void optionSetMembers(tOptions *, tOptDesc *, char const * const *, unsigned int); extern void optionShowRange(tOptions *, tOptDesc *, void *, int); extern void optionStackArg(tOptions *, tOptDesc *); extern void optionTimeDate(tOptions *, tOptDesc *); extern void optionTimeVal(tOptions *, tOptDesc *); extern void optionUnstackArg(tOptions *, tOptDesc *); extern void optionUsage(tOptions *, int); extern void optionVendorOption(tOptions *, tOptDesc *); extern void optionVersionStderr(tOptions *, tOptDesc *); extern void * text_mmap(char const *, int, int, tmap_info_t *); extern int text_munmap(tmap_info_t *); CPLUSPLUS_CLOSER #endif /* AUTOOPTS_OPTIONS_H_GUARD */ /** @} * * Local Variables: * c-file-style: "stroustrup" * indent-tabs-mode: nil * End: * options.h ends here */
61527ca8c9b749953f7c045e886aa2d104f191e0
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
/src/mono/mono/eventpipe/ep-rt-mono.c
de9d2e8671c07ee3ddf70787063bc46d7ea9161e
[ "MIT" ]
permissive
dotnet/runtime
f6fd23936752e202f8e4d6d94f3a4f3b0e77f58f
47bb554d298e1e34c4e3895d7731e18ad1c47d02
refs/heads/main
2023-09-03T15:35:46.493337
2023-09-03T08:13:23
2023-09-03T08:13:23
210,716,005
13,765
5,179
MIT
2023-09-14T21:58:52
2019-09-24T23:36:39
C#
UTF-8
C
false
false
25,889
c
ep-rt-mono.c
#include <config.h> #ifdef ENABLE_PERFTRACING #include <eventpipe/ep-rt-config.h> #include <eventpipe/ep-types.h> #include <eventpipe/ep-rt.h> #include <eventpipe/ep.h> #include <eventpipe/ep-session.h> #include <mono/utils/mono-lazy-init.h> #include <mono/utils/mono-time.h> #include <mono/utils/mono-threads.h> #include <mono/utils/mono-rand.h> #include <mono/metadata/profiler.h> #include <mono/mini/mini-runtime.h> #include <minipal/getexepath.h> #include <runtime_version.h> #include <clretwallmain.h> extern void InitProvidersAndEvents (void); // EventPipe init state. static gboolean _eventpipe_initialized; // Runtime init state. gboolean _ep_rt_mono_runtime_initialized; // EventPipe TLS key. MonoNativeTlsKey _ep_rt_mono_thread_holder_tls_id; static MonoNativeTlsKey _thread_data_tls_id; // Random byte provider. static gpointer _rand_provider; // EventPipe global config lock. ep_rt_spin_lock_handle_t _ep_rt_mono_config_lock = {0}; // OS cmd line. mono_lazy_init_t _ep_rt_mono_os_cmd_line_init = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED; char *_ep_rt_mono_os_cmd_line = NULL; // Managed cmd line. mono_lazy_init_t _ep_rt_mono_managed_cmd_line_init = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED; char *_ep_rt_mono_managed_cmd_line = NULL; // Mono profilers (shared with runtime provider). MonoProfilerHandle _ep_rt_mono_default_profiler_provider = NULL; // Providers EVENTPIPE_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context = {0}; EVENTPIPE_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context = {0}; EVENTPIPE_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_DOTNET_Context = {0}; EVENTPIPE_TRACE_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_STRESS_PROVIDER_DOTNET_Context = {0}; EVENTPIPE_TRACE_CONTEXT MICROSOFT_DOTNETRUNTIME_MONO_PROFILER_PROVIDER_DOTNET_Context = {0}; #define RUNTIME_PROVIDER_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context #define RUNTIME_PRIVATE_PROVIDER_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_DOTNET_Context #define RUNTIME_RUNDOWN_PROVIDER_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_DOTNET_Context #define RUNTIME_STRESS_PROVIDER_CONTEXT MICROSOFT_WINDOWS_DOTNETRUNTIME_STRESS_PROVIDER_DOTNET_Context #define RUNTIME_MONO_PROFILER_PROVIDER_CONTEXT MICROSOFT_DOTNETRUNTIME_MONO_PROFILER_PROVIDER_DOTNET_Context void ep_rt_mono_thread_exited (void); bool ep_rt_mono_rand_try_get_bytes ( uint8_t *buffer, size_t buffer_size) { EP_ASSERT (_rand_provider != NULL); ERROR_DECL (error); return mono_rand_try_get_bytes (&_rand_provider, (guchar *)buffer, (gssize)buffer_size, error); } char * ep_rt_mono_get_managed_cmd_line (void) { return mono_runtime_get_managed_cmd_line (); } char * ep_rt_mono_get_os_cmd_line (void) { MONO_REQ_GC_NEUTRAL_MODE; // we only return the native host here since getting the full commandline is complicated and // it's not super important to have the correct value since it'll only be used during startup // until we have the managed commandline char *host_path = minipal_getexepath (); // minipal_getexepath doesn't use Mono APIs to allocate strings so // we can't use g_free (which the callers of this method expect to do) // so create another copy and return that one char *res = g_strdup (host_path); free (host_path); return res; } #ifdef HOST_WIN32 ep_rt_file_handle_t ep_rt_mono_file_open_write (const ep_char8_t *path) { if (!path) return INVALID_HANDLE_VALUE; ep_char16_t *path_utf16 = ep_rt_utf8_to_utf16le_string (path); if (!path_utf16) return INVALID_HANDLE_VALUE; ep_rt_file_handle_t res; MONO_ENTER_GC_SAFE; res = (ep_rt_file_handle_t)CreateFileW (path_utf16, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); MONO_EXIT_GC_SAFE; ep_rt_utf16_string_free (path_utf16); return res; } bool ep_rt_mono_file_close (ep_rt_file_handle_t handle) { bool res; MONO_ENTER_GC_SAFE; res = CloseHandle (handle); MONO_EXIT_GC_SAFE; return res; } static void win32_io_interrupt_handler (void *ignored) { } bool ep_rt_mono_file_write ( ep_rt_file_handle_t handle, const uint8_t *buffer, uint32_t numbytes, uint32_t *byteswritten) { MONO_REQ_GC_UNSAFE_MODE; bool res; MonoThreadInfo *info = mono_thread_info_current (); gboolean alerted = FALSE; if (info) { mono_thread_info_install_interrupt (win32_io_interrupt_handler, NULL, &alerted); if (alerted) { return false; } mono_win32_enter_blocking_io_call (info, handle); } MONO_ENTER_GC_SAFE; if (info && mono_thread_info_is_interrupt_state (info)) { res = false; } else { res = WriteFile (handle, buffer, numbytes, (PDWORD)byteswritten, NULL) ? true : false; } MONO_EXIT_GC_SAFE; if (info) { mono_win32_leave_blocking_io_call (info, handle); mono_thread_info_uninstall_interrupt (&alerted); } return res; } #else #include <fcntl.h> #include <unistd.h> ep_rt_file_handle_t ep_rt_mono_file_open_write (const ep_char8_t *path) { int fd; mode_t perms = 0666; if (!path) return INVALID_HANDLE_VALUE; MONO_ENTER_GC_SAFE; fd = creat (path, perms); MONO_EXIT_GC_SAFE; if (fd == -1) return INVALID_HANDLE_VALUE; return (ep_rt_file_handle_t)(ptrdiff_t)fd; } bool ep_rt_mono_file_close (ep_rt_file_handle_t handle) { int fd = (int)(ptrdiff_t)handle; MONO_ENTER_GC_SAFE; close (fd); MONO_EXIT_GC_SAFE; return true; } bool ep_rt_mono_file_write ( ep_rt_file_handle_t handle, const uint8_t *buffer, uint32_t numbytes, uint32_t *byteswritten) { MONO_REQ_GC_UNSAFE_MODE; int fd = (int)(ptrdiff_t)handle; uint32_t ret; MonoThreadInfo *info = mono_thread_info_current (); if (byteswritten != NULL) *byteswritten = 0; do { MONO_ENTER_GC_SAFE; ret = write (fd, buffer, numbytes); MONO_EXIT_GC_SAFE; } while (ret == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info)); if (ret == -1) { if (errno == EINTR) ret = 0; else return false; } if (byteswritten != NULL) *byteswritten = ret; return true; } #endif // HOST_WIN32 EventPipeThread * ep_rt_mono_thread_get_or_create (void) { EventPipeThreadHolder *thread_holder = (EventPipeThreadHolder *)mono_native_tls_get_value (_ep_rt_mono_thread_holder_tls_id); if (!thread_holder) { thread_holder = thread_holder_alloc_func (); mono_native_tls_set_value (_ep_rt_mono_thread_holder_tls_id, thread_holder); } return ep_thread_holder_get_thread (thread_holder); } EventPipeMonoThreadData * ep_rt_mono_thread_data_get_or_create (void) { EventPipeMonoThreadData *thread_data = (EventPipeMonoThreadData *)mono_native_tls_get_value (_thread_data_tls_id); if (!thread_data) { thread_data = ep_rt_object_alloc (EventPipeMonoThreadData); mono_native_tls_set_value (_thread_data_tls_id, thread_data); } return thread_data; } void * ep_rt_mono_thread_attach (bool background_thread) { MonoThread *thread = NULL; // NOTE, under netcore, only root domain exists. if (!mono_thread_current ()) { thread = mono_thread_internal_attach (mono_get_root_domain ()); if (background_thread && thread) { mono_thread_set_state (thread, ThreadState_Background); mono_thread_info_set_flags (MONO_THREAD_INFO_FLAGS_NO_SAMPLE); } } return thread; } void * ep_rt_mono_thread_attach_2 (bool background_thread, EventPipeThreadType thread_type) { void *result = ep_rt_mono_thread_attach (background_thread); if (result && thread_type == EP_THREAD_TYPE_SAMPLING) { // Increase sampling thread priority, accepting failures. #ifdef HOST_WIN32 SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST); #elif _POSIX_PRIORITY_SCHEDULING int policy; int priority; struct sched_param param; int schedparam_result = pthread_getschedparam (pthread_self (), &policy, &param); if (schedparam_result == 0) { // Attempt to switch the thread to real time scheduling. This will not // necessarily work on all OSs; for example, most Linux systems will give // us EPERM here unless configured to allow this. priority = param.sched_priority; param.sched_priority = sched_get_priority_max (SCHED_RR); if (param.sched_priority != -1) { schedparam_result = pthread_setschedparam (pthread_self (), SCHED_RR, &param); if (schedparam_result != 0) { // Fallback, attempt to increase to max priority using current policy. param.sched_priority = sched_get_priority_max (policy); if (param.sched_priority != -1 && param.sched_priority != priority) pthread_setschedparam (pthread_self (), policy, &param); } } } #endif } return result; } void ep_rt_mono_thread_detach (void) { MonoThread *current_thread = mono_thread_current (); if (current_thread) mono_thread_internal_detach (current_thread); } void ep_rt_mono_thread_exited (void) { if (_eventpipe_initialized) { EventPipeThreadHolder *thread_holder = (EventPipeThreadHolder *)mono_native_tls_get_value (_ep_rt_mono_thread_holder_tls_id); if (thread_holder) thread_holder_free_func (thread_holder); mono_native_tls_set_value (_ep_rt_mono_thread_holder_tls_id, NULL); EventPipeMonoThreadData *thread_data = (EventPipeMonoThreadData *)mono_native_tls_get_value (_thread_data_tls_id); if (thread_data) ep_rt_object_free (thread_data); mono_native_tls_set_value (_thread_data_tls_id, NULL); } } #ifdef HOST_WIN32 int64_t ep_rt_mono_perf_counter_query (void) { LARGE_INTEGER value; if (QueryPerformanceCounter (&value)) return (int64_t)value.QuadPart; else return 0; } int64_t ep_rt_mono_perf_frequency_query (void) { LARGE_INTEGER value; if (QueryPerformanceFrequency (&value)) return (int64_t)value.QuadPart; else return 0; } void ep_rt_mono_system_time_get (EventPipeSystemTime *system_time) { SYSTEMTIME value; GetSystemTime (&value); EP_ASSERT (system_time != NULL); ep_system_time_set ( system_time, value.wYear, value.wMonth, value.wDayOfWeek, value.wDay, value.wHour, value.wMinute, value.wSecond, value.wMilliseconds); } int64_t ep_rt_mono_system_timestamp_get (void) { FILETIME value; GetSystemTimeAsFileTime (&value); return (int64_t)((((uint64_t)value.dwHighDateTime) << 32) | (uint64_t)value.dwLowDateTime); } #else #include <sys/types.h> #include <sys/stat.h> #include <utime.h> #include <time.h> #if HAVE_SYS_TIME_H #include <sys/time.h> #endif // HAVE_SYS_TIME_H #if HAVE_MACH_ABSOLUTE_TIME #include <mach/mach_time.h> static mono_lazy_init_t _ep_rt_mono_time_base_info_init = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED; static mach_timebase_info_data_t _ep_rt_mono_time_base_info = {0}; #endif #ifdef HAVE_LOCALTIME_R #define HAVE_GMTIME_R 1 #endif static const int64_t SECS_BETWEEN_1601_AND_1970_EPOCHS = 11644473600LL; static const int64_t SECS_TO_100NS = 10000000; static const int64_t SECS_TO_NS = 1000000000; static const int64_t MSECS_TO_MIS = 1000; /* clock_gettime () is found by configure on Apple builds, but its only present from ios 10, macos 10.12, tvos 10 and watchos 3 */ #if defined (HAVE_CLOCK_MONOTONIC) && (defined(HOST_IOS) || defined(HOST_OSX) || defined(HOST_WATCHOS) || defined(HOST_TVOS)) #undef HAVE_CLOCK_MONOTONIC #endif #ifndef HAVE_CLOCK_MONOTONIC static const int64_t MISECS_TO_NS = 1000; #endif static void time_base_info_lazy_init (void); static int64_t system_time_to_int64 ( time_t sec, long nsec); #if HAVE_MACH_ABSOLUTE_TIME static void time_base_info_lazy_init (void) { kern_return_t result = mach_timebase_info (&_ep_rt_mono_time_base_info); if (result != KERN_SUCCESS) memset (&_ep_rt_mono_time_base_info, 0, sizeof (_ep_rt_mono_time_base_info)); } #endif int64_t ep_rt_mono_perf_counter_query (void) { #if HAVE_MACH_ABSOLUTE_TIME return (int64_t)mach_absolute_time (); #elif HAVE_CLOCK_MONOTONIC struct timespec ts; int result = clock_gettime (CLOCK_MONOTONIC, &ts); if (result == 0) return ((int64_t)(ts.tv_sec) * (int64_t)(SECS_TO_NS)) + (int64_t)(ts.tv_nsec); #else #error "ep_rt_mono_perf_counter_get requires either mach_absolute_time () or clock_gettime (CLOCK_MONOTONIC) to be supported." #endif return 0; } int64_t ep_rt_mono_perf_frequency_query (void) { #if HAVE_MACH_ABSOLUTE_TIME // (numer / denom) gives you the nanoseconds per tick, so the below code // computes the number of ticks per second. We explicitly do the multiplication // first in order to help minimize the error that is produced by integer division. mono_lazy_initialize (&_ep_rt_mono_time_base_info_init, time_base_info_lazy_init); if (_ep_rt_mono_time_base_info.denom == 0 || _ep_rt_mono_time_base_info.numer == 0) return 0; return ((int64_t)(SECS_TO_NS) * (int64_t)(_ep_rt_mono_time_base_info.denom)) / (int64_t)(_ep_rt_mono_time_base_info.numer); #elif HAVE_CLOCK_MONOTONIC // clock_gettime () returns a result in terms of nanoseconds rather than a count. This // means that we need to either always scale the result by the actual resolution (to // get a count) or we need to say the resolution is in terms of nanoseconds. We prefer // the latter since it allows the highest throughput and should minimize error propagated // to the user. return (int64_t)(SECS_TO_NS); #else #error "ep_rt_mono_perf_frequency_query requires either mach_absolute_time () or clock_gettime (CLOCK_MONOTONIC) to be supported." #endif return 0; } void ep_rt_mono_system_time_get (EventPipeSystemTime *system_time) { time_t tt; #if HAVE_GMTIME_R struct tm ut; #endif /* HAVE_GMTIME_R */ struct tm *ut_ptr; struct timeval time_val; int timeofday_retval; EP_ASSERT (system_time != NULL); tt = time (NULL); /* We can't get millisecond resolution from time (), so we get it from gettimeofday () */ timeofday_retval = gettimeofday (&time_val, NULL); #if HAVE_GMTIME_R ut_ptr = &ut; if (gmtime_r (&tt, ut_ptr) == NULL) #else /* HAVE_GMTIME_R */ if ((ut_ptr = gmtime (&tt)) == NULL) #endif /* HAVE_GMTIME_R */ EP_UNREACHABLE (); uint16_t milliseconds = 0; if (timeofday_retval != -1) { int old_seconds; int new_seconds; milliseconds = (uint16_t)(time_val.tv_usec / MSECS_TO_MIS); old_seconds = ut_ptr->tm_sec; new_seconds = time_val.tv_sec % 60; /* just in case we reached the next second in the interval between time () and gettimeofday () */ if (old_seconds != new_seconds) milliseconds = 999; } ep_system_time_set ( system_time, (uint16_t)(1900 + ut_ptr->tm_year), (uint16_t)ut_ptr->tm_mon + 1, (uint16_t)ut_ptr->tm_wday, (uint16_t)ut_ptr->tm_mday, (uint16_t)ut_ptr->tm_hour, (uint16_t)ut_ptr->tm_min, (uint16_t)ut_ptr->tm_sec, milliseconds); } static int64_t system_time_to_int64 ( time_t sec, long nsec) { return ((int64_t)sec + SECS_BETWEEN_1601_AND_1970_EPOCHS) * SECS_TO_100NS + (nsec / 100); } int64_t ep_rt_mono_system_timestamp_get (void) { #if HAVE_CLOCK_MONOTONIC struct timespec time; if (clock_gettime (CLOCK_REALTIME, &time) == 0) return system_time_to_int64 (time.tv_sec, time.tv_nsec); #else struct timeval time; if (gettimeofday (&time, NULL) == 0) return system_time_to_int64 (time.tv_sec, time.tv_usec * MISECS_TO_NS); #endif else return system_time_to_int64 (0, 0); } #endif #ifndef HOST_WIN32 #if defined(__APPLE__) #if defined (HOST_OSX) G_BEGIN_DECLS gchar ***_NSGetEnviron(void); G_END_DECLS #define environ (*_NSGetEnviron()) #else static char *_ep_rt_mono_environ[1] = { NULL }; #define environ _ep_rt_mono_environ #endif /* defined (HOST_OSX) */ #else G_BEGIN_DECLS extern char **environ; G_END_DECLS #endif /* defined (__APPLE__) */ #endif /* !defined (HOST_WIN32) */ void ep_rt_mono_os_environment_get_utf16 (dn_vector_ptr_t *os_env) { EP_ASSERT (os_env != NULL); #ifdef HOST_WIN32 LPWSTR envs = GetEnvironmentStringsW (); if (envs) { LPWSTR next = envs; while (*next) { dn_vector_ptr_push_back (os_env, ep_rt_utf16_string_dup (next)); next += ep_rt_utf16_string_len (next) + 1; } FreeEnvironmentStringsW (envs); } #else gchar **next = NULL; for (next = environ; *next != NULL; ++next) dn_vector_ptr_push_back (os_env, ep_rt_utf8_to_utf16le_string (*next)); #endif } void ep_rt_mono_init_providers_and_events (void) { InitProvidersAndEvents (); } void ep_rt_mono_provider_config_init (EventPipeProviderConfiguration *provider_config) { if (!ep_rt_utf8_string_compare (ep_config_get_rundown_provider_name_utf8 (), ep_provider_config_get_provider_name (provider_config))) { RUNTIME_RUNDOWN_PROVIDER_CONTEXT.Level = (uint8_t)ep_provider_config_get_logging_level (provider_config); RUNTIME_RUNDOWN_PROVIDER_CONTEXT.EnabledKeywordsBitmask = ep_provider_config_get_keywords (provider_config); RUNTIME_RUNDOWN_PROVIDER_CONTEXT.IsEnabled = true; } } bool ep_rt_mono_providers_validate_all_disabled (void) { return (!RUNTIME_PROVIDER_CONTEXT.IsEnabled && !RUNTIME_PRIVATE_PROVIDER_CONTEXT.IsEnabled && !RUNTIME_RUNDOWN_PROVIDER_CONTEXT.IsEnabled && !RUNTIME_STRESS_PROVIDER_CONTEXT.IsEnabled && !RUNTIME_MONO_PROFILER_PROVIDER_CONTEXT.IsEnabled); } bool ep_rt_mono_method_get_simple_assembly_name ( ep_rt_method_desc_t *method, ep_char8_t *name, size_t name_len) { EP_ASSERT (method != NULL); EP_ASSERT (name != NULL); MonoClass *method_class = mono_method_get_class (method); MonoImage *method_image = method_class ? mono_class_get_image (method_class) : NULL; const ep_char8_t *assembly_name = method_image ? mono_image_get_name (method_image) : NULL; if (!assembly_name) return false; g_strlcpy (name, assembly_name, name_len); return true; } bool ep_rt_mono_method_get_full_name ( ep_rt_method_desc_t *method, ep_char8_t *name, size_t name_len) { EP_ASSERT (method != NULL); EP_ASSERT (name != NULL); char *full_method_name = mono_method_get_name_full (method, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL); if (!full_method_name) return false; g_strlcpy (name, full_method_name, name_len); g_free (full_method_name); return true; } static bool is_keword_enabled (uint64_t enabled_keywords, uint64_t keyword) { return (enabled_keywords & keyword) == keyword; } uint64_t ep_rt_mono_session_calculate_and_count_all_keywords ( const ep_char8_t *provider, uint64_t keywords[], uint64_t count[], size_t len) { ep_requires_lock_held (); uint64_t keywords_for_all_sessions = 0; for (int i = 0; i < EP_MAX_NUMBER_OF_SESSIONS; i++) { EventPipeSession *session = ep_volatile_load_session_without_barrier (i); if (session) { EventPipeSessionProviderList *providers = ep_session_get_providers (session); EP_ASSERT (providers != NULL); EventPipeSessionProvider *session_provider = ep_session_provider_list_find_by_name (ep_session_provider_list_get_providers (providers), provider); if (session_provider) { uint64_t session_keywords = ep_session_provider_get_keywords (session_provider); for (uint64_t j = 0; j < len; j++) { if (is_keword_enabled (session_keywords, keywords [j])) count [j]++; } keywords_for_all_sessions = keywords_for_all_sessions | session_keywords; } } } ep_requires_lock_held (); return keywords_for_all_sessions; } bool ep_rt_mono_sesion_has_all_started (void) { ep_requires_lock_held (); bool all_started = true; for (uint32_t i = 0; i < EP_MAX_NUMBER_OF_SESSIONS; ++i) { EventPipeSession *session = ep_volatile_load_session_without_barrier (i); if (session) { all_started = ep_session_has_started (session); if (!all_started) break; } } ep_requires_lock_held (); return all_started; } static void runtime_initialized_callback (MonoProfiler *prof) { _ep_rt_mono_runtime_initialized = TRUE; } static void thread_started_callback ( MonoProfiler *prof, uintptr_t tid) { ep_rt_mono_runtime_provider_thread_started_callback (prof, tid); } static void thread_stopped_callback ( MonoProfiler *prof, uintptr_t tid) { ep_rt_mono_runtime_provider_thread_stopped_callback (prof, tid); ep_rt_mono_thread_exited (); } void ep_rt_mono_component_init (void) { ep_rt_spin_lock_alloc (&_ep_rt_mono_config_lock); RUNTIME_PROVIDER_CONTEXT = MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_EVENTPIPE_Context; RUNTIME_PRIVATE_PROVIDER_CONTEXT = MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_EVENTPIPE_Context; RUNTIME_RUNDOWN_PROVIDER_CONTEXT = MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_EVENTPIPE_Context; RUNTIME_STRESS_PROVIDER_CONTEXT = MICROSOFT_WINDOWS_DOTNETRUNTIME_STRESS_PROVIDER_EVENTPIPE_Context; RUNTIME_MONO_PROFILER_PROVIDER_CONTEXT = MICROSOFT_DOTNETRUNTIME_MONO_PROFILER_PROVIDER_EVENTPIPE_Context; _ep_rt_mono_default_profiler_provider = mono_profiler_create (NULL); char *diag_env = g_getenv("MONO_DIAGNOSTICS"); if (diag_env) { int diag_argc = 1; char **diag_argv = g_new (char *, 1); if (diag_argv) { diag_argv [0] = NULL; if (!mono_parse_options_from (diag_env, &diag_argc, &diag_argv)) { for (int i = 0; i < diag_argc; ++i) { if (diag_argv [i]) { if (strncmp (diag_argv [i], "--diagnostic-ports=", 19) == 0) { char *diag_ports_env = g_getenv("DOTNET_DiagnosticPorts"); if (diag_ports_env) mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_DIAGNOSTICS, "DOTNET_DiagnosticPorts environment variable already set, ignoring --diagnostic-ports used in MONO_DIAGNOSTICS environment variable"); else g_setenv ("DOTNET_DiagnosticPorts", diag_argv [i] + 19, TRUE); g_free (diag_ports_env); } else if (ep_rt_mono_profiler_provider_parse_options (diag_argv [i])) { ; } else { mono_trace (G_LOG_LEVEL_ERROR, MONO_TRACE_DIAGNOSTICS, "Failed parsing MONO_DIAGNOSTICS environment variable, unknown option: %s", diag_argv [i]); } g_free (diag_argv [i]); diag_argv [i] = NULL; } } g_free (diag_argv); } else { mono_trace (G_LOG_LEVEL_ERROR, MONO_TRACE_DIAGNOSTICS, "Failed parsing MONO_DIAGNOSTICS environment variable"); } } } g_free (diag_env); ep_rt_mono_runtime_provider_component_init (); ep_rt_mono_profiler_provider_component_init (); } void ep_rt_mono_init (void) { EP_ASSERT (_ep_rt_mono_default_profiler_provider != NULL); mono_native_tls_alloc (&_ep_rt_mono_thread_holder_tls_id, NULL); mono_native_tls_alloc (&_thread_data_tls_id, NULL); mono_100ns_ticks (); mono_rand_open (); _rand_provider = mono_rand_init (NULL, 0); ep_rt_mono_runtime_provider_init (); ep_rt_mono_profiler_provider_init (); mono_profiler_set_runtime_initialized_callback (_ep_rt_mono_default_profiler_provider, runtime_initialized_callback); mono_profiler_set_thread_started_callback (_ep_rt_mono_default_profiler_provider, thread_started_callback); mono_profiler_set_thread_stopped_callback (_ep_rt_mono_default_profiler_provider, thread_stopped_callback); _eventpipe_initialized = TRUE; } void ep_rt_mono_init_finish (void) { if (mono_runtime_get_no_exec ()) return; // Managed init of diagnostics classes, like registration of RuntimeEventSource (if available). ERROR_DECL (error); MonoClass *runtime_event_source = mono_class_from_name_checked (mono_get_corlib (), "System.Diagnostics.Tracing", "RuntimeEventSource", error); if (is_ok (error) && runtime_event_source) { MonoMethod *init = mono_class_get_method_from_name_checked (runtime_event_source, "Initialize", -1, 0, error); if (is_ok (error) && init) { mono_runtime_try_invoke_handle (init, NULL_HANDLE, NULL, error); } } mono_error_cleanup (error); } void ep_rt_mono_fini (void) { ep_rt_mono_runtime_provider_fini (); ep_rt_mono_profiler_provider_fini (); if (_eventpipe_initialized) mono_rand_close (_rand_provider); _rand_provider = NULL; _eventpipe_initialized = FALSE; _ep_rt_mono_runtime_initialized = FALSE; if (_ep_rt_mono_default_profiler_provider) { mono_profiler_set_runtime_initialized_callback (_ep_rt_mono_default_profiler_provider, NULL); mono_profiler_set_thread_started_callback (_ep_rt_mono_default_profiler_provider, NULL); mono_profiler_set_thread_stopped_callback (_ep_rt_mono_default_profiler_provider, NULL); } _ep_rt_mono_default_profiler_provider = NULL; if (_ep_rt_mono_thread_holder_tls_id) mono_native_tls_free (_ep_rt_mono_thread_holder_tls_id); _ep_rt_mono_thread_holder_tls_id = 0; if (_thread_data_tls_id) mono_native_tls_free (_thread_data_tls_id); _thread_data_tls_id = 0; _ep_rt_mono_os_cmd_line_init = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED; _ep_rt_mono_os_cmd_line = NULL; _ep_rt_mono_managed_cmd_line_init = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED; _ep_rt_mono_managed_cmd_line = NULL; ep_rt_spin_lock_free (&_ep_rt_mono_config_lock); } void EP_CALLBACK_CALLTYPE EventPipeEtwCallbackDotNETRuntimeRundown ( const uint8_t *source_id, unsigned long is_enabled, uint8_t level, uint64_t match_any_keywords, uint64_t match_all_keywords, EventFilterDescriptor *filter_data, void *callback_data) { RUNTIME_RUNDOWN_PROVIDER_CONTEXT.Level = level; RUNTIME_RUNDOWN_PROVIDER_CONTEXT.EnabledKeywordsBitmask = match_any_keywords; RUNTIME_RUNDOWN_PROVIDER_CONTEXT.IsEnabled = (is_enabled == 1 ? true : false); } void EP_CALLBACK_CALLTYPE EventPipeEtwCallbackDotNETRuntimePrivate ( const uint8_t *source_id, unsigned long is_enabled, uint8_t level, uint64_t match_any_keywords, uint64_t match_all_keywords, EventFilterDescriptor *filter_data, void *callback_data) { RUNTIME_PRIVATE_PROVIDER_CONTEXT.Level = level; RUNTIME_PRIVATE_PROVIDER_CONTEXT.EnabledKeywordsBitmask = match_any_keywords; RUNTIME_PRIVATE_PROVIDER_CONTEXT.IsEnabled = (is_enabled == 1 ? true : false); } void EP_CALLBACK_CALLTYPE EventPipeEtwCallbackDotNETRuntimeStress ( const uint8_t *source_id, unsigned long is_enabled, uint8_t level, uint64_t match_any_keywords, uint64_t match_all_keywords, EventFilterDescriptor *filter_data, void *callback_data) { RUNTIME_STRESS_PROVIDER_CONTEXT.Level = level; RUNTIME_STRESS_PROVIDER_CONTEXT.EnabledKeywordsBitmask = match_any_keywords; RUNTIME_STRESS_PROVIDER_CONTEXT.IsEnabled = (is_enabled == 1 ? true : false); } #endif /* ENABLE_PERFTRACING */ MONO_EMPTY_SOURCE_FILE(eventpipe_rt_mono);
f79a820fdd40366b17d59635a3c0d78f4fdc44fe
9b886f22aabb00ecbaaba8b87f988119e0300b3f
/src/testutil.c
687aafb7bc4b1290818ac0e12b3831825a55dfdf
[ "LicenseRef-scancode-public-domain", "Apache-2.0" ]
permissive
spotify/sparkey
db0409dec26c6e96537ecbd8d40c5b2b033678da
d694f20f35caa1cb514c84f3f02e94f71248f857
refs/heads/master
2023-09-03T03:10:01.123186
2023-08-17T09:06:05
2023-08-17T09:06:05
12,488,811
505
57
Apache-2.0
2023-08-17T09:06:07
2013-08-30T14:52:09
C
UTF-8
C
false
false
1,496
c
testutil.c
/* * Copyright (c) 2012-2013 Spotify AB * * 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 <stdlib.h> #include <inttypes.h> #include "util.c" void assert_equals(const char *expected, const char *actual) { if (expected == NULL && actual != NULL) { printf("Expected NULL but got '%s'\n", actual); exit(1); } if (expected != NULL && actual == NULL) { printf("Expected '%s' but got NULL\n", expected); exit(1); } if (expected != NULL && actual != NULL && strcmp(expected, actual)) { printf("Expected '%s' but got '%s'\n", expected, actual); exit(1); } } int main() { assert_equals(NULL, sparkey_create_log_filename(NULL)); assert_equals(NULL, sparkey_create_log_filename("")); assert_equals(NULL, sparkey_create_log_filename("spi")); assert_equals(".spl", sparkey_create_log_filename(".spi")); assert_equals(NULL, sparkey_create_log_filename(".spx")); assert_equals("foo.spl", sparkey_create_log_filename("foo.spi")); printf("Success!\n"); }
3b0e8714cae4318a371d16fb7aa1778e38e3ce74
b970e053302588f44ee1c6b7187c4769934c857f
/ajax/libs/openlayers/5.0.0/proj/epsg3857.js
f47d4e8ba7519e19a9d00d67f07769acb5dd8d18
[ "MIT" ]
permissive
cdnjs/cdnjs
2fe0f21477c08618fe609da844f5d133224c3eda
6843ffa5339e4595b3a6893ae3e9ede1117cc5f9
refs/heads/master
2023-07-23T14:52:44.587645
2023-07-23T07:12:24
2023-07-23T07:12:24
1,409,811
8,894
5,633
MIT
2023-06-27T12:32:50
2011-02-25T05:53:47
null
UTF-8
C
false
false
3,561
js
epsg3857.js
/** * @module ol/proj/epsg3857 */ import {inherits} from '../util.js'; import {cosh} from '../math.js'; import Projection from '../proj/Projection.js'; import Units from '../proj/Units.js'; /** * Radius of WGS84 sphere * * @const * @type {number} */ export const RADIUS = 6378137; /** * @const * @type {number} */ export const HALF_SIZE = Math.PI * RADIUS; /** * @const * @type {module:ol/extent~Extent} */ export const EXTENT = [ -HALF_SIZE, -HALF_SIZE, HALF_SIZE, HALF_SIZE ]; /** * @const * @type {module:ol/extent~Extent} */ export const WORLD_EXTENT = [-180, -85, 180, 85]; /** * @classdesc * Projection object for web/spherical Mercator (EPSG:3857). * * @constructor * @extends {module:ol/proj/Projection} * @param {string} code Code. */ function EPSG3857Projection(code) { Projection.call(this, { code: code, units: Units.METERS, extent: EXTENT, global: true, worldExtent: WORLD_EXTENT, getPointResolution: function(resolution, point) { return resolution / cosh(point[1] / RADIUS); } }); } inherits(EPSG3857Projection, Projection); /** * Projections equal to EPSG:3857. * * @const * @type {Array.<module:ol/proj/Projection>} */ export const PROJECTIONS = [ new EPSG3857Projection('EPSG:3857'), new EPSG3857Projection('EPSG:102100'), new EPSG3857Projection('EPSG:102113'), new EPSG3857Projection('EPSG:900913'), new EPSG3857Projection('urn:ogc:def:crs:EPSG:6.18:3:3857'), new EPSG3857Projection('urn:ogc:def:crs:EPSG::3857'), new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857') ]; /** * Transformation from EPSG:4326 to EPSG:3857. * * @param {Array.<number>} input Input array of coordinate values. * @param {Array.<number>=} opt_output Output array of coordinate values. * @param {number=} opt_dimension Dimension (default is `2`). * @return {Array.<number>} Output array of coordinate values. */ export function fromEPSG4326(input, opt_output, opt_dimension) { const length = input.length; const dimension = opt_dimension > 1 ? opt_dimension : 2; let output = opt_output; if (output === undefined) { if (dimension > 2) { // preserve values beyond second dimension output = input.slice(); } else { output = new Array(length); } } const halfSize = HALF_SIZE; for (let i = 0; i < length; i += dimension) { output[i] = halfSize * input[i] / 180; let y = RADIUS * Math.log(Math.tan(Math.PI * (input[i + 1] + 90) / 360)); if (y > halfSize) { y = halfSize; } else if (y < -halfSize) { y = -halfSize; } output[i + 1] = y; } return output; } /** * Transformation from EPSG:3857 to EPSG:4326. * * @param {Array.<number>} input Input array of coordinate values. * @param {Array.<number>=} opt_output Output array of coordinate values. * @param {number=} opt_dimension Dimension (default is `2`). * @return {Array.<number>} Output array of coordinate values. */ export function toEPSG4326(input, opt_output, opt_dimension) { const length = input.length; const dimension = opt_dimension > 1 ? opt_dimension : 2; let output = opt_output; if (output === undefined) { if (dimension > 2) { // preserve values beyond second dimension output = input.slice(); } else { output = new Array(length); } } for (let i = 0; i < length; i += dimension) { output[i] = 180 * input[i] / HALF_SIZE; output[i + 1] = 360 * Math.atan( Math.exp(input[i + 1] / RADIUS)) / Math.PI - 90; } return output; }
2f9098182d6072ffde78d57cefb79936e84cec43
aa3befea459382dc5c01c925653d54f435b3fb0f
/libs/libc/unistd/lib_swab.c
2f183ff978ff0869b737ff599c76b8a9245a0c21
[ "MIT-open-group", "BSD-3-Clause", "HPND-sell-variant", "BSD-4-Clause-UC", "LicenseRef-scancode-warranty-disclaimer", "MIT-0", "LicenseRef-scancode-bsd-atmel", "LicenseRef-scancode-gary-s-brown", "LicenseRef-scancode-proprietary-license", "SunPro", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "LicenseRef-scancode-other-permissive", "HPND", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "GPL-1.0-or-later", "CC-BY-2.0", "CC-BY-4.0" ]
permissive
apache/nuttx
14519a7bff4a87935d94fb8fb2b19edb501c7cec
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
refs/heads/master
2023-08-25T06:55:45.822534
2023-08-23T16:03:31
2023-08-24T21:25:47
228,103,273
407
241
Apache-2.0
2023-09-14T18:26:05
2019-12-14T23:27:55
C
UTF-8
C
false
false
2,923
c
lib_swab.c
/**************************************************************************** * libs/libc/unistd/lib_swab.c * * 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. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <sys/types.h> #include <unistd.h> #include <assert.h> /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: swab * * Description: * The swab() function will copy nbytes bytes, which are pointed to by * 'src', to the object pointed to by 'dest', exchanging adjacent bytes. * The 'nbytes' argument should be even. If 'nbytes' is odd, swab() copies * and exchanges 'nbytes'-1 bytes and the disposition of the last byte is * unspecified. If copying takes place between objects that overlap, the * behavior is undefined. If nbytes is negative, swab() does nothing. * * Returned Value: * None * ****************************************************************************/ void swab(FAR const void *src, FAR void *dest, ssize_t nbytes) { FAR const uint8_t *src8 = (FAR const uint8_t *)src; FAR uint8_t *dest8 = (FAR uint8_t *)dest; FAR uint8_t *end8; DEBUGASSERT(src != NULL && dest != NULL); /* Do nother if nbytes is negative or it there are few then 2 bytes to be * transferred. */ if (nbytes > 1) { /* The end of dest buffer + 1 byte (skipping any odd numbered byte at * the end of the buffer. */ end8 = dest8 + (nbytes & ~1); /* Loop until the destination is equal to the end + 1 address */ while (dest8 != end8) { register uint8_t tmp; /* Transfer the bytes, swapping the order */ tmp = *src8++; *dest8++ = *src8++; *dest8++ = tmp; } } }
94508d4c1084c5fd30f36bb7441d4d0e1b60c06a
30b736259b38c916e96f8e1517f92231070f5464
/nimble/controller/include/controller/ble_ll_resolv.h
b9ca7fd38741773aa9f290dbe2eea375be7e9363
[ "Apache-2.0", "LicenseRef-scancode-gary-s-brown", "BSD-3-Clause" ]
permissive
apache/mynewt-nimble
5bcc87df4482705c5a6542467bab028c8fd4e5fe
b5e107e9c55f32d18b16e5afc0a7e1720b901b68
refs/heads/master
2023-09-01T19:28:57.874159
2023-08-31T09:07:59
2023-08-31T14:46:07
113,086,218
606
354
Apache-2.0
2023-09-14T12:14:19
2017-12-04T19:34:47
C
UTF-8
C
false
false
3,915
h
ble_ll_resolv.h
/* * 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. */ #ifndef H_BLE_LL_RESOLV_ #define H_BLE_LL_RESOLV_ #ifdef __cplusplus extern "C" { #endif /* * An entry in the resolving list. * The identity address is stored in little endian format. * The local rpa is stored in little endian format. * The IRKs are stored in big endian format. * * Note: * rl_local_irk and rl_peer_irk need to be word aligned */ struct ble_ll_resolv_entry { uint8_t rl_addr_type; uint8_t rl_priv_mode; uint8_t rl_has_local; uint8_t rl_has_peer; uint8_t rl_local_irk[16]; uint8_t rl_peer_irk[16]; uint8_t rl_identity_addr[BLE_DEV_ADDR_LEN]; uint8_t rl_local_rpa[BLE_DEV_ADDR_LEN]; uint8_t rl_peer_rpa[BLE_DEV_ADDR_LEN]; }; extern struct ble_ll_resolv_entry g_ble_ll_resolv_list[]; /* Clear the resolving list */ int ble_ll_resolv_list_clr(void); /* Read the size of the resolving list */ int ble_ll_resolv_list_read_size(uint8_t *rspbuf, uint8_t *rsplen); /* Add a device to the resolving list */ int ble_ll_resolv_list_add(const uint8_t *cmdbuf, uint8_t len); /* Remove a device from the resolving list */ int ble_ll_resolv_list_rmv(const uint8_t *cmdbuf, uint8_t len); /* Address resolution enable command */ int ble_ll_resolv_enable_cmd(const uint8_t *cmdbuf, uint8_t len); int ble_ll_resolv_peer_addr_rd(const uint8_t *cmdbuf, uint8_t len, uint8_t *rspbuf, uint8_t *rsplen); int ble_ll_resolv_local_addr_rd(const uint8_t *cmdbuf, uint8_t len, uint8_t *rspbuf, uint8_t *rsplen); /* Finds 'addr' in resolving list. Doesnt check if address resolution enabled */ struct ble_ll_resolv_entry * ble_ll_resolv_list_find(const uint8_t *addr, uint8_t addr_type); static inline int8_t ble_ll_resolv_get_idx(struct ble_ll_resolv_entry *rl) { return rl - g_ble_ll_resolv_list; } /* Returns true if address resolution is enabled */ uint8_t ble_ll_resolv_enabled(void); /* Reset private address resolution */ void ble_ll_resolv_list_reset(void); /* Generate local or peer RPA. It is up to caller to make sure required IRK * is present on RL */ void ble_ll_resolv_get_priv_addr(struct ble_ll_resolv_entry *rl, int local, uint8_t *addr); void ble_ll_resolv_set_peer_rpa(int index, uint8_t *rpa); void ble_ll_resolv_set_local_rpa(int index, uint8_t *rpa); /* Generate a resolvable private address. */ int ble_ll_resolv_gen_rpa(uint8_t *addr, uint8_t addr_type, uint8_t *rpa, int local); /* Set the resolvable private address timeout */ int ble_ll_resolv_set_rpa_tmo(const uint8_t *cmdbuf, uint8_t len); /* Set the privacy mode */ int ble_ll_resolve_set_priv_mode(const uint8_t *cmdbuf, uint8_t len); /* Get the RPA timeout, in seconds */ uint32_t ble_ll_resolv_get_rpa_tmo(void); /* Resolve a resolvable private address */ int ble_ll_resolv_rpa(const uint8_t *rpa, const uint8_t *irk); /* Try to resolve peer RPA and return index on RL if matched */ int ble_ll_resolv_peer_rpa_any(const uint8_t *rpa); /* Initialize resolv*/ void ble_ll_resolv_init(void); #ifdef __cplusplus } #endif #endif
4e9daff8ec3e9b43d9dc6593e8bcae664b572d7e
4cf3ee2c90e6ad1cea9cdba1b1e76224eee2ac4d
/apps/keymaps/keymap-x5.c
fb2fbfa605d9b12d236bf5e1c2dc4994898e361b
[]
no_license
Rockbox/rockbox
36f73fc2660f3edb32dc07db26c5f9b88851975f
67c4231e34cd8147963a054c44a715f3413fb2e3
refs/heads/master
2021-09-15T22:10:00.710240
2021-08-29T12:19:02
2021-09-12T17:35:35
3,184,247
394
157
null
2021-09-05T11:00:28
2012-01-15T15:37:35
C
UTF-8
C
false
false
25,950
c
keymap-x5.c
/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id$ * * Copyright (C) 2006 Jonathan Gordon * * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ****************************************************************************/ /* * * Button Code Definitions for iaudio m5/x5 targets * * Note that button combos are incompatible on this targets, except for those * with the power button. But these are discouraged because the the power button * also does the hardware poweroff * * \TODO test! */ #include "config.h" #include "action.h" #include "button.h" #include "settings.h" /* CONTEXT_CUSTOM's used in this file... CONTEXT_CUSTOM|CONTEXT_TREE = the standard list/tree defines (without directions) */ /** Keep things alphabetized for easy reference but standard contexts can ** be first and sub-alphebetized. **/ /** Standard Button Contexts **/ static const struct button_mapping button_context_standard[] = { { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE }, { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE }, { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE }, { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, { ACTION_STD_OK, BUTTON_PLAY, BUTTON_NONE }, { ACTION_STD_MENU, BUTTON_REC|BUTTON_REL, BUTTON_REC }, { ACTION_STD_QUICKSCREEN,BUTTON_REC|BUTTON_REPEAT, BUTTON_REC }, { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE }, LAST_ITEM_IN_LIST }; /* button_context_standard */ static const struct button_mapping remote_button_context_standard[] = { { ACTION_STD_PREV, BUTTON_RC_VOL_UP, BUTTON_NONE }, { ACTION_STD_PREVREPEAT, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_NEXT, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, { ACTION_STD_NEXTREPEAT, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_CONTEXT, BUTTON_RC_MODE|BUTTON_REPEAT, BUTTON_RC_MODE }, { ACTION_STD_CANCEL, BUTTON_RC_REW, BUTTON_NONE }, { ACTION_STD_OK, BUTTON_RC_FF, BUTTON_NONE }, { ACTION_STD_OK, BUTTON_RC_PLAY, BUTTON_NONE }, { ACTION_STD_MENU, BUTTON_RC_MENU|BUTTON_REL, BUTTON_RC_MENU }, { ACTION_STD_QUICKSCREEN, BUTTON_RC_MENU|BUTTON_REPEAT, BUTTON_RC_MENU }, LAST_ITEM_IN_LIST }; /* remote_button_context_standard */ /** Bookmark Screen **/ static const struct button_mapping button_context_bmark[] = { { ACTION_BMS_DELETE, BUTTON_REC|BUTTON_REPEAT, BUTTON_REC }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST), }; /* button_context_settings_bmark */ static const struct button_mapping remote_button_context_bmark[] = { { ACTION_BMS_DELETE, BUTTON_RC_REC|BUTTON_REPEAT, BUTTON_RC_REC }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST), }; /* button_context_settings_bmark */ /** FM Radio Screen **/ static const struct button_mapping button_context_radio[] = { { ACTION_FM_MENU, BUTTON_SELECT | BUTTON_REPEAT, BUTTON_NONE }, { ACTION_FM_PRESET, BUTTON_SELECT | BUTTON_REL, BUTTON_SELECT }, { ACTION_FM_STOP, BUTTON_POWER, BUTTON_NONE }, { ACTION_FM_MODE, BUTTON_PLAY | BUTTON_REPEAT, BUTTON_PLAY }, { ACTION_FM_EXIT, BUTTON_REC | BUTTON_REL, BUTTON_REC }, { ACTION_FM_PLAY, BUTTON_PLAY | BUTTON_REL, BUTTON_PLAY }, { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) }; /* button_context_radio */ static const struct button_mapping remote_button_context_radio[] = { { ACTION_FM_MENU, BUTTON_RC_MODE|BUTTON_REPEAT, BUTTON_RC_MODE }, { ACTION_FM_PRESET, BUTTON_RC_MODE|BUTTON_REL, BUTTON_RC_MODE }, { ACTION_FM_STOP, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_RC_PLAY }, { ACTION_FM_PLAY, BUTTON_RC_PLAY|BUTTON_REL, BUTTON_RC_PLAY }, { ACTION_FM_MODE, BUTTON_RC_REC|BUTTON_REPEAT, BUTTON_RC_REC }, { ACTION_FM_EXIT, BUTTON_RC_MENU|BUTTON_REL, BUTTON_RC_MENU }, { ACTION_STD_PREVREPEAT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_NEXT, BUTTON_RC_FF, BUTTON_NONE }, { ACTION_STD_NEXTREPEAT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) }; /* remote_button_context_radio */ /** Keyboard **/ static const struct button_mapping button_context_keyboard[] = { { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE }, { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE }, { ACTION_KBD_DONE, BUTTON_PLAY, BUTTON_NONE }, { ACTION_KBD_ABORT, BUTTON_REC, BUTTON_NONE }, { ACTION_KBD_MORSE_SELECT, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE }, LAST_ITEM_IN_LIST }; /* button_context_keyboard */ static const struct button_mapping remote_button_context_keyboard[] = { { ACTION_KBD_LEFT, BUTTON_RC_REW, BUTTON_NONE }, { ACTION_KBD_LEFT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_KBD_RIGHT, BUTTON_RC_FF, BUTTON_NONE }, { ACTION_KBD_RIGHT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_KBD_UP, BUTTON_RC_VOL_UP, BUTTON_NONE }, { ACTION_KBD_UP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_KBD_DOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, { ACTION_KBD_DOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_KBD_PAGE_FLIP, BUTTON_RC_MODE, BUTTON_NONE }, { ACTION_KBD_SELECT, BUTTON_RC_PLAY|BUTTON_REL, BUTTON_RC_PLAY }, { ACTION_KBD_DONE, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_RC_PLAY }, { ACTION_KBD_ABORT, BUTTON_RC_REC, BUTTON_NONE }, LAST_ITEM_IN_LIST }; /* remote_button_context_keyboard */ /** Pitchscreen **/ static const struct button_mapping button_context_pitchscreen[] = { { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE }, { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE }, { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_PS_NUDGE_LEFT, BUTTON_LEFT, BUTTON_NONE }, { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE }, { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE }, { ACTION_PS_TOGGLE_MODE, BUTTON_SELECT, BUTTON_NONE }, { ACTION_PS_RESET, BUTTON_POWER, BUTTON_NONE }, { ACTION_PS_EXIT, BUTTON_PLAY, BUTTON_NONE }, { ACTION_PS_SLOWER, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_PS_FASTER, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_pitchscreen */ static const struct button_mapping remote_button_context_pitchscreen[] = { { ACTION_PS_INC_SMALL, BUTTON_RC_VOL_UP, BUTTON_NONE }, { ACTION_PS_INC_BIG, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_PS_DEC_SMALL, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, { ACTION_PS_DEC_BIG, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_PS_NUDGE_LEFT, BUTTON_RC_REW, BUTTON_NONE }, { ACTION_PS_NUDGE_LEFTOFF, BUTTON_RC_REW|BUTTON_REL, BUTTON_NONE }, { ACTION_PS_NUDGE_RIGHT, BUTTON_RC_FF, BUTTON_NONE }, { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RC_FF|BUTTON_REL, BUTTON_NONE }, { ACTION_PS_TOGGLE_MODE, BUTTON_RC_MODE, BUTTON_NONE }, { ACTION_PS_RESET, BUTTON_RC_REC, BUTTON_NONE }, { ACTION_PS_EXIT, BUTTON_RC_PLAY, BUTTON_NONE }, { ACTION_PS_SLOWER, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_PS_FASTER, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* remote_button_context_pitchscreen */ /** Quickscreen **/ static const struct button_mapping button_context_quickscreen[] = { { ACTION_QS_TOP, BUTTON_UP, BUTTON_NONE }, { ACTION_QS_TOP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_QS_DOWN, BUTTON_DOWN, BUTTON_NONE }, { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_QS_LEFT, BUTTON_LEFT, BUTTON_NONE }, { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_QS_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_REC, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_quickscreen */ static const struct button_mapping remote_button_context_quickscreen[] = { { ACTION_QS_TOP, BUTTON_RC_VOL_UP, BUTTON_NONE }, { ACTION_QS_TOP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_QS_DOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, { ACTION_QS_DOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_QS_LEFT, BUTTON_RC_REW, BUTTON_NONE }, { ACTION_QS_LEFT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_QS_RIGHT, BUTTON_RC_FF, BUTTON_NONE }, { ACTION_QS_RIGHT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_RC_REC, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* remote_button_context_quickscreen */ /** Recording Screen **/ static const struct button_mapping button_context_recscreen[] = { { ACTION_REC_PAUSE, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, { ACTION_STD_CANCEL, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, { ACTION_REC_NEWFILE, BUTTON_REC|BUTTON_REL, BUTTON_REC }, { ACTION_STD_MENU, BUTTON_REC|BUTTON_REPEAT, BUTTON_REC }, { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE }, { ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_recscreen */ static const struct button_mapping remote_button_context_recscreen[] = { { ACTION_REC_PAUSE, BUTTON_RC_PLAY|BUTTON_REL, BUTTON_RC_PLAY }, { ACTION_STD_CANCEL, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_RC_PLAY }, { ACTION_REC_NEWFILE, BUTTON_RC_REC, BUTTON_NONE }, { ACTION_STD_MENU, BUTTON_RC_MENU, BUTTON_NONE }, { ACTION_SETTINGS_INC, BUTTON_RC_FF, BUTTON_NONE }, { ACTION_SETTINGS_INCREPEAT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_SETTINGS_DEC, BUTTON_RC_REW, BUTTON_NONE }, { ACTION_SETTINGS_DECREPEAT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* remote_button_context_recscreen */ /** Settings - General Mappings **/ static const struct button_mapping button_context_settings[] = { { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE }, { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE }, { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_REC, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_settings */ static const struct button_mapping remote_button_context_settings[] = { { ACTION_SETTINGS_INC, BUTTON_RC_VOL_UP, BUTTON_NONE }, { ACTION_SETTINGS_INCREPEAT, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_SETTINGS_DEC, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, { ACTION_SETTINGS_DECREPEAT, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_PREV, BUTTON_RC_REW, BUTTON_NONE }, { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_RC_REC, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* remote_button_context_settings */ /** Settings - Using Sliders **/ static const struct button_mapping button_context_settings_r_is_inc[] = { { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE }, { ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE }, { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE }, { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_REC, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_settings_r_is_inc */ static const struct button_mapping remote_button_context_settings_r_is_inc[] = { { ACTION_SETTINGS_INC, BUTTON_RC_FF, BUTTON_NONE }, { ACTION_SETTINGS_INCREPEAT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_SETTINGS_DEC, BUTTON_RC_REW, BUTTON_NONE }, { ACTION_SETTINGS_DECREPEAT, BUTTON_RC_REW|BUTTON_REPEAT,BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_RC_REC, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* remote_button_context_settings_r_is_inc */ /** Settings - Time/Date **/ static const struct button_mapping button_context_settings_time[] = { { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) }; /* button_context_settings */ /** Tree **/ static const struct button_mapping button_context_tree[] = { { ACTION_NONE, BUTTON_PLAY, BUTTON_NONE }, { ACTION_TREE_WPS, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, { ACTION_TREE_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_tree */ static const struct button_mapping remote_button_context_tree[] = { { ACTION_NONE, BUTTON_RC_PLAY, BUTTON_NONE }, { ACTION_TREE_WPS, BUTTON_RC_PLAY|BUTTON_REL, BUTTON_RC_PLAY }, { ACTION_TREE_STOP, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_RC_PLAY }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* remote_button_context_tree */ static const struct button_mapping button_context_tree_scroll_lr[] = { { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, { ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE), }; /* button_context_tree_scroll_lr */ static const struct button_mapping remote_button_context_tree_scroll_lr[] = { { ACTION_NONE, BUTTON_RC_REW, BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW }, { ACTION_TREE_ROOT_INIT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_RC_REW }, { ACTION_TREE_PGLEFT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_NONE, BUTTON_RC_FF, BUTTON_NONE }, { ACTION_STD_OK, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF }, { ACTION_TREE_PGRIGHT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE), }; /* remote_button_context_tree_scroll_lr */ /** While-Playing Screen (WPS) **/ static const struct button_mapping button_context_wps[] = { { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, { ACTION_WPS_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT }, { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT }, { ACTION_WPS_VOLDOWN, BUTTON_DOWN, BUTTON_NONE }, { ACTION_WPS_VOLDOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_VOLUP, BUTTON_UP, BUTTON_NONE }, { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, { ACTION_WPS_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, { ACTION_WPS_MENU, BUTTON_REC|BUTTON_REL, BUTTON_REC }, { ACTION_WPS_QUICKSCREEN, BUTTON_REC|BUTTON_REPEAT, BUTTON_REC }, /* * Can't really do combos on M5 * { ACTION_WPS_VIEW_PLAYLIST, BUTTON_REC|BUTTON_SELECT, BUTTON_NONE }, */ LAST_ITEM_IN_LIST }; /* button_context_wps */ static const struct button_mapping remote_button_context_wps[] = { { ACTION_WPS_PLAY, BUTTON_RC_PLAY|BUTTON_REL, BUTTON_RC_PLAY }, { ACTION_WPS_STOP, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_RC_PLAY }, { ACTION_WPS_SKIPPREV, BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW }, { ACTION_WPS_SEEKBACK, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_STOPSEEK, BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW|BUTTON_REPEAT }, { ACTION_WPS_SKIPNEXT, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF }, { ACTION_WPS_SEEKFWD, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_STOPSEEK, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF|BUTTON_REPEAT }, { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE }, { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_BROWSE, BUTTON_RC_MODE|BUTTON_REL, BUTTON_RC_MODE }, { ACTION_WPS_CONTEXT, BUTTON_RC_MODE|BUTTON_REPEAT, BUTTON_RC_MODE }, { ACTION_WPS_MENU, BUTTON_RC_MENU|BUTTON_REL, BUTTON_RC_MENU }, { ACTION_WPS_QUICKSCREEN, BUTTON_RC_MENU|BUTTON_REPEAT, BUTTON_RC_MENU }, LAST_ITEM_IN_LIST }; /* remote_button_context_wps */ /** Yes/No Screen **/ static const struct button_mapping button_context_yesnoscreen[] = { { ACTION_YESNO_ACCEPT, BUTTON_SELECT, BUTTON_NONE }, LAST_ITEM_IN_LIST }; /* button_context_settings_yesnoscreen */ static const struct button_mapping remote_button_context_yesnoscreen[] = { { ACTION_YESNO_ACCEPT, BUTTON_RC_PLAY, BUTTON_NONE }, LAST_ITEM_IN_LIST }; /* remote_button_context_settings_yesnoscreen */ static const struct button_mapping* get_context_mapping_remote( int context ) { context ^= CONTEXT_REMOTE; switch (context) { /* anything that uses remote_button_context_standard */ default: return remote_button_context_standard; /* remote contexts with special mapping */ case CONTEXT_BOOKMARKSCREEN: return remote_button_context_bmark; case CONTEXT_FM: return remote_button_context_radio; case CONTEXT_KEYBOARD: case CONTEXT_MORSE_INPUT: return remote_button_context_keyboard; case CONTEXT_PITCHSCREEN: return remote_button_context_pitchscreen; case CONTEXT_QUICKSCREEN: return remote_button_context_quickscreen; case CONTEXT_RECSCREEN: return remote_button_context_recscreen; case CONTEXT_SETTINGS: return remote_button_context_settings; case CONTEXT_SETTINGS_COLOURCHOOSER: case CONTEXT_SETTINGS_EQ: case CONTEXT_SETTINGS_TIME: return remote_button_context_settings_r_is_inc; case CONTEXT_TREE: case CONTEXT_MAINMENU: if (global_settings.hold_lr_for_scroll_in_list) return remote_button_context_tree_scroll_lr; /* else fall through to CONTEXT_TREE|CONTEXT_CUSTOM */ case CONTEXT_TREE|CONTEXT_CUSTOM: return remote_button_context_tree; case CONTEXT_WPS: return remote_button_context_wps; case CONTEXT_YESNOSCREEN: return remote_button_context_yesnoscreen; } } const struct button_mapping* get_context_mapping( int context ) { if (context & CONTEXT_REMOTE) return get_context_mapping_remote(context); switch( context ) { /* anything that uses button_context_standard */ case CONTEXT_LIST: case CONTEXT_STD: default: return button_context_standard; /* contexts with special mapping */ case CONTEXT_BOOKMARKSCREEN: return button_context_bmark; case CONTEXT_FM: return button_context_radio; case CONTEXT_KEYBOARD: case CONTEXT_MORSE_INPUT: return button_context_keyboard; case CONTEXT_PITCHSCREEN: return button_context_pitchscreen; case CONTEXT_QUICKSCREEN: return button_context_quickscreen; case CONTEXT_RECSCREEN: return button_context_recscreen; case CONTEXT_SETTINGS: return button_context_settings; case CONTEXT_SETTINGS_COLOURCHOOSER: case CONTEXT_SETTINGS_EQ: case CONTEXT_SETTINGS_RECTRIGGER: return button_context_settings_r_is_inc; case CONTEXT_SETTINGS_TIME: return button_context_settings_time; case CONTEXT_TREE: case CONTEXT_MAINMENU: if (global_settings.hold_lr_for_scroll_in_list) return button_context_tree_scroll_lr; /* else fall through to CONTEXT_TREE|CONTEXT_CUSTOM */ case CONTEXT_TREE|CONTEXT_CUSTOM: return button_context_tree; case CONTEXT_WPS: return button_context_wps; case CONTEXT_YESNOSCREEN: return button_context_yesnoscreen; } }
c5184a80dbdd798b3780b963154cdaebf428bd8a
7f6c235b0598353549959c18f69eefd20b766907
/include/arch/gb/cgb.h
38a504183fc954a1d6bb64997024f8eed4bd38db
[ "ClArtistic" ]
permissive
z88dk/z88dk
46dfd4905f36d99333173cadd0a660839befc9f0
8b07f37cc43c5d9ffe69b563c80763491d8faff7
refs/heads/master
2023-09-04T19:29:49.254958
2023-09-03T20:51:24
2023-09-03T20:51:24
54,035,569
820
263
NOASSERTION
2023-09-05T11:09:04
2016-03-16T13:48:16
Assembly
UTF-8
C
false
false
2,125
h
cgb.h
/** @file gb/cgb.h Support for Color GameBoy. */ #ifndef _CGB_H #define _CGB_H #include <sys/types.h> #include <sys/compiler.h> /** Macro to create a palette entry out of the color components. */ #define RGB(r, g, b) \ ((((uint16_t)(b) & 0x1f) << 10) | (((uint16_t)(g) & 0x1f) << 5) | (((uint16_t)(r) & 0x1f) << 0)) /** Common colors based on the EGA default palette. */ #define RGB_RED RGB(31, 0, 0) #define RGB_DARKRED RGB(15, 0, 0) #define RGB_GREEN RGB( 0, 31, 0) #define RGB_DARKGREEN RGB( 0, 15, 0) #define RGB_BLUE RGB( 0, 0, 31) #define RGB_DARKBLUE RGB( 0, 0, 15) #define RGB_YELLOW RGB(31, 31, 0) #define RGB_DARKYELLOW RGB(21, 21, 0) #define RGB_CYAN RGB( 0, 31, 31) #define RGB_AQUA RGB(28, 5, 22) #define RGB_PINK RGB(11, 0, 31) #define RGB_PURPLE RGB(21, 0, 21) #define RGB_BLACK RGB( 0, 0, 0) #define RGB_DARKGRAY RGB(10, 10, 10) #define RGB_LIGHTGRAY RGB(21, 21, 21) #define RGB_WHITE RGB(31, 31, 31) #define RGB_LIGHTFLESH RGB(30, 20, 15) #define RGB_BROWN RGB(10, 10, 0) #define RGB_ORANGE RGB(30, 20, 0) #define RGB_TEAL RGB(15, 15, 0) /** Set bkg palette(s). */ void __LIB__ set_bkg_palette(uint16_t first_palette, uint16_t nb_palettes, uint16_t *rgb_data) __smallc NONBANKED; /** Set sprite palette(s). */ void __LIB__ set_sprite_palette(uint16_t first_palette, uint16_t nb_palettes, uint16_t *rgb_data) __smallc NONBANKED; /** Set a bkg palette entry. */ void __LIB__ set_bkg_palette_entry(uint16_t palette, uint16_t entry, uint16_t rgb_data) __smallc; /** Set a sprite palette entry. */ void __LIB__ set_sprite_palette_entry(uint16_t palette, uint16_t entry, uint16_t rgb_data) __smallc; /** Set CPU speed to slow operation. Make sure interrupts are disabled before call. @see cpu_fast */ void __LIB__ cpu_slow(void); /** Set CPU speed to fast operation. Make sure interrupts are disabled before call. @see cpu_slow */ void __LIB__ cpu_fast(void); /** Set defaults compatible with normal GameBoy. */ void __LIB__ cgb_compatibility(void); #endif /* _CGB_H */
51fa9091c80cabf42c9c9bb001923de67f136f57
5741e4e7e3fedc3ae03996843b2bcfec70e17049
/c/meterpreter/source/mingw-include/filtereg.h
1572cb9e28fadd5a9138e7232c54e7000d48f13a
[ "BSD-3-Clause", "PSF-2.0", "Python-2.0", "Zlib", "BSD-4-Clause", "BSD-2-Clause" ]
permissive
rapid7/metasploit-payloads
5981b44a1054d307d97b9cffcdbb559bfc690625
dcaad10486e22885d0cbcbce508e3e763ce689e9
refs/heads/master
2023-09-01T01:27:12.834909
2023-07-11T13:27:41
2023-07-11T13:27:41
18,418,533
1,674
743
NOASSERTION
2023-09-14T16:58:38
2014-04-03T21:18:24
C
UTF-8
C
false
false
16,077
h
filtereg.h
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 8.01.0622 */ /* @@MIDL_FILE_HEADING( ) */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 500 #endif /* verify that the <rpcsal.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCSAL_H_VERSION__ #define __REQUIRED_RPCSAL_H_VERSION__ 100 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif /* __RPCNDR_H_VERSION__ */ #ifndef COM_NO_WINDOWS_H #include "windows.h" #include "ole2.h" #endif /*COM_NO_WINDOWS_H*/ #ifndef __filtereg_h__ #define __filtereg_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ #ifndef __ILoadFilter_FWD_DEFINED__ #define __ILoadFilter_FWD_DEFINED__ typedef interface ILoadFilter ILoadFilter; #endif /* __ILoadFilter_FWD_DEFINED__ */ #ifndef __ILoadFilterWithPrivateComActivation_FWD_DEFINED__ #define __ILoadFilterWithPrivateComActivation_FWD_DEFINED__ typedef interface ILoadFilterWithPrivateComActivation ILoadFilterWithPrivateComActivation; #endif /* __ILoadFilterWithPrivateComActivation_FWD_DEFINED__ */ /* header files for imported files */ #include "oaidl.h" #include "ocidl.h" #include "filter.h" #ifdef __cplusplus extern "C"{ #endif /* interface __MIDL_itf_filtereg_0000_0000 */ /* [local] */ #include <winapifamily.h> #pragma region Desktop Family #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) EXTERN_C const CLSID CLSID_FilterRegistration; extern RPC_IF_HANDLE __MIDL_itf_filtereg_0000_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_filtereg_0000_0000_v0_0_s_ifspec; #ifndef __ILoadFilter_INTERFACE_DEFINED__ #define __ILoadFilter_INTERFACE_DEFINED__ /* interface ILoadFilter */ /* [unique][helpstring][uuid][object] */ typedef struct _FILTERED_DATA_SOURCES { const WCHAR *pwcsExtension; const WCHAR *pwcsMime; const CLSID *pClsid; const WCHAR *pwcsOverride; } FILTERED_DATA_SOURCES; EXTERN_C const IID IID_ILoadFilter; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("c7310722-ac80-11d1-8df3-00c04fb6ef4f") ILoadFilter : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE LoadIFilter( /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsPath, /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources, /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter, /* [in] */ BOOL fUseDefault, /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid, /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize, /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt) = 0; virtual HRESULT STDMETHODCALLTYPE LoadIFilterFromStorage( /* [in] */ __RPC__in_opt IStorage *pStg, /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter, /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsOverride, /* [in] */ BOOL fUseDefault, /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid, /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize, /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt) = 0; virtual HRESULT STDMETHODCALLTYPE LoadIFilterFromStream( /* [in] */ __RPC__in_opt IStream *pStm, /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources, /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter, /* [in] */ BOOL fUseDefault, /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid, /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize, /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt) = 0; }; #else /* C style interface */ typedef struct ILoadFilterVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( __RPC__in ILoadFilter * This, /* [in] */ __RPC__in REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( __RPC__in ILoadFilter * This); ULONG ( STDMETHODCALLTYPE *Release )( __RPC__in ILoadFilter * This); HRESULT ( STDMETHODCALLTYPE *LoadIFilter )( __RPC__in ILoadFilter * This, /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsPath, /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources, /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter, /* [in] */ BOOL fUseDefault, /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid, /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize, /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt); HRESULT ( STDMETHODCALLTYPE *LoadIFilterFromStorage )( __RPC__in ILoadFilter * This, /* [in] */ __RPC__in_opt IStorage *pStg, /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter, /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsOverride, /* [in] */ BOOL fUseDefault, /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid, /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize, /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt); HRESULT ( STDMETHODCALLTYPE *LoadIFilterFromStream )( __RPC__in ILoadFilter * This, /* [in] */ __RPC__in_opt IStream *pStm, /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources, /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter, /* [in] */ BOOL fUseDefault, /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid, /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize, /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt); END_INTERFACE } ILoadFilterVtbl; interface ILoadFilter { CONST_VTBL struct ILoadFilterVtbl *lpVtbl; }; #ifdef COBJMACROS #define ILoadFilter_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ILoadFilter_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ILoadFilter_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ILoadFilter_LoadIFilter(This,pwcsPath,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) \ ( (This)->lpVtbl -> LoadIFilter(This,pwcsPath,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) #define ILoadFilter_LoadIFilterFromStorage(This,pStg,pUnkOuter,pwcsOverride,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) \ ( (This)->lpVtbl -> LoadIFilterFromStorage(This,pStg,pUnkOuter,pwcsOverride,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) #define ILoadFilter_LoadIFilterFromStream(This,pStm,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) \ ( (This)->lpVtbl -> LoadIFilterFromStream(This,pStm,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ILoadFilter_INTERFACE_DEFINED__ */ #ifndef __ILoadFilterWithPrivateComActivation_INTERFACE_DEFINED__ #define __ILoadFilterWithPrivateComActivation_INTERFACE_DEFINED__ /* interface ILoadFilterWithPrivateComActivation */ /* [unique][helpstring][uuid][object] */ EXTERN_C const IID IID_ILoadFilterWithPrivateComActivation; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("40BDBD34-780B-48D3-9BB6-12EBD4AD2E75") ILoadFilterWithPrivateComActivation : public ILoadFilter { public: virtual HRESULT STDMETHODCALLTYPE LoadIFilterWithPrivateComActivation( /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *filteredSources, /* [in] */ BOOL useDefault, /* [out] */ __RPC__out CLSID *filterClsid, /* [out] */ __RPC__out BOOL *isFilterPrivateComActivated, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **filterObj) = 0; }; #else /* C style interface */ typedef struct ILoadFilterWithPrivateComActivationVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( __RPC__in ILoadFilterWithPrivateComActivation * This, /* [in] */ __RPC__in REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( __RPC__in ILoadFilterWithPrivateComActivation * This); ULONG ( STDMETHODCALLTYPE *Release )( __RPC__in ILoadFilterWithPrivateComActivation * This); HRESULT ( STDMETHODCALLTYPE *LoadIFilter )( __RPC__in ILoadFilterWithPrivateComActivation * This, /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsPath, /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources, /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter, /* [in] */ BOOL fUseDefault, /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid, /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize, /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt); HRESULT ( STDMETHODCALLTYPE *LoadIFilterFromStorage )( __RPC__in ILoadFilterWithPrivateComActivation * This, /* [in] */ __RPC__in_opt IStorage *pStg, /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter, /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsOverride, /* [in] */ BOOL fUseDefault, /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid, /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize, /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt); HRESULT ( STDMETHODCALLTYPE *LoadIFilterFromStream )( __RPC__in ILoadFilterWithPrivateComActivation * This, /* [in] */ __RPC__in_opt IStream *pStm, /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources, /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter, /* [in] */ BOOL fUseDefault, /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid, /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize, /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt); HRESULT ( STDMETHODCALLTYPE *LoadIFilterWithPrivateComActivation )( __RPC__in ILoadFilterWithPrivateComActivation * This, /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *filteredSources, /* [in] */ BOOL useDefault, /* [out] */ __RPC__out CLSID *filterClsid, /* [out] */ __RPC__out BOOL *isFilterPrivateComActivated, /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **filterObj); END_INTERFACE } ILoadFilterWithPrivateComActivationVtbl; interface ILoadFilterWithPrivateComActivation { CONST_VTBL struct ILoadFilterWithPrivateComActivationVtbl *lpVtbl; }; #ifdef COBJMACROS #define ILoadFilterWithPrivateComActivation_QueryInterface(This,riid,ppvObject) \ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) #define ILoadFilterWithPrivateComActivation_AddRef(This) \ ( (This)->lpVtbl -> AddRef(This) ) #define ILoadFilterWithPrivateComActivation_Release(This) \ ( (This)->lpVtbl -> Release(This) ) #define ILoadFilterWithPrivateComActivation_LoadIFilter(This,pwcsPath,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) \ ( (This)->lpVtbl -> LoadIFilter(This,pwcsPath,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) #define ILoadFilterWithPrivateComActivation_LoadIFilterFromStorage(This,pStg,pUnkOuter,pwcsOverride,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) \ ( (This)->lpVtbl -> LoadIFilterFromStorage(This,pStg,pUnkOuter,pwcsOverride,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) #define ILoadFilterWithPrivateComActivation_LoadIFilterFromStream(This,pStm,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) \ ( (This)->lpVtbl -> LoadIFilterFromStream(This,pStm,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) #define ILoadFilterWithPrivateComActivation_LoadIFilterWithPrivateComActivation(This,filteredSources,useDefault,filterClsid,isFilterPrivateComActivated,filterObj) \ ( (This)->lpVtbl -> LoadIFilterWithPrivateComActivation(This,filteredSources,useDefault,filterClsid,isFilterPrivateComActivated,filterObj) ) #endif /* COBJMACROS */ #endif /* C style interface */ #endif /* __ILoadFilterWithPrivateComActivation_INTERFACE_DEFINED__ */ /* interface __MIDL_itf_filtereg_0000_0002 */ /* [local] */ #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */ #pragma endregion extern RPC_IF_HANDLE __MIDL_itf_filtereg_0000_0002_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_filtereg_0000_0002_v0_0_s_ifspec; /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
4d41955851740cd65c659877881037a6ece9f0bc
581bdcc078d282e388f1b655d4cfc4e08152d117
/tools/peview/peprpwnd.c
6e7e36e7bca7db64cc5928ecf03d9d7e4375ef1d
[ "MIT", "BSD-3-Clause", "LGPL-2.0-or-later", "Zlib", "LGPL-2.1-or-later", "GPL-2.0-only", "LicenseRef-scancode-public-domain" ]
permissive
winsiderss/systeminformer
774928be871f0055263ac5e62ae0a598b098486b
5a6b442acd45d681f699a133d476a3211d072871
refs/heads/master
2023-08-28T15:43:41.074679
2023-08-27T20:59:20
2023-08-27T20:59:20
50,824,485
2,137
292
MIT
2023-09-10T22:35:12
2016-02-01T08:10:21
C
UTF-8
C
false
false
32,394
c
peprpwnd.c
/* * Copyright (c) 2022 Winsider Seminars & Solutions, Inc. All rights reserved. * * This file is part of System Informer. * * Authors: * * dmex 2021 * */ #include <peview.h> #include <secedit.h> typedef struct _PV_WINDOW_SECTION { PH_STRINGREF Name; PVOID Instance; PWSTR Template; DLGPROC DialogProc; PVOID Parameter; HWND DialogHandle; HTREEITEM TreeItemHandle; } PV_WINDOW_SECTION, *PPV_WINDOW_SECTION; INT_PTR CALLBACK PvTabWindowDialogProc( _In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ); #define SWP_NO_ACTIVATE_MOVE_SIZE_ZORDER (SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER) #define SWP_SHOWWINDOW_ONLY (SWP_NO_ACTIVATE_MOVE_SIZE_ZORDER | SWP_SHOWWINDOW) #define SWP_HIDEWINDOW_ONLY (SWP_NO_ACTIVATE_MOVE_SIZE_ZORDER | SWP_HIDEWINDOW) VOID PvDestroyTabSection( _In_ PPV_WINDOW_SECTION Section ); VOID PvEnterTabSectionView( _In_ PPV_WINDOW_SECTION NewSection ); VOID PvLayoutTabSectionView( VOID ); VOID PvEnterTabSectionViewInner( _In_ PPV_WINDOW_SECTION Section, _Inout_ HDWP *ContainerDeferHandle ); VOID PvCreateTabSectionDialog( _In_ PPV_WINDOW_SECTION Section ); VOID PvTabWindowOnSize( VOID ); PPV_WINDOW_SECTION PvFindTabSectionByName( _In_ PPH_STRINGREF Name ); PPV_WINDOW_SECTION PvGetSelectedTabSection( _In_opt_ PVOID TreeItemHandle ); PPV_WINDOW_SECTION PvCreateTabSection( _In_ PWSTR Name, _In_ PVOID Instance, _In_ PWSTR Template, _In_ DLGPROC DialogProc, _In_opt_ PVOID Parameter ); static HWND PvPropertiesWindowHandle = NULL; static HWND PvTabTreeControl = NULL; static HWND PvTabContainerControl = NULL; static INT PvPropertiesWindowShowCommand = SW_SHOW; static PH_LAYOUT_MANAGER PvTabWindowLayoutManager; static PPH_LIST PvTabSectionList = NULL; static PPV_WINDOW_SECTION PvTabCurrentSection = NULL; VOID PvShowPePropertiesWindow( VOID ) { BOOL result; MSG message; PH_AUTO_POOL autoPool; PhInitializeAutoPool(&autoPool); PvPropertiesWindowHandle = PhCreateDialog( PhInstanceHandle, MAKEINTRESOURCE(IDD_TABWINDOW), NULL, PvTabWindowDialogProc, NULL ); if (PhGetIntegerSetting(L"MainWindowState") == SW_MAXIMIZE) PvPropertiesWindowShowCommand = SW_MAXIMIZE; ShowWindow(PvPropertiesWindowHandle, PvPropertiesWindowShowCommand); SetForegroundWindow(PvPropertiesWindowHandle); while (result = GetMessage(&message, NULL, 0, 0)) { if (result == -1) break; if (!IsDialogMessage(PvPropertiesWindowHandle, &message)) { TranslateMessage(&message); DispatchMessage(&message); } PhDrainAutoPool(&autoPool); } PhDeleteAutoPool(&autoPool); } VOID PvAddTreeViewSections( VOID ) { PPV_WINDOW_SECTION section; PH_MAPPED_IMAGE_IMPORTS imports; PH_MAPPED_IMAGE_EXPORTS exports; PIMAGE_LOAD_CONFIG_DIRECTORY32 config32; PIMAGE_LOAD_CONFIG_DIRECTORY64 config64; PIMAGE_DATA_DIRECTORY entry; PvTabSectionList = PhCreateList(30); PvTabCurrentSection = NULL; // General page section = PvCreateTabSection( L"General", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEGENERAL), PvPeGeneralDlgProc, NULL ); // Headers page PvCreateTabSection( L"Headers", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEHEADERS), PvPeHeadersDlgProc, NULL ); // Load Config page if (NT_SUCCESS(PhGetMappedImageDataEntry(&PvMappedImage, IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG, &entry))) { PvCreateTabSection( L"Load Config", PhInstanceHandle, MAKEINTRESOURCE(IDD_PELOADCONFIG), PvPeLoadConfigDlgProc, NULL ); } // Sections page PvCreateTabSection( L"Sections", PhInstanceHandle, MAKEINTRESOURCE(IDD_PESECTIONS), PvPeSectionsDlgProc, NULL ); // Directories page PvCreateTabSection( L"Directories", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEDIRECTORY), PvPeDirectoryDlgProc, NULL ); // Imports page if ((NT_SUCCESS(PhGetMappedImageImports(&imports, &PvMappedImage)) && imports.NumberOfDlls != 0) || (NT_SUCCESS(PhGetMappedImageDelayImports(&imports, &PvMappedImage)) && imports.NumberOfDlls != 0)) { PvCreateTabSection( L"Imports", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEIMPORTS), PvPeImportsDlgProc, NULL ); } // Exports page if (NT_SUCCESS(PhGetMappedImageExports(&exports, &PvMappedImage)) && exports.NumberOfEntries != 0) { PPV_EXPORTS_PAGECONTEXT exportsPageContext; PPV_PROPPAGECONTEXT propPageContext; LPPROPSHEETPAGE propSheetPage; exportsPageContext = PhAllocateZero(sizeof(PV_EXPORTS_PAGECONTEXT)); exportsPageContext->FreePropPageContext = TRUE; exportsPageContext->Context = ULongToPtr(0); // PhGetMappedImageExportsEx with no flags propPageContext = PhAllocateZero(sizeof(PV_PROPPAGECONTEXT)); propPageContext->Context = exportsPageContext; propSheetPage = PhAllocateZero(sizeof(PROPSHEETPAGE)); propSheetPage->lParam = (LPARAM)propPageContext; PvCreateTabSection( L"Exports", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEEXPORTS), PvPeExportsDlgProc, propSheetPage ); } if (NT_SUCCESS(PhGetMappedImageExportsEx(&exports, &PvMappedImage, PH_GET_IMAGE_EXPORTS_ARM64EC)) && exports.NumberOfEntries != 0) { PPV_EXPORTS_PAGECONTEXT exportsPageContext; PPV_PROPPAGECONTEXT propPageContext; LPPROPSHEETPAGE propSheetPage; exportsPageContext = PhAllocateZero(sizeof(PV_EXPORTS_PAGECONTEXT)); exportsPageContext->FreePropPageContext = TRUE; exportsPageContext->Context = ULongToPtr(PH_GET_IMAGE_EXPORTS_ARM64EC); propPageContext = PhAllocateZero(sizeof(PV_PROPPAGECONTEXT)); propPageContext->Context = exportsPageContext; propSheetPage = PhAllocateZero(sizeof(PROPSHEETPAGE)); propSheetPage->lParam = (LPARAM)propPageContext; PvCreateTabSection( L"Exports ARM64EC", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEEXPORTS), PvPeExportsDlgProc, propSheetPage ); } // Resources page if (NT_SUCCESS(PhGetMappedImageDataEntry(&PvMappedImage, IMAGE_DIRECTORY_ENTRY_RESOURCE, &entry))) { PvCreateTabSection( L"Resources", PhInstanceHandle, MAKEINTRESOURCE(IDD_PERESOURCES), PvPeResourcesDlgProc, NULL ); } // CLR page if (NT_SUCCESS(PhGetMappedImageDataEntry(&PvMappedImage, IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR, &entry)) && (PvImageCor20Header = PhMappedImageRvaToVa(&PvMappedImage, entry->VirtualAddress, NULL))) { NTSTATUS status = STATUS_SUCCESS; __try { PhProbeAddress( PvImageCor20Header, sizeof(IMAGE_COR20_HEADER), PvMappedImage.ViewBase, PvMappedImage.Size, 4 ); } __except (EXCEPTION_EXECUTE_HANDLER) { status = GetExceptionCode(); } if (NT_SUCCESS(status)) { PvCreateTabSection( L"CLR", PhInstanceHandle, MAKEINTRESOURCE(IDD_PECLR), PvpPeClrDlgProc, NULL ); PvCreateTabSection( L"CLR Imports", PhInstanceHandle, MAKEINTRESOURCE(IDD_PECLRIMPORTS), PvpPeClrImportsDlgProc, NULL ); PvCreateTabSection( L"CLR Tables", PhInstanceHandle, MAKEINTRESOURCE(IDD_PECLRTABLES), PvpPeClrTablesDlgProc, NULL ); } } // CFG page if (PvMappedImage.NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_GUARD_CF) { PvCreateTabSection( L"CFG", PhInstanceHandle, MAKEINTRESOURCE(IDD_PECFG), PvpPeCgfDlgProc, NULL ); } // TLS page if (NT_SUCCESS(PhGetMappedImageDataEntry(&PvMappedImage, IMAGE_DIRECTORY_ENTRY_TLS, &entry))) { PvCreateTabSection( L"TLS", PhInstanceHandle, MAKEINTRESOURCE(IDD_TLS), PvpPeTlsDlgProc, NULL ); } // ProdId page { ULONG imageDosStubLength = ((PIMAGE_DOS_HEADER)PvMappedImage.ViewBase)->e_lfanew - RTL_SIZEOF_THROUGH_FIELD(IMAGE_DOS_HEADER, e_lfanew); if (imageDosStubLength != 0 && imageDosStubLength != 64) { PvCreateTabSection( L"ProdID", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEPRODID), PvpPeProdIdDlgProc, NULL ); } } // Exceptions page { BOOLEAN has_exceptions = FALSE; if (PvMappedImage.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { if (NT_SUCCESS(PhGetMappedImageLoadConfig32(&PvMappedImage, &config32)) && RTL_CONTAINS_FIELD(config32, config32->Size, SEHandlerCount)) { if (config32->SEHandlerCount && config32->SEHandlerTable) has_exceptions = TRUE; } } else { if (NT_SUCCESS(PhGetMappedImageDataEntry(&PvMappedImage, IMAGE_DIRECTORY_ENTRY_EXCEPTION, &entry))) { has_exceptions = TRUE; } } if (has_exceptions) { PvCreateTabSection( L"Exceptions", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEEXCEPTIONS), PvpPeExceptionDlgProc, NULL ); } } // Relocations page if (NT_SUCCESS(PhGetMappedImageDataEntry(&PvMappedImage, IMAGE_DIRECTORY_ENTRY_BASERELOC, &entry))) { PvCreateTabSection( L"Relocations", PhInstanceHandle, MAKEINTRESOURCE(IDD_PERELOCATIONS), PvpPeRelocationDlgProc, NULL ); } // Dynmic Relocations page if (NT_SUCCESS(PhGetMappedImageDynamicRelocationsTable(&PvMappedImage, NULL))) { PvCreateTabSection( L"Dynamic Relocations", PhInstanceHandle, MAKEINTRESOURCE(IDD_PERELOCATIONS), PvpPeDynamicRelocationDlgProc, NULL ); } // CHPE page { BOOLEAN hasCHPE = FALSE; if (PvMappedImage.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { if (NT_SUCCESS(PhGetMappedImageLoadConfig32(&PvMappedImage, &config32)) && RTL_CONTAINS_FIELD(config32, config32->Size, CHPEMetadataPointer)) { if (config32->CHPEMetadataPointer) hasCHPE = TRUE; } } else { if (NT_SUCCESS(PhGetMappedImageLoadConfig64(&PvMappedImage, &config64)) && RTL_CONTAINS_FIELD(config64, config64->Size, CHPEMetadataPointer)) { if (config64->CHPEMetadataPointer) hasCHPE = TRUE; } } if (hasCHPE) { PvCreateTabSection( L"CHPE", PhInstanceHandle, MAKEINTRESOURCE(IDD_PELOADCONFIG), PvpPeCHPEDlgProc, NULL ); } } // Certificates page if (NT_SUCCESS(PhGetMappedImageDataEntry(&PvMappedImage, IMAGE_DIRECTORY_ENTRY_SECURITY, &entry))) { PvCreateTabSection( L"Certificates", PhInstanceHandle, MAKEINTRESOURCE(IDD_PESECURITY), PvpPeSecurityDlgProc, NULL ); } // Debug page if (NT_SUCCESS(PhGetMappedImageDataEntry(&PvMappedImage, IMAGE_DIRECTORY_ENTRY_DEBUG, &entry))) { PvCreateTabSection( L"Debug", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEDEBUG), PvpPeDebugDlgProc, NULL ); } // Volatile page { BOOLEAN valid = FALSE; if (PvMappedImage.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { if (NT_SUCCESS(PhGetMappedImageLoadConfig32(&PvMappedImage, &config32)) && RTL_CONTAINS_FIELD(config32, config32->Size, VolatileMetadataPointer)) { if (config32->VolatileMetadataPointer) valid = TRUE; } } else { if (NT_SUCCESS(PhGetMappedImageLoadConfig64(&PvMappedImage, &config64)) && RTL_CONTAINS_FIELD(config64, config64->Size, VolatileMetadataPointer)) { if (config64->VolatileMetadataPointer) valid = TRUE; } } if (valid) { PvCreateTabSection( L"Volatile Metadata", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEVOLATILE), PvpPeVolatileDlgProc, NULL ); } } // EH continuation page { BOOLEAN has_ehcont = FALSE; if (PvMappedImage.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { if (NT_SUCCESS(PhGetMappedImageLoadConfig32(&PvMappedImage, &config32)) && RTL_CONTAINS_FIELD(config32, config32->Size, GuardEHContinuationCount)) { if (config32->GuardEHContinuationTable && config32->GuardEHContinuationCount) has_ehcont = TRUE; } } else { if (NT_SUCCESS(PhGetMappedImageLoadConfig64(&PvMappedImage, &config64)) && RTL_CONTAINS_FIELD(config64, config64->Size, GuardEHContinuationCount)) { if (config64->GuardEHContinuationTable && config64->GuardEHContinuationCount) has_ehcont = TRUE; } } if (has_ehcont) { PvCreateTabSection( L"EH Continuation", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEEHCONT), PvpPeEhContDlgProc, NULL ); } } // Debug POGO page { BOOLEAN debugPogoValid = FALSE; PVOID debugEntry; if (NT_SUCCESS(PhGetMappedImageDebugEntryByType( &PvMappedImage, IMAGE_DEBUG_TYPE_POGO, NULL, &debugEntry ))) { debugPogoValid = TRUE; } if (debugPogoValid) { PvCreateTabSection( L"POGO", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEDEBUGPOGO), PvpPeDebugPogoDlgProc, NULL ); PvCreateTabSection( L"CRT", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEDEBUGCRT), PvpPeDebugCrtDlgProc, NULL ); } } // Properties page PvCreateTabSection( L"Properties", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEPROPSTORAGE), PvpPePropStoreDlgProc, NULL ); // Extended attributes page PvCreateTabSection( L"Attributes", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEATTR), PvpPeExtendedAttributesDlgProc, NULL ); // Streams page PvCreateTabSection( L"Streams", PhInstanceHandle, MAKEINTRESOURCE(IDD_PESTREAMS), PvpPeStreamsDlgProc, NULL ); // Layout page PvCreateTabSection( L"Layout", PhInstanceHandle, MAKEINTRESOURCE(IDD_PELAYOUT), PvpPeLayoutDlgProc, NULL ); // Links page PvCreateTabSection( L"Links", PhInstanceHandle, MAKEINTRESOURCE(IDD_PELINKS), PvpPeLinksDlgProc, NULL ); // Processes page PvCreateTabSection( L"Processes", PhInstanceHandle, MAKEINTRESOURCE(IDD_PIDS), PvpPeProcessesDlgProc, NULL ); // Hashes page PvCreateTabSection( L"Hashes", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEHASHES), PvpPeHashesDlgProc, NULL ); // Text preview page PvCreateTabSection( L"Preview", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEPREVIEW), PvpPePreviewDlgProc, NULL ); // Symbols page PvCreateTabSection( L"Symbols", PhInstanceHandle, MAKEINTRESOURCE(IDD_PESYMBOLS), PvpSymbolsDlgProc, NULL ); // VS_VERSIONINFO page PvCreateTabSection( L"VersionInfo", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEVERSIONINFO), PvpPeVersionInfoDlgProc, NULL ); // Mappings page if (KphLevelEx(FALSE) >= KphLevelMed) { PvCreateTabSection( L"Mappings", PhInstanceHandle, MAKEINTRESOURCE(IDD_PERELOCATIONS), PvpMappingsDlgProc, NULL ); } // MUI page PvCreateTabSection( L"MUI", PhInstanceHandle, MAKEINTRESOURCE(IDD_PEVERSIONINFO), PvpPeMuiResourceDlgProc, NULL ); if (PhGetIntegerSetting(L"MainWindowPageRestoreEnabled")) { PPH_STRING startPage; PPV_WINDOW_SECTION startSection; BOOLEAN foundStartPage = FALSE; if (startPage = PhGetStringSetting(L"MainWindowPage")) { if (startSection = PvFindTabSectionByName(&startPage->sr)) { TreeView_SelectItem(PvTabTreeControl, startSection->TreeItemHandle); foundStartPage = TRUE; } PhDereferenceObject(startPage); } if (!foundStartPage) { TreeView_SelectItem(PvTabTreeControl, section->TreeItemHandle); } SetFocus(PvTabTreeControl); } else { TreeView_SelectItem(PvTabTreeControl, section->TreeItemHandle); SetFocus(PvTabTreeControl); //PvEnterTabSectionView(section); } PvTabWindowOnSize(); } INT_PTR CALLBACK PvTabWindowDialogProc( _In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) { switch (uMsg) { case WM_INITDIALOG: { PvTabTreeControl = GetDlgItem(hwndDlg, IDC_SECTIONTREE); PvTabContainerControl = GetDlgItem(hwndDlg, IDD_CONTAINER); PhSetWindowText(hwndDlg, PhaFormatString(L"%s Properties", PhGetString(PvFileName))->Buffer); //PhSetWindowStyle(GetDlgItem(hwndDlg, IDC_SEPARATOR), SS_OWNERDRAW, SS_OWNERDRAW); PhSetControlTheme(PvTabTreeControl, L"explorer"); TreeView_SetExtendedStyle(PvTabTreeControl, TVS_EX_DOUBLEBUFFER, TVS_EX_DOUBLEBUFFER); TreeView_SetBkColor(PvTabTreeControl, GetSysColor(COLOR_3DFACE)); PvSetTreeViewImageList(hwndDlg, PvTabTreeControl); PhInitializeLayoutManager(&PvTabWindowLayoutManager, hwndDlg); PhAddLayoutItem(&PvTabWindowLayoutManager, PvTabTreeControl, NULL, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_BOTTOM); //PhAddLayoutItem(&PvTabWindowLayoutManager, GetDlgItem(hwndDlg, IDC_SEPARATOR), NULL, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_BOTTOM); PhAddLayoutItem(&PvTabWindowLayoutManager, PvTabContainerControl, NULL, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM); PhAddLayoutItem(&PvTabWindowLayoutManager, GetDlgItem(hwndDlg, IDC_OPTIONS), NULL, PH_ANCHOR_LEFT | PH_ANCHOR_BOTTOM); PhAddLayoutItem(&PvTabWindowLayoutManager, GetDlgItem(hwndDlg, IDC_SECURITY), NULL, PH_ANCHOR_LEFT | PH_ANCHOR_BOTTOM); PhAddLayoutItem(&PvTabWindowLayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_RIGHT | PH_ANCHOR_BOTTOM); if (PhEnableThemeSupport) PhInitializeWindowTheme(hwndDlg, TRUE); { HICON smallIcon; HICON largeIcon; if (!PhExtractIcon(PvFileName->Buffer, &PvImageLargeIcon, &PvImageSmallIcon)) { PhGetStockApplicationIcon(&PvImageSmallIcon, &PvImageLargeIcon); } PhGetStockApplicationIcon(&smallIcon, &largeIcon); SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)smallIcon); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)largeIcon); } if (PvpLoadDbgHelp(&PvSymbolProvider)) { PPH_STRING fileName; if (NT_SUCCESS(PhGetProcessMappedFileName(NtCurrentProcess(), PvMappedImage.ViewBase, &fileName))) { if (PvMappedImage.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { PhLoadModuleSymbolProvider( PvSymbolProvider, fileName, (ULONG64)PvMappedImage.NtHeaders32->OptionalHeader.ImageBase, PvMappedImage.NtHeaders32->OptionalHeader.SizeOfImage ); } else { PhLoadModuleSymbolProvider( PvSymbolProvider, fileName, (ULONG64)PvMappedImage.NtHeaders->OptionalHeader.ImageBase, PvMappedImage.NtHeaders->OptionalHeader.SizeOfImage ); } PhDereferenceObject(fileName); } PhLoadModulesForVirtualSymbolProvider(PvSymbolProvider, NtCurrentProcessId()); } PvAddTreeViewSections(); if (PhGetIntegerPairSetting(L"MainWindowPosition").X) PhLoadWindowPlacementFromSetting(L"MainWindowPosition", L"MainWindowSize", hwndDlg); else PhCenterWindow(hwndDlg, NULL); } break; case WM_DESTROY: { ULONG i; PPV_WINDOW_SECTION section; PhSaveWindowPlacementToSetting(L"MainWindowPosition", L"MainWindowSize", hwndDlg); PvSaveWindowState(hwndDlg); if (PhGetIntegerSetting(L"MainWindowPageRestoreEnabled")) PhSetStringSetting2(L"MainWindowPage", &PvTabCurrentSection->Name); PhDeleteLayoutManager(&PvTabWindowLayoutManager); for (i = 0; i < PvTabSectionList->Count; i++) { section = PvTabSectionList->Items[i]; PvDestroyTabSection(section); } PhDereferenceObject(PvTabSectionList); PvTabSectionList = NULL; PostQuitMessage(0); } break; case WM_DPICHANGED: { PvSetTreeViewImageList(hwndDlg, PvTabTreeControl); } break; case WM_SIZE: { PvTabWindowOnSize(); } break; case WM_COMMAND: { switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDCANCEL: case IDOK: DestroyWindow(hwndDlg); break; case IDC_OPTIONS: { PvShowOptionsWindow(hwndDlg); } break; case IDC_SECURITY: { PhEditSecurity( hwndDlg, PhGetString(PvFileName), L"FileObject", PhpOpenFileSecurity, NULL, NULL ); } break; } } break; case WM_DRAWITEM: { PDRAWITEMSTRUCT drawInfo = (PDRAWITEMSTRUCT)lParam; //if (drawInfo->CtlID == IDC_SEPARATOR) //{ // RECT rect; // // rect = drawInfo->rcItem; // rect.right = 2; // // if (PhEnableThemeSupport) // { // switch (PhCsGraphColorMode) // { // case 0: // New colors // { // FillRect(drawInfo->hDC, &rect, GetSysColorBrush(COLOR_3DHIGHLIGHT)); // rect.left += 1; // FillRect(drawInfo->hDC, &rect, GetSysColorBrush(COLOR_3DSHADOW)); // } // break; // case 1: // Old colors // { // SetDCBrushColor(drawInfo->hDC, RGB(0, 0, 0)); // FillRect(drawInfo->hDC, &rect, GetStockBrush(DC_BRUSH)); // } // break; // } // } // else // { // FillRect(drawInfo->hDC, &rect, GetSysColorBrush(COLOR_3DHIGHLIGHT)); // rect.left += 1; // FillRect(drawInfo->hDC, &rect, GetSysColorBrush(COLOR_3DSHADOW)); // } // // return TRUE; //} } break; case WM_NOTIFY: { LPNMHDR header = (LPNMHDR)lParam; switch (header->code) { case TVN_SELCHANGED: { LPNMTREEVIEW treeview = (LPNMTREEVIEW)lParam; PPV_WINDOW_SECTION section; if (section = PvGetSelectedTabSection(treeview->itemNew.hItem)) { PvEnterTabSectionView(section); } } break; case NM_SETCURSOR: { if (header->hwndFrom == PvTabTreeControl) { PhSetCursor(PhLoadArrowCursor()); SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); return TRUE; } } break; } } break; } return FALSE; } VOID PvTabWindowOnSize( VOID ) { PhLayoutManagerLayout(&PvTabWindowLayoutManager); if (PvTabSectionList && PvTabSectionList->Count != 0) { PvLayoutTabSectionView(); } } HTREEITEM PvTreeViewInsertItem( _In_opt_ HTREEITEM HandleInsertAfter, _In_ PWSTR Text, _In_ PVOID Context ) { TV_INSERTSTRUCT insert; memset(&insert, 0, sizeof(TV_INSERTSTRUCT)); insert.hParent = TVI_ROOT; insert.hInsertAfter = HandleInsertAfter; insert.item.mask = TVIF_TEXT | TVIF_PARAM; insert.item.pszText = Text; insert.item.lParam = (LPARAM)Context; return TreeView_InsertItem(PvTabTreeControl, &insert); } PPV_WINDOW_SECTION PvGetSelectedTabSection( _In_opt_ PVOID TreeItemHandle ) { TVITEM item; HTREEITEM itemHandle; if (TreeItemHandle) itemHandle = TreeItemHandle; else itemHandle = TreeView_GetSelection(PvTabTreeControl); memset(&item, 0, sizeof(TVITEM)); item.mask = TVIF_PARAM | TVIF_HANDLE; item.hItem = itemHandle; if (!TreeView_GetItem(PvTabTreeControl, &item)) return NULL; return (PPV_WINDOW_SECTION)item.lParam; } PPV_WINDOW_SECTION PvCreateTabSection( _In_ PWSTR Name, _In_ PVOID Instance, _In_ PWSTR Template, _In_ DLGPROC DialogProc, _In_opt_ PVOID Parameter ) { PPV_WINDOW_SECTION section; section = PhAllocateZero(sizeof(PV_WINDOW_SECTION)); PhInitializeStringRefLongHint(&section->Name, Name); section->Instance = Instance; section->Template = Template; section->DialogProc = DialogProc; section->Parameter = Parameter; section->TreeItemHandle = PvTreeViewInsertItem(TVI_LAST, Name, section); PhAddItemList(PvTabSectionList, section); return section; } PPV_WINDOW_SECTION PhOptionsCreateSectionAdvanced( _In_ PWSTR Name, _In_ PVOID Instance, _In_ PWSTR Template, _In_ DLGPROC DialogProc, _In_opt_ PVOID Parameter ) { PPV_WINDOW_SECTION section; section = PhAllocateZero(sizeof(PV_WINDOW_SECTION)); PhInitializeStringRefLongHint(&section->Name, Name); section->Instance = Instance; section->Template = Template; section->DialogProc = DialogProc; section->Parameter = Parameter; PhAddItemList(PvTabSectionList, section); return section; } VOID PvDestroyTabSection( _In_ PPV_WINDOW_SECTION Section ) { PhFree(Section); } PPV_WINDOW_SECTION PvFindTabSectionByName( _In_ PPH_STRINGREF Name ) { ULONG i; PPV_WINDOW_SECTION section; for (i = 0; i < PvTabSectionList->Count; i++) { section = PvTabSectionList->Items[i]; if (PhEqualStringRef(&section->Name, Name, TRUE)) return section; } return NULL; } VOID PvLayoutTabSectionView( VOID ) { if (PvTabCurrentSection && PvTabCurrentSection->DialogHandle) { RECT clientRect; GetClientRect(PvTabContainerControl, &clientRect); SetWindowPos( PvTabCurrentSection->DialogHandle, NULL, 0, 0, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top, SWP_NOACTIVATE | SWP_NOZORDER ); } } VOID PvEnterTabSectionView( _In_ PPV_WINDOW_SECTION NewSection ) { ULONG i; PPV_WINDOW_SECTION section; PPV_WINDOW_SECTION oldSection; HDWP containerDeferHandle; if (PvTabCurrentSection == NewSection) return; oldSection = PvTabCurrentSection; PvTabCurrentSection = NewSection; containerDeferHandle = BeginDeferWindowPos(PvTabSectionList->Count); PvEnterTabSectionViewInner(NewSection, &containerDeferHandle); PvLayoutTabSectionView(); for (i = 0; i < PvTabSectionList->Count; i++) { section = PvTabSectionList->Items[i]; if (section != NewSection) PvEnterTabSectionViewInner(section, &containerDeferHandle); } EndDeferWindowPos(containerDeferHandle); if (NewSection->DialogHandle) RedrawWindow(NewSection->DialogHandle, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW); } VOID PvEnterTabSectionViewInner( _In_ PPV_WINDOW_SECTION Section, _Inout_ HDWP *ContainerDeferHandle ) { if (Section == PvTabCurrentSection && !Section->DialogHandle) PvCreateTabSectionDialog(Section); if (Section->DialogHandle) { if (Section == PvTabCurrentSection) *ContainerDeferHandle = DeferWindowPos(*ContainerDeferHandle, Section->DialogHandle, NULL, 0, 0, 0, 0, SWP_SHOWWINDOW_ONLY | SWP_NOREDRAW); else *ContainerDeferHandle = DeferWindowPos(*ContainerDeferHandle, Section->DialogHandle, NULL, 0, 0, 0, 0, SWP_HIDEWINDOW_ONLY | SWP_NOREDRAW); } } VOID PvCreateTabSectionDialog( _In_ PPV_WINDOW_SECTION Section ) { Section->DialogHandle = PhCreateDialogFromTemplate( PvTabContainerControl, DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE, Section->Instance, Section->Template, Section->DialogProc, Section->Parameter ); PhInitializeWindowTheme(Section->DialogHandle, PhEnableThemeSupport); }
b8f8d01c63566c17aebd4bd22fe94ad9124e507a
dfb9c45447721431326cc16bb7655cca7b20eeb9
/src/elem/XKeyPad_Num-setup.h
6fc2e41dc5fc4805725454bf256a150d1802c007
[ "LicenseRef-scancode-proprietary-license", "MIT" ]
permissive
ImpulseAdventure/GUIslice
6257ec4b2a02205b7c1ba00b8795e573609fb1bf
e002baae1ac7cd6c504a26aea78dd81fdc21fcb7
refs/heads/master
2023-08-04T20:51:27.740337
2022-04-09T16:23:57
2022-04-09T16:23:57
69,373,650
993
216
MIT
2022-04-09T16:30:29
2016-09-27T15:55:00
C
UTF-8
C
false
false
5,667
h
XKeyPad_Num-setup.h
#ifndef _GUISLICE_EX_XKEYPAD_NUM_SETUP_H_ #define _GUISLICE_EX_XKEYPAD_NUM_SETUP_H_ #include "elem/XKeyPad.h" #include "elem/XKeyPad_Num.h" // ============================================================================ // This is the setup file associated with the XKeyPad_Num // ============================================================================ #define XKEYPAD_EXTEND_CHAR 0 // 0=Single-char, 1=Multi-char #define XKEYPAD_LABEL_MAX 6 // Max buffer for a key label #define XKEYPAD_DISP_MAX 12 // Maximum display length (without NULL) #define XKEYPAD_KEY_W 25 // Default key width #define XKEYPAD_KEY_H 25 // Default key height #define XKEYPAD_SPACING_X 0 // Default key spacing in X direction #define XKEYPAD_SPACING_Y 0 // Default key spacing in Y direction // Other custom settings / values static const char* KEYPAD_LABEL_NEGATIVE = "-"; static const char* KEYPAD_LABEL_DECIMAL_PT = "."; // Define the set of available KeyPad layouts typedef enum { // List of keypad layouts E_XKEYPAD_SET_NUM, // Terminator E_XKEYPAD_SET__MAX, } gslc_teXKeyPadSel; // Define the startup layout static const int8_t XKEYPAD_LAYOUT_DEFAULT = E_XKEYPAD_SET_NUM; // Define local list of variant-specific button ID types enum { // --- Variant-specific special buttons // These are reserved the global ID range 16..31 KEYPAD_IDV_DECIMAL = 16, KEYPAD_IDV_MINUS, }; // Define the text strings for each special button // - And associate with each Key ID static gslc_tsLabelSpecial KEYPAD_SPECIAL_LABEL[] = { { KEYPAD_ID_BACKSPACE, "BS"}, { KEYPAD_IDV_DECIMAL, "."}, { KEYPAD_IDV_MINUS, "-"}, { KEYPAD_ID_ESC, "ESC"}, { KEYPAD_ID_ENTER, "ENT"}, { KEYPAD_ID_SCROLL_LEFT, "<"}, { KEYPAD_ID_SCROLL_RIGHT, ">"}, // Terminate list { KEYPAD_ID__END,""}, }; // Text for the basic buttons // - For each of the available keypad layouts, provide a // single character per button. // - Each keypad layout should have the same number of characters, // so use a dummy character (eg. space) if a key button // is unused. // The definition of keypad labels depends on whether // support for extended character sets is required. #if (XKEYPAD_EXTEND_CHAR) // Support extended character set static const char* KEYPAD_SET_LABEL[E_XKEYPAD_SET__MAX][10] = { { // Numeric "0","1","2","3","4","5","6","7","8","9", }, }; #else // Support ASCII character set static const char* KEYPAD_SET_LABEL[] = { "0123456789", // Num }; #endif // XKEYPAD_EXTEND_CHAR // Define a layout of the KeyPad // - { ID, ROW, COL, ROWSPAN< COLSPAN, TYPE } static gslc_tsKey KEYPAD_LAYOUT[] = { // Text field { KEYPAD_ID_TXT, 0, 1, 1, 4, E_XKEYPAD_TYPE_TXT }, // Special & Basic buttons { KEYPAD_ID_SCROLL_LEFT, 0, 0, 1, 1, E_XKEYPAD_TYPE_SPECIAL }, { KEYPAD_ID_SCROLL_RIGHT, 0, 5, 1, 1, E_XKEYPAD_TYPE_SPECIAL }, { KEYPAD_ID_ESC, 0, 6, 1, 2, E_XKEYPAD_TYPE_SPECIAL }, { KEYPAD_ID_BASIC_START+0 , 1, 0, 1, 1, E_XKEYPAD_TYPE_BASIC }, // "0" { KEYPAD_ID_BASIC_START+1 , 1, 1, 1, 1, E_XKEYPAD_TYPE_BASIC }, // "1", { KEYPAD_ID_BASIC_START+2 , 1, 2, 1, 1, E_XKEYPAD_TYPE_BASIC }, // "2", { KEYPAD_ID_BASIC_START+3 , 1, 3, 1, 1, E_XKEYPAD_TYPE_BASIC }, // "3", { KEYPAD_ID_BASIC_START+4 , 1, 4, 1, 1, E_XKEYPAD_TYPE_BASIC }, // "4", { KEYPAD_IDV_MINUS, 1, 5, 1, 1, E_XKEYPAD_TYPE_SPECIAL }, { KEYPAD_ID_BACKSPACE, 1, 6, 1, 2, E_XKEYPAD_TYPE_SPECIAL }, { KEYPAD_ID_BASIC_START+5 , 2, 0, 1, 1, E_XKEYPAD_TYPE_BASIC }, // "5", { KEYPAD_ID_BASIC_START+6 , 2, 1, 1, 1, E_XKEYPAD_TYPE_BASIC }, // "6", { KEYPAD_ID_BASIC_START+7 , 2, 2, 1, 1, E_XKEYPAD_TYPE_BASIC }, // "7" , { KEYPAD_ID_BASIC_START+8 , 2, 3, 1, 1, E_XKEYPAD_TYPE_BASIC }, // "8", { KEYPAD_ID_BASIC_START+9 , 2, 4, 1, 1, E_XKEYPAD_TYPE_BASIC }, // "9", { KEYPAD_IDV_DECIMAL, 2, 5, 1, 1, E_XKEYPAD_TYPE_SPECIAL }, { KEYPAD_ID_ENTER, 2, 6, 1, 2, E_XKEYPAD_TYPE_SPECIAL }, // End of list { KEYPAD_ID__END,0,0,0,0,E_XKEYPAD_TYPE_END }, }; // Define a layout to use for each KeyPad page static gslc_tsKey* KEYPAD_LAYOUTS[E_XKEYPAD_SET__MAX] = { KEYPAD_LAYOUT, // Num }; // Define colors // - Default colors #define XKEYPAD_COL_DISABLE_TXT GSLC_COL_GRAY_LT1 #define XKEYPAD_COL_DISABLE_FILL GSLC_COL_BLACK #define XKEYPAD_COL_DEF_TXT GSLC_COL_WHITE #define XKEYPAD_COL_DEF_FRAME GSLC_COL_GRAY #define XKEYPAD_COL_DEF_FILL GSLC_COL_GRAY_DK1 #define XKEYPAD_COL_DEF_GLOW GSLC_COL_GRAY_LT3 // - Color overrides for common keys #define XKEYPAD_COL_BASIC_FILL GSLC_COL_BLUE_DK1 #define XKEYPAD_COL_BASIC_GLOW GSLC_COL_BLUE_LT4 #define XKEYPAD_COL_TEXT_TXT GSLC_COL_YELLOW #define XKEYPAD_COL_TEXT_FILL GSLC_COL_BLACK #define XKEYPAD_COL_TEXT_GLOW GSLC_COL_GRAY_DK2 #define XKEYPAD_COL_SPACE_FILL GSLC_COL_BLUE_DK1 #define XKEYPAD_COL_SPACE_GLOW GSLC_COL_BLUE_LT4 #define XKEYPAD_COL_ESC_FILL GSLC_COL_RED_DK1 #define XKEYPAD_COL_ESC_GLOW GSLC_COL_RED_LT4 #define XKEYPAD_COL_ENTER_FILL GSLC_COL_GREEN_DK1 #define XKEYPAD_COL_ENTER_GLOW GSLC_COL_GREEN_LT4 #define XKEYPAD_COL_SCROLL_L_FILL GSLC_COL_BLUE_DK1 #define XKEYPAD_COL_SCROLL_L_GLOW GSLC_COL_BLUE_LT4 #define XKEYPAD_COL_SCROLL_R_FILL GSLC_COL_BLUE_DK1 #define XKEYPAD_COL_SCROLL_R_GLOW GSLC_COL_BLUE_LT4 // - Color overrides for variant-specific keys #define XKEYPAD_COL_DECIMAL_FILL GSLC_COL_GRAY_DK1 #define XKEYPAD_COL_DECIMAL_GLOW GSLC_COL_GRAY_LT4 #define XKEYPAD_COL_MINUS_FILL GSLC_COL_GRAY_DK1 #define XKEYPAD_COL_MINUS_GLOW GSLC_COL_GRAY_LT4 #endif // _GUISLICE_EX_XKEYPAD_NUM_SETUP_H_
b850f18a7eda9e3773df7424dfb9922bc5ee48d6
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/bluetrum/libcpu/cpu/interrupt.h
d950f1f9b4504ade38f8d51de3641576440f2634
[ "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
124
h
interrupt.h
#ifndef INTERRUPT_H__ #define INTERRUPT_H__ void rt_hw_irq_enable(int vector); void rt_hw_irq_disable(int vector); #endif
ed13f79dc88efcd796dd12e0b9b51a5cffb2dae4
321d11eaee885ceb3a74db0a062f9bbdf282148c
/crypto/conf/conf_lib.c
05e7bf19cc7b35202753119e15bf917ba3b573bf
[ "Apache-2.0", "OpenSSL", "LicenseRef-scancode-proprietary-license" ]
permissive
openssl/openssl
75691ebaae957793f2ff0673f77545277dfb3988
5318c012885a5382eadbf95aa9c1d35664bca819
refs/heads/master
2023-09-03T15:22:52.727123
2023-09-01T07:10:49
2023-09-02T14:30:01
7,634,677
24,148
11,569
Apache-2.0
2023-09-14T19:48:11
2013-01-15T22:34:48
C
UTF-8
C
false
false
10,807
c
conf_lib.c
/* * Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include "internal/e_os.h" #include <stdio.h> #include <string.h> #include "internal/conf.h" #include "crypto/ctype.h" #include <openssl/crypto.h> #include <openssl/err.h> #include <openssl/conf.h> #include <openssl/conf_api.h> #include "conf_local.h" #include <openssl/lhash.h> static CONF_METHOD *default_CONF_method = NULL; /* Init a 'CONF' structure from an old LHASH */ void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash) { if (default_CONF_method == NULL) default_CONF_method = NCONF_default(); default_CONF_method->init(conf); conf->data = hash; } /* * The following section contains the "CONF classic" functions, rewritten in * terms of the new CONF interface. */ int CONF_set_default_method(CONF_METHOD *meth) { default_CONF_method = meth; return 1; } LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, long *eline) { LHASH_OF(CONF_VALUE) *ltmp; BIO *in = NULL; #ifdef OPENSSL_SYS_VMS in = BIO_new_file(file, "r"); #else in = BIO_new_file(file, "rb"); #endif if (in == NULL) { ERR_raise(ERR_LIB_CONF, ERR_R_SYS_LIB); return NULL; } ltmp = CONF_load_bio(conf, in, eline); BIO_free(in); return ltmp; } #ifndef OPENSSL_NO_STDIO LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, long *eline) { BIO *btmp; LHASH_OF(CONF_VALUE) *ltmp; if ((btmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) { ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB); return NULL; } ltmp = CONF_load_bio(conf, btmp, eline); BIO_free(btmp); return ltmp; } #endif LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, long *eline) { CONF ctmp; int ret; CONF_set_nconf(&ctmp, conf); ret = NCONF_load_bio(&ctmp, bp, eline); if (ret) return ctmp.data; return NULL; } STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, const char *section) { if (conf == NULL) { return NULL; } else { CONF ctmp; CONF_set_nconf(&ctmp, conf); return NCONF_get_section(&ctmp, section); } } char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, const char *name) { if (conf == NULL) { return NCONF_get_string(NULL, group, name); } else { CONF ctmp; CONF_set_nconf(&ctmp, conf); return NCONF_get_string(&ctmp, group, name); } } long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, const char *name) { int status; long result = 0; ERR_set_mark(); if (conf == NULL) { status = NCONF_get_number_e(NULL, group, name, &result); } else { CONF ctmp; CONF_set_nconf(&ctmp, conf); status = NCONF_get_number_e(&ctmp, group, name, &result); } ERR_pop_to_mark(); return status == 0 ? 0L : result; } void CONF_free(LHASH_OF(CONF_VALUE) *conf) { CONF ctmp; CONF_set_nconf(&ctmp, conf); NCONF_free_data(&ctmp); } #ifndef OPENSSL_NO_STDIO int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out) { BIO *btmp; int ret; if ((btmp = BIO_new_fp(out, BIO_NOCLOSE)) == NULL) { ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB); return 0; } ret = CONF_dump_bio(conf, btmp); BIO_free(btmp); return ret; } #endif int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out) { CONF ctmp; CONF_set_nconf(&ctmp, conf); return NCONF_dump_bio(&ctmp, out); } /* * The following section contains the "New CONF" functions. They are * completely centralised around a new CONF structure that may contain * basically anything, but at least a method pointer and a table of data. * These functions are also written in terms of the bridge functions used by * the "CONF classic" functions, for consistency. */ CONF *NCONF_new_ex(OSSL_LIB_CTX *libctx, CONF_METHOD *meth) { CONF *ret; if (meth == NULL) meth = NCONF_default(); ret = meth->create(meth); if (ret == NULL) { ERR_raise(ERR_LIB_CONF, ERR_R_CONF_LIB); return NULL; } ret->libctx = libctx; return ret; } CONF *NCONF_new(CONF_METHOD *meth) { return NCONF_new_ex(NULL, meth); } void NCONF_free(CONF *conf) { if (conf == NULL) return; conf->meth->destroy(conf); } void NCONF_free_data(CONF *conf) { if (conf == NULL) return; conf->meth->destroy_data(conf); } OSSL_LIB_CTX *NCONF_get0_libctx(const CONF *conf) { return conf->libctx; } typedef STACK_OF(OPENSSL_CSTRING) SECTION_NAMES; IMPLEMENT_LHASH_DOALL_ARG_CONST(CONF_VALUE, SECTION_NAMES); static void collect_section_name(const CONF_VALUE *v, SECTION_NAMES *names) { /* A section is a CONF_VALUE with name == NULL */ if (v->name == NULL) sk_OPENSSL_CSTRING_push(names, v->section); } static int section_name_cmp(OPENSSL_CSTRING const *a, OPENSSL_CSTRING const *b) { return strcmp(*a, *b); } STACK_OF(OPENSSL_CSTRING) *NCONF_get_section_names(const CONF *cnf) { SECTION_NAMES *names; if ((names = sk_OPENSSL_CSTRING_new(section_name_cmp)) == NULL) return NULL; lh_CONF_VALUE_doall_SECTION_NAMES(cnf->data, collect_section_name, names); sk_OPENSSL_CSTRING_sort(names); return names; } int NCONF_load(CONF *conf, const char *file, long *eline) { if (conf == NULL) { ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF); return 0; } return conf->meth->load(conf, file, eline); } #ifndef OPENSSL_NO_STDIO int NCONF_load_fp(CONF *conf, FILE *fp, long *eline) { BIO *btmp; int ret; if ((btmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) { ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB); return 0; } ret = NCONF_load_bio(conf, btmp, eline); BIO_free(btmp); return ret; } #endif int NCONF_load_bio(CONF *conf, BIO *bp, long *eline) { if (conf == NULL) { ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF); return 0; } return conf->meth->load_bio(conf, bp, eline); } STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, const char *section) { if (conf == NULL) { ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF); return NULL; } if (section == NULL) { ERR_raise(ERR_LIB_CONF, CONF_R_NO_SECTION); return NULL; } return _CONF_get_section_values(conf, section); } char *NCONF_get_string(const CONF *conf, const char *group, const char *name) { char *s = _CONF_get_string(conf, group, name); /* * Since we may get a value from an environment variable even if conf is * NULL, let's check the value first */ if (s) return s; if (conf == NULL) { ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE); return NULL; } ERR_raise_data(ERR_LIB_CONF, CONF_R_NO_VALUE, "group=%s name=%s", group, name); return NULL; } static int default_is_number(const CONF *conf, char c) { return ossl_isdigit(c); } static int default_to_int(const CONF *conf, char c) { return (int)(c - '0'); } int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, long *result) { char *str; long res; int (*is_number)(const CONF *, char) = &default_is_number; int (*to_int)(const CONF *, char) = &default_to_int; if (result == NULL) { ERR_raise(ERR_LIB_CONF, ERR_R_PASSED_NULL_PARAMETER); return 0; } str = NCONF_get_string(conf, group, name); if (str == NULL) return 0; if (conf != NULL) { if (conf->meth->is_number != NULL) is_number = conf->meth->is_number; if (conf->meth->to_int != NULL) to_int = conf->meth->to_int; } for (res = 0; is_number(conf, *str); str++) { const int d = to_int(conf, *str); if (res > (LONG_MAX - d) / 10L) { ERR_raise(ERR_LIB_CONF, CONF_R_NUMBER_TOO_LARGE); return 0; } res = res * 10 + d; } *result = res; return 1; } long _CONF_get_number(const CONF *conf, const char *section, const char *name) { int status; long result = 0; ERR_set_mark(); status = NCONF_get_number_e(conf, section, name, &result); ERR_pop_to_mark(); return status == 0 ? 0L : result; } #ifndef OPENSSL_NO_STDIO int NCONF_dump_fp(const CONF *conf, FILE *out) { BIO *btmp; int ret; if ((btmp = BIO_new_fp(out, BIO_NOCLOSE)) == NULL) { ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB); return 0; } ret = NCONF_dump_bio(conf, btmp); BIO_free(btmp); return ret; } #endif int NCONF_dump_bio(const CONF *conf, BIO *out) { if (conf == NULL) { ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF); return 0; } return conf->meth->dump(conf, out); } /* * These routines call the C malloc/free, to avoid intermixing with * OpenSSL function pointers before the library is initialized. */ OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void) { OPENSSL_INIT_SETTINGS *ret = malloc(sizeof(*ret)); if (ret == NULL) return NULL; memset(ret, 0, sizeof(*ret)); ret->flags = DEFAULT_CONF_MFLAGS; return ret; } #ifndef OPENSSL_NO_STDIO int OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings, const char *filename) { char *newfilename = NULL; if (filename != NULL) { newfilename = strdup(filename); if (newfilename == NULL) return 0; } free(settings->filename); settings->filename = newfilename; return 1; } void OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *settings, unsigned long flags) { settings->flags = flags; } int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings, const char *appname) { char *newappname = NULL; if (appname != NULL) { newappname = strdup(appname); if (newappname == NULL) return 0; } free(settings->appname); settings->appname = newappname; return 1; } #endif void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings) { free(settings->filename); free(settings->appname); free(settings); }
a877df1c7444266f630da82d93de92752259646f
222f18d098566069f8d72135e2ea3249438df2d6
/c64/src/prog/circle_test.c
e69a85835fa1d5b03993653c1dd1b3544da5b707
[]
no_license
MJoergen/nexys4ddr
e36c10aa82a43e0a914e50b1b5cb03af01cf282c
683c80c1c4abbf536c3bdb0b98b2ece8aaf7bef6
refs/heads/master
2023-09-01T06:36:50.833132
2023-08-30T06:43:09
2023-08-30T06:43:09
103,973,677
137
19
null
null
null
null
UTF-8
C
false
false
2,102
c
circle_test.c
// // This is a complete demo. Features demonstrated are: // Keyboard input. // Moving sprites. // Horizontal scrolling text. TBD // #include "memorymap.h" #include "zeropage.h" // Variables to be stored in the zero-page. #include "circle.h" // Routines to move the sprite around in a circle. #include "smult.h" // Signed 8-bit multiplication. #define COL_LIGHT 0x6F // 011_011_11 #define COL_DARK 0x44 // 010_001_00 #define COL_BLACK 0x00 // 000_000_00 static unsigned char irqA; static unsigned char irqX; static unsigned char irqY; static unsigned char irqCnt; #define YPOS_LINE1 2 // The interrupt service routine. void __fastcall__ irq(void) { __asm__("STA %v", irqA); // Store A register __asm__("TXA"); __asm__("STA %v", irqX); // Store X register __asm__("TYA"); __asm__("STA %v", irqY); // Store Y register circle_move(); __asm__("LDA %v", irqY); // Restore Y __asm__("TAY"); __asm__("LDA %v", irqX); // Restore X __asm__("TAX"); __asm__("LDA %v", irqA); // Restore A __asm__("RTI"); } // end of irq // Entry point after CPU reset void __fastcall__ reset(void) { __asm__("SEI"); // Disable all interrupts __asm__("LDX #$FF"); __asm__("TXS"); // Reset stack pointer smult_init(); circle_init(); // Configure text color __asm__("LDA #%b", COL_LIGHT); __asm__("STA %w", VGA_ADDR_FGCOL); __asm__("LDA #%b", COL_DARK); __asm__("STA %w", VGA_ADDR_BGCOL); // Configure VGA interrupt __asm__("LDA #%b", YPOS_LINE1); __asm__("STA %w", VGA_ADDR_YLINE); // Set the interrupt at the end of the first line __asm__("LDA #$01"); __asm__("STA %w", VGA_ADDR_MASK); __asm__("LDA %w", VGA_ADDR_IRQ); // Clear any pending IRQ __asm__("LDA #$00"); __asm__("STA %v", irqCnt); __asm__("CLI"); loop: goto loop; // Just do an endless loop. } // end of reset // Non-maskable interrupt void __fastcall__ nmi(void) { // Not used. __asm__("RTI"); } // end of nmi
cf59a7e7d8c04c1b8ae68747ab45bb2ac556fc5c
5de3ec4e6c65e60da1ed32b03748f96de7ef0b95
/Pods/Headers/Private/Realm/RLMResults_Private.h
177a372b6d69d59f9e8d216af3e908bd99444e2a
[ "MIT" ]
permissive
aaronpearce/DevSwitch
5154730f4f9eabcc14a6ad1222c6823b250b991e
98a1e6ded11907a02d21380ca93999d34b85b0b2
refs/heads/master
2021-06-10T22:56:56.239592
2021-06-04T21:25:40
2021-06-04T21:25:40
177,062,016
457
25
MIT
2019-03-24T22:37:41
2019-03-22T03:00:31
Swift
UTF-8
C
false
false
43
h
RLMResults_Private.h
../../../Realm/include/RLMResults_Private.h
fa9384d4cc5571c00175a8b4cc619efcc5a95809
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
/third_party/intel/xsaveintrin.internal.h
fa72c42b2ff990c744685fa95fc334a53a1c559e
[ "ISC" ]
permissive
jart/cosmopolitan
fb11b5658939023977060a7c6c71a74093d9cb44
0d748ad58e1063dd1f8560f18a0c75293b9415b7
refs/heads/master
2023-09-06T09:17:29.303607
2023-09-02T03:49:13
2023-09-02T03:50:18
272,457,606
11,887
435
ISC
2023-09-14T17:47:58
2020-06-15T14:16:13
C
UTF-8
C
false
false
1,480
h
xsaveintrin.internal.h
/* clang-format off */ #if defined(__x86_64__) && !(__ASSEMBLER__ + __LINKER__ + 0) #ifndef _X86GPRINTRIN_H_INCLUDED # error "Never use <xsaveintrin.h> directly; include <x86gprintrin.h> instead." #endif #ifndef _XSAVEINTRIN_H_INCLUDED #define _XSAVEINTRIN_H_INCLUDED #ifndef __XSAVE__ #pragma GCC push_options #pragma GCC target("xsave") #define __DISABLE_XSAVE__ #endif extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _xsave (void *__P, long long __M) { __builtin_ia32_xsave (__P, __M); } extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _xrstor (void *__P, long long __M) { __builtin_ia32_xrstor (__P, __M); } extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _xsetbv (unsigned int __A, long long __V) { __builtin_ia32_xsetbv (__A, __V); } extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _xgetbv (unsigned int __A) { return __builtin_ia32_xgetbv (__A); } #ifdef __x86_64__ extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _xsave64 (void *__P, long long __M) { __builtin_ia32_xsave64 (__P, __M); } extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _xrstor64 (void *__P, long long __M) { __builtin_ia32_xrstor64 (__P, __M); } #endif #ifdef __DISABLE_XSAVE__ #undef __DISABLE_XSAVE__ #pragma GCC pop_options #endif #endif #endif
7032419799a6375dc31864bb433846b748127d57
e5aa0f7de0dcbc86408348c51e6bf0edb8e833e9
/sway/commands/bar/modifier.c
983d21795c2f09cfe4b3768b113e4d3f92e20566
[ "MIT" ]
permissive
swaywm/sway
8400f4fa5eebaccfceb9196b2692b80ae27eef3c
89f85312687b7fd1777c936e169e6400cee0a4b4
refs/heads/master
2023-09-06T01:57:38.706040
2023-08-30T14:57:25
2023-08-30T14:57:25
40,217,904
11,469
1,362
MIT
2023-09-14T11:37:52
2015-08-05T01:31:45
C
UTF-8
C
false
false
1,160
c
modifier.c
#include <string.h> #include "sway/commands.h" #include "sway/input/keyboard.h" #include "log.h" #include "stringop.h" struct cmd_results *bar_cmd_modifier(int argc, char **argv) { struct cmd_results *error = NULL; if ((error = checkarg(argc, "modifier", EXPECTED_EQUAL_TO, 1))) { return error; } uint32_t mod = 0; if (strcmp(argv[0], "none") != 0) { list_t *split = split_string(argv[0], "+"); for (int i = 0; i < split->length; ++i) { uint32_t tmp_mod; if ((tmp_mod = get_modifier_mask_by_name(split->items[i])) > 0) { mod |= tmp_mod; } else if (strcmp(split->items[i], "none") == 0) { error = cmd_results_new(CMD_INVALID, "none cannot be used along with other modifiers"); list_free_items_and_destroy(split); return error; } else { error = cmd_results_new(CMD_INVALID, "Unknown modifier '%s'", (char *)split->items[i]); list_free_items_and_destroy(split); return error; } } list_free_items_and_destroy(split); } config->current_bar->modifier = mod; sway_log(SWAY_DEBUG, "Show/Hide the bar when pressing '%s' in hide mode.", argv[0]); return cmd_results_new(CMD_SUCCESS, NULL); }
7fea622d3bcf4bb62155184d7437641fc3dcaecd
ea910d9946ff96f44bf8895508d053f3075f7c3a
/third_party/emu2/src/video.h
aef252f800297c70e2242429482ecae69fb69dcc
[ "GPL-2.0-only", "BSD-2-Clause", "GPL-1.0-or-later", "MIT", "GPL-3.0-only", "LicenseRef-scancode-public-domain" ]
permissive
davidgiven/cowgol
290e4ba4e6e87b4619a5f69c0c156145f31cee88
ec33ae1293df3937c6397575a0f7defb5e3b4a4d
refs/heads/master
2023-07-13T20:31:01.261973
2023-03-06T19:06:34
2023-03-06T19:06:34
93,265,830
180
29
BSD-2-Clause
2023-03-05T19:29:03
2017-06-03T18:12:02
C
UTF-8
C
false
false
411
h
video.h
#pragma once #include <stdint.h> void int10(void); // Redraws terminal screen void check_screen(void); // Returns 1 if video emulation is active. int video_active(void); // Writes a character to the video screen void video_putch(char ch); // Get current column in current page int video_get_col(void); // CRTC port read/write uint8_t video_crtc_read(int port); void video_crtc_write(int port, uint8_t value);
306eb9021d0ee9a583a5a45e63fefdc8edf86e80
3ddf7c08dace0ba443dcd10ad806f6642ff9566c
/userspace/libc/include/pthread.h
ca5aae817b095ca161a392ebed6369cc2d605796
[]
no_license
IAIK/sweb
044897896535b0a0ec14d3ac639db8a9af55871d
ad1b59a5c2acbd4bff346bdf282a4d5e21bd9cb1
refs/heads/main
2023-05-28T18:47:43.138570
2023-03-25T23:45:18
2023-05-19T22:53:52
21,390,148
120
178
null
2023-05-19T22:53:54
2014-07-01T14:13:15
C++
UTF-8
C
false
false
1,544
h
pthread.h
#pragma once #include "types.h" #ifdef __cplusplus extern "C" { #endif //pthread typedefs typedef size_t pthread_t; typedef unsigned int pthread_attr_t; //pthread mutex typedefs typedef unsigned int pthread_mutex_t; typedef unsigned int pthread_mutexattr_t; //pthread spinlock typedefs typedef unsigned int pthread_spinlock_t; //pthread cond typedefs typedef unsigned int pthread_cond_t; typedef unsigned int pthread_condattr_t; extern int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); extern void pthread_exit(void *value_ptr); extern int pthread_cancel(pthread_t thread); extern int pthread_join(pthread_t thread, void **value_ptr); extern int pthread_detach(pthread_t thread); extern int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr); extern int pthread_mutex_destroy(pthread_mutex_t *mutex); extern int pthread_mutex_lock(pthread_mutex_t *mutex); extern int pthread_mutex_unlock(pthread_mutex_t *mutex); extern int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); extern int pthread_cond_destroy(pthread_cond_t *cond); extern int pthread_cond_signal(pthread_cond_t *cond); extern int pthread_cond_broadcast(pthread_cond_t *cond); extern int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); extern int pthread_setcancelstate(int state, int *oldstate); extern int pthread_setcanceltype(int type, int *oldtype); #ifdef __cplusplus } #endif
246e93dec5b1df1d80166cdc828d717f979af7e7
128268956eeb76f92d5e89e7002f005bfaddd59d
/include/erasurecode/erasurecode_version.h
5f06cd77bb1de6d6d093d8c40348bb6cc060f4d7
[ "BSD-2-Clause" ]
permissive
openstack/liberasurecode
f95dba37221e534494596842799b664700fa5cbc
cc7de356d6c210b84622264b2ff93a22abdbaf8d
refs/heads/master
2023-07-30T11:19:27.008201
2023-07-13T19:33:26
2023-07-13T19:33:26
58,626,647
136
45
BSD-2-Clause
2021-08-08T06:11:00
2016-05-12T09:15:38
C
UTF-8
C
false
false
1,686
h
erasurecode_version.h
/* * <Copyright> * * 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. 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 HOLDER 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 _ERASURECODE_VERSION_H_ #define _ERASURECODE_VERSION_H_ #define _MAJOR 1 #define _MINOR 6 #define _REV 3 #define _VERSION(x, y, z) ((x << 16) | (y << 8) | (z)) #define LIBERASURECODE_VERSION _VERSION(_MAJOR, _MINOR, _REV) #ifndef LIBERASURECODE_SO_SUFFIX #define LIBERASURECODE_SO_SUFFIX "" #endif // LIBERASURECODE_SO_SUFFIX #endif // _ERASURECODE_VERSION_H_
76841ac1967aed6359710782a812fbed66c0eed8
0cc343d927d5db6693006018986715c43acab961
/src/win/caml_stopwatch.c
990a68784ddf8c529423eacec8febc317b19adf8
[ "MIT" ]
permissive
verifast/verifast
ec0101fc4a69bd33c5f66be4444169c4e060ead8
d152da790c7ebf72ce616533a6c83082629adbdb
refs/heads/master
2023-08-25T00:13:51.464802
2023-08-13T10:00:00
2023-08-13T10:00:00
14,519,163
325
64
NOASSERTION
2023-08-10T21:16:08
2013-11-19T08:57:02
OCaml
UTF-8
C
false
false
1,406
c
caml_stopwatch.c
#include <windows.h> #include <intrin.h> #include <caml/mlvalues.h> #include <caml/alloc.h> value caml_stopwatch_getpid() { return caml_copy_int32(GetCurrentProcessId()); } value caml_lock_process_to_processor_1() { HANDLE currentProcess = GetCurrentProcess(); SetProcessAffinityMask(currentProcess, 1); return Val_unit; } value caml_stopwatch_processor_ticks() { return caml_copy_int64(__rdtsc()); } struct stopwatch { unsigned __int64 counter; unsigned __int64 startTimestamp; }; #ifdef __MINGW32__ #define NO_TIMESTAMP (0x0100000000000000LLU) #else #define NO_TIMESTAMP (0x0100000000000000i64) #endif value caml_stopwatch_create() { struct stopwatch *block = (void *)caml_alloc_small(4, Abstract_tag); block->counter = 0; block->startTimestamp = NO_TIMESTAMP; return (value)block; } value caml_stopwatch_start(value stopwatch) { struct stopwatch *s = (void *)stopwatch; s->startTimestamp = __rdtsc(); return Val_unit; } value caml_stopwatch_stop(value stopwatch) { struct stopwatch *s = (void *)stopwatch; unsigned __int64 tsc = __rdtsc(); s->counter += tsc - s->startTimestamp; s->startTimestamp = NO_TIMESTAMP; return Val_unit; } value caml_stopwatch_ticks(value stopwatch) { struct stopwatch *s = (void *)stopwatch; return caml_copy_int64(s->counter); }
259b0cae46bd1a2440ed7fd262f55e49108dcf7b
821128c7e0c6b41c08474e98dffc9dd5f72b8857
/test/unwrapper_test.c
0ec88aabf5490487324fe3b90951b9c09026b22c
[ "MIT" ]
permissive
yuanrongxi/razor
304b9c5d5a9e011f212dbcb8c773f8e4b4133fef
b361d64ca3357226af3d6c9651bc235905066141
refs/heads/master
2023-07-19T07:47:49.092351
2023-07-16T07:17:50
2023-07-16T07:17:50
126,000,077
322
152
MIT
2021-09-07T10:49:37
2018-03-20T10:25:35
C++
UTF-8
C
false
false
1,163
c
unwrapper_test.c
#include <stdio.h> #include <assert.h> #include "cf_unwrapper.h" static void test_unwrapper32() { cf_unwrapper_t seq_32; int64_t vals[6] = { 0xfffffffc, 0xffffffff, 0xfffffffe, 0xfffffffd, (int64_t)0xffffffff + 1, (int64_t)0xffffffff + 2 }; uint64_t val; int i; init_unwrapper32(&seq_32); seq_32.last_value = 65537 + 40000; for (i = 0; i < 6; i++){ val = wrap_uint32(&seq_32, vals[i]); printf("src = %lld, dst = %llu\n", vals[i], val); } } static void test_unwrapper16() { cf_unwrapper_t seq_16; int32_t vals[6] = { 65533, 65536, 65535, 65534, 65537, 65538 }; uint32_t val; int i; init_unwrapper16(&seq_16); seq_16.last_value = 65532; for (i = 0; i < 6; i++){ val = wrap_uint16(&seq_16, vals[i]); printf("src = %d, dst = %u\n", vals[i], val); } } static void test_for() { cf_unwrapper_t seq_16; uint32_t i, val; init_unwrapper16(&seq_16); for (i = 0; i < 1000000; i += 10){ val = wrap_uint16(&seq_16, i & 0xffff); assert(val == i); } } int test_unwrapper() { uint32_t k = (5 << 26) / 1000; printf("k = %u \n", k); test_unwrapper32(); printf("===============\n"); test_unwrapper16(); test_for(); return 0; }
93993d68df5eb1e13caef8e84ea96a0902c6edbe
5ff4b6986e6799bc0e143e060bafc14369030d8b
/toolchain/riscv-isa-sim/riscv/insns/vsll_vx.h
823510b2c5124d58b1ec6cd349d0ff14421499ba
[ "LicenseRef-scancode-bsd-3-clause-jtag", "GPL-3.0-or-later", "MIT", "LicenseRef-scancode-unknown-license-reference", "GPL-1.0-or-later", "LLVM-exception", "Apache-2.0", "BSD-3-Clause" ]
permissive
pulp-platform/mempool
7583204b2436cfc12ed95599463e51ad4df51557
c98fb3ada4f255623eaf9b09861f397a60c3d96b
refs/heads/main
2023-08-08T09:07:56.696580
2023-07-27T17:24:38
2023-07-27T17:24:38
223,218,149
178
28
Apache-2.0
2023-07-27T17:24:39
2019-11-21T16:34:37
C
UTF-8
C
false
false
58
h
vsll_vx.h
// vsll VI_VX_LOOP ({ vd = vs2 << (rs1 & (sew - 1)); })
1284e4a2c435b9e721c322892d9fe72b058209f6
7e41167bfae6d2c38689b7e0993b308e045cbd05
/libarchive/libarchive/libarchive/test/test_write_format_cpio_odc.c
e2136f87cfb02aa525d4f511f8ae7fd476c5e015
[ "BSD-3-Clause", "curl", "GPL-1.0-or-later", "MIT", "Python-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-bsd-unchanged" ]
permissive
holzschu/ios_system
7b18993dbcb33331c353e0257ca54847a5d1b1bb
6a83eb1c6c383a562fbe33a7e97677e88d305b51
refs/heads/master
2023-08-14T09:11:40.627903
2023-04-18T15:12:29
2023-04-18T15:12:29
113,187,304
882
155
BSD-3-Clause
2023-08-19T19:15:35
2017-12-05T13:42:50
C
UTF-8
C
false
false
9,477
c
test_write_format_cpio_odc.c
/*- * Copyright (c) 2003-2007 Tim Kientzle * All rights reserved. * * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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. */ #include "test.h" __FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_cpio_odc.c 201247 2009-12-30 05:59:21Z kientzle $"); static int is_octal(const char *p, size_t l) { while (l > 0) { if (*p < '0' || *p > '7') return (0); --l; ++p; } return (1); } /* * Detailed verification that cpio 'odc' archives are written with * the correct format. */ DEFINE_TEST(test_write_format_cpio_odc) { struct archive *a; struct archive_entry *entry; char *buff, *e, *file; size_t buffsize = 100000; size_t used; buff = malloc(buffsize); /* Create a new archive in memory. */ assert((a = archive_write_new()) != NULL); assertEqualIntA(a, 0, archive_write_set_format_cpio(a)); assertEqualIntA(a, 0, archive_write_set_compression_none(a)); assertEqualIntA(a, 0, archive_write_open_memory(a, buff, buffsize, &used)); /* * Add various files to it. * TODO: Extend this to cover more filetypes. */ /* "file" with 10 bytes of content */ assert((entry = archive_entry_new()) != NULL); archive_entry_set_mtime(entry, 1, 10); archive_entry_set_pathname(entry, "file"); archive_entry_set_mode(entry, S_IFREG | 0664); archive_entry_set_size(entry, 10); archive_entry_set_uid(entry, 80); archive_entry_set_gid(entry, 90); archive_entry_set_dev(entry, 12); archive_entry_set_ino(entry, 89); archive_entry_set_nlink(entry, 2); assertEqualIntA(a, 0, archive_write_header(a, entry)); archive_entry_free(entry); assertEqualIntA(a, 10, archive_write_data(a, "1234567890", 10)); /* Hardlink to "file" with 10 bytes of content */ assert((entry = archive_entry_new()) != NULL); archive_entry_set_mtime(entry, 1, 10); archive_entry_set_pathname(entry, "linkfile"); archive_entry_set_mode(entry, S_IFREG | 0664); archive_entry_set_size(entry, 10); archive_entry_set_uid(entry, 80); archive_entry_set_gid(entry, 90); archive_entry_set_dev(entry, 12); archive_entry_set_ino(entry, 89); archive_entry_set_nlink(entry, 2); assertEqualIntA(a, 0, archive_write_header(a, entry)); archive_entry_free(entry); assertEqualIntA(a, 10, archive_write_data(a, "1234567890", 10)); /* "dir" */ assert((entry = archive_entry_new()) != NULL); archive_entry_set_mtime(entry, 2, 20); archive_entry_set_pathname(entry, "dir"); archive_entry_set_mode(entry, S_IFDIR | 0775); archive_entry_set_size(entry, 10); archive_entry_set_nlink(entry, 2); assertEqualIntA(a, 0, archive_write_header(a, entry)); archive_entry_free(entry); /* Write of data to dir should fail == zero bytes get written. */ assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10)); /* "symlink" pointing to "file" */ assert((entry = archive_entry_new()) != NULL); archive_entry_set_mtime(entry, 3, 30); archive_entry_set_pathname(entry, "symlink"); archive_entry_set_mode(entry, 0664); archive_entry_set_filetype(entry, AE_IFLNK); archive_entry_set_symlink(entry,"file"); archive_entry_set_size(entry, 0); archive_entry_set_uid(entry, 88); archive_entry_set_gid(entry, 98); archive_entry_set_dev(entry, 12); archive_entry_set_ino(entry, 90); archive_entry_set_nlink(entry, 1); assertEqualIntA(a, 0, archive_write_header(a, entry)); archive_entry_free(entry); /* Write of data to symlink should fail == zero bytes get written. */ assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10)); #if ARCHIVE_VERSION_NUMBER < 2000000 archive_write_finish(a); #else assert(0 == archive_write_finish(a)); #endif /* * Verify the archive format. * * Notes on the ino validation: cpio does not actually require * that the ino values written to the archive match those read * from disk. It really requires that: * * matching non-zero ino values be written as matching * non-zero values * * non-matching non-zero ino values be written as non-matching * non-zero values * Libarchive further ensures that zero ino values get written * as zeroes. This allows the cpio writer to generate * synthetic ino values for the archive that may be different * than those on disk in order to avoid problems due to truncation. * This is especially needed for odc (POSIX format) that * only supports 18-bit ino values. */ e = buff; /* "file" */ file = e; /* Remember where this starts... */ assert(is_octal(e, 76)); /* Entire header is octal digits. */ assertEqualMem(e + 0, "070707", 6); /* Magic */ assertEqualMem(e + 6, "000014", 6); /* dev */ assert(memcmp(e + 12, "000000", 6) != 0); /* ino must be != 0 */ assertEqualMem(e + 18, "100664", 6); /* Mode */ assertEqualMem(e + 24, "000120", 6); /* uid */ assertEqualMem(e + 30, "000132", 6); /* gid */ assertEqualMem(e + 36, "000002", 6); /* nlink */ assertEqualMem(e + 42, "000000", 6); /* rdev */ assertEqualMem(e + 48, "00000000001", 11); /* mtime */ assertEqualMem(e + 59, "000005", 6); /* Name size */ assertEqualMem(e + 65, "00000000012", 11); /* File size */ assertEqualMem(e + 76, "file\0", 5); /* Name contents */ assertEqualMem(e + 81, "1234567890", 10); /* File contents */ e += 91; /* hardlink to "file" */ assert(is_octal(e, 76)); /* Entire header is octal digits. */ assertEqualMem(e + 0, "070707", 6); /* Magic */ assertEqualMem(e + 6, "000014", 6); /* dev */ assertEqualMem(e + 12, file + 12, 6); /* ino must match above */ assertEqualMem(e + 18, "100664", 6); /* Mode */ assertEqualMem(e + 24, "000120", 6); /* uid */ assertEqualMem(e + 30, "000132", 6); /* gid */ assertEqualMem(e + 36, "000002", 6); /* nlink */ assertEqualMem(e + 42, "000000", 6); /* rdev */ assertEqualMem(e + 48, "00000000001", 11); /* mtime */ assertEqualMem(e + 59, "000011", 6); /* Name size */ assertEqualMem(e + 65, "00000000012", 11); /* File size */ assertEqualMem(e + 76, "linkfile\0", 9); /* Name contents */ assertEqualMem(e + 85, "1234567890", 10); /* File contents */ e += 95; /* "dir" */ assert(is_octal(e, 76)); assertEqualMem(e + 0, "070707", 6); /* Magic */ assertEqualMem(e + 6, "000000", 6); /* dev */ assertEqualMem(e + 12, "000000", 6); /* ino */ assertEqualMem(e + 18, "040775", 6); /* Mode */ assertEqualMem(e + 24, "000000", 6); /* uid */ assertEqualMem(e + 30, "000000", 6); /* gid */ assertEqualMem(e + 36, "000002", 6); /* Nlink */ assertEqualMem(e + 42, "000000", 6); /* rdev */ assertEqualMem(e + 48, "00000000002", 11); /* mtime */ assertEqualMem(e + 59, "000004", 6); /* Name size */ assertEqualMem(e + 65, "00000000000", 11); /* File size */ assertEqualMem(e + 76, "dir\0", 4); /* name */ e += 80; /* "symlink" pointing to "file" */ assert(is_octal(e, 76)); /* Entire header is octal digits. */ assertEqualMem(e + 0, "070707", 6); /* Magic */ assertEqualMem(e + 6, "000014", 6); /* dev */ assert(memcmp(e + 12, file + 12, 6) != 0); /* ino must != file ino */ assert(memcmp(e + 12, "000000", 6) != 0); /* ino must != 0 */ assertEqualMem(e + 18, "120664", 6); /* Mode */ assertEqualMem(e + 24, "000130", 6); /* uid */ assertEqualMem(e + 30, "000142", 6); /* gid */ assertEqualMem(e + 36, "000001", 6); /* nlink */ assertEqualMem(e + 42, "000000", 6); /* rdev */ assertEqualMem(e + 48, "00000000003", 11); /* mtime */ assertEqualMem(e + 59, "000010", 6); /* Name size */ assertEqualMem(e + 65, "00000000004", 11); /* File size */ assertEqualMem(e + 76, "symlink\0", 8); /* Name contents */ assertEqualMem(e + 84, "file", 4); /* File contents == link target */ e += 88; /* TODO: Verify other types of entries. */ /* Last entry is end-of-archive marker. */ assert(is_octal(e, 76)); assertEqualMem(e + 0, "070707", 6); /* Magic */ assertEqualMem(e + 6, "000000", 6); /* dev */ assertEqualMem(e + 12, "000000", 6); /* ino */ assertEqualMem(e + 18, "000000", 6); /* Mode */ assertEqualMem(e + 24, "000000", 6); /* uid */ assertEqualMem(e + 30, "000000", 6); /* gid */ assertEqualMem(e + 36, "000001", 6); /* Nlink */ assertEqualMem(e + 42, "000000", 6); /* rdev */ assertEqualMem(e + 48, "00000000000", 11); /* mtime */ assertEqualMem(e + 59, "000013", 6); /* Name size */ assertEqualMem(e + 65, "00000000000", 11); /* File size */ assertEqualMem(e + 76, "TRAILER!!!\0", 11); /* Name */ e += 87; assertEqualInt((int)used, e - buff); free(buff); }
bc14f8580cd0129ba28776a76951df973fcf96fe
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/hc32l136/Libraries/HC32L136_StdPeriph_Driver/src/wdt.c
0a3ea826dc7a590622a446ce9946d27e9d1e6ed0
[ "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
6,212
c
wdt.c
/************************************************************************************* * Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. * * This software is owned and published by: * Huada Semiconductor Co.,Ltd ("HDSC"). * * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. * * This software contains source code for use with HDSC * components. This software is licensed by HDSC to be adapted only * for use in systems utilizing HDSC components. HDSC shall not be * responsible for misuse or illegal use of this software for devices not * supported herein. HDSC is providing this software "AS IS" and will * not be responsible for issues arising from incorrect user implementation * of the software. * * Disclaimer: * HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED * WARRANTY OF NONINFRINGEMENT. * HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, * SAVINGS OR PROFITS, * EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED * FROM, THE SOFTWARE. * * This software may be replicated in part or whole for the licensed use, * with the restriction that this Disclaimer and Copyright notice must be * included with each copy of this software, whether used in part or whole, * at all times. */ /******************************************************************************/ /** \file wdt.c ** ** WDT function driver API. ** @link WdtGroup Some description @endlink ** ** - 2017-05-17 1.0 CJ First version for Device Driver Library of Module. ** ******************************************************************************/ /******************************************************************************/ /* Include files */ /******************************************************************************/ #include "wdt.h" /** ****************************************************************************** ** \defgroup WdtGroup ** ******************************************************************************/ //@{ /******************************************************************************/ /* Local function prototypes ('static') */ /******************************************************************************/ static func_ptr_t pfnWdtCallback = NULL; /** ****************************************************************************** ** \brief WDT溢出时间设置函数 ** ** \param [in] u8LoadValue 溢出时间 ** ** \retval 无 ** ******************************************************************************/ void Wdt_WriteWdtLoad(uint8_t u8LoadValue) { M0P_WDT->CON_f.WOV = u8LoadValue; } /** ****************************************************************************** ** \brief WDT初始化函数 ** ** \param [in] stcConfig 初始化结构 ** ** \retval Ok ** ******************************************************************************/ en_result_t Wdt_Init(stc_wdt_config_t* pstcConfig) { en_result_t enRet = Error; ASSERT(NULL != pstcConfig); Wdt_WriteWdtLoad(pstcConfig->u8LoadValue); pfnWdtCallback = pstcConfig->pfnWdtIrqCb; M0P_WDT->CON_f.WINT_EN = pstcConfig->enResetEnable; if(pstcConfig->enResetEnable) { EnableNvic(WDT_IRQn,IrqLevel3,TRUE); } enRet = Ok; return enRet; } /** ****************************************************************************** ** \brief WDT复位及启动函数 ** ** \param [in] 无 ** ** \retval Ok ** ******************************************************************************/ en_result_t Wdt_Start(void) { en_result_t enRet = Error; M0P_WDT->RST = 0x1E; M0P_WDT->RST = 0xE1; enRet = Ok; return enRet; } /** ****************************************************************************** ** \brief WDT复位及启动函数 ** ** \param [in] 无 ** ** \retval Ok ** ******************************************************************************/ void Wdt_Feed(void) { M0P_WDT->RST = 0x1E; M0P_WDT->RST = 0xE1; } /** ****************************************************************************** ** \brief WDT读取当前计数值函数 ** ** \param [in] 无 ** ** \retval 计数值 ** ******************************************************************************/ uint8_t Wdt_ReadWdtValue(void) { uint8_t u8Count; u8Count = M0P_WDT->CON_f.WCNTL; return u8Count; } /** ****************************************************************************** ** \brief WDT读取当前运行状态 ** ** \param [in] 无 ** ** \retval 状态值 ** ******************************************************************************/ uint8_t Wdt_ReadwdtStatus(void) { return M0P_WDT->CON_f.WDTR; } /** ****************************************************************************** ** \brief WDT中断处理函数 ** ** \param [in] 无 ** ** \retval 无 ** ******************************************************************************/ void Wdt_IRQHandler(void) { if(M0P_WDT->CON_f.WDINT) { Wdt_Start();//clr wdt 标记 if(NULL != pfnWdtCallback) { pfnWdtCallback(); } } } //@} // WdtGroup
5e384e93de925e37081ddff41ba557dced04457a
b6fd3ebe265cc089f76391068f07d2e7ea361e76
/core/fw/lexer.c
e2917bf94742b0c18533fc886971eeee1e1e4561
[ "MIT" ]
permissive
foone/BRender-v1.3.2
55bbdba6470234e158f82247bb5e03c2c27b9e3e
d88d0ed41122664b9781015b517db64353e16f19
refs/heads/main
2022-05-05T22:39:56.191332
2022-05-05T22:33:54
2022-05-05T22:33:54
488,348,032
486
35
MIT
2022-05-03T23:06:16
2022-05-03T20:06:34
C
UTF-8
C
false
false
13,178
c
lexer.c
/* * Copyright (c) 1993-1995 by Argonaut Technologies Limited. All rights reserved. * * $Id: lexer.c 1.1 1997/12/10 16:41:08 jon Exp $ * $Locker: $ * * Generic lexer */ #include "fw.h" #include "brassert.h" #define MAX_STRING 256 static void lexerAdvance(struct br_lexer * l); static void lexerAdvanceDump(struct br_lexer * l); /* * Default error handler, does nothing */ static void BR_CALLBACK lexerError(struct br_lexer *l, char *string) { } struct br_lexer * BR_RESIDENT_ENTRY BrLexerAllocate(struct br_lexer_keyword *keywords, int nkeywords) { struct br_lexer * l; l = BrResAllocate(fw.res,sizeof(*l), BR_MEMORY_LEXER); if(l == NULL) return NULL; l->keywords = keywords; l->nkeywords = nkeywords; l->advance = lexerAdvance; l->source = NULL; l->string_buffer = BrResAllocate(l, MAX_STRING, BR_MEMORY_LEXER); l->string_buffer_size = MAX_STRING; l->error = lexerError; return l; } char BR_RESIDENT_ENTRY BrLexerCommentSet(struct br_lexer * l, char eol_comment) { char old = l->eol_comment; l->eol_comment = eol_comment; return old; } br_lexer_error_cbfn * BR_RESIDENT_ENTRY BrLexerErrorSet(struct br_lexer * l, br_lexer_error_cbfn *error) { br_lexer_error_cbfn *old = l->error; if(error == NULL) l->error = lexerError; else l->error = error; if(old == lexerError) return NULL; else return old; } void BR_RESIDENT_ENTRY BrLexerFree(struct br_lexer * l) { /* * Free up lexer (will free up all sources and any files) */ BrResFree(l); } static void BR_CALLBACK fileGetchar(struct br_lexer_source *source) { source->next = BrFileGetChar(source->ptr); } br_error BR_RESIDENT_ENTRY BrLexerPushFile(struct br_lexer * l, char *file) { br_lexer_source *s; void *f; int mode = BR_FS_MODE_TEXT; /* * Try to open file */ f = BrFileOpenRead(file, 0, NULL, &mode); if(f == NULL) return BRE_FAIL; s = BrResAllocate(l, sizeof(*s), BR_MEMORY_LEXER); if(s == NULL) return BRE_NO_MEMORY; /* * Attach file resource to source */ BrResAdd(s,f); s->name = file; s->line = 1; s->getchar = fileGetchar; s->ptr = f; /* * Setup first charater */ s->getchar(s); /* * Link onto front of list of sources */ s->prev = l->source; l->source = s; return BRE_OK; } static void BR_CALLBACK stringGetchar(struct br_lexer_source *source) { char *cp = source->ptr; if(cp == NULL || *cp == '\0') { source->next = BR_EOF; } else { source->next = *cp; source->ptr = cp+1; } } br_error BR_RESIDENT_ENTRY BrLexerPushString(struct br_lexer * l, char *string, char *name) { br_lexer_source *s; s = BrResAllocate(l, sizeof(*s), BR_MEMORY_LEXER); if(s == NULL) return BRE_NO_MEMORY; s->name = name; s->line = 1; s->getchar = stringGetchar; s->ptr = string; /* * Setup first charater */ s->getchar(s); /* * Link onto front of list of sources */ s->prev = l->source; l->source = s; return BRE_OK; } struct br_lexer_source * BR_RESIDENT_ENTRY BrLexerPop(struct br_lexer * l) { br_lexer_source *s; s = l->source; if(s == NULL) return s; /* * Set current source to previous */ l->source = s->prev; BrResFree(s); return s; } static void lexerAdvance(struct br_lexer * l) { int n; br_boolean got_point; for(;;) { if(l->source == NULL) { l->current.id = T_EOF; return; } if(l->source->next == BR_EOF) { /* * End of current source - pop current and try again */ BrLexerPop(l); continue; } else if((l->eol_comment != '\0') && (l->source->next == l->eol_comment)) { /* * Comment - skip until EOL or EOF */ for(;;) { l->source->getchar(l->source); if(l->source->next == '\n' || l->source->next == BR_EOF) break; } continue; } else if(l->source->next == '\n') { /* * Newline - track line number */ l->source->line++; l->source->getchar(l->source); continue; } else if(l->source->next == '"') { /* * Read a string - read characters until '"', newline, or EOF */ n = 0; for(n=0; n < l->string_buffer_size; ) { l->source->getchar(l->source); if(l->source->next == '"' || l->source->next == '\n' || l->source->next == BR_EOF) break; l->string_buffer[n++] = (char)l->source->next; } if(l->source->next != '"') { l->current.id = T_ERROR; l->current.v.string = "Unterminated string"; l->source->getchar(l->source); return; } l->string_buffer[n] = '\0'; l->current.v.string = l->string_buffer; l->current.id = T_STRING; l->source->getchar(l->source); return; } else if(BrIsSpace(l->source->next) || l->source->next == '\032') { /* * white space - ignore */ l->source->getchar(l->source); continue; } else if(BrIsAlpha(l->source->next) || l->source->next == '_') { /* * Idenitifier - read characters until not alpha, _ or 0-9 */ l->string_buffer[0] = (char)l->source->next; for(n=1; n < l->string_buffer_size-1; ) { l->source->getchar(l->source); if(!(BrIsAlpha(l->source->next) || BrIsDigit(l->source->next) || l->source->next == '_')) break; l->string_buffer[n++] = (char)l->source->next; } l->string_buffer[n] = '\0'; l->current.v.string = l->string_buffer; /* * Try to look up a keyword */ for(n=0; n < l->nkeywords; n++) { if(l->keywords[n].name[0] == l->string_buffer[0] && !BrStrICmp(l->keywords[n].name,l->string_buffer)) { /* * Found a keyword - which are based at 128 */ l->current.id = l->keywords[n].id; return; } } l->current.id = T_IDENT; l->current.v.string = l->string_buffer; return; } else if(BrIsDigit(l->source->next)) { /* * Read a number */ l->string_buffer[0] = (char)l->source->next; l->source->getchar(l->source); got_point = BR_FALSE; for(n=1; n < l->string_buffer_size-1; n++) { switch(l->source->next) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'x': case 'X': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': l->string_buffer[n] = (char)l->source->next; l->source->getchar(l->source); break; case '.': got_point = BR_TRUE; l->string_buffer[n] = (char)l->source->next; l->source->getchar(l->source); break; default: goto done; } } done: l->string_buffer[n] = '\0'; /* * If this is not a real number, then generate an integer token */ if(got_point) { l->current.v.real = BrStrToF(l->string_buffer, NULL); l->current.id = T_REAL; return; } else { l->current.v.integer = BrStrToL(l->string_buffer,0,0); l->current.id = T_INTEGER; return; } } else if(BrIsPrint(l->source->next)) { /* * All other printable characters turn into tokens */ l->current.id = l->source->next; l->source->getchar(l->source); return; } else l->current.id = T_ERROR; l->current.v.string = "Unexpected character"; l->source->getchar(l->source); return; } } #if DEBUG static void lexerAdvanceDump(struct br_lexer * l) { char *tname,*tvalue; char val[40]; char tmp[256]; /* * Do the normal advance operation */ lexerAdvance(l); switch(l->current.id) { case T_EOF: tname = "EOF"; tvalue = NULL; break; case T_IDENT: tname = "IDENT"; tvalue = l->current.v.string; break; case T_ERROR: tname = "ERROR"; tvalue = l->current.v.string; break; case T_STRING: tname = "STRING"; tvalue = l->current.v.string; break; case T_REAL: tname = "REAL"; BrSprintfN(val, BR_ASIZE(val), "%g", l->current.v.real); tvalue = val; break; case T_INTEGER: tname = "INTEGER"; BrSprintfN(val, BR_ASIZE(val), "%d",l->current.v.integer); tvalue = val; break; default: if(l->current.id >= T_KEYWORD) { tname = l->current.v.string; tvalue = NULL; } else if(BrIsPrint(l->current.id)) { tname = val; val[0] = l->current.id; val[1] = '\0'; tvalue = NULL; } else { BrSprintfN(val, BR_ASIZE(val), "??? %d", l->current.id); tname = val; tvalue = NULL; } } tmp[0] = '<'; BrStrCpy(tmp+1,tname); if(tvalue) { BrStrCat(tmp,":"); BrStrCat(tmp,tvalue); } BrStrCat(tmp,">"); l->putline(tmp, l->putline_arg); } #endif br_error BR_RESIDENT_ENTRY BrLexerDumpSet(struct br_lexer * l, br_putline_cbfn *putline, void *putline_arg) { #if DEBUG if(putline) { l->advance = lexerAdvanceDump; l->putline = putline; l->putline_arg = putline_arg; } else { l->advance = lexerAdvance; } #endif return BRE_OK; } void BR_RESIDENT_ENTRY BrLexerTokenError(struct br_lexer * l, br_lexer_token_id t) { int i; char tmp[256]; if(l->current.id == T_ERROR) { } else switch(t) { case T_EOF: BrLexerError(l, "expected end of file"); break; case T_ERROR: BrLexerError(l, l->current.v.string); break; case T_IDENT: BrLexerError(l, "expected an identifier"); break; case T_STRING: BrLexerError(l, "expected a string"); break; case T_INTEGER: BrLexerError(l, "expected an integer"); break; case T_REAL: BrLexerError(l, "expected a real number"); break; default: if(t >= T_KEYWORD) { for(i=0; i < l->nkeywords; i++) { if(l->keywords[i].id == t) break; } if(i < l->nkeywords) BrSprintfN(tmp, BR_ASIZE(tmp), "expected '%s'", l->keywords[i].name); else BrSprintfN(tmp, BR_ASIZE(tmp), "expected unknown keyword %d", t); } else if(BrIsPrint(t)) { BrSprintfN(tmp, BR_ASIZE(tmp), "expected '%c'", t); } else { BrSprintfN(tmp, BR_ASIZE(tmp), "expected unknown token %d", t); } BrLexerError(l, tmp); } /* * Advance until expected token or EOF */ while(BrLexerCurrent(l) != t && BrLexerCurrent(l) != T_EOF) { BrLexerAdvance(l); } } /* * Generate a string describing the current source position */ void BR_RESIDENT_ENTRY BrLexerPosition(struct br_lexer * l, char *buf, br_size_t buf_size) { ASSERT(buf_size >= 1); if(l->source == NULL || l->source->name == NULL) { buf[0] = '\0'; return; } BrSprintfN(buf, buf_size, "%s:%d ",l->source->name, l->source->line); } br_fixed_ls BR_RESIDENT_ENTRY BrParseFixed(struct br_lexer * l) { br_boolean neg = BR_FALSE; br_fixed_ls x; if(BrLexerCurrent(l) == T_PLUS) BrLexerAdvance(l); if(BrLexerCurrent(l) == T_DASH) { neg = BR_TRUE; BrLexerAdvance(l); } if(BrLexerCurrent(l) == T_REAL) { x = BrFloatToFixed(BrLexerReal(l)); BrLexerAdvance(l); } else if(BrLexerCurrent(l) == T_INTEGER) { x = BrIntToFixed(BrLexerInteger(l)); BrLexerAdvance(l); } else { BrLexerError(l, "expecting a fixed"); BrLexerAdvance(l); x = BrScalarToFixed(BR_SCALAR(0.0)); } if(neg) return -x; else return x; } br_float BR_RESIDENT_ENTRY BrParseFloat(struct br_lexer * l) { br_boolean neg = BR_FALSE; br_float f; if(BrLexerCurrent(l) == T_PLUS) BrLexerAdvance(l); if(BrLexerCurrent(l) == T_DASH) { neg = BR_TRUE; BrLexerAdvance(l); } if(BrLexerCurrent(l) == T_REAL) { f = BrLexerReal(l); BrLexerAdvance(l); } else if(BrLexerCurrent(l) == T_INTEGER) { f = (br_float)BrLexerInteger(l); BrLexerAdvance(l); } else { BrLexerError(l, "expecting a float"); BrLexerAdvance(l); f = 0.0F; } if(neg) return -f; else return f; } br_int_32 BR_RESIDENT_ENTRY BrParseInteger(struct br_lexer * l) { br_boolean neg = BR_FALSE; br_int_32 i; if(BrLexerCurrent(l) == T_PLUS) BrLexerAdvance(l); if(BrLexerCurrent(l) == T_DASH) { neg = BR_TRUE; BrLexerAdvance(l); } if(BrLexerCurrent(l) == T_INTEGER) { i = BrLexerInteger(l); BrLexerAdvance(l); } else { BrLexerError(l, "expecting an integer"); BrLexerAdvance(l); i = 0; } if(neg) return -i; else return i; } br_int_32 BR_RESIDENT_ENTRY BrParseVectorFixed(struct br_lexer * l, br_fixed_ls *v, br_int_32 max) { int n; BrLexerExpect(l, T_LSQUARE); for(n=0;n < max; n++) { *v++ = BrParseFixed(l); if(BrLexerCurrent(l) == T_RSQUARE) break; BrLexerExpect(l, T_COMMA); } BrLexerExpect(l, T_RSQUARE); return n+1; } br_int_32 BR_RESIDENT_ENTRY BrParseVectorFloat(struct br_lexer * l, br_float *v, br_int_32 max) { int n; BrLexerExpect(l, T_LSQUARE); for(n=0;n < max; n++) { *v++ = BrParseFloat(l); if(BrLexerCurrent(l) == T_RSQUARE) break; BrLexerExpect(l, T_COMMA); } BrLexerExpect(l, T_RSQUARE); return n+1; } br_int_32 BR_RESIDENT_ENTRY BrParseMatrixFixed(struct br_lexer * l, br_fixed_ls *m, br_int_32 width, br_int_32 max_h) { int n; BrLexerExpect(l, T_LSQUARE); for(n=0; n < max_h; n++, m+= width) { BrParseVectorFixed(l,m,width); if(BrLexerCurrent(l) == T_RSQUARE) break; BrLexerExpect(l, T_COMMA); } BrLexerExpect(l, T_RSQUARE); return n; } br_int_32 BR_RESIDENT_ENTRY BrParseMatrixFloat(struct br_lexer * l, br_float *m, br_int_32 width, br_int_32 max_h) { int n; BrLexerExpect(l, T_LSQUARE); for(n=0; n < max_h; n++, m+= width) { BrParseVectorFloat(l,m,width); if(BrLexerCurrent(l) == T_RSQUARE) break; BrLexerExpect(l, T_COMMA); } BrLexerExpect(l, T_RSQUARE); return n; }
2dc36522f08584a5a351bdfe9cfb52fb783354f0
ea49dd7d31d2e0b65ce6aadf1274f3bb70abfaf9
/problems/0268_Missing_Number/missing_number_by_Rocky.c
dea700ab58745c7a0c2c56fd87482fdbaffa5578
[]
no_license
yychuyu/LeetCode
907a3d7d67ada9714e86103ac96422381e75d683
48384483a55e120caf5d8d353e9aa287fce3cf4a
refs/heads/master
2020-03-30T15:02:12.492378
2019-06-19T01:52:45
2019-06-19T01:52:45
151,345,944
134
331
null
2019-08-01T02:56:10
2018-10-03T01:26:28
C++
UTF-8
C
false
false
414
c
missing_number_by_Rocky.c
#include <stdio.h> #include <stdlib.h> int missingNumber(int* nums, int numsSize) { int i; int a[10000] = {0}; for (i = 0; i < numsSize; i++) { a[nums[i]] = 1; } for (i = 0; i < numsSize + 1; i++) { if (a[i] != 1) return i; } return -1; } int main() { int a[10] = {0, 2, 3, 1, 5, 6, 4, 7, 8, 9}; printf("%d", missingNumber(a, 10)); return 0; }
368fb205550dd217775e444c22826dbbc79fe5e7
cce217852fee0a222fdca9f8f6ee8897c540c663
/patch/sticky.h
277bb342e7ba7aa15f537fe57fc5a4a4b7400a5e
[ "MIT" ]
permissive
bakkeby/dwm-flexipatch
d3e920f13701714d33a5ea75a12bb52df68f54aa
7849eaa08b71d359c939b946598716539b4ba1d7
refs/heads/master
2023-08-31T22:09:22.250888
2023-08-24T16:18:03
2023-08-24T16:18:03
206,426,925
1,094
366
MIT
2023-08-24T16:18:04
2019-09-04T22:35:38
C
UTF-8
C
false
false
43
h
sticky.h
static void togglesticky(const Arg *arg);
953f135c036c137c10c948ec258bcabaa43740a5
5efe877bf5ebc9da1e7edb8efabb66b88a78cee4
/DcpmPkg/driver/NvmDimmDriver.h
5a49423d25b1232b9eea41b93f164480a217b4c1
[ "BSD-3-Clause" ]
permissive
intel/ipmctl
342996a882ea7f4d3abf06fd175ec5d5673829b3
c75bd840ea7820c8f93a5488fcff75d08beedd51
refs/heads/master
2023-08-11T03:49:16.000607
2023-05-05T02:26:49
2023-05-05T02:26:49
133,425,750
176
64
BSD-3-Clause
2023-03-20T23:15:23
2018-05-14T21:53:46
C
UTF-8
C
false
false
12,197
h
NvmDimmDriver.h
/* * Copyright (c) 2018, Intel Corporation. * SPDX-License-Identifier: BSD-3-Clause */ #ifndef _NVMDIMM_DRIVER_H_ #define _NVMDIMM_DRIVER_H_ #include <Uefi.h> #include <NvmDimmDriverData.h> #include <Dimm.h> #ifndef OS_BUILD #include <DcpmmTypes.h> #endif #if defined(DYNAMIC_WA_ENABLE) #define DYNAMIC_WA_ENV_VARIABLE_NAME L"PMMD_FLAGS" #define WA_FLAG_ALWAYS_LOAD L"ALWAYS_LOAD" #define WA_FLAG_SIMICS L"SIMICS" #define WA_FLAG_UNLOAD_OTHER_DRIVERS L"UNLOAD" #define WA_FLAG_IGNORE_UID_NUMS L"IGNORE_UID_NUMBERS" #define WA_FLAG_NO_PCD_INIT L"NO_PCD_INIT" #endif /** This is the generated IFR binary data for each formset defined in VFR. This data array is ready to be used as input of HiiAddPackages() to create a package list (which contains Form packages, String packages, etc). **/ extern UINT8 NvmDimmDriverFormsBin[]; /** This is the generated String package data for all .UNI files. This data array is ready to be used as input of HiiAddPackages() to create a package list (which contains Form packages, String packages, etc). **/ extern UINT8 IntelOptanePMemDriverStrings[]; /** Libraries **/ #include <Library/UefiBootServicesTableLib.h> #include <Library/MemoryAllocationLib.h> #include <Library/BaseMemoryLib.h> #include <Library/BaseLib.h> #include <Library/UefiLib.h> #include <Library/DevicePathLib.h> #include <Library/DebugLib.h> #include <Library/HiiLib.h> #include <Library/UefiRuntimeServicesTableLib.h> /** UEFI Driver Model Protocols **/ #include <Protocol/DriverBinding.h> #include <Protocol/DriverSupportedEfiVersion.h> #include <Protocol/ComponentName2.h> #include <Protocol/ComponentName.h> #include <Protocol/DriverDiagnostics2.h> #include <Protocol/DriverDiagnostics.h> #include <Protocol/DriverHealth.h> #include <Protocol/LoadedImage.h> #include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h> /** Consumed Protocols **/ #include <Protocol/PciIo.h> /** Produced Protocols **/ #include <Protocol/BlockIo.h> #include <Protocol/BlockIo2.h> #include "NvmDimmConfig.h" #include <NvmDimmPassThru.h> #include <NvmFirmwareManagement.h> #include <Protocol/StorageSecurityCommand.h> #include <Protocol/NvdimmLabel.h> /** Protocol instances **/ extern EFI_DRIVER_BINDING_PROTOCOL gNvmDimmDriverDriverBinding; extern EFI_COMPONENT_NAME2_PROTOCOL gNvmDimmDriverComponentName2; extern EFI_COMPONENT_NAME_PROTOCOL gNvmDimmDriverComponentName; extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gNvmDimmDriverDriverDiagnostics2; extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gNvmDimmDriverDriverDiagnostics; extern EFI_DRIVER_HEALTH_PROTOCOL gNvmDimmDriverHealth; extern EFI_DCPMM_CONFIG2_PROTOCOL gNvmDimmDriverNvmDimmConfig; extern EFI_FIRMWARE_MANAGEMENT_PROTOCOL gNvmDimmFirmwareManagementProtocol; extern EFI_STORAGE_SECURITY_COMMAND_PROTOCOL gNvmDimmDriverStorageSecurityCommand; extern EFI_BLOCK_IO_PROTOCOL gNvmDimmDriverBlockIo; extern EFI_NVDIMM_LABEL_PROTOCOL gNvdimmLabelProtocol; extern EFI_DCPMM_PBR_PROTOCOL gNvmDimmDriverNvmDimmPbr; typedef struct _PMEM_DEV { LIST_ENTRY Dimms; LIST_ENTRY ISs; LIST_ENTRY ISsNfit; LIST_ENTRY Namespaces; BOOLEAN DimmSkuConsistency; BOOLEAN RegionsAndNsInitialized; BOOLEAN RegionsNfitInitialized; BOOLEAN NamespacesInitialized; BOOLEAN IsMemModeAllowedByBios; ParsedFitHeader *pFitHead; ParsedPcatHeader *pPcatHead; // Note: Only the PMTT 0.2 table is parsed and placed here! ParsedPmttHeader *pPmttHead; } PMEM_DEV; /** Specifies the alignments used by the driver. All of the values are in bytes. **/ typedef struct { UINT64 RegionPartitionAlignment; UINT64 RegionVolatileAlignment; UINT64 RegionPersistentAlignment; UINT64 PmNamespaceMinSize; } ALIGNMENT_SETTINGS; /** NvmDimmDriver Data structure **/ typedef struct { EFI_HANDLE Handle; EFI_HANDLE DriverHandle; EFI_HANDLE ControllerHandle; EFI_HANDLE HiiHandle; EFI_DEVICE_PATH_PROTOCOL *pControllerDevicePathInstance; #ifndef OS_BUILD /** BIOS Dcpmm protocol **/ EFI_DCPMM_PROTOCOL *pDcpmmProtocol; #endif // !OS_BUILD PMEM_DEV PMEMDev; /** NvmDimm data **/ EFI_DCPMM_CONFIG2_PROTOCOL NvmDimmConfig; /** This flag informs us if we installed the Device Path on the controller and should uninstall it or not. **/ BOOLEAN UninstallDevicePath; /** All of the minimal sizes and alignment values for the DIMM partitioning and Namespaces creation. **/ ALIGNMENT_SETTINGS Alignments; #if defined(DYNAMIC_WA_ENABLE) /** In case we need to try to load the driver when the binding handle is not present in the system, we can use this workaround to force-load the driver. Warning: the driver still requires NFIT to work properly. **/ BOOLEAN AlwaysLoadDriver; /** If we have set the 'AlwaysLoadDriver' flag, this indicates if we had already created ourselves a handle to bind. **/ BOOLEAN HandleCreated; /** If this driver and the HII driver are already loaded, unload them before loading **/ BOOLEAN UnloadExistingDrivers; /** Special set of workarounds to be applied in SIMICS environment **/ BOOLEAN SimicsWorkarounds; /** Disable checks of the same NVDIMM UID among dimms. Used when same SPD data is flashed without on many dimms. **/ BOOLEAN IgnoreTheSameUIDNumbers; /** During Initialization of the driver, avoid using any commands that touch the PCD data. **/ BOOLEAN PcdUsageDisabledOnInit; #endif /** DYNAMIC_WA_ENABLE **/ } NVMDIMMDRIVER_DATA; /** Structure to store EFI-related dimms data **/ typedef struct { EFI_HANDLE DeviceHandle; //!< The UEFI device handle that has the protocols installed EFI_DEVICE_PATH_PROTOCOL *pDevicePath; //!< The device path we need to release when unloading the driver DIMM *pDimm; //!< The DIMM shared information EFI_UNICODE_STRING_TABLE *pDimmName; //!< The localized dimm name table for the ComponentName2 Protocol /** We create an instance per DIMM so we are able to identify on which DIMM handle the protocol procedure was called. **/ EFI_FIRMWARE_MANAGEMENT_PROTOCOL FirmwareManagementInstance; EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurityCommandInstance; EFI_DRIVER_HEALTH_PROTOCOL DriverHealthProtocolInstance; EFI_BLOCK_IO_PROTOCOL BlockIoProtocolInstance; EFI_NVDIMM_LABEL_PROTOCOL NvdimmLabelProtocolInstance; } EFI_DIMMS_DATA; /** Type used to determine what kind of device is the particular set of Controller and Child handles aiming to. **/ typedef enum { Controller, Dimm, Namespace, All, Unknown } NvmDeviceType; /** This function performs all necessary checks to determine what device type are the input parameters pointing to. This function is meant to be used by the ComponentName and DriverHealth protocols. @param[in] ControllerHandle EFI_HANDLE passed from the UEFI Libs, trying to resolve the device type for. @param[in] ChildHandle EFI_HANDLE passed from the UEFI Libs, trying to resolve the device type for. @param[out] pDimmPid is a pointer to the PID of the DIMM. @param[out] pResultDevice All if the ControllerHandle equals NULL. Controller if the ControllerHandle is our controller and the ChildHandle equals NULL. Dimm if the Controller equals to our controller and the ChildHandle equals to one of our DIMM handles. Namespace if the Controller equals to our controller and the ChildHandle equals to one of our block namespaces OR if the Controller equals to one of our DIMM handles and the ChildHandle equals to the block namespace that resides on the specific DIMM. Unknown all other cases. @retval EFI_SUCCESS - Matching manged device type for given handles @retval EFI_INVALID_PARAMETER - if at least one of the input parameters equals NULL. @retval EFI_UNSUPPORTED - Handles provided are not managed by driver **/ EFI_STATUS ResolveDeviceType( IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle, OUT UINT16 *pDimmPid OPTIONAL, OUT NvmDeviceType *pResultDevice ); /** AddStringToUnicodeTable Adds the provided string in the "en/eng" language to the provided UNICODE STRING TABLE. @param[in] pStringToAdd pointer to the Unicode string to be added. @param[in,out] ppTableToAddTo pointer to a pointer to the UNICODE STRING TABLE that the string needs to be added. @retval EFI_SUCCESS - everything went fine. @retval EFI_INVALID_PARAMETER - at least one of the input parameters equals NULL. Other return values from the AddUnicodeString2 function. **/ EFI_STATUS AddStringToUnicodeTable( IN CHAR16 *pStringToAdd, IN OUT EFI_UNICODE_STRING_TABLE **ppTableToAddTo ); /** Function that allows to "refresh" the existing DIMMs. If a DIMM is inaccessible, all of the ISs and namespaces that it was a part of will be removed. @param[in] DoDriverCleanup, if the caller wants namespaces cleaned up including unloading protocols @retval EFI_SUCCESS if all DIMMs are working. @retval EFI_INVALID_PARAMETER if any of pointer parameters in NULL @retval EFI_ABORTED if at least one DIMM is not responding. @retval EFI_OUT_OF_RESOURCES if the memory allocation fails. @retval EFI_NO_RESPONSE FW busy for one or more dimms **/ EFI_STATUS ReenumerateNamespacesAndISs( IN BOOLEAN DoDriverCleanup ); /** Function tries to remove all of the block namespaces protocols, then it removes all of the enumerated namespaces from the LSA and also the ISs. @retval EFI_SUCCESS the object were cleared successfully Error return codes from CleanBlockNamespaces function **/ EFI_STATUS CleanNamespacesAndISs( ); /** Returns the EFI_UNICODE_STRING_TABLE containing the Namespace Name. @param[in] NamespaceHandle the handle that we want to search for. @param[out] ppNamespaceName - pointer to where the function should place pointer to the Namespace EFI_UNICODE_STRING_TABLE. The value will be NULL if we will not find the Namespace. @retval EFI_SUCCeSS if we have found the Namespace. @retval EFI_INVALID_PARAMETER if at least one of the input parameters equals NULL. @retval EFI_NOT_FOUND if we could not locate the Namespace. **/ EFI_STATUS GetNamespaceName( IN EFI_HANDLE NamespaceHandle, OUT EFI_UNICODE_STRING_TABLE **ppNamespaceName ); /** This function checks if we are managing the ChildHandle. If yes - it returns the DIMMs PID. And the pointer to its EFI_UNICODE_STRING_TABLE @param[in] ChildHandle the handle that we want to search for. @param[out] Optional pointer to where the function should place pointer to the child EFI_UNICODE_STRING_TABLE. The value will be NULL if we will not find the DIMM @retval UINT16 DimmID of the DIMM or 0 of we did not find the device. **/ EFI_STATUS HandleToPID( IN EFI_HANDLE ChildHandle, OUT EFI_UNICODE_STRING_TABLE **ppChildDeviceName OPTIONAL, OUT UINT16 *pDimmPid ); /** This function checks if we are managing the ChildHandle. If yes - it returns the DIMMs PID and the optional pointer to its EFI_UNICODE_STRING_TABLE @param[in] ChildHandle the handle that we want to search for. @param[out] Optional pointer to where the function should place pointer to the child EFI_UNICODE_STRING_TABLE. The value will be NULL if we will not find the DIMM @param[out] pDimmPid is a pointer to the PID of the DIMM. @retval EFI_SUCCESS if we have found the ChildHandle. @retval EFI_INVALID_PARAMETER if at least one of the input parameters equals NULL. @retval EFI_NOT_FOUND if we could not locate the ChildHandle. **/ UINT16 GetDimmEfiDataIndex( IN UINT16 DimmPid, OPTIONAL IN DIMM *pDimm, OPTIONAL IN EFI_HANDLE DimmHandle OPTIONAL ); /** This function makes calls to the dimms required to initialize the driver. @retval EFI_SUCCESS if no errors. @retval EFI_xxxx depending on error encountered. **/ EFI_STATUS InitializeDimms(); /** Include files with function prototypes **/ #include "DriverBinding.h" #include "ComponentName.h" #include "DriverDiagnostics.h" #include "DriverHealth.h" #endif /** _NVMDIMM_DRIVER_H_ **/
08125c9e8477d53186d26fa1ff75854f267cf9bc
7e1cd9b94c0c8c443f993362dc185dfc35ceb963
/interface/vmcs_host/vc_vchi_gencmd.h
da86b5d68ae5ba8ee19ffeacc59610b8a41696ba
[ "BSD-3-Clause" ]
permissive
raspberrypi/userland
92e557234bb6d7f701066543e0efc36dfb54a52c
cc1ca18fb0689b01cc2ca2aa4b400dcee624a213
refs/heads/master
2023-08-20T15:41:23.695645
2023-04-19T10:38:04
2023-04-20T13:36:13
6,367,886
1,608
928
BSD-3-Clause
2023-09-13T09:54:26
2012-10-24T09:58:46
C
UTF-8
C
false
false
4,297
h
vc_vchi_gencmd.h
/* Copyright (c) 2012, Broadcom Europe Ltd 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 the copyright holder 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 HOLDER 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 VC_VCHI_GENCMD_H #define VC_VCHI_GENCMD_H #include "vchost_platform_config.h" #include "interface/vchi/vchi.h" #include "interface/vcos/vcos.h" //for VCHPRE_ abd VCHPOST_ macro's for func declaration /* Initialise general command service. Returns it's interface number. This initialises the host side of the interface, it does not send anything to VideoCore. */ VCHPRE_ int VCHPOST_ vc_gencmd_init(void); VCHPRE_ void VCHPOST_ vc_vchi_gencmd_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections ); /* Stop the service from being used. */ VCHPRE_ void VCHPOST_ vc_gencmd_stop(void); /* Functions to support videocore suspend/resume for cases where vc_gencmd_send expects a response to * ensure videocore is not shut down (done internally in vc_gencmd / vc_gencmd_until) */ VCHPRE_ int VCHPOST_ use_gencmd_service(void); VCHPRE_ int VCHPOST_ release_gencmd_service(void); /****************************************************************************** Send commands to VideoCore. These all return 0 for success. They return VC_MSGFIFO_FIFO_FULL if there is insufficient space for the whole message in the fifo, and none of the message is sent. ******************************************************************************/ /* send command to general command serivce */ VCHPRE_ int VCHPOST_ vc_gencmd_send( const char *format, ... ); /* get resonse from general command serivce */ VCHPRE_ int VCHPOST_ vc_gencmd_read_response(char *response, int maxlen); /* convenience function to send command and receive the response */ VCHPRE_ int VCHPOST_ vc_gencmd(char *response, int maxlen, const char *format, ...); /****************************************************************************** Utilities to help interpret the responses. ******************************************************************************/ /* Read the value of a property=value type pair from a string (typically VideoCore's response to a general command). Return non-zero if found. */ VCHPRE_ int VCHPOST_ vc_gencmd_string_property(char *text, const char *property, char **value, int *length); /* Read the numeric value of a property=number field from a response string. Return non-zero if found. */ VCHPRE_ int VCHPOST_ vc_gencmd_number_property(char *text, const char *property, int *number); /* Send a command until the desired response is received, the error message is detected, or the timeout */ VCHPRE_ int VCHPOST_ vc_gencmd_until( char *cmd, const char *property, char *value, const char *error_string, int timeout); #endif
60d3d4baea1415d5d1f74df0dc937ccb96ab06d2
12bfb9ef2028a0378f576f5f58a05a2c5e107ba2
/tools/disambiguate/disambiguate2.c
41543148c197c097675f426aa7e6889ae941e0c1
[ "MIT" ]
permissive
cntools/libsurvive
095a21b2fb20156b6222b44bb32c5e0ae6745cc6
ec902cc048baecbca3d704482d3923bdb84a1e7d
refs/heads/master
2023-08-26T05:14:26.842420
2023-04-17T15:45:08
2023-04-17T15:45:08
75,029,407
336
76
MIT
2023-04-17T15:45:10
2016-11-29T01:14:05
C
UTF-8
C
false
false
6,259
c
disambiguate2.c
#include <stdio.h> #include <stdint.h> #include <stdbool.h> typedef uint8_t pulse_data; #if 0 struct sync_pulse_lengths { uint32_t expected_offset; uint16_t min; uint16_t max; pulse_data simple_data; pulse_data data; }; const struct sync_pulse_lengths sync_pulses[] = { {400000, 2880, 3024, 0x0, 0x0}, // SKIP 0 DATA 0 AXIS 0 {400000, 3380, 3524, 0x1, 0x1}, // SKIP 0 DATA 0 AXIS 1 {400000, 3880, 4024, 0x0, 0x2}, // SKIP 0 DATA 1 AXIS 0 {400000, 4380, 4524, 0x1, 0x3}, // SKIP 0 DATA 1 AXIS 1 { 20000, 4880, 5024, 0x2, 0x4}, // SKIP 1 DATA 0 AXIS 0 { 20000, 5380, 5524, 0x3, 0x5}, // SKIP 1 DATA 0 AXIS 1 { 20000, 5880, 6024, 0x2, 0x6}, // SKIP 1 DATA 1 AXIS 0 { 20000, 6380, 6524, 0x3, 0x7}, // SKIP 1 DATA 1 AXIS 1 }; #endif const uint32_t pulse_types[] = { 0, 1, 0, 1, 2, 3, 2, 3, }; typedef enum { PT_UNKNOWN = 0, PT_SWEEP = 1, PT_SYNC = 2 } pulse_type; typedef enum { AX_J = 0, AX_K = 1 } scan_axis; typedef enum { SK_ON = 0x4, SK_OFF = 0 } scan_skip; #define DEBUG(...) printf(__VA_ARGS__) #define PULSE_BIT_AXIS 0x1 #define PULSE_BIT_DATA 0x2 #define PULSE_BIT_SKIP 0x4 #define PULSE_DATA(D) ((D >> 1)&0x1) #define PULSE_AXIS(D) ((scan_axis)(D&0x01)) #define PULSE_SKIP(D) ((D >> 2)&0x1) pulse_data get_pulse_data(uint32_t length) { uint16_t temp = length - 2880; #if BETTER_SAFE_THAN_FAST if (temp < 0 || length > 6525) { return -1; } #endif if ((temp % 500) < 150) { return temp / 500; } return -1; } struct disambiguator; typedef pulse_type (*pulse_fn)(struct disambiguator * d, uint32_t timestamp, uint32_t length); typedef void (*data_fn)(struct disambiguator * d, uint8_t bit); void null_data_fn(struct disambiguator * d __attribute__((unused)), uint8_t bit __attribute__((unused))) { return; } struct disambiguator { pulse_fn pulse_fn; data_fn data_fn; uint32_t last_master_sync; bool locked; }; void disambiguator_init(struct disambiguator * d); pulse_type disambiguator_sync_start(struct disambiguator * d, uint32_t timestamp, uint32_t length); pulse_type disambiguator_sync_A1(struct disambiguator * d, uint32_t timestamp, uint32_t length); pulse_type disambiguator_sync_B0(struct disambiguator * d, uint32_t timestamp, uint32_t length); pulse_type disambiguator_sync_B1(struct disambiguator * d, uint32_t timestamp, uint32_t length); pulse_type disambiguator_sync_DONE(struct disambiguator * d, uint32_t timestamp, uint32_t length); void disambiguator_init(struct disambiguator * d) { d->data_fn = &null_data_fn; d->pulse_fn = &disambiguator_sync_start; d->locked = false; } pulse_type disambiguator_sync_start(struct disambiguator * d, uint32_t timestamp, uint32_t length) { DEBUG("START %10d %6d %6d\n", timestamp, 0, length); pulse_data dd = get_pulse_data(length); if ((dd & (PULSE_BIT_AXIS | PULSE_BIT_SKIP)) == 0) { d->pulse_fn = &disambiguator_sync_A1; d->last_master_sync = timestamp; } return PT_UNKNOWN; } pulse_type disambiguator_sync_A1(struct disambiguator * d, uint32_t timestamp, uint32_t length) { pulse_data dd = get_pulse_data(length); uint32_t diff = timestamp - d->last_master_sync; DEBUG("A1 %10d %6d %6d\n", timestamp, diff, length); if (18720 > diff) { return PT_UNKNOWN; } if (diff > 21600) { d->pulse_fn = &disambiguator_sync_start; return PT_UNKNOWN; } if ((dd & (PULSE_BIT_AXIS | PULSE_BIT_SKIP)) == PULSE_BIT_SKIP) { d->pulse_fn = &disambiguator_sync_B0; } return PT_UNKNOWN; } pulse_type disambiguator_sync_B0(struct disambiguator * d, uint32_t timestamp, uint32_t length) { pulse_data dd = get_pulse_data(length); uint32_t diff = timestamp - d->last_master_sync; DEBUG("B0 %10d %6d %6d\n", timestamp, diff, length); if (398832 > diff) { return PT_UNKNOWN; } if (diff > 401136) { d->pulse_fn = &disambiguator_sync_start; return PT_UNKNOWN; } if ((dd & (PULSE_BIT_AXIS | PULSE_BIT_SKIP)) == PULSE_BIT_AXIS) { d->pulse_fn = &disambiguator_sync_B1; d->last_master_sync = timestamp; } return PT_UNKNOWN; } pulse_type disambiguator_sync_B1(struct disambiguator * d, uint32_t timestamp, uint32_t length) { pulse_data dd = get_pulse_data(length); uint32_t diff = timestamp - d->last_master_sync; DEBUG("B1 %10d %6d %6d\n", timestamp, diff, length); if (18720 > diff) { return PT_UNKNOWN; } if (diff > 21600) { d->pulse_fn = &disambiguator_sync_start; return PT_UNKNOWN; } if ((dd & (PULSE_BIT_AXIS | PULSE_BIT_SKIP)) == (PULSE_BIT_AXIS|PULSE_BIT_SKIP)) { d->pulse_fn = &disambiguator_sync_DONE; d->locked = true; } return PT_UNKNOWN; } pulse_type disambiguator_sync_DONE(struct disambiguator * d __attribute__((unused)), uint32_t timestamp, uint32_t length) { DEBUG("DONE %10d %6d %6d\n", timestamp, 0, length); return PT_UNKNOWN; } uint32_t fake_pulse_length(pulse_data d) { return 3000 + (d*500); } int main() { #ifdef TEST struct disambiguator d; d.data_fn = &null_data_fn; d.pulse_fn = &disambiguator_sync_start; d.pulse_fn(&d, 0, 3000); d.pulse_fn(&d, 20000, fake_pulse_length(PULSE_BIT_SKIP)); d.pulse_fn(&d, 20000, 3500); #else FILE * f = fopen( "raw_light_data_from_watchman.sorted.csv", "r" ); if (f == NULL) { fprintf(stderr, "ERROR OPENING INPUT FILE\n"); return -1; } //long last = 0, lastl = 0; long lastl = 0; struct disambiguator d; disambiguator_init(&d); for (;;) { char controller[10]; int sensor; int unknown; int length; long time; if (fscanf(f, "%s %d %d %d %li", controller, &sensor, &unknown, &length, &time) != 5) { break; } printf("%s: ", controller); if (lastl > time) { printf("BACKWARDS: %li %li\n", lastl, time); } lastl = time; d.pulse_fn(&d, time, length); /* switch (d.step_fn(&d, time, length)) { default: case P_UNKNOWN: //printf("UNKN %s %2d %li %d\n", controller, sensor, time - last, length); continue; case P_SYNC: { double l = length; char cc = round(l / 500) - 6; int ll = (length+125)/250; printf("SYNC %s %2d %10li %5d %c%d %10li %d %d\n", controller, sensor, time, length, (cc & 0x1) ? 'k' : 'j', (cc >> 1) & 0x3, time-last, ll & 1, (ll >> 1) - 6); last = time; } continue; case P_SWEEP: printf("SWEEP %s %2d %10li %5d\n", controller, sensor, time - last, length); continue; }*/ } fclose(f); #endif }
c0a07512ddb386dfe9815d0443268e4ff5ff01ee
984bc4181baec6e5a4b05a657e666b0e9f89f3f3
/3rdparty/mongo-c-driver-1.21.2/src/libmongoc/tests/mock_server/future.h
a3b249b513b9e33e953d07c9ad90abe8f1f149e7
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
treefrogframework/treefrog-framework
0173245ff92162d2107af79861505981980d1eca
a1df97793e8cc628779378e5adae9af6987460c1
refs/heads/master
2023-08-22T03:57:58.891846
2023-05-18T14:00:42
2023-05-18T14:00:42
7,067,532
1,152
263
BSD-3-Clause
2023-08-08T20:25:03
2012-12-08T13:17:01
C++
UTF-8
C
false
false
3,862
h
future.h
#ifndef FUTURE_H #define FUTURE_H #include <bson/bson.h> #include "future-value.h" #include "mongoc/mongoc-thread-private.h" /************************************************** * * Generated by build/generate-future-functions.py. * * DO NOT EDIT THIS FILE. * *************************************************/ /* clang-format off */ typedef struct { bool resolved; bool awaited; future_value_t return_value; int argc; future_value_t *argv; mongoc_cond_t cond; bson_mutex_t mutex; bson_thread_t thread; } future_t; future_t *future_new (future_value_type_t return_type, int argc); future_value_t *future_get_param (future_t *future, int i); void future_start (future_t *future, BSON_THREAD_FUN_TYPE (start_routine)); void future_resolve (future_t *future, future_value_t return_value); bool future_wait (future_t *future); bool future_wait_max (future_t *future, int64_t timeout_ms); void future_get_void (future_t *future); bool future_get_bool (future_t *future); char_ptr future_get_char_ptr (future_t *future); char_ptr_ptr future_get_char_ptr_ptr (future_t *future); int future_get_int (future_t *future); int64_t future_get_int64_t (future_t *future); size_t future_get_size_t (future_t *future); ssize_t future_get_ssize_t (future_t *future); uint32_t future_get_uint32_t (future_t *future); void_ptr future_get_void_ptr (future_t *future); const_char_ptr future_get_const_char_ptr (future_t *future); bson_error_ptr future_get_bson_error_ptr (future_t *future); bson_ptr future_get_bson_ptr (future_t *future); const_bson_ptr future_get_const_bson_ptr (future_t *future); const_bson_ptr_ptr future_get_const_bson_ptr_ptr (future_t *future); mongoc_async_ptr future_get_mongoc_async_ptr (future_t *future); mongoc_bulk_operation_ptr future_get_mongoc_bulk_operation_ptr (future_t *future); mongoc_client_ptr future_get_mongoc_client_ptr (future_t *future); mongoc_client_pool_ptr future_get_mongoc_client_pool_ptr (future_t *future); mongoc_collection_ptr future_get_mongoc_collection_ptr (future_t *future); mongoc_cluster_ptr future_get_mongoc_cluster_ptr (future_t *future); mongoc_cmd_parts_ptr future_get_mongoc_cmd_parts_ptr (future_t *future); mongoc_cursor_ptr future_get_mongoc_cursor_ptr (future_t *future); mongoc_database_ptr future_get_mongoc_database_ptr (future_t *future); mongoc_gridfs_file_ptr future_get_mongoc_gridfs_file_ptr (future_t *future); mongoc_gridfs_ptr future_get_mongoc_gridfs_ptr (future_t *future); mongoc_insert_flags_t future_get_mongoc_insert_flags_t (future_t *future); mongoc_iovec_ptr future_get_mongoc_iovec_ptr (future_t *future); mongoc_server_stream_ptr future_get_mongoc_server_stream_ptr (future_t *future); mongoc_query_flags_t future_get_mongoc_query_flags_t (future_t *future); const_mongoc_index_opt_t future_get_const_mongoc_index_opt_t (future_t *future); mongoc_server_description_ptr future_get_mongoc_server_description_ptr (future_t *future); mongoc_ss_optype_t future_get_mongoc_ss_optype_t (future_t *future); mongoc_topology_ptr future_get_mongoc_topology_ptr (future_t *future); mongoc_write_concern_ptr future_get_mongoc_write_concern_ptr (future_t *future); mongoc_change_stream_ptr future_get_mongoc_change_stream_ptr (future_t *future); mongoc_remove_flags_t future_get_mongoc_remove_flags_t (future_t *future); const_mongoc_find_and_modify_opts_ptr future_get_const_mongoc_find_and_modify_opts_ptr (future_t *future); const_mongoc_iovec_ptr future_get_const_mongoc_iovec_ptr (future_t *future); const_mongoc_read_prefs_ptr future_get_const_mongoc_read_prefs_ptr (future_t *future); const_mongoc_write_concern_ptr future_get_const_mongoc_write_concern_ptr (future_t *future); void future_destroy (future_t *future); #endif /* FUTURE_H */
5cce1be7b7af0696d99decace990b128f2fec422
771b8d391585df59d8c7438e21e54976c4180011
/lib/libOTe/KyberOT/testvectors.c
a374b609bd37b8422a3088939803f3f0ff06e9c5
[ "MIT", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
cryptobiu/libscapi
1f11f92065c1cea418e73b932c9810d374bac060
1f70a88548501eaca5fb635194443e7a2b871088
refs/heads/master
2023-08-10T08:34:21.304797
2022-08-16T16:48:20
2022-08-16T16:48:20
53,246,303
186
74
MIT
2023-07-20T11:01:17
2016-03-06T08:59:43
C++
UTF-8
C
false
false
2,369
c
testvectors.c
/* Deterministic randombytes by Daniel J. Bernstein */ /* taken from SUPERCOP (https://bench.cr.yp.to) */ #include "api.h" #include <math.h> #include <stdio.h> #include <stdint.h> #include <string.h> #define NTESTS 1000 typedef uint32_t uint32; static uint32 seed[32] = { 3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5 } ; static uint32 in[12]; static uint32 out[8]; static int outleft = 0; #define ROTATE(x,b) (((x) << (b)) | ((x) >> (32 - (b)))) #define MUSH(i,b) x = t[i] += (((x ^ seed[i]) + sum) ^ ROTATE(x,b)); static void surf(void) { uint32 t[12]; uint32 x; uint32 sum = 0; int r; int i; int loop; for (i = 0;i < 12;++i) t[i] = in[i] ^ seed[12 + i]; for (i = 0;i < 8;++i) out[i] = seed[24 + i]; x = t[11]; for (loop = 0;loop < 2;++loop) { for (r = 0;r < 16;++r) { sum += 0x9e3779b9; MUSH(0,5) MUSH(1,7) MUSH(2,9) MUSH(3,13) MUSH(4,5) MUSH(5,7) MUSH(6,9) MUSH(7,13) MUSH(8,5) MUSH(9,7) MUSH(10,9) MUSH(11,13) } for (i = 0;i < 8;++i) out[i] ^= t[i + 4]; } } void randombytes(unsigned char *x,unsigned long long xlen) { while (xlen > 0) { if (!outleft) { if (!++in[0]) if (!++in[1]) if (!++in[2]) ++in[3]; surf(); outleft = 8; } *x = out[--outleft]; printf("%02x", *x); ++x; --xlen; } printf("\n"); } int main(void) { unsigned char key_a[KYBER_SYMBYTES], key_b[KYBER_SYMBYTES]; unsigned char pk[KYBER_PUBLICKEYBYTES]; unsigned char sendb[KYBER_CIPHERTEXTBYTES]; unsigned char sk_a[KYBER_SECRETKEYBYTES]; int i,j; for(i=0;i<NTESTS;i++) { // Key-pair generation crypto_kem_keypair(pk, sk_a); for(j=0;j<CRYPTO_PUBLICKEYBYTES;j++) printf("%02x",pk[j]); printf("\n"); for(j=0;j<CRYPTO_SECRETKEYBYTES;j++) printf("%02x",sk_a[j]); printf("\n"); // Encapsulation crypto_kem_enc(sendb, key_b, pk); for(j=0;j<CRYPTO_CIPHERTEXTBYTES;j++) printf("%02x",sendb[j]); printf("\n"); for(j=0;j<CRYPTO_BYTES;j++) printf("%02x",key_b[j]); printf("\n"); // Decapsulation crypto_kem_dec(key_a, sendb, sk_a); for(j=0;j<CRYPTO_BYTES;j++) printf("%02x",key_a[j]); printf("\n"); for(j=0;j<CRYPTO_BYTES;j++) { if(key_a[j] != key_b[j]) { fprintf(stderr, "ERROR\n"); return -1; } } } return 0; }
8bd483991bf27b20d5f8be3e13bc4fbf00ec68c5
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/sparc/include/asm/xor_64.h
ee8edc68423ec46663c41fe3cf2d36e238dbfea2
[ "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
2,613
h
xor_64.h
/* * include/asm/xor.h * * High speed xor_block operation for RAID4/5 utilizing the * UltraSparc Visual Instruction Set and Niagara block-init * twin-load instructions. * * Copyright (C) 1997, 1999 Jakub Jelinek (jj@ultra.linux.cz) * Copyright (C) 2006 David S. Miller <davem@davemloft.net> * * 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, or (at your option) * any later version. * * You should have received a copy of the GNU General Public License * (for example /usr/src/linux/COPYING); if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <asm/spitfire.h> extern void xor_vis_2(unsigned long, unsigned long *, unsigned long *); extern void xor_vis_3(unsigned long, unsigned long *, unsigned long *, unsigned long *); extern void xor_vis_4(unsigned long, unsigned long *, unsigned long *, unsigned long *, unsigned long *); extern void xor_vis_5(unsigned long, unsigned long *, unsigned long *, unsigned long *, unsigned long *, unsigned long *); /* XXX Ugh, write cheetah versions... -DaveM */ static struct xor_block_template xor_block_VIS = { .name = "VIS", .do_2 = xor_vis_2, .do_3 = xor_vis_3, .do_4 = xor_vis_4, .do_5 = xor_vis_5, }; extern void xor_niagara_2(unsigned long, unsigned long *, unsigned long *); extern void xor_niagara_3(unsigned long, unsigned long *, unsigned long *, unsigned long *); extern void xor_niagara_4(unsigned long, unsigned long *, unsigned long *, unsigned long *, unsigned long *); extern void xor_niagara_5(unsigned long, unsigned long *, unsigned long *, unsigned long *, unsigned long *, unsigned long *); static struct xor_block_template xor_block_niagara = { .name = "Niagara", .do_2 = xor_niagara_2, .do_3 = xor_niagara_3, .do_4 = xor_niagara_4, .do_5 = xor_niagara_5, }; #undef XOR_TRY_TEMPLATES #define XOR_TRY_TEMPLATES \ do { \ xor_speed(&xor_block_VIS); \ xor_speed(&xor_block_niagara); \ } while (0) /* For VIS for everything except Niagara. */ #define XOR_SELECT_TEMPLATE(FASTEST) \ ((tlb_type == hypervisor && \ (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 || \ sun4v_chip_type == SUN4V_CHIP_NIAGARA2 || \ sun4v_chip_type == SUN4V_CHIP_NIAGARA3 || \ sun4v_chip_type == SUN4V_CHIP_NIAGARA4 || \ sun4v_chip_type == SUN4V_CHIP_NIAGARA5)) ? \ &xor_block_niagara : \ &xor_block_VIS)
fc12eb2bb9ad993ee82f66fda411e493b98d61c4
14ed2724b7c610543959f23d401e7b90283e63c4
/Source/rnmesh.c
ef0194e20367f3e09f0440724ca14f13a12d8bfd
[ "MIT" ]
permissive
powervr-graphics/PowerVR-Series1
d0ec36623d257e05c078e5d3f4bdfcd786ba46a4
c8c11cbe29c5b758ed1ef9600fc8614fc8da618e
refs/heads/main
2023-08-14T18:42:40.609670
2022-03-23T10:29:37
2022-03-23T10:29:37
467,444,934
260
17
null
null
null
null
UTF-8
C
false
false
165,966
c
rnmesh.c
/***************************************************************************** *;++ * Name : $RCSfile: rnmesh.c,v $ * Title : RNMESH.C * C Author : Jim Page * Created : 21/04/95 * * Copyright : 1995-2022 Imagination Technologies (c) * License : MIT * * Description : Mesh node rendering control * * Program Type : C module (.dll) * * RCS info: * * $Date: 1997/10/07 13:12:04 $/user/rcs/revfiles/sabre/sgl/RCS/ * $Revision: 1.214 $ * $Locker: $ * $Log: rnmesh.c,v $ * Revision 1.214 1997/10/07 13:12:04 mjg * Smallest bug fix of all time? Added the character 'r'. The inline * version of PackTo20Bit in ProcessEdgesAllVisble (PCX1 only) was altered * by the previous compiler to do a reverse subtraction, even though the * hand coded line was for a normal subtraction. The new compiler didn't * do this and so any SGL mesh that was supposed to be entirely on screen, * wasn't. * * Revision 1.213 1997/09/11 10:24:23 erf * Read dithering quality setting. * * Revision 1.212 1997/09/03 10:30:28 dm * asm changed to __asm for new proton compiler * * Revision 1.211 1997/07/18 13:56:47 gdc * PC'ified * * Revision 1.210 1997/07/14 19:32:28 mjg * Added PCX2_003 compile switch. * * Revision 1.209 1997/06/23 16:15:43 gdc * downgraded some warnings to messages and a assert to a warning * * Revision 1.208 1997/06/17 10:24:55 mjg * Added FORCE_NO_FPU option. * * Revision 1.207 1997/06/04 11:14:44 gdc * removed some compiler warnings * * Revision 1.206 1997/05/16 10:33:03 gdc * downgraded another one * * Revision 1.205 1997/05/15 21:12:38 gdc * downgraded an assert to a warning * * Revision 1.204 1997/05/15 15:03:35 gdc * downgraded a warning to a message * * Revision 1.203 1997/05/13 17:55:42 mjg * Replaced PVROS memory management calls with SGL. * * Revision 1.202 1997/05/12 12:46:30 mjg * Changed an ASSERT to a DBG_WARNING. * * Revision 1.201 1997/05/02 07:42:44 erf * Removed UINT32's etc and replaced with sgl_uint32's etc. * * Revision 1.200 1997/04/30 19:20:47 jop * Put Ed's changes back to how they were * * Revision 1.199 1997/04/29 14:48:48 erf * Added new PVROS API function call mechanism. * * Revision 1.198 1997/04/25 20:36:20 mjg * Removed a few warnings - had problems with the (float const (*)[4]) array * * Revision 1.197 1997/04/21 20:01:29 mjg * Implemented new parameter buffer structures. * * Revision 1.196 1997/04/21 15:28:56 mjg * Replaced ParamBufferInfo with PVRParamBuffs. * * Revision 1.195 1997/04/10 10:09:11 mjg * Fixed an ASSERT replaced a division. * * Revision 1.194 1997/04/09 10:57:38 gdc * removed all references to projection_mat global form this file * all values now got via functions * * Revision 1.193 1997/04/08 14:39:28 gdc * local proj mat is now accessed thru functions not as a global * * Revision 1.192 1997/04/07 13:34:23 gdc * added a trans set ID as a funtion parameter rather than a * global variable * * Revision 1.191 1997/04/04 17:41:58 gdc * removed some redundant code and made fRegionSclae be got from * projection matrix struct * * Revision 1.190 1997/03/31 22:09:15 jop * Sorted out WIN32/DOS32 issues * * Revision 1.189 1997/03/27 12:36:08 erf * Operating system independent memory allocation/deallocation macros. * 1. Added #include "pvrosapi.h" to include new macros. * 2. Changed malloc, calloc, realloc and free to PVROSMalloc, PVROSCalloc, * PVROSRealloc and PVROSFree. * * Revision 1.188 1997/03/25 10:24:44 erf * When processing meshes read texture filtering quality setting to * set the bilinear register on PCX2. * * Revision 1.187 1997/03/11 12:48:44 sxy * Disabled the function call CreatePointData() for texture wraping, * the job is done in dlmesh.c. * * Revision 1.186 1997/03/10 16:26:14 erf * Fix assembler in ProcessEdgesAllVisible() which I broke in the doing * version 1.185. Sorry !!! * * Revision 1.185 1997/03/05 17:34:11 erf * 1. Removed changes made by SXY in 1.183 to check the C value. * This is already done in pkisp.c. * 2. Removed 'current_trans_set_id++' since it was compiled out * anyway. * * Revision 1.184 1997/02/27 15:33:02 gdc * got previous change to compile * * Revision 1.183 1997/02/27 15:08:26 sxy * Added check fC values for PCX2. * * Revision 1.182 1997/02/27 10:12:56 sxy * Added flat non_textured translucent mesh, fixed bug neche-flipsgl. * * Revision 1.181 1997/02/25 12:47:37 gdc * changed mesh non-textured shading to use non-branching texas packing * routines, which might get a little speed up. * * Revision 1.180 1997/02/12 10:21:18 mjg * Reverted to a slightly more optimal version of the chage below. * * Revision 1.179 1997/02/11 18:49:16 mjg * Support for negative scaling. * * Revision 1.178 1997/02/04 10:32:46 gdc * Changed defintion of gfRegion[X-Y]Scale in conjunction with change to * dvdevice.c of this date * * Revision 1.177 1997/02/03 10:55:50 gdc * removed D3DOPTIM_SGL conditionals as this is now the only option * * Revision 1.176 1997/01/29 18:17:21 mjg * Put in a check to stop solid regions running out of sabre space. * * Revision 1.175 1997/01/10 19:51:23 erf * Fixed PCX2 disappearing planes at edge of screen. * * Revision 1.174 1996/12/18 18:24:03 erf * PCX2 needs to scale A, B & C parameters to prevent overflow. * ie 32 bit to 20 bit conversion overflow prevention. * Forget what I said in Rev 1.167. * * Revision 1.173 1996/12/11 16:47:15 erf * Changed #if defined(ICL) to #if ICL. * * Revision 1.172 1996/12/10 23:17:38 erf * Changed compile switches: * 1. PVR1 to ISPTSP. * 2. PVR2 to PCX1. * 3. PVR3 to PCX2. * * Revision 1.171 1996/12/03 17:00:19 erf * Using D3DOPTIM_SGL compile switch for D3D potimisation with SGL do: * 1. No need to correct current_trans_set_id with translucent planes. * * Revision 1.170 1996/12/02 13:03:13 erf * D3D optimisation enabled for SGL using D3DOPTIM_SGL compile switch. * * Revision 1.169 1996/11/30 00:14:10 erf * In D3DOPTIM for translucency do: * 1. Ensure current_trans_set_id multiple of 2 and > 1. * 2. Depths are passed as are. ie remove negate. * * Revision 1.168 1996/11/29 12:25:59 erf * Using D3DOPTIM compile switch for optimisation do: * 1. Remove division of RegSize in the calculation of gfRegionYScale. * Absolute Y co-ordinates are calculated. * 2. Use FirstYRegionExact and LastYRegionExact to calculate absolute Y co-ordinates. * 3. Use new routines AddRegionSolid() and AddRegionSeeThru() to add objects. * 4. Change ASSERTs to check absolute Y co-ordinates. * * Revision 1.167 1996/11/14 15:59:45 erf * Use PVR3 compile switch for PCX2 to: * 1. Don't scale A, B & C parameters for perpendicular edges. * 2. No need to scale A, B & C parameters to prevent overflow. * * Revision 1.166 1996/11/08 15:43:49 gdc * changed size of malloc for setting up gpXEdges to be correct size * previously was bigger than required * * Revision 1.165 1996/11/07 12:10:47 erf * Added PVR3 compile switch for PCX2 to: * 1. Change n32A, B & C to f32A, B & C. * 2. Remove need for FLOAT_TO_FIXED. * * Revision 1.164 1996/11/07 09:52:22 erf * Added PVR3 compile switch to: * 1.Remove calls to PackTo20Bit() since not needed in PCX2. * * Revision 1.163 1996/11/06 15:03:46 gdc * moved a malloc from MeshAtListTrav to MaeshOnSglInit to avoid potential * memory leak if many devices are created (and possibly destroyed) * * Revision 1.162 1996/11/01 15:15:09 gdc * changed z-depth for translucent pass sorting to be face average rather * than a single vertex * * Revision 1.161 1996/10/30 15:41:06 gdc * hopefully fixed the NEC mesh plate clip rejection - vertices infront * of the front clipping plane had their Y-direction outsideness wrong * way round * * Revision 1.160 1996/10/29 18:20:16 gdc * did a couple of changes to make n32C value calculation more consistent * and removed a multiply in the process * * Revision 1.159 1996/10/11 12:08:19 msh * "Small number" checks modified for Midas Arcade * * Revision 1.158 1996/10/11 11:52:42 mal * Added some more metric macros. * * Revision 1.157 1996/10/10 11:11:55 mal * Modified some of the metric macros. * * Revision 1.156 1996/10/04 17:13:26 mal * Added some metric macros. * * Revision 1.155 1996/10/03 16:05:41 ncj * Fixed macro reference * * Revision 1.154 1996/10/03 12:42:57 mal * Added some metric macros for profiling code. * * Revision 1.153 1996/10/01 17:41:24 mjg * Moved stuff that was done at the start to being done at the beginning * of each display list traversal - helps BestFitRegions. * * Revision 1.152 1996/09/12 15:09:08 mal * Modified SGL_MAX_PLANES limit to SGL_MAX_PLANES. * Shadows may now have more than SGL_MAX_PLANES. * Set to twice SGL_MAX_PLANES value. re: NHE 044a, 049A. * * Revision 1.151 1996/09/04 14:35:52 sjf * "improved" sorting of translucent passes with large meshes by * basing ordering on individual faces, rather than the overal * bounding box. * * Revision 1.150 1996/09/02 14:34:29 sjf * Hmm Just realised that the small object rejection would work * better for Quads if I used the diagonal AC instead of the eged * AB. This change won't really affect Triangles. * * Revision 1.149 1996/08/30 15:49:10 sjf * Added in small object rejection for PVR1. * * Revision 1.148 1996/08/29 13:12:17 sjf * Added new param to AddRegionTranslucent. * * Revision 1.147 1996/08/28 10:19:04 sjf * Have redone the smooth shading using a much better method: this merely * comes up with new pseudo positions for clipped vertices. There is still * a minor problem with the way it chooses how to clip (it currently clips * the line between the z clipped vertex and the furthest Z vertex), but this * is minor compared to the way it was. * * Revision 1.146 1996/08/27 14:17:38 sjf * Have done a "partial" fix to the smooth shading/quad clipping code * so that now, at least, it doesn't flash! Unfortunately the code * interpolates the normals, rather than the intensity values, which * means that as points are clipped, the shading changes. I'm going to * try to fix this in the next version, but it will also require changing * the smooth shading code as well. * * Revision 1.145 1996/08/21 11:55:52 sjf * Improved the marking of the clipped flags on vertices. If the vertex was * Z clipped, it wasn't bothering to check the clipping VS the other clipping planes. * It now does this, which should allow us to eliminate a few more invisible * faces + improve the possibility of rejecting whole meshes outright. * * Revision 1.144 1996/08/20 10:11:22 sjf * Added ifdef to comment out/use mesh code that does its own region handling. * * Revision 1.143 1996/07/24 14:01:45 gdc * In processedgesallvisible cast 'cmp' instuct on [esp] resgiter to DWORD PTR * for compatability with intel compiler upgrade - no effect on previous compiler version * * Revision 1.142 1996/07/15 16:52:44 jrc * Restored the RCS revision logging. * * Revision 1.137 1996/07/08 17:31:03 jop * Added new smooth shading mode * * Revision 1.135 1996/07/06 01:42:33 sjf * Fixed another (hopefully only remaining) case of non textured * translucency, which was causing "cat scratch" render lock up. * * Revision 1.134 1996/07/05 15:15:13 jop * Added a temporary fix for the smooth shading clipping bug * * Revision 1.133 1996/07/05 07:57:36 sjf * 1) Added some debug only code * 2) Fixed bug with texture pre-process crashing if the first faces * used the global material. * * Revision 1.132 1996/06/24 16:21:04 sjf * 1) Forced off translucency if for any local material there is * a nontextured face. * 2) Fixed a bug from last version which incorrectly chose shdaing * umm shading options. * * Revision 1.131 1996/06/21 14:40:56 jrc * Surrounded OutputDebugString calls by #if WIN32. * * Revision 1.130 1996/06/20 20:45:14 jop * (Combined SJF and JOP editing)..... * HOPEFULLY ... * 1) Fixed the texture wrapping so that it only comes on when S and * O maps are actually defined * 2) (Now this may be dubious) turned off smooth shading when translucency * is on. I know there IS a problem with the hardware with PVR1 but I've * also disabled it on PCX1 as well. If this is OK in PCX1 then take the * guard out!. * * Revision 1.128 1996/06/06 23:06:03 sjf * Added material instancing,. * * Revision 1.127 1996/06/05 12:24:04 sjf * Found a very rare bug where if a horizontal (or vertical) edge lay JUST * above (or to the left) of a tile, a one pixel gap would appear between * abutting faces. This seems to occur because the ABC parameters for the edge * DRAW the edge in the NEXT tile (due to slight error/rounding differences). * .. but the vertices "tile" number get TRUNCATED into the top (or left) region * This causes the break. What I've done is added a small "slop" value which should * push the region calculation into the next region. There IS a VERY small chance that * it may get pushed too far and we'll get the same effect in reverse, but I haven't * seen this happen. * * Revision 1.126 1996/06/04 16:12:43 sjf * In texture caching, forgot to check the quality flags. Fixed now. * * Revision 1.125 1996/05/30 20:32:49 sjf * Added texture caching. * * Revision 1.124 1996/05/23 16:53:16 jop * Some stuff to make the b4 compiler happy(ier) * * Revision 1.123 1996/05/20 19:30:29 jop * Fixed MechWarrior texture bug - a naughty ! where there shouldn't * have been * * Revision 1.122 1996/05/17 18:57:06 jop * edge asm code now checks for no edges in list * * Revision 1.121 1996/05/15 12:14:31 sjf * Hopefully, (I not confirmed) fixed the problem with incorrect * Z values on near-perpendicular mesh faces. * * Revision 1.120 1996/05/11 18:45:07 sjf * Hopefully fixed some rather nasty bugs when there is a mixture of shading etc * types - the flat shading was wrong! * * Revision 1.119 1996/05/10 20:51:05 jop * Fixed bug causing the wrong asm code to be built for pvr1 * * Revision 1.118 1996/05/09 17:33:10 jop * Fixed PVR2 negation in edge calc * * Revision 1.117 1996/05/08 12:36:23 sjf * Fixed a problem if an empty mesh is given to the process routine. It now * aborts early, rather than crashing :) * * Revision 1.116 1996/05/03 16:27:56 sjf * Got rid of unneeded parameter in a pack routine. * * Revision 1.115 1996/05/02 12:34:12 jop * Fixed plane size bug, and Edges asm * * Revision 1.114 1996/05/01 14:01:26 sjf * 1) Eliminated texel sampling * 2) Fixed bug I introduced when deleting unused local materials - it would * sometimes have a local material affect the global settings. Not a bad bug * but nice to have fixed. * * Revision 1.113 1996/05/01 12:02:22 jrc * Removed some static variables that were changed but not used. * * Revision 1.112 1996/04/30 20:34:17 sjf * Fixed really horrible bug with tranlucent meshes. Basically * it would fill ISP parameter space with a load of crap when * it encountered one. * * Revision 1.111 1996/04/30 18:02:29 jop * Removed some excess includes * * Revision 1.110 1996/04/29 15:07:16 sjf * Fixed a bug which could cause part of a mesh, which ahd several * local materials, to disappear. * * Revision 1.109 1996/04/26 14:47:52 jop * double barrel p20bit now removed temporarily * * Revision 1.108 1996/04/25 14:33:13 jrc * Oops, now changed the previous log message to avoid nested comments in the * header! * * Revision 1.107 1996/04/25 14:28:08 jrc * Changed a // comment to a C style comment on a #if 0 line. This is * required for the dependency file creation by the unix makefile. * * Revision 1.106 1996/04/25 13:18:45 jop * Put double barelled 20bit routine into edge code * * Revision 1.105 1996/04/25 11:19:59 jop * Added assembly fot 20 bit packing * * Revision 1.104 1996/04/25 09:58:25 jop * ProcessEdgesAllVisible now in assembler for ICL builds * * Revision 1.103 1996/04/24 18:46:16 sjf * 1) Used a local variable to store intermediate flag values in the process partly vis * verts routine * 2) Used some local variables in the transform of normal in face processing, so it * should allow better FP overlap with Intels ICL compiler. * * Revision 1.102 1996/04/24 13:49:31 sjf * To get better overlap of FP instructions (well with the ICL compiler) added * in some temporary variables, which convinces the compiler that source and * destination dont overlap in memory. * * Revision 1.101 1996/04/24 01:04:54 jop * Fixed bug where even if PackmeshParams ran out of space, entries * would still be placed in region data for the planes that didn't * exist. This could be tidied, at the moment the entirety of * what is given to DoplaneStuff is rejected - could work out * exactly when to stop....? Yeah, maybe not. * * Revision 1.100 1996/04/23 18:58:02 sjf * 1) Tidied up some long lines * 2) Made sure when "pre_cull" was off, it didnt allocate any extra mem * 3) Allowed use of "int" compares to do FP sign tests when on Pentiac. * 4) Hopefully sped up the test for texture wrapping by moving it out * of loops. * * Revision 1.99 1996/04/23 16:51:29 sjf * dlmesh now deletes "unused" postions of anonymous meshes. Had to access * some alternative fields to cope with this. * * Revision 1.98 1996/04/22 16:10:57 sjf * added call to non textured pack routine * * Revision 1.97 1996/04/20 16:46:19 sjf * Added a smooth textured packing routine. * * Revision 1.96 1996/04/20 16:17:31 jop * Refined edge and vertex structures further * * Revision 1.95 1996/04/20 13:17:53 sjf * Got rid of redundant f1OverZ from point structure. * * Revision 1.94 1996/04/19 19:54:29 sjf * Added a call to the specialised flat textured pack routine. * * Revision 1.93 1996/04/19 16:53:45 jop * Added asm pre-cull preprocessor * * Revision 1.92 1996/04/18 14:05:13 jop * Added pre-culling mode * * Revision 1.91 1996/04/18 12:52:31 sjf * Some more optimisations (I think I added the "fast" edge calculation method * to the "partly visible" edge routine, when it detected that the edge was, in fact, * completely visible. * 2) Also tried to get integer/FPDiv overlap by rearanging a bit of code. This * should speed up pentium performance, and shouldn't harm other, better, processors. * * Revision 1.90 1996/04/17 15:47:52 sjf * Re-arranged the order of rejection of offscreen meshes + allowed * the partly visible vertex processing to report if the mesh * is actually completely onscreen (or competely offscreen). * * Revision 1.89 1996/04/16 19:09:03 sjf * 1) Removed Vertex flags copy from original data (no longer needed) * 2) Added new Wizzo! (tm) edge calculation for on screen edges. * * Revision 1.88 1996/04/16 16:35:38 jop * Added out clamping bug in dodgy rep point code * * Revision 1.87 1996/04/12 15:22:47 jop * Fixed special case smooth shading rep point bugs * * Revision 1.86 1996/04/11 19:00:33 jop * Sorted out // comment * * Revision 1.85 1996/04/11 14:20:16 jop * Added points data array to mesh structure * * Revision 1.84 1996/04/04 18:16:16 jop * Working file for beta4 * * Revision 1.83 1996/04/04 12:59:09 jop * All of ProcessFacesVisible optionally in asm now * * Revision 1.82 1996/04/04 11:23:19 sjf * Re-put in my code - and removed jims changes to cope with only SGL_MAX_PLANES per * material. Basically, this code is now in DLMESH so that we do fewer tests when * rendering. * 2) fixed a bug that was stopping texture wrapping. * * Revision 1.81 1996/04/03 18:11:42 jop * A lot of assembler, and extended simon's changes * for compatability with big meshes (such as nefertiti) * * Revision 1.80 1996/04/02 17:44:49 sjf * Changed compares for culling mode to precalculated values. * * Revision 1.79 1996/04/02 12:34:49 sjf * Optimised like mad in rnmesh * * Revision 1.78 1996/03/26 17:01:53 jop * More optimising * * Revision 1.77 1996/03/25 19:36:25 sjf * Changed region Min & Maxs to Region Rect structure * 2) Changed to use standard bounding box struct. * * Revision 1.76 1996/03/25 15:07:28 jop * Optimisations * * Revision 1.75 1996/03/19 16:47:26 jop * Sorted out double slash error * * Revision 1.74 1996/03/05 16:14:54 jop * added tranlucency back again * * Revision 1.73 1996/03/05 13:30:02 jop * Fixed edge bug in new code. * * Revision 1.71 1996/02/12 23:03:04 jop * Decluttered partly visible mesh processing * * Revision 1.70 1996/02/09 16:32:42 jop * Went to new list method * * Revision 1.69 1996/01/31 14:25:48 jop * Changed shading/points structs * * Revision 1.68 1995/12/18 18:54:58 sjf * disabled REPORT_FRAME_RATE .. * * Revision 1.67 1995/12/18 18:20:02 jop * Added some stuff which noone wants * * Revision 1.66 1995/11/28 11:06:52 pdl * removed two messages. * * Revision 1.65 1995/11/15 14:31:58 jop * Added a performance analyser * * Revision 1.64 1995/11/09 18:22:12 jop * new structures adopted * * Revision 1.63 1995/11/05 15:27:10 sjf * Rewrote the code that handles the mesh region packing - seems a lot faster * now (about 2 fps!!). * * Revision 1.62 1995/11/02 20:54:54 jop * Fixed dropout bug (INT8s wrapping round) * * Revision 1.61 1995/11/02 19:50:04 sjf * 1) Added user defineable culling on an object by object basis * 2) Added fog as a quality setting. * * Revision 1.60 1995/11/02 14:31:52 jop * Fixed typo * * Revision 1.59 1995/11/02 14:23:39 jop * Clamping replaced on visible faces * * Revision 1.58 1995/11/02 12:39:35 jop * Fixed texturing rep point algorithm * * Revision 1.57 1995/11/01 19:32:10 jop * Added to get rid of extra mesh bits * * Revision 1.56 1995/10/31 16:26:03 jop * Added back (probably unnecessarily) perpendicular planes and * fixed the nefertiti disappearing bug (back & front face culling??) * * Revision 1.55 1995/10/30 16:56:55 jop * Back face culling enabled * * Revision 1.54 1995/10/29 12:01:55 jop * Fixed bug in edge calculation - edges with 1 vertex behind the camera * weren't calculated properly - the vertex's screen space coords were * random * * Revision 1.53 1995/10/28 23:17:46 jop * Downgraded a DPF to VERBOSE * * Revision 1.52 1995/10/27 19:16:48 jop * Killed a few namco course bugs - going outside region arrays * * Revision 1.51 1995/10/27 17:39:00 jop * Now throws away perp planes * * Revision 1.50 1995/10/27 14:25:04 jop * Made region sizes non-rnmesh dependant! * * Revision 1.49 1995/10/27 13:17:43 pdl * Fixed batch shading (pf_reversed) bug * * Revision 1.48 1995/10/26 16:52:05 jop * Ifdef'd vsgl.h * * Revision 1.47 1995/10/26 15:54:24 jop * RnGetRegionsFromBBox now used to reject offscreen faces. Cut&Paste * bug removed from texture wrapping code. * * Revision 1.46 1995/10/22 18:39:34 sjf * Removed simulator window stuff. * * Revision 1.45 1995/10/20 20:08:03 jop * killed spurious include * * Revision 1.44 1995/10/20 20:03:44 jop * Added simulator window * * Revision 1.43 1995/10/18 13:50:18 jop * Fixed region bbox flushing problem * * Revision 1.42 1995/10/17 12:41:25 jrc * Now passing rectangle of regions as a struct to RnDetermineRegionsFromBBox. * * Revision 1.41 1995/10/13 12:20:34 sjf * There is a bug in Put Planes In regions (or there abouts) which makes it fail * when it runs out of Mesh Region Blocks. a fix, I just increased the * number and size of the blocks, but this is not a good solution (i.e. it may * re-appear). It would be better to fix the whole way the system worked. * * Revision 1.40 1995/10/11 10:29:24 pdl * corrected a cut'n'paste bug in the call to texas packer. * * Revision 1.39 1995/10/08 17:27:23 jop * Improved region bbox calculations and unprojectable rep points * now properly detected. CAVEAT - texturing may go weird if all vertices * are offscreen bur polygon is visible * * Revision 1.38 1995/10/06 18:08:45 jop * Better bounding box rejection * * Revision 1.37 1995/10/06 16:07:04 jop * Fixed typos * * Revision 1.36 1995/10/06 16:00:31 jop * Installed new texture scaling * * Revision 1.35 1995/10/06 14:19:47 jop * Divided up RnProcessMeshNode and adjust region optimiser to pack * reverse regions befor forward regions * * Revision 1.34 1995/10/05 14:11:00 jop * Fixed non-portable code in region optimiser * * Revision 1.33 1995/10/04 18:53:57 jop * Removed old regio-ising code * * Revision 1.32 1995/10/04 10:42:19 jop * Added support for region sorted sabre data * * Revision 1.31 1995/10/02 13:44:26 jop * Improved bounding box calculation (it works now) and fiddled with * Wireframe mode stuff * * Revision 1.30 1995/09/28 10:29:58 pdl * RnProcessMaterialNode has changed. * * Revision 1.29 1995/09/26 08:50:59 sjf * 1) This version was previously checked in by JOP but accidently * got full of DOS ^M chars... I obsoleted that version and * have rechecked it in in Unix format. (it wouldn't compile * under Linux gcc) * 2) The original changes were the removal of dud parameters from * the flat shading routines. * * * Revision 1.28 1995/09/13 18:41:20 jop * Removed buggy highlight variable from DoPlaneStuff * * Revision 1.27 1995/09/13 18:25:51 jop * Changed to different smooth shading call * , * * Revision 1.26 1995/09/12 18:39:53 jop * Several optimisations * * Revision 1.25 1995/09/05 12:07:38 jop * Tidied up sabre region stuff * * Revision 1.21 1995/08/24 17:23:46 jop * removed export keyword * * Revision 1.19 1995/08/24 15:35:36 jop * Implemented texture wrapping * , * * Revision 1.18 1995/08/23 15:56:25 jop * pf_reversed flag now used to indicate flipped polygons. Also VecNegate used for * negating vectors. * * Revision 1.17 1995/08/21 21:59:47 jop * Fixed various bugs * * Revision 1.11 1995/08/04 17:17:47 jop * Added ASSERT to warn if polygon's normal is 0,0,0# * * Revision 1.10 1995/08/03 16:01:26 jop * Changed to Stel's dual shading commands * * Revision 1.8 1995/07/27 18:43:08 jop * Added extra params * * Revision 1.7 1995/07/27 13:14:44 jop * Didi it properly this time * * Revision 1.6 1995/07/27 13:12:29 jop * removed some non-UNIX bugs * * Revision 1.5 1995/07/27 12:59:47 jop * put test routine in ifdef WIN32 thingys * * Revision 1.4 1995/07/27 11:01:15 jop * Added more stuff * * Revision 1.2 1995/07/25 16:40:01 jop * Loads of new stuff * * Revision 1.1 1995/07/23 17:19:23 jop * Initial revision * * *;-- *****************************************************************************/ /* // define Debug Module IDs */ #include <math.h> #include <stdio.h> #define MODULE_ID MODID_RNMESH #include "sgl.h" #include "sgl_defs.h" #include "sgl_math.h" #include "dlnodes.h" #include "rnglobal.h" #include "rnstate.h" #include "list.h" #include "pmsabre.h" #include "rnconvst.h" #include "rnfshade.h" #include "rnmater.h" #include "rntex.h" #include "pktsp.h" #include "pkisp.h" #include "dvdevice.h" #include "rncamera.h" #include "rnmesh.h" #include "rnshade.h" #include "rnreject.h" #include "profile.h" #include "pvrosapi.h" #include "sglmem.h" #include "txmops.h" #include "rnmater.h" #include "metrics.h" #include "parmbuff.h" /* Needed for optimised object packing routines in dregion.c. */ #include "dregion.h" #define PRE_CULL 0 SGL_EXTERN_TIME_REF /* if we are timing code !!! */ #define DEBUG_REGIONS FALSE /* // Cull mode for the current mesh */ static sgl_bool keepAntiClock; static sgl_bool keepClockwise; #if PRE_CULL static sgl_uint32 CullMode; #endif #if DEBUG_REGIONS static int gnRegionHistogram[32][24]; static int gnRegionSections; #endif /* // These only define the INITIAL Max vertices and edges. They are automatically // expanded for larger meshes. */ #define MAX_XVERTICES 100 #define MAX_XEDGES 300 /* // These are the transformed vertices and edge, PLUS how big the structures are. // As stated, they are automatically expanded as required */ static int gnXVertices = 0; static PTRANSVERTEX gpXVertices = NULL; static int gnXEdges = 0; static PTRANSEDGE gpXEdges = NULL; #if PRE_CULL static sgl_uint8 *gpXEdgeIndex = NULL; static sgl_uint8 *gpXVertexIndex = NULL; #endif static TRANSFORMED_PLANE_STRUCT *gXPlaneList[SGL_MAX_INTERNAL_PLANES]; static CONV_POINTS_STRUCT gPointsData[SGL_MAX_INTERNAL_PLANES]; static XMESHEXTRA gXExtras[SGL_MAX_INTERNAL_PLANES]; static SMOOTHPARAMS gSP; /* // for translucent mesh handling. Ideally this SHOULD be a local, passed, // variable, but What the hey. */ static BBOX_MINMAX_STRUCT BBoxMinmax; /********************************************************************/ /********************************************************************/ /* // Mesh Region Handling */ /********************************************************************/ /********************************************************************/ #define USE_INTERNAL_REGION_HANDLING 0 #if USE_INTERNAL_REGION_HANDLING #define X_REGIONS 32 #define Y_REGIONS 24 #define PLANES_IN_BLOCK 40 typedef struct { int NumForPlanes; int NumRevPlanes; sgl_int32 ForPlaneIndices[PLANES_IN_BLOCK]; sgl_int32 RevPlaneIndices[PLANES_IN_BLOCK]; }MESH_REGION_BLOCK_STRUCT; typedef struct { int MinX, MinY, MaxX, MaxY; } REGIONS_IN_USE; /* // Declare the array of Mesh regions */ static MESH_REGION_BLOCK_STRUCT MeshRegion[Y_REGIONS][X_REGIONS]; static REGIONS_IN_USE RegionsInUse; #define VERTEX_VISIBLE 0x80000000UL #define EDGE_VISIBLE 0x80000000UL #define FACE_VISIBLE 0x80 static void InitRegionBuffers () { MESH_REGION_BLOCK_STRUCT *pRegion; int Count; /* // get pointer to the first region */ pRegion = &MeshRegion[0][0]; /* // Step through all the regions (in no particular order) // and intialise the number of planes to 0 */ for (Count = X_REGIONS * Y_REGIONS; Count != 0; Count --, pRegion++) { pRegion->NumForPlanes =0; pRegion->NumRevPlanes =0; } RegionsInUse.MaxX = -1; RegionsInUse.MaxY = -1; RegionsInUse.MinX = X_REGIONS + 1; RegionsInUse.MinY = Y_REGIONS + 1; } static int OutputRegionPlanes (TRANSFORMED_PLANE_STRUCT *Planes, XMESHEXTRA *Extras) { int nYr, nXr; int YLimit, XLimit; /*so the compiler KNOWS these won't vary*/ MESH_REGION_BLOCK_STRUCT *pRegion; int nTotalPlanes = 0; /* // Step through the used Mesh Regions */ YLimit = RegionsInUse.MaxY; XLimit = RegionsInUse.MaxX; for (nYr = RegionsInUse.MinY; nYr <= YLimit; nYr ++) { /* // Get pointer to the first X region in this bunch of y's */ pRegion = &MeshRegion[nYr][RegionsInUse.MinX]; /* // Step through the X regions */ for (nXr = RegionsInUse.MinX; nXr <= XLimit; nXr ++, pRegion ++) { sgl_uint32 u32StartOfSection; int nSabrePlanes; /* // Do the "reverse" planes first */ if(pRegion->NumRevPlanes) { /* // Add it to the hardware param buffer etc */ u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; nSabrePlanes = PackMeshParamsOrdered (Planes, Extras, pRegion->RevPlaneIndices, pRegion->NumRevPlanes); AddRegionOpaqueSingle (nXr, nYr, u32StartOfSection, nSabrePlanes); nTotalPlanes += nSabrePlanes; /* // Clear the count out so we don't have to do this later */ pRegion->NumRevPlanes = 0; }/*end some reverse planes*/ /* // Do the forward planes next so they might end up in front // of the "reverse" ones when pixels jave the same z depth */ if(pRegion->NumForPlanes) { /* // Add it to the hardware param buffer etc */ u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; nSabrePlanes = PackMeshParamsOrdered (Planes, Extras, pRegion->ForPlaneIndices, pRegion->NumForPlanes); AddRegionOpaqueSingle (nXr, nYr, u32StartOfSection, nSabrePlanes); nTotalPlanes += nSabrePlanes; /* // Clear the count out so we don't have to do this later */ pRegion->NumForPlanes = 0; }/*end do forward planes*/ }/*end for x regions*/ }/*end for y*/ /* re-init the in use regions */ RegionsInUse.MaxX = -1; RegionsInUse.MaxY = -1; RegionsInUse.MinX = X_REGIONS + 1; RegionsInUse.MinY = Y_REGIONS + 1; return (nTotalPlanes); } static int OutputRegionTranPlanes (TRANSFORMED_PLANE_STRUCT *Planes, XMESHEXTRA *Extras, float NearZ) { int nYr, nXr; int YLimit, XLimit; /*so the compiler KNOWS these won't vary*/ MESH_REGION_BLOCK_STRUCT *pRegion; int nTotalPlanes = 0; /* // Step through the used Mesh Regions */ YLimit = RegionsInUse.MaxY; XLimit = RegionsInUse.MaxX; for (nYr = RegionsInUse.MinY; nYr <= YLimit; nYr ++) { /* // Get pointer to the first X region in this bunch of y's */ pRegion = &MeshRegion[nYr][RegionsInUse.MinX]; /* // Step through the X regions */ for (nXr = RegionsInUse.MinX; nXr <= XLimit; nXr ++, pRegion ++) { sgl_uint32 u32StartOfSection; int nSabrePlanes; /* // Do the "reverse" planes first */ if(pRegion->NumRevPlanes) { /* // Add it to the hardware param buffer etc */ u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; nSabrePlanes = PackMeshParamsOrdered (Planes, Extras, pRegion->RevPlaneIndices, pRegion->NumRevPlanes); AddRegionTranslucentSingle (nXr, nYr, u32StartOfSection, nSabrePlanes,NearZ); nTotalPlanes += nSabrePlanes; /* // Clear the count out so we don't have to do this later */ pRegion->NumRevPlanes = 0; }/*end some reverse planes*/ /* // Do the forward planes next so they might end up in front // of the "reverse" ones when pixels jave the same z depth */ if(pRegion->NumForPlanes) { /* // Add it to the hardware param buffer etc */ u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; nSabrePlanes = PackMeshParamsOrdered (Planes, Extras, pRegion->ForPlaneIndices, pRegion->NumForPlanes); AddRegionTranslucentSingle (nXr, nYr, u32StartOfSection, nSabrePlanes,NearZ); nTotalPlanes += nSabrePlanes; /* // Clear the count out so we don't have to do this later */ pRegion->NumForPlanes = 0; }/*end do forward planes*/ }/*end for x regions*/ }/*end for y*/ /* re-init the in use regions */ RegionsInUse.MaxX = -1; RegionsInUse.MaxY = -1; RegionsInUse.MinX = X_REGIONS + 1; RegionsInUse.MinY = Y_REGIONS + 1; return (nTotalPlanes); } #endif USE_INTERNAL_REGION_HANDLING int PutPlanesInRegions( TRANSFORMED_PLANE_STRUCT *Planes, XMESHEXTRA *Extras, sgl_uint32 nPlanes) { #if ! USE_INTERNAL_REGION_HANDLING sgl_uint32 nTotalPlanes, k; PXMESHEXTRA pExtra = Extras; nTotalPlanes = PackMeshParams (Planes, Extras, nPlanes); if (nTotalPlanes > 0) { /* Add objects, while we've still got enough ISP space */ for (k = nPlanes; (k !=0) && (pExtra->u32SabreIndex < ((PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos)-pExtra->nSabrePlanes)); k--, ++pExtra) { sgl_uint32 XYData; /* Formulate region data and type of object. */ XYData = ENCODE_OBJXYDATA( PACKED_TYPE_OPAQUE, pExtra->RegionsRect.FirstXRegion, pExtra->RegionsRect.FirstYRegion, pExtra->RegionsRect.LastXRegion, pExtra->RegionsRect.LastYRegion ); /* Use the add single opaque object function */ AddRegionSolid( XYData, pExtra->nSabrePlanes, pExtra->u32SabreIndex); } } return (nTotalPlanes); #else sgl_uint32 nPlane, nTotalPlanes = 0; PXMESHEXTRA pExtra; ASSERT (nPlanes > 0); SGL_TIME_START(PUT_PLANES_REGION_TIME) pExtra = gXExtras; for (nPlane = 0; nPlane < nPlanes; nPlane++, pExtra++) { sgl_int32 nXMin = pExtra->n32MinX; sgl_int32 nXMax = pExtra->n32MaxX; sgl_int32 nYMin = pExtra->n32MinY; sgl_int32 nYMax = pExtra->n32MaxY; /* sanity check ... */ ASSERT ((nXMin >= 0) && (nXMin < X_REGIONS)); ASSERT ((nXMax >= 0) && (nXMax < X_REGIONS)); ASSERT ((nYMin >= 0) && (nYMin < Y_REGIONS)); ASSERT ((nYMax >= 0) && (nYMax < Y_REGIONS)); ASSERT (nXMin <= nXMax); ASSERT (nYMin <= nYMax); /*////////////// // If this poly is puny, then lump it with other // tiny faces, otherwise add it explicitly to the // parameter lists. // NOTE: Use bitwise AND as this will be cheaper than // the additional branch. ///////////// */ if((nXMin == nXMax) & (nYMin == nYMax)) { MESH_REGION_BLOCK_STRUCT *pRegion; /* // Update the bounds on the used regions */ CHOOSE_MIN (RegionsInUse.MinX, nXMin); CHOOSE_MIN (RegionsInUse.MinY, nYMin); CHOOSE_MAX (RegionsInUse.MaxX, nXMax); CHOOSE_MAX (RegionsInUse.MaxY, nYMax); pRegion = &MeshRegion[nYMin][nXMin]; /* // if a reverse polygon plane */ if (GlobalTransformedPlanes[nPlane].pOriginalData->flags & pf_reversed) { /* // if this region is full, then flush it */ if(pRegion->NumRevPlanes == PLANES_IN_BLOCK) { sgl_uint32 u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; int nSabrePlanes; /* // Add it to the hardware param buffer etc */ SGL_TIME_SUSPEND(PUT_PLANES_REGION_TIME) nSabrePlanes = PackMeshParamsOrdered (Planes, Extras, pRegion->RevPlaneIndices, pRegion->NumRevPlanes); SGL_TIME_RESUME(PUT_PLANES_REGION_TIME) AddRegionOpaqueSingle (nXMin, nYMin, u32StartOfSection, nSabrePlanes); nTotalPlanes += nSabrePlanes; /* // Add the new plane to the start */ pRegion->RevPlaneIndices[0] = nPlane; pRegion->NumRevPlanes = 1; } /* // Else just add it */ else { pRegion->RevPlaneIndices[pRegion->NumRevPlanes] = nPlane; pRegion->NumRevPlanes ++; } } /* // else is a forward one */ else { /* // if this region is full, then flush it */ if(pRegion->NumForPlanes == PLANES_IN_BLOCK) { sgl_uint32 u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; int nSabrePlanes; /* // Add it to the hardware param buffer etc */ u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; SGL_TIME_SUSPEND(PUT_PLANES_REGION_TIME) nSabrePlanes = PackMeshParamsOrdered (Planes, Extras, pRegion->ForPlaneIndices, pRegion->NumForPlanes); SGL_TIME_RESUME(PUT_PLANES_REGION_TIME) AddRegionOpaqueSingle (nXMin, nYMin, u32StartOfSection, nSabrePlanes); nTotalPlanes += nSabrePlanes; /* // Add the new plane to the start */ pRegion->ForPlaneIndices[0] = nPlane; pRegion->NumForPlanes = 1; } /* // Else just add it */ else { pRegion->ForPlaneIndices[pRegion->NumForPlanes] = nPlane; pRegion->NumForPlanes ++; } }/*end if forward or reverse*/ } /*////////////// // Else this face should be added as a complete object ///////////// */ else { sgl_int32 index; REGIONS_RECT_STRUCT TheRegions; sgl_uint32 nSabrePlanes; sgl_uint32 u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; TheRegions.FirstXRegion = nXMin; TheRegions.LastXRegion = nXMax; TheRegions.FirstYRegion = nYMin; TheRegions.LastYRegion = nYMax; index = nPlane; SGL_TIME_SUSPEND(PUT_PLANES_REGION_TIME) nSabrePlanes = PackMeshParamsOrdered (Planes, Extras, &index, 1); AddRegionOpaque(&TheRegions, u32StartOfSection, nSabrePlanes); SGL_TIME_RESUME(PUT_PLANES_REGION_TIME) nTotalPlanes+= nSabrePlanes; }/*end else*/ }/*end for plane*/ nTotalPlanes += OutputRegionPlanes (Planes, Extras); SGL_TIME_STOP(PUT_PLANES_REGION_TIME) return (nTotalPlanes); #endif } /********************************************************************/ static int PutTranPlanesInRegions( TRANSFORMED_PLANE_STRUCT *Planes, XMESHEXTRA *Extras, sgl_uint32 nPlanes, int nCurrTransSetID) { #if ! USE_INTERNAL_REGION_HANDLING sgl_uint32 nTotalPlanes, k; PXMESHEXTRA pExtra = Extras; nTotalPlanes = PackMeshParams (Planes, Extras, nPlanes); if (nTotalPlanes > 0) { sgl_uint32 XYData; TRANS_REGION_DEPTHS_STRUCT Trans; const TRANS_REGION_DEPTHS_STRUCT *pTrans; for (k = nPlanes; k !=0 ; k--, ++pExtra) { /* Optimisation uses AddRegionSeeThru() routine. * Pack description for routine. */ XYData = ENCODE_OBJXYDATA( PACKED_TYPE_TRANSLUCENT, pExtra->RegionsRect.FirstXRegion, pExtra->RegionsRect.FirstYRegion, pExtra->RegionsRect.LastXRegion, pExtra->RegionsRect.LastYRegion); /* Use the NearZ direct, allow for inversion */ Trans.BaseDepth = pExtra->NearZ; Trans.DepthDx = 0.0f; Trans.DepthDy = 0.0f; pTrans = (const TRANS_REGION_DEPTHS_STRUCT *) &Trans; /* Use the add single translucent object function */ AddRegionSeeThru( XYData, nCurrTransSetID, pExtra->nSabrePlanes, pExtra->u32SabreIndex, pTrans); } } return (nTotalPlanes); #else sgl_uint32 nPlane, nTotalPlanes = 0; PXMESHEXTRA pExtra; ASSERT (nPlanes > 0); pExtra = gXExtras; for (nPlane = 0; nPlane < nPlanes; nPlane++, pExtra++) { sgl_int32 nXMin = pExtra->n32MinX; sgl_int32 nXMax = pExtra->n32MaxX; sgl_int32 nYMin = pExtra->n32MinY; sgl_int32 nYMax = pExtra->n32MaxY; /* sanity check ... */ ASSERT ((nXMin >= 0) && (nXMin < X_REGIONS)); ASSERT ((nXMax >= 0) && (nXMax < X_REGIONS)); ASSERT ((nYMin >= 0) && (nYMin < Y_REGIONS)); ASSERT ((nYMax >= 0) && (nYMax < Y_REGIONS)); ASSERT (nXMin <= nXMax); ASSERT (nYMin <= nYMax); /*////////////// // If this poly is puny, then lump it with other // tiny faces, otherwise add it explicitly to the // parameter lists. // NOTE: Use bitwise AND as this will be cheaper than // the additional branch. ///////////// */ if((nXMin == nXMax) & (nYMin == nYMax)) { MESH_REGION_BLOCK_STRUCT *pRegion; /* // Update the bounds on the used regions */ CHOOSE_MIN (RegionsInUse.MinX, nXMin); CHOOSE_MIN (RegionsInUse.MinY, nYMin); CHOOSE_MAX (RegionsInUse.MaxX, nXMax); CHOOSE_MAX (RegionsInUse.MaxY, nYMax); pRegion = &MeshRegion[nYMin][nXMin]; /* // if a reverse polygon plane */ if (GlobalTransformedPlanes[nPlane].pOriginalData->flags & pf_reversed) { /* // if this region is full, then flush it */ if(pRegion->NumRevPlanes == PLANES_IN_BLOCK) { sgl_uint32 u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; int nSabrePlanes; /* // Add it to the hardware param buffer etc */ nSabrePlanes = PackMeshParamsOrdered (Planes, Extras, pRegion->RevPlaneIndices, pRegion->NumRevPlanes); AddRegionTranslucentSingle (nXMin, nYMin, u32StartOfSection, nSabrePlanes,NearZ); nTotalPlanes += nSabrePlanes; /* // Add the new plane to the start */ pRegion->RevPlaneIndices[0] = nPlane; pRegion->NumRevPlanes = 1; } /* // Else just add it */ else { pRegion->RevPlaneIndices[pRegion->NumRevPlanes] = nPlane; pRegion->NumRevPlanes ++; } } /* // else is a forward one */ else { /* // if this region is full, then flush it */ if(pRegion->NumForPlanes == PLANES_IN_BLOCK) { sgl_uint32 u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; int nSabrePlanes; /* // Add it to the hardware param buffer etc */ u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; nSabrePlanes = PackMeshParamsOrdered (Planes, Extras, pRegion->ForPlaneIndices, pRegion->NumForPlanes); AddRegionTranslucentSingle (nXMin, nYMin, u32StartOfSection, nSabrePlanes,NearZ); nTotalPlanes += nSabrePlanes; /* // Add the new plane to the start */ pRegion->ForPlaneIndices[0] = nPlane; pRegion->NumForPlanes = 1; } /* // Else just add it */ else { pRegion->ForPlaneIndices[pRegion->NumForPlanes] = nPlane; pRegion->NumForPlanes ++; } }/*end if forward or reverse*/ } /*////////////// // Else this face should be added as a complete object ///////////// */ else { sgl_int32 index; REGIONS_RECT_STRUCT TheRegions; sgl_uint32 nSabrePlanes; sgl_uint32 u32StartOfSection = PVRParamBuffs[PVR_PARAM_TYPE_ISP].uBufferPos; TheRegions.FirstXRegion = nXMin; TheRegions.LastXRegion = nXMax; TheRegions.FirstYRegion = nYMin; TheRegions.LastYRegion = nYMax; index = nPlane; nSabrePlanes = PackMeshParamsOrdered (Planes, Extras, &index, 1); AddRegionTranslucent(&TheRegions, u32StartOfSection, nSabrePlanes,NearZ); nTotalPlanes+= nSabrePlanes; }/*end else*/ }/*end for plane*/ nTotalPlanes += OutputRegionTranPlanes (Planes, Extras, NearZ); return (nTotalPlanes); #endif } /********************************************************************/ void RnMeshOnSglInitialise () { int k; for (k = 0; k < SGL_MAX_INTERNAL_PLANES; ++k) { gXPlaneList[k] = &GlobalTransformedPlanes[k]; } #if USE_INTERNAL_REGION_HANDLING InitRegionBuffers (); #endif gnXEdges = SglReadPrivateProfileInt ("Mesh", "MaxEdges", MAX_XEDGES, "sgl.ini"); gpXEdges = SGLMalloc (sizeof (TRANSEDGE) * gnXEdges); ASSERT (gpXEdges); gnXVertices = SglReadPrivateProfileInt ("Mesh", "MaxVertices", MAX_XVERTICES, "sgl.ini"); gpXVertices = SGLMalloc (sizeof (TRANSVERTEX) * gnXVertices); ASSERT (gpXVertices); #if PRE_CULL gpXVertexIndex = SGLMalloc (sizeof (sgl_uint8) * gnXVertices); gpXEdgeIndex = SGLMalloc (sizeof (sgl_uint8) * gnXEdges); ASSERT (gpXVertexIndex); ASSERT (gpXEdgeIndex); #endif } /************************************************************************** * Function Name : DoPlaneStuff (LOCAL FUNCTION) * **************************************************************************/ static int DoPlaneStuff (const MESH_NODE_STRUCT *pMesh, int nPlanes, MASTER_STATE_STRUCT *pState, MATERIAL_STATE_STRUCT *pMaterial, int nCurrTransSetID) { int k; sgl_bool bShadowLights; sgl_bool bFogOn; sgl_bool HasTranslucent; int ORedFlags, ANDedFlags, FlagsMask; SGL_TIME_START(PLANE_STUFF_TIME) bShadowLights = pState->pLightsState->flags & lsf_shadows; ORedFlags = pMesh->ORedPlaneFlags; ANDedFlags = pMesh->ANDedPlaneFlags; FlagsMask = ~(0); HasTranslucent = (pMaterial->texas_precomp.LowWord & MASK_TRANS); /* //check quality state // // If there is no smooth shading, then disable it */ #if 0 /* //if we have both translucency and smooth shading, turn the smooth //shading off instead of the translucency */ if (!(pState->pQualityState->flags & qf_smooth_shading)|| HasTranslucent) #else if (!(pState->pQualityState->flags & qf_smooth_shading)) #endif { /* // switch off smooth shading */ ORedFlags &= ~pf_smooth_shad; ANDedFlags &= ~pf_smooth_shad; /* // This is only needed when we are doing a mixture of shading types */ FlagsMask &= ~pf_smooth_shad; } /* // if texturing is turned off OR there is no texture in the current material */ if (!(pState->pQualityState->flags & qf_textures) || !(pMaterial->texture_flags & MASK_TEXTURE)) { /* // switch off texturing */ ORedFlags &= ~pf_textured; ANDedFlags &= ~pf_textured; /* // This is only needed when we are doing a mixture of shading types */ FlagsMask &= ~pf_textured; /*HasTranslucent = FALSE;*/ } /* // Else we are either texture wrapping or direct texturing, so set up // the texture projection matrix accordingly */ else { int ThisTextureSize = TexasGetTextureDimension (&pMaterial->texas_precomp); /* // Do we need change the texture projection bit of the // local projection matrix for a different sized texture? */ if(!RnGlobalLocalProjMatTextureIsValid(ThisTextureSize)) { RnRescaleLocalProjectionTexture(ThisTextureSize, pState->pTransformState); } /* // Since we have texturing, make sure we turn it on */ ORedFlags |= pf_textured; ANDedFlags |= pf_textured; /*HasTranslucent = (pMaterial->texas_precomp.LowWord & MASK_TRANS);*/ }/*if textured */ #if 0 /*fix by simon, shoes by cardin, hair by ...*/ if(HasTranslucent) { return; } #endif /* // OK Smooth shading and translucency is OUT! on Midas3, possibly PCX1 and // possibly PCX2 as well. // (we'll need to check the latter case) */ /* And, I'm guessing PCX2_003 doesn't do it either ! - MJG */ #if ISPTSP || PCX1 || PCX2 || PCX2_003 if(HasTranslucent) { /* // switch off smooth shading */ ORedFlags &= ~pf_smooth_shad; ANDedFlags &= ~pf_smooth_shad; /* // This is only needed when we are doing a mixture of shading types */ FlagsMask &= ~pf_smooth_shad; #if PCX1 || PCX2 || PCX2_003 DPF((DBG_MESSAGE, "Disabling smooth translucent. IS this Needed?")); #endif } #endif /* // if all the surfaces in the objects are to be textured/shaded in the same // manner ... */ if(ORedFlags == ANDedFlags) { bFogOn = pState->pQualityState->flags & qf_fog; /* // turn off texture wrapping if it is not enabled in the material // (IE texture on amd premapped off) */ if((ANDedFlags & (pf_pre_mapped|pf_textured))== pf_textured) { /* // If wrapping impossible, switch it off */ if(! (pMaterial->texture_flags & wrapping_on)) { ANDedFlags &= ~pf_textured; } } SGL_TIME_SUSPEND(PLANE_STUFF_TIME) switch (ANDedFlags & ~(pf_pre_mapped)) { case pf_textured: { if (ANDedFlags & pf_pre_mapped) { DoTextureMappingFast (nPlanes, (const TRANSFORMED_PLANE_STRUCT *const*) gXPlaneList, pState->pTransformState, pMaterial, GlobalTextureResults); } /* // Else texture wrap it */ else { DoTextureWrapping (nPlanes, gXPlaneList, pState->pTransformState, pMaterial, GlobalTextureResults); } DoFlatTextureShading (FALSE, nPlanes, gXPlaneList, pState->pTransformState, pMaterial, pState->pLightsState, GlobalShadingResults); PackTexasParamsFlatTextured(nPlanes, GlobalTextureResults, GlobalShadingResults, bShadowLights, bFogOn, gXPlaneList, pMaterial); break; } case pf_textured | pf_smooth_shad: { if (ANDedFlags & pf_pre_mapped) { DoTextureMappingFast (nPlanes, (const TRANSFORMED_PLANE_STRUCT *const*) gXPlaneList, pState->pTransformState, pMaterial, GlobalTextureResults); } else { DoTextureWrapping (nPlanes, gXPlaneList, pState->pTransformState, pMaterial, GlobalTextureResults); } GetSmoothShadingParametersAdjoint (nPlanes, gXPlaneList, pState->pTransformState, pMaterial, pState->pLightsState, GlobalShadingResults, &gSP); PackTexasParamsSmoothTextured(nPlanes, GlobalTextureResults, GlobalShadingResults, bShadowLights, bFogOn, gXPlaneList, pMaterial); break; } case pf_smooth_shad: { /* // Also turn off translucency if no texture - this is not a // good way of working around the hardware, but will do for // now at least. */ #if 0 /* //if we have both translucency and smooth shading, turn the smooth //shading off instead of the translucency */ /*HasTranslucent = FALSE;*/ #else HasTranslucent = FALSE; #endif GetSmoothShadingParametersAdjoint (nPlanes, gXPlaneList, pState->pTransformState, pMaterial, pState->pLightsState, GlobalShadingResults, &gSP); if(bShadowLights) { PackTexasParamsSmoothNonTexturedShad (nPlanes, GlobalShadingResults, bFogOn, gXPlaneList); } else { PackTexasParamsSmoothNonTextured (nPlanes, GlobalShadingResults, bFogOn, gXPlaneList); } break; } default: { /* // Also turn off translucency if no texture - this is not a // good way of working around the hardware, but will do for // now at least. */ /*HasTranslucent = FALSE;*/ DoFlatShading (FALSE, nPlanes, gXPlaneList, pState->pTransformState, pMaterial, pState->pLightsState, GlobalShadingResults); if(HasTranslucent) { PackTexasParamsFlatNonTexturedTrans(nPlanes, GlobalShadingResults, bShadowLights, bFogOn, pMaterial->translucent_int, gXPlaneList); } else { PackTexasParamsFlatNonTextured(nPlanes, GlobalShadingResults, bShadowLights, bFogOn, gXPlaneList); } break; } } SGL_TIME_RESUME(PLANE_STUFF_TIME) } /* // Else we have a variety of shading operations to apply */ else { static TRANSFORMED_PLANE_STRUCT *gXVisible[SGL_MAX_INTERNAL_PLANES]; static TRANSFORMED_PLANE_STRUCT *gXTextured[SGL_MAX_INTERNAL_PLANES]; static TRANSFORMED_PLANE_STRUCT *gXTexWrap[SGL_MAX_INTERNAL_PLANES]; static TRANSFORMED_PLANE_STRUCT *gXShaded[SGL_MAX_INTERNAL_PLANES]; static TRANSFORMED_PLANE_STRUCT *gXTexShad[SGL_MAX_INTERNAL_PLANES]; static TRANSFORMED_PLANE_STRUCT *gXTexWrapShad[SGL_MAX_INTERNAL_PLANES]; int nVisible = 0; int nTextured = 0; int nTexWrap = 0; int nShaded = 0; int nTexShad = 0; int nTexWrapShad = 0; int FaceFlag; /* // The following code could be made a LOT faster... */ /* // Clear off unneeded flags */ FlagsMask &= ~(pf_pre_mapped | pf_reversed); /* faces have different material properties */ for (k = 0; k < nPlanes; ++k) { FaceFlag = GlobalTransformedPlanes[k].flags; /* // turn off texture wrapping if it is not enabled in the material */ if((FaceFlag & (pf_pre_mapped | pf_textured))== pf_textured) { /* // If wrapping impossible, switch it off */ if(! (pMaterial->texture_flags & wrapping_on)) { FaceFlag &= ~pf_textured; } } /* // Also turn off translucency. THIS IS NOT a proper fix - but // we cant have non-textured translucency! What we should do // is individually put planes in with either translucent or // non translucent routines (see below) but I haven't time to // sort out that sort of nonsense now. SJF */ if(!(FaceFlag & pf_textured)) { HasTranslucent = FALSE; } switch (FaceFlag & FlagsMask) { case pf_textured: { if (FaceFlag & pf_pre_mapped) { gXTextured[nTextured++] = &GlobalTransformedPlanes[k]; } else { gXTexWrap[nTexWrap++] = &GlobalTransformedPlanes[k]; } break; } case pf_textured | pf_smooth_shad: { if (FaceFlag & pf_pre_mapped) { gXTexShad[nTexShad++] = &GlobalTransformedPlanes[k]; } else { gXTexWrapShad[nTexWrapShad++] = &GlobalTransformedPlanes[k]; } break; } case pf_smooth_shad: { gXShaded[nShaded++] = &GlobalTransformedPlanes[k]; break; } default: { gXVisible[nVisible++] = &GlobalTransformedPlanes[k]; break; } }/*end switch*/ } bFogOn = pState->pQualityState->flags & qf_fog; SGL_TIME_SUSPEND(PLANE_STUFF_TIME) if (nTexShad) { GetSmoothShadingParametersAdjoint (nTexShad, (TRANSFORMED_PLANE_STRUCT **) gXTexShad, pState->pTransformState, pMaterial, pState->pLightsState, GlobalShadingResults, &gSP); DoTextureMappingFast (nTexShad, (const TRANSFORMED_PLANE_STRUCT * const*) gXTexShad, pState->pTransformState, pMaterial, GlobalTextureResults); PackTexasParamsSmoothTextured (nTexShad, GlobalTextureResults, GlobalShadingResults, bShadowLights, bFogOn, gXTexShad, pMaterial); } if (nTexWrapShad) { GetSmoothShadingParametersAdjoint (nTexWrapShad, gXTexWrapShad, pState->pTransformState, pMaterial, pState->pLightsState, GlobalShadingResults, &gSP); DoTextureWrapping (nTexWrapShad, gXTexWrapShad, pState->pTransformState, pMaterial, GlobalTextureResults); PackTexasParamsSmoothTextured (nTexWrapShad, GlobalTextureResults, GlobalShadingResults, bShadowLights, bFogOn, gXTexWrapShad, pMaterial); } if (nTextured) { DoTextureMappingFast (nTextured, (const TRANSFORMED_PLANE_STRUCT *const*) gXTextured, pState->pTransformState, pMaterial, GlobalTextureResults); DoFlatTextureShading (FALSE, nTextured, gXTextured, pState->pTransformState, pMaterial, pState->pLightsState, GlobalShadingResults); PackTexasParamsFlatTextured (nTextured, GlobalTextureResults, GlobalShadingResults,bShadowLights, bFogOn, gXTextured, pMaterial); } if (nTexWrap) { DoTextureWrapping (nTexWrap, gXTexWrap, pState->pTransformState, pMaterial, GlobalTextureResults); DoFlatTextureShading (FALSE, nTexWrap, gXTexWrap, pState->pTransformState, pMaterial,pState->pLightsState, GlobalShadingResults); PackTexasParamsFlatTextured(nTexWrap, GlobalTextureResults, GlobalShadingResults, bShadowLights, bFogOn, gXTexWrap, pMaterial); } if (nShaded) { GetSmoothShadingParametersAdjoint (nShaded, gXShaded, pState->pTransformState, pMaterial, pState->pLightsState, GlobalShadingResults, &gSP); PackTexasParamsNonTextured(nShaded,GlobalShadingResults, TRUE, bShadowLights, bFogOn, gXShaded); } if (nVisible) { DoFlatShading (FALSE, nVisible, gXVisible, pState->pTransformState, pMaterial, pState->pLightsState, GlobalShadingResults); PackTexasParamsNonTextured(nVisible, GlobalShadingResults, FALSE, bShadowLights, bFogOn, gXVisible); } SGL_TIME_RESUME(PLANE_STUFF_TIME) }/*end else*/ SGL_TIME_STOP(PLANE_STUFF_TIME) if (HasTranslucent) { return (PutTranPlanesInRegions (GlobalTransformedPlanes, gXExtras, nPlanes, nCurrTransSetID)); } else { return (PutPlanesInRegions (GlobalTransformedPlanes, gXExtras, nPlanes)); } } /************************************************************************** * Function Name : ProcessVerticesAllVisible (LOCAL FUNCTION) * Inputs : pVertices - pointer to start of an array of vertex data * nVertices - the number of vertices to process * * * NOTE: There is a problem I (sjf) had to work around concerning the region * calculation of vertices and the Edge ABC parameter generation. IF a * vertex was JUST above (or to the left) of a region boundary, it will * naturally be placed in that region. Unfornately, with the rounding that * is somehow done with the edge ABC calculation, the edge ends up JUST * in the region below. Thus if you have a horizontal (or vertical) join * which lies a TINY fraction above (or to the left) between two faces, * you get a one pixel gap appearing - the chances of this are slim, but * it is very annoying when it does appear. To "fix" this, I've added a * small round up value which will push such vertices into the next region. * * I guess we could potentially have the reverse situation, (because of * this "rounding" up) but the value seems to be small enough that * I haven't seen it occur. **************************************************************************/ #define FIX_ROUNDING_PROBLEM (0.001f) static void ProcessVerticesAllVisible( PVERTEX pVertex, int nVertices, const TRANSFORM_STRUCT *pTransform) { PTRANSVERTEX pXVertex; PROJECTION_MATRIX_STRUCT * const pProjMat = RnGlobalGetProjMat (); float fRegionXScale = pProjMat->fRegionXScale; float SxDash = pProjMat->SxDash; float SyDash = pProjMat->SyDash; float OxDash = pProjMat->OxDash; float OyDash = pProjMat->OyDash; register float f1OverZ; float fXws, fYws, fZws; float fXss, fYss; #if PRE_CULL sgl_uint8 *p = gpXVertexIndex; #endif SGL_TIME_START(TRANSFORM_VERTICES_ALL_TIME) pXVertex = gpXVertices; for (/*None*/; nVertices != 0; --nVertices, ++pVertex, ++pXVertex) { #if PRE_CULL if (*p) { #endif pXVertex->pvVertex = pVertex->vVertex; /* // For brevity define v, and m as shortcuts into the vector and // matrix */ #define v pVertex->vVertex #define m pTransform->mat fXws = v[0] * m[0][0] + v[1] * m[0][1] + v[2] * m[0][2] + m[0][3]; fYws = v[0] * m[1][0] + v[1] * m[1][1] + v[2] * m[1][2] + m[1][3]; fZws = v[0] * m[2][0] + v[1] * m[2][1] + v[2] * m[2][2] + m[2][3]; pXVertex->vWorldSpace[0] = fXws; pXVertex->vWorldSpace[1] = fYws; pXVertex->vWorldSpace[2] = fZws; #undef v #undef m f1OverZ = 1.0f / fZws; fXss = (SxDash * fXws * f1OverZ) + OxDash; fYss = (SyDash * fYws * f1OverZ) + OyDash; pXVertex->vScreenSpace[0] = fXss; pXVertex->vScreenSpace[1] = fYss; /* Work out which region it falls in */ pXVertex->nRegion[0] = (sgl_int32) (fXss * fRegionXScale + FIX_ROUNDING_PROBLEM); /* For optimisation exact Y co-ordinates required. */ pXVertex->nRegion[1] = (sgl_int32) fYss; ASSERT(RnGlobalProjMatRegionOnScreen(pXVertex->nRegion[0], pXVertex->nRegion[1])); #if PRE_CULL } ++p; #endif } SGL_TIME_STOP(TRANSFORM_VERTICES_ALL_TIME) } /************************************************************************** * Function Name : ProcessVerticesPartlyVisible (LOCAL FUNCTION) * Inputs : pVertices - pointer to start of an array of vertex data * nVertices - the number of vertices to process * **************************************************************************/ static TEST_BOX_ENUM ProcessVerticesPartlyVisible (PVERTEX pVertex, int nVertices, const TRANSFORM_STRUCT *pTransform) { PTRANSVERTEX pXVertex; PROJECTION_MATRIX_STRUCT * const pProjMat = RnGlobalGetProjMat (); float SxDash = pProjMat->SxDash; float SyDash = pProjMat->SyDash; float OxDash = pProjMat->OxDash; float OyDash = pProjMat->OyDash; register float f1OverZ; float fXws, fYws, fZws; float fXss, fYss; float FirstYRegionExact, LastYRegionExact; float foregroundDistance, fRegionXScale, FirstXRegion, LastXRegion; float fViewportMinX, fViewportMaxX, fViewportMinY, fViewportMaxY; /* // These are used to determine if the mesh is entirely // on screen, or possibly entirely offscreen, or partly on screen. */ sgl_bool AnyClipping; int AndFlags; SGL_TIME_START(TRANSFORM_VERTICES_PARTLY_TIME) FirstYRegionExact = (float)pProjMat->FirstYRegionExact; LastYRegionExact = (float)pProjMat->LastYRegionExact; foregroundDistance = pProjMat->foregroundDistance; fRegionXScale = pProjMat->fRegionXScale; FirstXRegion = (float)pProjMat->FirstXRegion; LastXRegion = (float)pProjMat->LastXRegion; fViewportMinX = pProjMat->fViewportMinX; fViewportMaxX = pProjMat->fViewportMaxX; fViewportMinY = pProjMat->fViewportMinY; fViewportMaxY = pProjMat->fViewportMaxY; #if PRE_CULL sgl_uint8 *p = gpXVertexIndex; #endif AnyClipping = FALSE; AndFlags =~0; pXVertex = gpXVertices; for (/*None*/; nVertices != 0; --nVertices, ++pVertex, ++pXVertex) { #if PRE_CULL if (*p) { #endif pXVertex->pvVertex = pVertex->vVertex; /* // For brevity define v, and m as shortcuts into the vector and // matrix */ #define v pVertex->vVertex #define m pTransform->mat fXws = v[0] * m[0][0] + v[1] * m[0][1] + v[2] * m[0][2] + m[0][3]; fYws = v[0] * m[1][0] + v[1] * m[1][1] + v[2] * m[1][2] + m[1][3]; fZws = v[0] * m[2][0] + v[1] * m[2][1] + v[2] * m[2][2] + m[2][3]; pXVertex->vWorldSpace[0] = fXws; pXVertex->vWorldSpace[1] = fYws; pXVertex->vWorldSpace[2] = fZws; #undef v #undef m /* // Check first if it is on the wrong side of the foreground // clipping plane. */ if (fZws < foregroundDistance) { int Flags; AnyClipping = TRUE; Flags = CLIPPED_Z; /* // Test the other viewing fustrum boundaries as well // // Test against Min X */ if(fXws < fViewportMinX * fZws) { Flags |= CLIPPED_MINUS_X; } /* // Test against Max X. Note that min and max x clipping // is not mutually exclusive with a negative Z. */ if(fXws > fViewportMaxX * fZws) { Flags |= CLIPPED_PLUS_X; } /* // Test against Min Y. */ if(fYws < fViewportMinY * fZws) { Flags |= CLIPPED_MINUS_Y; } /* // Test against Max Y. */ if(fYws > fViewportMaxY * fZws) { Flags |= CLIPPED_PLUS_Y; } pXVertex->Flags = Flags; AndFlags &= Flags; } else { sgl_int32 Region; int Flags; f1OverZ = 1.0f / fZws; fXss = (SxDash * fXws * f1OverZ) + OxDash; fYss = (SyDash * fYws * f1OverZ) + OyDash; pXVertex->vScreenSpace[0] = fXss; pXVertex->vScreenSpace[1] = fYss; /* // Work out which region it falls in. // NOTE: There is a REALLY unlikely bug which could occur if the // mesh face is absolutely enormous and the projected region is // larger than can be represented by an sgl_int32.... but who could // be bothered testing for it.... */ Region = (sgl_int32) (fXss * fRegionXScale + FIX_ROUNDING_PROBLEM); if(Region < FirstXRegion) { pXVertex->nRegion[0] = (sgl_int32)FirstXRegion; Flags = CLIPPED_MINUS_X; AnyClipping = TRUE; } else if(Region > LastXRegion) { pXVertex->nRegion[0] = (sgl_int32)LastXRegion; Flags = CLIPPED_PLUS_X; AnyClipping = TRUE; } else { pXVertex->nRegion[0] = Region; Flags = 0; } /* Correction needed with Y region. Absolute Y co-ordinates required. */ Region = (sgl_int32) fYss; /* first Y region is the top of the viewport - max Y */ if(Region < FirstYRegionExact) { pXVertex->nRegion[1] = (sgl_int32)FirstYRegionExact; Flags |= CLIPPED_PLUS_Y; AnyClipping = TRUE; } else if(Region > LastYRegionExact) { pXVertex->nRegion[1] = (sgl_int32)LastYRegionExact; Flags |= CLIPPED_MINUS_Y; AnyClipping = TRUE; } else { pXVertex->nRegion[1] = Region; } /* // Update whether all the vertices are to one side of the // view pyramid, and the flag values for this vertex. */ AndFlags &= Flags; pXVertex->Flags= Flags; }/*end else NOT Z clipped*/ #if PRE_CULL } ++p; #endif }/*end for */ /* //Decide whether the mesh is entirely on screen etc */ if(!AnyClipping) { SGL_TIME_STOP(TRANSFORM_VERTICES_PARTLY_TIME) return(TB_BOX_ALL_ONSCREEN); } else if(AndFlags) { SGL_TIME_STOP(TRANSFORM_VERTICES_PARTLY_TIME) return(TB_BOX_OFFSCREEN); } else { SGL_TIME_STOP(TRANSFORM_VERTICES_PARTLY_TIME) return(TB_BOX_PART_ONSCREEN); } } /************************************************************************** * Function Name : ProcessEdgesAllVisible (LOCAL FUNCTION) * Inputs : pEdges - pointer to start of an array of edge data * nEdges - the number of edges to process * **************************************************************************/ /*sgl_int32 PackTo20BitDoubleBarrel (const float F1, const float F2, int *pV1, int *pV2);*/ void ProcessEdgesAllVisible (PEDGE pEdge, int nEdges) { #if ICL && !(PCX2 || PCX2_003) /* // Define the largest exponent the SABRE hardware can handle */ #define MAX_LEGAL_20_EXPONENT (14) /* // Define whether we should have an extra 1/2 bits accuracy // when changing from IEEE 24 bit mantissa to the 16 bit // mantissa of the Sabre Float */ #define USE_ROUNDING 0 /*/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // IEEE version ///////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// */ #define IEEE_SIGN_BIT (0x80000000L) /* // Mantissa is in lower 23 bits */ #define IEEE_MANTISSA_MASK 0x007FFFFFL /* ((1L<<23)-1) */ #define IEEE_ASSUMED_MANTISSA_BIT 0x00800000L /* (1L<<23L) */ /* // Values for getting the IEEE exponent */ #define IEEE_E_MASK (0xFF) #define IEEE_E_SHIFT (23) /* // Define how much we have to shift down the IEEE mantissa // to get the right number of bits for the 20bit float // NOTE this INCLUDES the assumed Most sig bit. */ #define IEEE_TO_20_SHIFT 9 /* (24 - 15) */ /* // Define how to round from the IEEE float to the 20 bit float. // the rounding bit is the bit JUST after the where the // 20 bit mantissa runs out */ #define MANTISSA_ROUND 0x00000100L /*(1L<<(IEEE_TO_20_SHIFT - 1))*/ /* // Define the maximum mantissa we can hold, so we can reset a value // if we get an overflow in rounding. // // Also define which bit will get set if we get an overflow */ #define MAX_MANTISSA 0x00FFFFFFL /*((0x8000L << (IEEE_TO_20_SHIFT)) - 1)*/ #define MANTISSA_OVERFLOW 0x01000000L /*(0x8000L << (IEEE_TO_20_SHIFT))*/ /* // A mask so we can negate JUST the mantissa */ #define MASK_20_MANTISSA (0xFFFFL) /* 16 bits */ /* // Define the IEEE exponent which is effectively the same // as a "zero" exponent in our 20bit "sabre floats" */ #define IEEE_E_SHIFT_DOWN (102) /* // Define range of exponents we can handle */ #define IEEE_E_SMALLEST 87 /*(IEEE_E_SHIFT_DOWN - 15)*/ #define IEEE_E_LARGEST 116 /*(IEEE_E_SHIFT_DOWN + MAX_LEGAL_20_EXPONENT )*/ /* // Where to put the exponent in the 20 bit number */ #define SHIFT_20_EXP (16) /* // Where the sign bit is for 20 bit S float */ #define SIGN_BIT_FOR_20BIT 0x00008000L /*(1<<15)*/ static float fFloatToFixed = FLOAT_TO_FIXED; static float fMaxCentre = 1024.0f; static float fHalfOffset = 1024.0f; SGL_TIME_START(TRANSFORM_EDGES_ALL_TIME) __asm { push ebx push esi push edi mov ecx, DWORD PTR nEdges mov eax, DWORD PTR pEdge /* make sure the parameters are half useful */ or ecx, ecx jz FEAV_BombOut or eax, eax jz FEAV_BombOut /* create a new stack frame */ sub esp, 12 mov [esp + 4], ecx /* esp: parameter for PackTo20Bit esp + 4: counter esp + 8: fMaxValueTmpStore */ mov esi, eax mov edi, gpXEdges mov ebx, DWORD PTR gpXVertices /* registers eax: - ebx: gpXVertices ecx: - edx: - esi: pEdge edi: pXEdge */ FEAV_loop: ; int 3 /* edx: pV1 ecx: pV2 sizeof (TRANSVERTEX) = 36 = 4*9 */ mov edx, [esi].nIDV1 mov ecx, [esi].nIDV2 lea edx, [edx+edx*8] lea ecx, [ecx+ecx*8] lea edx, [ebx+edx*4] lea ecx, [ebx+ecx*4] /* // Compute initial A,B,&C values before scaling, using the // projected vertex positions fA = pV1->vScreenSpace[1] - pV2->vScreenSpace[1]; fB = pV2->vScreenSpace[0] - pV1->vScreenSpace[0]; fC = (pV1->vScreenSpace[0] * pV2->vScreenSpace[1]) - (pV2->vScreenSpace[0] * pV1->vScreenSpace[1]); */ fld DWORD PTR 4[edx].vScreenSpace fsub DWORD PTR 4[ecx].vScreenSpace fld DWORD PTR 0[ecx].vScreenSpace fsub DWORD PTR 0[edx].vScreenSpace fld DWORD PTR 0[edx].vScreenSpace fmul DWORD PTR 4[ecx].vScreenSpace fld DWORD PTR 0[ecx].vScreenSpace fmul DWORD PTR 4[edx].vScreenSpace fxch ST(1) fsubrp ST(1), ST /* MaxVal = sfabs(MAX_CENTRE * (fA+fB) + fC) + HALF_OFFSET * (sfabs(fA) + sfabs(fB)); */ fld ST(2) ; fA fC fB fA fadd ST, ST(2) ; fA+fB fC fB fA fld ST(2) ; fB fA+fB fC fB fA fabs ; fabs(fB) fA+fB fC fB fA fld ST(4) ; fA fabs(fB) fA+fB fC fB fA fabs ; fabs(fA) fabs(fB) fA+fB fC fB fA fxch ST(2) ; fA+fB fabs(fB) fabs(fA) fC fB fA fmul DWORD PTR fMaxCentre ; M*(fA+fB) fabs(fB) fabs(fA) fC fB fA fxch ST(1) ; fabs(fB) M*(fA+fB) fabs(fA) fC fB fA faddp ST(2), ST ; M*(fA+fB) fabs(fA)+fabs(fB) fC fB fA fadd ST, ST(2) ; (M*(fA+fB))+fC fabs(fA)+fabs(fB) fC fB fA fxch ST(1) ; fabs(fA)+fabs(fB) (M*(fA+fB))+fC fC fB fA fmul DWORD PTR fHalfOffset ; H*(fabs(fA)+fabs(fB)) (M*(fA+fB))+fC fC fB fA fxch ST(2) ; fC (M*(fA+fB))+fC H*(fabs(fA)+fabs(fB)) fB fA fmul DWORD PTR fFloatToFixed ; fC*f2F (M*(fA+fB))+fC H*(fabs(fB)+fabs(fA)) fB fA fxch ST(1) ; (M*(fA+fB))+fC fC*f2F H*(fabs(fB)+fabs(fA)) fB fA fabs ; fabs((M*(fA+fB))+fC) fC*f2F H*(fabs(fA)+fabs(fB)) fB fA faddp ST(2), ST ; fC*f2F H*(fabs(fB)+fabs(fA))+fabs((M*(fA+fB))+fC) fB fA fxch ST(1) /* fMaxVal fC fB fA */ fstp DWORD PTR 8[esp] /* C B A - - - - - - */ mov ecx, 8[esp] mov edx, ecx and ecx, 0x7F800000 neg ecx and edx, 0x007FFFFF+0x7FFFFFFF+1 add ecx, 0x7E800000 xor edx, 0x007FFFFF and ecx, 0x7F800000 or ecx, edx mov 8[esp], ecx fmul DWORD PTR 8[esp] /* C B A - - - - */ fxch ST(2) /* A B c - - - - */ add esi, SIZE EDGE fmul DWORD PTR 8[esp] fxch ST(2) /* c B a - - - - */ fistp DWORD PTR 8[edi] /* B a - - - - */ fmul DWORD PTR 8[esp] fxch ST(1) /* a b - - - - */ fstp DWORD PTR 0[esp] /* b - - - - */ #if 0 call PackTo20Bit mov DWORD PTR 0[edi], eax #else /* Pack to 20 bit format ecx: exponent edx: mantissa */ mov ecx, 0[esp] mov edx, ecx ; exp = (intVal >> IEEE_E_SHIFT) & IEEE_E_MASK shr ecx, IEEE_E_SHIFT and ecx, IEEE_E_MASK ; mantissa = (intVal & IEEE_MANTISSA_MASK) | IEEE_ASSUMED_MANTISSA_BIT; and edx, IEEE_MANTISSA_MASK or edx, IEEE_ASSUMED_MANTISSA_BIT cmp ecx, IEEE_E_SMALLEST jge p20_1_1 xor edx, edx ; exponent too small, clip to 0 jmp p20_1exit p20_1_1: ; exp = exp - IEEE_E_SHIFT_DOWN; sub ecx, IEEE_E_SHIFT_DOWN cmp ecx, 0 jge p20_1_2 neg ecx ; this number is denormalised in 20 bit shr edx, cl add edx, MANTISSA_ROUND shr edx, IEEE_TO_20_SHIFT cmp DWORD PTR 0[esp], 0 jge p20_1exit #if PCX1 or edx, SIGN_BIT_FOR_20BIT #else neg edx and edx, MASK_20_MANTISSA #endif jmp p20_1exit p20_1_2: shr edx, IEEE_TO_20_SHIFT shl ecx, SHIFT_20_EXP cmp DWORD PTR 0[esp], 0 jge p20_1_3 #if PCX1 or edx, SIGN_BIT_FOR_20BIT #else neg edx and edx, MASK_20_MANTISSA #endif p20_1_3: or edx, ecx p20_1exit: mov DWORD PTR 0[edi], edx #endif fstp DWORD PTR 0[esp] /* b - - - - */ #if 0 call PackTo20Bit mov DWORD PTR 4[edi], eax #else /* Pack to 20 bit format ecx: exponent edx: mantissa */ mov ecx, 0[esp] mov edx, ecx ; exp = (intVal >> IEEE_E_SHIFT) & IEEE_E_MASK shr ecx, IEEE_E_SHIFT and ecx, IEEE_E_MASK ; mantissa = (intVal & IEEE_MANTISSA_MASK) | IEEE_ASSUMED_MANTISSA_BIT; and edx, IEEE_MANTISSA_MASK or edx, IEEE_ASSUMED_MANTISSA_BIT cmp ecx, IEEE_E_SMALLEST jge p20_2_1 xor edx, edx ; exponent too small, clip to 0 jmp p20_2exit p20_2_1: ; exp = exp - IEEE_E_SHIFT_DOWN; sub ecx, IEEE_E_SHIFT_DOWN cmp ecx, 0 jge p20_2_2 neg ecx ; this number is denormalised in 20 bit shr edx, cl add edx, MANTISSA_ROUND shr edx, IEEE_TO_20_SHIFT cmp DWORD PTR 0[esp], 0 jge p20_2exit #if PCX1 or edx, SIGN_BIT_FOR_20BIT #else neg edx and edx, MASK_20_MANTISSA #endif jmp p20_2exit p20_2_2: shr edx, IEEE_TO_20_SHIFT shl ecx, SHIFT_20_EXP cmp DWORD PTR 0[esp], 0 jge p20_2_3 #if PCX1 or edx, SIGN_BIT_FOR_20BIT #else neg edx and edx, MASK_20_MANTISSA #endif p20_2_3: or edx, ecx p20_2exit: mov DWORD PTR 4[edi], edx #endif add edi, SIZE TRANSEDGE dec DWORD PTR 4[esp] jnz FEAV_loop add esp, 12 FEAV_BombOut: pop edi pop esi pop ebx } SGL_TIME_STOP(TRANSFORM_EDGES_ALL_TIME) #else PTRANSEDGE pXEdge; #if PRE_CULL sgl_uint8 *p = gpXEdgeIndex; #endif SGL_TIME_START(TRANSFORM_EDGES_ALL_TIME) pXEdge = gpXEdges; for (/*NOTHING*/; nEdges != 0; --nEdges, ++pEdge, ++pXEdge) { #if PRE_CULL if (*p) { #endif /* // New wizzo faster edge computation that uses screen // coordinates directly. This can be done because we know // the end points are on screen. // Simon */ float fA, fB, fC; float MaxVal; PTRANSVERTEX pV1, pV2; ASSERT (pEdge->nIDV1 != pEdge->nIDV2); /* // Get pointers to the vertices at each end of the edge */ pV1 = gpXVertices + pEdge->nIDV1; pV2 = gpXVertices + pEdge->nIDV2; /* // Compute initial A,B,&C values before scaling, using the // projected vertex positions */ fA = pV1->vScreenSpace[1] - pV2->vScreenSpace[1]; fB = pV2->vScreenSpace[0] - pV1->vScreenSpace[0]; fC = (pV1->vScreenSpace[0] * pV2->vScreenSpace[1]) - (pV2->vScreenSpace[0] * pV1->vScreenSpace[1]); /* // to prevent the 20Bit SFLOATS from overflowing (currently // they are 2x larger than I originally thought necessary) */ #define MAX_CENTRE (1024.0f) #define HALF_OFFSET (1024.0f) MaxVal = sfabs(MAX_CENTRE * (fA+fB) + fC) + HALF_OFFSET * (sfabs(fA) + sfabs(fB)); #undef MAX_CENTRE #undef HALF_OFFSET MaxVal = ApproxRecip (MaxVal); #if (PCX2 || PCX2_003) && !FORCE_NO_FPU /* PCX2 has IEEE floating point support. No need for rescaling. */ pXEdge->f32A = fA * MaxVal; pXEdge->f32B = fB * MaxVal; pXEdge->f32C = fC * MaxVal; #else SGL_TIME_SUSPEND(TRANSFORM_EDGES_ALL_TIME) #if 1 pXEdge->n32A = PackTo20Bit (fA * MaxVal); pXEdge->n32B = PackTo20Bit (fB * MaxVal); #else PackTo20BitDoubleBarrel (fA * MaxVal, fB * MaxVal, &pXEdge->n32A, &pXEdge->n32B); #endif SGL_TIME_RESUME(TRANSFORM_EDGES_ALL_TIME) pXEdge->n32C = (sgl_int32)(fC * MaxVal * FLOAT_TO_FIXED); #endif #if PRE_CULL } ++p; #endif }/*end for*/ SGL_TIME_STOP(TRANSFORM_EDGES_ALL_TIME) #endif } /************************************************************************** * Function Name : ProcessEdgesPartlyVisible (LOCAL FUNCTION) * Inputs : pEdges - pointer to start of an array of edge data * nEdges - the number of edges to process * **************************************************************************/ static void ProcessEdgesPartlyVisible (PEDGE pEdge, int nEdges) { PTRANSVERTEX pV1, pV2; PTRANSEDGE pXEdge; #if PRE_CULL sgl_uint8 *p = gpXEdgeIndex; #endif float fOverflowRescale; float yToCorner, xToCorner, xPerPixel, yPerPixel; PROJECTION_MATRIX_STRUCT * const pProjMat = RnGlobalGetProjMat (); sgl_vector RCentre; SGL_TIME_START(TRANSFORM_EDGES_PARTLY_TIME) RCentre[0] = pProjMat->RCentre[0]; RCentre[1] = pProjMat->RCentre[1]; RCentre[2] = pProjMat->RCentre[2]; yToCorner = pProjMat->yToCorner; xToCorner = pProjMat->xToCorner; fOverflowRescale = pProjMat->fOverflowRescale; xPerPixel = pProjMat->xPerPixel; yPerPixel = pProjMat->yPerPixel; pXEdge = gpXEdges; for (/*Nothing*/ ; nEdges != 0; --nEdges, ++pEdge, ++pXEdge) { #if PRE_CULL if (*p) { #endif ASSERT (pEdge->nIDV1 != pEdge->nIDV2); pV1 = gpXVertices + pEdge->nIDV1; pV2 = gpXVertices + pEdge->nIDV2; /* // If the end points are on screen, then use the faster method. */ if((pV1->Flags | pV2->Flags) == 0) { float fA, fB, fC; float MaxVal; /* // Compute initial A,B,&C values before scaling, using the // projected vertex positions */ fA = pV1->vScreenSpace[1] - pV2->vScreenSpace[1]; fB = pV2->vScreenSpace[0] - pV1->vScreenSpace[0]; fC = (pV1->vScreenSpace[0] * pV2->vScreenSpace[1]) - (pV2->vScreenSpace[0] * pV1->vScreenSpace[1]); /* // These values are a bit odd .. they are desgined // to prevent the 20Bit SFLOATS from overflowing */ #define MAX_CENTRE (1024.0f) #define HALF_OFFSET (1024.0f) MaxVal = sfabs(MAX_CENTRE * (fA+fB) + fC) + HALF_OFFSET * (sfabs(fA) + sfabs(fB)); #undef MAX_CENTRE #undef HALF_OFFSET MaxVal = ApproxRecip (MaxVal); #if (PCX2 || PCX2_003) && !FORCE_NO_FPU /* PCX2 has IEEE floating point support. No need for rescaling. */ pXEdge->f32A = fA * MaxVal; pXEdge->f32B = fB * MaxVal; pXEdge->f32C = fC * MaxVal; #else SGL_TIME_SUSPEND(TRANSFORM_EDGES_PARTLY_TIME) pXEdge->n32A = PackTo20Bit (fA * MaxVal); pXEdge->n32B = PackTo20Bit (fB * MaxVal); SGL_TIME_RESUME(TRANSFORM_EDGES_PARTLY_TIME) pXEdge->n32C = (sgl_int32)(fC * MaxVal * FLOAT_TO_FIXED); #endif } /* // Else use the world space coords to compute the edge parameters */ else { sgl_vector vN; float fCentreDotNormal; float fXBorder; float fYBorder; float fMaxValue; float fA, fB; /* //Screen space coords already calculated - calculate edge plane // equation */ CrossProd (pV1->vWorldSpace, pV2->vWorldSpace, vN); ASSERT ((vN[0] != 0) || (vN[1] != 0) || (vN[2] != 0)); /* calculate sabre parameters for edge plane */ fCentreDotNormal = DotProd (vN, RCentre); fXBorder = vN[0] * xToCorner; fYBorder = vN[1] * yToCorner; fMaxValue = sfabs (fCentreDotNormal) + sfabs (fXBorder) + sfabs (fYBorder); fMaxValue = - fOverflowRescale * ApproxRecip (fMaxValue); fA = vN[0] * xPerPixel * fMaxValue; fB = vN[1] * yPerPixel * fMaxValue; #if (PCX2 || PCX2_003) && !FORCE_NO_FPU /* PCX2 has IEEE floating point support. No need for rescaling. * Negative all parameters. */ pXEdge->f32A = fA; pXEdge->f32B = fB; pXEdge->f32C = ((fCentreDotNormal-(fXBorder+fYBorder))*fMaxValue); #else SGL_TIME_SUSPEND(TRANSFORM_EDGES_PARTLY_TIME) pXEdge->n32A = PackTo20Bit (fA); pXEdge->n32B = PackTo20Bit (fB); SGL_TIME_RESUME(TRANSFORM_EDGES_PARTLY_TIME) pXEdge->n32C = (sgl_int32)((fCentreDotNormal-(fXBorder+fYBorder))*fMaxValue*FLOAT_TO_FIXED); #endif } #if PRE_CULL } ++p; #endif } SGL_TIME_STOP(TRANSFORM_EDGES_PARTLY_TIME) } /************************************************************************** * Function Name : TransformAndComputeSabreParamsVisible (LOCAL FUNCTION) * Inputs : pFace - pointer to start of an array of face data * numFaces - the number of faces to process * pTransform - pointer to the transformation * * Outputs : pTransformedPlanes - the planes/faces after transformation * pExtras - the rest of the data needed for * * Returns : The number of planes/polys NOT rejected. (IE Not * back-face culled) * This version does no clipping rejection - ie it * should be called by the "entirely onscreen" code. **************************************************************************/ static int TransformAndComputeSabreParamsVisible(const FACE **ppExtFace, int numFaces, const TRANSFORM_STRUCT *pTransform, PXMESHEXTRA pXExtra, TRANSFORMED_PLANE_STRUCT *pXPlane, const CONV_SHADING_STRUCT **ppExtShadingData, const CONV_TEXTURE_UNION **ppExtTextureData, const CONV_POINTS_STRUCT **ppExtPointsData) { int NumProcessed; /* // To make the code simpler, rather than have two different // loops for processing normals: IE either using normal matrix // (ie either uniform or no scaling) or transpose of inverse // (when non uniform). Basically, since the non-uniform is // fairly rare, we will copy the inverse and transpose it, // which means we can use the same code */ float const (*m)[4]; float matcopy[3][4]; PTRANSVERTEX pVert; const FACE *pFace; const CONV_SHADING_STRUCT *pShadingData; const CONV_TEXTURE_UNION *pTextureData; const CONV_POINTS_STRUCT *pPointsData; float fCentreDotNormal; float fXBorder; float fYBorder; float fOverflowRescale; float yToCorner, xToCorner, xPerPixel, yPerPixel; PROJECTION_MATRIX_STRUCT * const pProjMat = RnGlobalGetProjMat (); sgl_vector RCentre; SGL_TIME_START(TRANSFORM_COMPUTE_SABRE_ALL_TIME) RCentre[0] = pProjMat->RCentre[0]; RCentre[1] = pProjMat->RCentre[1]; RCentre[2] = pProjMat->RCentre[2]; yToCorner = pProjMat->yToCorner; xToCorner = pProjMat->xToCorner; fOverflowRescale = pProjMat->fOverflowRescale; xPerPixel = pProjMat->xPerPixel; yPerPixel = pProjMat->yPerPixel; /* // Initialise the number processed and kept, to 0 */ NumProcessed = 0; /* // De-reference the Face, shading etc pointers to get local // copies that we increment. At the end of the routine, we // store these incremented values back again // // It SHOULD be much quicker to manipulate the local copies, as // this should result in less indirection. */ pFace = *ppExtFace; pShadingData= *ppExtShadingData; pTextureData= *ppExtTextureData; pPointsData = *ppExtPointsData; /* // If the transform matrix is non uniform, then copy the inverse, // transposing it at the same time // This is not very common (hopefully :) ) */ if ( (pTransform->scale_flag == arbitrary_scale) || (pTransform->has_neg_scaling)) { int i,j; if (pTransform->has_neg_scaling) { float fScale = -1.0f; for(i= 0; i < 3; i ++) { for(j= 0; j < 3; j ++) { matcopy[j][i] = pTransform->inv[i][j] * (fScale); } } } else { for(i= 0; i < 3; i ++) { for(j= 0; j < 3; j ++) { matcopy[j][i] = pTransform->inv[i][j]; } } } /* // Set up pointer to the copy */ m = (void*) matcopy; } /* // else just set the pointer at the usual matrix */ else { m = pTransform->mat; } /* // Step through the planes */ for(/*Nil*/; numFaces != 0; numFaces--, pFace++, pShadingData++, pTextureData++ , pPointsData++) { #if PRE_CULL if (pFace->EdgeFlags & FACE_VISIBLE) { #endif /* // Define some temporary float values so that the compiler // can assume that when we write to memory, we wont destroy // the source... as in the following matrix operation. */ float tmp1, tmp2, tmp3; /* // Transform the normal */ #define Norm pFace->PlaneData.normal tmp1 = Norm[0]*m[0][0] + Norm[1]*m[0][1] + Norm[2]*m[0][2]; tmp2 = Norm[0]*m[1][0] + Norm[1]*m[1][1] + Norm[2]*m[1][2]; tmp3 = Norm[0]*m[2][0] + Norm[1]*m[2][1] + Norm[2]*m[2][2]; #undef Norm pXPlane->normal[0] = tmp1; pXPlane->normal[1] = tmp2; pXPlane->normal[2] = tmp3; /* // Get a pointer to a transformed point on this face */ pVert = gpXVertices + pFace->pnVertexIDs[0]; /* // Get the "D" value of the plane */ pXPlane->d = DotProd(pXPlane->normal, pVert->vWorldSpace); #if PRE_CULL /* // Decide which way it faces, and whether we can cull it or not */ #if SLOW_FCMP && !MULTI_FP_REG if(FLOAT_TO_LONG(pXPlane->d) > 0) #else if(pXPlane->d > 0.0f) #endif { /* // This is a FORWARD PLANE (Jim has put something back-the-front) // reverse the normal to get it the right way round. */ VecNegate (pXPlane->normal); pXPlane->d = -pXPlane->d; pXExtra->u32EdgeFlags = pFace->EdgeFlags ^ 0xFF; pXPlane->flags = (int) pFace->PlaneData.flags | pf_reversed; } /* // Else is a reverse (anti clockwise) plane // (Something else is back the front) */ else { pXExtra->u32EdgeFlags = pFace->EdgeFlags; pXPlane->flags = (int) pFace->PlaneData.flags; } #else /* // Decide which way it faces, and whether we can cull it or not */ #if SLOW_FCMP && !MULTI_FP_REG if(FLOAT_TO_LONG(pXPlane->d) > 0) #else if(pXPlane->d > 0.0f) #endif { /* // Read the "static global" variable that was set up when we // first decided to process this mesh // // This is a FORWARD PLANE (Jim has put something backwards) // reverse the normal to get it the right way round. */ if (keepAntiClock) { VecNegate (pXPlane->normal); pXPlane->flags = (int) pFace->PlaneData.flags | pf_reversed; pXPlane->d = -pXPlane->d; pXExtra->u32EdgeFlags = pFace->EdgeFlags ^ 0xFF; } else { /* // cull back faces : Go to the next one */ continue; } } /* // Else is a reverse (anti clockwise) plane // (Something else is back the front) */ else { if (keepClockwise) { pXExtra->u32EdgeFlags = pFace->EdgeFlags; pXPlane->flags = (int) pFace->PlaneData.flags; } else { /* cull back faces */ continue; } } #endif /* // save the pointer to the original plane data... we will need // to access it again later, plus in the Transformed plane data as well. */ pXExtra->pOrigFace = pFace; pXPlane->pOriginalData = &pFace->PlaneData; /* // Compute the sabre params */ fCentreDotNormal = DotProd (pXPlane->normal, RCentre); fXBorder = pXPlane->normal[0] * xToCorner; fYBorder = pXPlane->normal[1] * yToCorner; if (sfabs (pXPlane->d) < (sfabs (fCentreDotNormal) + sfabs (fXBorder) + sfabs (fYBorder))) { DPF((DBG_VERBOSE, "Perpendicular polygon - bodging up flat plane ...")); ASSERT(pVert->vWorldSpace[2] >= pProjMat->foregroundDistance); #if (PCX2 || PCX2_003) && !FORCE_NO_FPU /* PCX2 has IEEE floating point support. */ pXPlane->f32C = (RCentre[2] / pVert->vWorldSpace[2]); pXPlane->f32A = 0.0f; pXPlane->f32B = 0.0f; #else pXPlane->n32C =(sgl_int32)(RCentre[2] * FLOAT_TO_FIXED / pVert->vWorldSpace[2]); SGL_TIME_SUSPEND(TRANSFORM_COMPUTE_SABRE_ALL_TIME) pXPlane->n32A = SFLOAT_20BIT_ZERO; pXPlane->n32B = SFLOAT_20BIT_ZERO; SGL_TIME_RESUME(TRANSFORM_COMPUTE_SABRE_ALL_TIME) #endif /* // Save pointers to the texturing and shading data // (On a pentium this makes use of // some of the cycles that are chewed up by the divide) // These 5 pointer assignment lines were originally AFTER // the if statement */ pXPlane->pShadingData= pShadingData; pXPlane->pTextureData= pTextureData; pXPlane->pPointsData= pPointsData; pXExtra++; NumProcessed++; } /* // Else this plane is well behaved */ else { float fInvD; float fA, fB; fInvD = fOverflowRescale / pXPlane->d; /* // Save pointers to the texturing and shading data // (On a pentium this makes use of // some of the cycles that are chewed up by the divide) // These 5 pointer assignment lines were originally AFTER // the if statement */ pXPlane->pShadingData= pShadingData; pXPlane->pTextureData= pTextureData; pXPlane->pPointsData= pPointsData; pXExtra++; NumProcessed++; fA = pXPlane->normal[0] * xPerPixel * fInvD; fB = pXPlane->normal[1] * yPerPixel * fInvD; #if (PCX2 || PCX2_003) && !FORCE_NO_FPU pXPlane->f32A = fA; pXPlane->f32B = fB; pXPlane->f32C = (fCentreDotNormal - (fXBorder + fYBorder)) * fInvD; #else SGL_TIME_SUSPEND(TRANSFORM_COMPUTE_SABRE_ALL_TIME) pXPlane->n32A = PackTo20Bit (fA); pXPlane->n32B = PackTo20Bit (fB); SGL_TIME_RESUME(TRANSFORM_COMPUTE_SABRE_ALL_TIME) pXPlane->n32C = (sgl_int32) ((fCentreDotNormal - (fXBorder + fYBorder)) * (fInvD * FLOAT_TO_FIXED)); #endif }/* end else choose projection method*/ /* // increment the pointers to the results */ pXPlane++; #if PRE_CULL } #endif }/*end for k*/ /* // Save the incremented pointers back again */ *ppExtFace = pFace; *ppExtShadingData = pShadingData; *ppExtTextureData = pTextureData; *ppExtPointsData = pPointsData; /* // Return the number we are left with */ SGL_TIME_STOP(TRANSFORM_COMPUTE_SABRE_ALL_TIME) return NumProcessed; } /************************************************************************** * Function Name : TransformAndComputeSabreParamsPartlyVisible (LOCAL FUNCTION) * Inputs : pFace - pointer to start of an array of face data * numFaces - the number of faces to process * pTransform - pointer to the transformation * * Outputs : pTransformedPlanes - the planes/faces after transformation * pExtras - the rest of the data needed for * * Returns : The number of planes/polys NOT rejected. (IE Not * back-face culled) OR in front of the foreground planw * * Description : Like the TransformAndComputeSabreParams routine except * it also checks if the faces are entirely in front of the * foreground Z plane, or to one side etc, * and rejects those that are. **************************************************************************/ static int TransformAndComputeSabreParamsPartlyVisible(const FACE **ppExtFace, int numFaces, const TRANSFORM_STRUCT *pTransform, PXMESHEXTRA pXExtra, TRANSFORMED_PLANE_STRUCT *pXPlane, const CONV_SHADING_STRUCT **ppExtShadingData, const CONV_TEXTURE_UNION **ppExtTextureData, const CONV_POINTS_STRUCT **ppExtPointsData) { int NumProcessed; /* // To make the code simpler, rather than have two different // loops for processing normals: IE either using normal matrix // (ie either uniform or no scaling) or transpose of inverse // (when non uniform). Basically, since the non-uniform is // fairly rare, we will copy the inverse and transpose it, // which means we can use the same code */ float const (*m)[4]; float matcopy[3][4]; PTRANSVERTEX pVert; const FACE *pFace; const CONV_SHADING_STRUCT *pShadingData; const CONV_TEXTURE_UNION *pTextureData; const CONV_POINTS_STRUCT *pPointsData; float foregroundDistance, invForegroundDistance, fOverflowRescale; float yToCorner, xToCorner, xPerPixel, yPerPixel; PROJECTION_MATRIX_STRUCT * const pProjMat = RnGlobalGetProjMat (); sgl_vector RCentre; foregroundDistance = pProjMat->foregroundDistance; invForegroundDistance = pProjMat->invForegroundDistance; RCentre[0] = pProjMat->RCentre[0]; RCentre[1] = pProjMat->RCentre[1]; RCentre[2] = pProjMat->RCentre[2]; yToCorner = pProjMat->yToCorner; xToCorner = pProjMat->xToCorner; fOverflowRescale = pProjMat->fOverflowRescale; xPerPixel = pProjMat->xPerPixel; yPerPixel = pProjMat->yPerPixel; SGL_TIME_START(TRANSFORM_COMPUTE_SABRE_PARTLY_TIME) /* // Initialise the number processed and kept, to 0 */ NumProcessed = 0; /* // De-reference the Face, shading etc pointers to get local // copies that we increment. At the end of the routine, we // store these incremented values back again // // It SHOULD be much quicker to manipulate the local copies, as // this should result in less indirection. */ pFace = *ppExtFace; pShadingData= *ppExtShadingData; pTextureData= *ppExtTextureData; pPointsData = *ppExtPointsData; /* // If the transform matrix is non uniform, then copy the inverse, // transposing it at the same time // This is not very common (hopefully :) ) */ if ( (pTransform->scale_flag == arbitrary_scale) || (pTransform->has_neg_scaling)) { int i,j; if (pTransform->has_neg_scaling) { float fScale = -1.0f; for(i= 0; i < 3; i ++) { for(j= 0; j < 3; j ++) { matcopy[j][i] = pTransform->inv[i][j] * (fScale); } } } else { for(i= 0; i < 3; i ++) { for(j= 0; j < 3; j ++) { matcopy[j][i] = pTransform->inv[i][j]; } } } /* // Set up pointer to the copy */ m = (void*) matcopy; } /* // else just set the pointer at the usual matrix */ else { m = pTransform->mat; } /* // Step through the planes */ for(/*Nil*/; numFaces != 0; numFaces--, pFace++, pShadingData++, pTextureData++, pPointsData++) { #if PRE_CULL if (pFace->EdgeFlags & FACE_VISIBLE) { #endif PTRANSVERTEX pVa, pVb, pVc; int Offscreen; float fCentreDotNormal; float fXBorder; float fYBorder; float tmp1, tmp2, tmp3; /* // First see if we can reject the face as being in front of the // front Z clipping plane, or to one side etc. Basically see if // ALL of the vertices have a particular clip flag set // // This bit of code is likely to be dog slow because of all // the array indexing. */ pVa = gpXVertices + pFace->pnVertexIDs[0]; pVb = gpXVertices + pFace->pnVertexIDs[1]; pVc = gpXVertices + pFace->pnVertexIDs[2]; Offscreen = pVa->Flags & pVb->Flags & pVc->Flags; if(pFace->nVertices == 4) { PTRANSVERTEX pVd; pVd = gpXVertices + pFace->pnVertexIDs[3]; Offscreen &= pVd->Flags; } /* // Ok if they are all clipped the same way, get the next face */ if(Offscreen) { continue; } /* // Now go on with exactly the same processing as in the non Z clipped // routine..... // // Transform the normal */ #define Norm pFace->PlaneData.normal tmp1 = Norm[0]*m[0][0] + Norm[1]*m[0][1] + Norm[2]*m[0][2]; tmp2 = Norm[0]*m[1][0] + Norm[1]*m[1][1] + Norm[2]*m[1][2]; tmp3 = Norm[0]*m[2][0] + Norm[1]*m[2][1] + Norm[2]*m[2][2]; #undef Norm pXPlane->normal[0] = tmp1; pXPlane->normal[1] = tmp2; pXPlane->normal[2] = tmp3; /* // Get a pointer to a transformed point on this face */ pVert = gpXVertices + pFace->pnVertexIDs[0]; /* // Get the "D" value of the plane */ pXPlane->d = DotProd(pXPlane->normal, pVert->vWorldSpace); #if PRE_CULL /* // Decide which way it faces, and whether we can cull it or not */ #if SLOW_FCMP && !MULTI_FP_REG if(FLOAT_TO_LONG(pXPlane->d) > 0) #else if(pXPlane->d > 0.0f) #endif { /* // This is a FORWARD PLANE (something is back-the-front) // reverse the normal to get it the right way round. */ VecNegate (pXPlane->normal); pXPlane->d = -pXPlane->d; /* // Reverse the edges, by flipping the flag */ pXExtra->u32EdgeFlags = pFace->EdgeFlags ^ 0xFF; pXPlane->flags = (int) pFace->PlaneData.flags | pf_reversed; } /* // Else is a reverse (anti clockwise) plane // (Something else is back the front) */ else { pXExtra->u32EdgeFlags = pFace->EdgeFlags; pXPlane->flags = (int) pFace->PlaneData.flags; } #else /* // Decide which way it faces, and whether we can cull it or not */ #if SLOW_FCMP && !MULTI_FP_REG if(FLOAT_TO_LONG(pXPlane->d) > 0) #else if(pXPlane->d > 0.0f) #endif { /* // Read the "static global" variable that was set up when we // first decided to process this mesh // // This is a FORWARD PLANE // reverse the normal to get it the right way round. */ if (keepAntiClock) { VecNegate (pXPlane->normal); pXPlane->flags = (int) pFace->PlaneData.flags | pf_reversed; pXPlane->d = -pXPlane->d; /* // Reverse the edges, by flipping the flag */ pXExtra->u32EdgeFlags = pFace->EdgeFlags ^ 0xFF; } else { /* // cull back faces : Go to the next one */ continue; } } /* // Else is a reverse (anti clockwise) plane // (Something else is back the front) */ else { if (keepClockwise) { pXExtra->u32EdgeFlags = pFace->EdgeFlags; pXPlane->flags = (int) pFace->PlaneData.flags; } else { /* cull back faces */ continue; } } #endif /* // save the pointer to the original plane data... we will need // to access it again later, plus in the Transformed plane data as well. */ pXExtra->pOrigFace = pFace; pXPlane->pOriginalData = &pFace->PlaneData; /* // Compute the sabre params */ fCentreDotNormal = DotProd (pXPlane->normal, RCentre); fXBorder = pXPlane->normal[0] * xToCorner; fYBorder = pXPlane->normal[1] * yToCorner; if (sfabs (pXPlane->d) < (sfabs (fCentreDotNormal) + sfabs (fXBorder) + sfabs (fYBorder))) { float fInvZdist; DPF((DBG_VERBOSE, "Perpendicular polygon - bodging up flat plane ...")); if(pVert->vWorldSpace[2] < foregroundDistance) { fInvZdist = invForegroundDistance; } else { fInvZdist = 1.0f/pVert->vWorldSpace[2]; } #if (PCX2 || PCX2_003) && !FORCE_NO_FPU /* PCX2 has IEEE floating point support. */ pXPlane->f32C = (RCentre[2] * fInvZdist); pXPlane->f32A = 0.0f; pXPlane->f32B = 0.0f; #else pXPlane->n32C =(sgl_int32)(RCentre[2] * FLOAT_TO_FIXED * fInvZdist); pXPlane->n32A = SFLOAT_20BIT_ZERO; pXPlane->n32B = SFLOAT_20BIT_ZERO; #endif /* // Save pointers to the texturing and shading data // (On a pentium this makes use of // some of the cycles that are chewed up by the divide) // These 5 pointer assignment lines were originally AFTER // the if statement */ pXPlane->pShadingData= pShadingData; pXPlane->pTextureData= pTextureData; pXPlane->pPointsData= pPointsData; pXExtra++; NumProcessed++; } /* // Else this plane is well behaved */ else { float fInvD; float fA, fB; fInvD = fOverflowRescale / pXPlane->d; /* // Save pointers to the texturing and shading data // (On a pentium this makes use of // some of the cycles that are chewed up by the divide) // These 5 pointer assignment lines were originally AFTER // the if statement */ pXPlane->pShadingData= pShadingData; pXPlane->pTextureData= pTextureData; pXPlane->pPointsData= pPointsData; pXExtra++; NumProcessed++; fA = pXPlane->normal[0] * xPerPixel * fInvD; fB = pXPlane->normal[1] * yPerPixel * fInvD; #if (PCX2 || PCX2_003) && !FORCE_NO_FPU pXPlane->f32A = fA; pXPlane->f32B = fB; pXPlane->f32C = ((fCentreDotNormal - (fXBorder + fYBorder)) * fInvD); #else SGL_TIME_SUSPEND(TRANSFORM_COMPUTE_SABRE_PARTLY_TIME) pXPlane->n32A = PackTo20Bit (fA); pXPlane->n32B = PackTo20Bit (fB); SGL_TIME_RESUME(TRANSFORM_COMPUTE_SABRE_PARTLY_TIME) pXPlane->n32C = (sgl_int32) ((fCentreDotNormal - (fXBorder + fYBorder)) * fInvD * FLOAT_TO_FIXED); #endif }/* end else choose projection method*/ /* // increment the pointers to the results */ pXPlane++; #if PRE_CULL } #endif }/*end for k*/ /* // Save the incremented pointers back again */ *ppExtFace = pFace; *ppExtShadingData = pShadingData; *ppExtTextureData = pTextureData; *ppExtPointsData = pPointsData; /* // Return the number we are left with */ SGL_TIME_STOP(TRANSFORM_COMPUTE_SABRE_PARTLY_TIME) return NumProcessed; } #if PRE_CULL static int PreprocessFacesVisible (int numVertices, int numEdges, int numFaces, VERTEX *pVertices, FACE *pFace, const TRANSFORM_STRUCT *pTransform) { #if ICL static float DminusEdotN; static sgl_uint32 iptr; __asm { push esi push edi push ebx mov esi, gpXVertexIndex mov edi, gpXEdgeIndex mov ebx, eax and ebx, 0x7FFFFFFF /* init vertex indices */ mov ecx, numVertices shr ecx, 2 V0: dec ecx mov DWORD PTR [esi+ecx*4], ebx jnz V0 /* init edge indices */ mov ecx, numEdges shr ecx, 2 E0: dec ecx mov DWORD PTR [edi+ecx*4], ebx jnz E0 /* if no culling is happening, exit */ cmp eax, 0xFFFFFFFF je PFVExit mov edx, numFaces mov ebx, pFace mov ecx, pTransform lea ecx, [ecx].inv mov iptr, ecx PFVLoop: /* load EyePointInObjectSpace */ mov ecx, iptr fld DWORD PTR 12[ecx] fld DWORD PTR 12[ecx+16] fld DWORD PTR 12[ecx+32] /* get object space coordinates for vertex 0 */ mov ecx, 0[ebx].pnVertexIDs lea ecx, [ecx*4] lea ecx, [ecx+ecx*2] add ecx, pVertices fld DWORD PTR 0[ecx].vVertex fld DWORD PTR 4[ecx].vVertex fld DWORD PTR 8[ecx].vVertex fxch ST(2) /* get vertex dot normal (d) */ lea ecx, [ebx].PlaneData.normal fmul DWORD PTR 0[ecx] fxch ST(1) fmul DWORD PTR 4[ecx] fxch ST(2) fmul DWORD PTR 8[ecx] fxch ST(2) faddp ST(1), ST faddp ST(1), ST fxch ST(3) /* get eye dot normal */ fmul DWORD PTR 0[ecx] fxch ST(2) fmul DWORD PTR 4[ecx] fxch ST(1) fmul DWORD PTR 8[ecx] fxch ST(2) faddp ST(1), ST faddp ST(1), ST /* get d - e.n */ fsubrp ST(1), ST fstp DWORD PTR [DminusEdotN] /* see if face is culled */ mov ecx, DWORD PTR [DminusEdotN] and ecx, 0x01000000UL + 0x7F000000UL xor ecx, CullMode jz NotVisible or BYTE PTR [ebx].EdgeFlags, 0x80 /* set the vertex and edge indices to 1 for visible */ mov eax, 0[ebx].pnVertexIDs mov ecx, 0[ebx].pnEdgeIDs mov BYTE PTR [esi+eax], 1 mov BYTE PTR [edi+ecx], 1 mov eax, 4[ebx].pnVertexIDs mov ecx, 4[ebx].pnEdgeIDs mov BYTE PTR [esi+eax], 1 mov BYTE PTR [edi+ecx], 1 mov eax, 8[ebx].pnVertexIDs mov ecx, 8[ebx].pnEdgeIDs mov BYTE PTR [esi+eax], 1 mov BYTE PTR [edi+ecx], 1 cmp DWORD PTR [ebx].nVertices, 4 jne NotFourV mov eax, 12[ebx].pnVertexIDs mov ecx, 12[ebx].pnEdgeIDs mov BYTE PTR [esi+eax], 1 mov BYTE PTR [edi+ecx], 1 NotFourV: add ebx, SIZE FACE dec edx jnz PFVLoop jmp PFVExit NotVisible: and BYTE PTR [ebx].EdgeFlags, 0x7F add ebx, SIZE FACE dec edx jnz PFVLoop PFVExit: pop ebx pop edi pop esi } #else sgl_vector EyePointInObjectSpace; float d, EyeDotNormal; sgl_uint8 *p; sgl_uint32 *p32; EyePointInObjectSpace[0] = pTransform->inv[0][3]; EyePointInObjectSpace[1] = pTransform->inv[1][3]; EyePointInObjectSpace[2] = pTransform->inv[2][3]; p = (sgl_uint8 *) gpXVertexIndex; while (numVertices--) { *(p++) = 0; } p = (sgl_uint8 *) gpXEdgeIndex; while (numEdges--) { *(p++) = 0; } for (/* nothing */; numFaces; numFaces--, pFace++) { d = DotProd (pFace->PlaneData.normal, pVertices[pFace->pnVertexIDs[0]].vVertex); EyeDotNormal = DotProd (pFace->PlaneData.normal, EyePointInObjectSpace); /* use bitwise ops to reduce branching */ if (((d > EyeDotNormal) & (keepAntiClock != 0)) | ((d < EyeDotNormal) & (keepClockwise != 0))) { pFace->EdgeFlags |= FACE_VISIBLE; if (pFace->nVertices == 3) { gpXVertexIndex[pFace->pnVertexIDs[0]] = 1; gpXVertexIndex[pFace->pnVertexIDs[1]] = 1; gpXVertexIndex[pFace->pnVertexIDs[2]] = 1; gpXEdgeIndex[pFace->pnEdgeIDs[0]] = 1; gpXEdgeIndex[pFace->pnEdgeIDs[1]] = 1; gpXEdgeIndex[pFace->pnEdgeIDs[2]] = 1; } else { gpXVertexIndex[pFace->pnVertexIDs[0]] = 1; gpXVertexIndex[pFace->pnVertexIDs[1]] = 1; gpXVertexIndex[pFace->pnVertexIDs[2]] = 1; gpXVertexIndex[pFace->pnVertexIDs[3]] = 1; gpXEdgeIndex[pFace->pnEdgeIDs[0]] = 1; gpXEdgeIndex[pFace->pnEdgeIDs[1]] = 1; gpXEdgeIndex[pFace->pnEdgeIDs[2]] = 1; gpXEdgeIndex[pFace->pnEdgeIDs[3]] = 1; } } else { pFace->EdgeFlags &= ~FACE_VISIBLE; } } #endif } #endif /************************************************************************** * Function Name : ProcessFacesVisible (LOCAL FUNCTION) * Inputs : pFace - pointer to start of an array of input face data * numFaces - the number of faces to process * pTransform - pointer to the transformation * * Outputs : pTransformedPlanes - the planes/faces after transformation * pExtras - the rest of the data needed for * * Returns : The number of planes/polys NOT rejected. (IE Not * back-face culled) * * This routine call the Transform and Compute Sabre * parameters routine, and then determines the regions * each of the faces are in. * * IT ASSUMES all the faces are COMPLETELY ON SCREEN. **************************************************************************/ #define CHOOSE_MINMAX(a,b,c) if(a<b)b=a;else if(a>c)c=a; static int ProcessFacesVisible (const FACE **ppFace, int numFaces, const TRANSFORM_STRUCT *pTransform, PXMESHEXTRA pXExtra, TRANSFORMED_PLANE_STRUCT *pXPlane, const CONV_SHADING_STRUCT **ppShadingData, const CONV_TEXTURE_UNION **ppTextureData, const CONV_POINTS_STRUCT **ppPointsData) { int k; #if 0 /*defined (ICL)*/ /* Otherwise NumRemaining is optimised into a reg - we want it in RAM! */ static int NumRemaining; #else int NumRemaining; #endif sgl_int32 n32MinX, n32MinY, n32MaxX, n32MaxY; PTRANSVERTEX pVa, pVb, pVc, pVd; /* // First of all, transform, cull, and calculate sabre parameters for // the faces. */ NumRemaining = TransformAndComputeSabreParamsVisible(ppFace, numFaces, pTransform, pXExtra, pXPlane, ppShadingData, ppTextureData, ppPointsData); ASSERT((NumRemaining >= 0) && (NumRemaining <= numFaces)); SGL_TIME_START(TRANSFORM_FACES_ALL_TIME) #if 0 /*defined (ICL)*/ __asm { cmp DWORD PTR [NumRemaining], 0 jle PFV_exit push ebp push esi push edi push ebx // int 3 // esi: pXExtra // edi: pXPlane // ebp: pFace // eax: - // ebx: - // ecx: - // edx: - mov esi, pXExtra mov edi, pXPlane PFV_loop: mov ebp, DWORD PTR [esi].pOrigFace mov ecx, DWORD PTR 0[ebp].pnVertexIDs mov edx, DWORD PTR [gpXVertices] lea ecx, DWORD PTR [ecx+ecx*4] lea ecx, DWORD PTR [edx+ecx*8] // pXPlane->projRepPoint[0] = pVa->vScreenSpace[0]; // pXPlane->projRepPoint[1] = pVa->vScreenSpace[1]; mov ebx, DWORD PTR 0[ecx].vScreenSpace mov edx, DWORD PTR 4[ecx].vScreenSpace mov DWORD PTR 0[edi + 48], ebx mov DWORD PTR 4[edi + 48], edx // VecCopy (pVa->vWorldSpace, pXPlane->repPnt); mov eax, DWORD PTR 0[ecx].vWorldSpace mov ebx, DWORD PTR 4[ecx].vWorldSpace mov edx, DWORD PTR 8[ecx].vWorldSpace mov DWORD PTR 0[edi].repPnt, eax mov DWORD PTR 4[edi].repPnt, ebx mov DWORD PTR 8[edi].repPnt, edx // VecCopy (pVa->pvVertex, pFace->PlaneData.rep_point); mov ebx, DWORD PTR [ecx].pvVertex fld DWORD PTR 0[ebx] fld DWORD PTR 4[ebx] fld DWORD PTR 8[ebx] fxch ST(2) fstp DWORD PTR 0[ebp].PlaneData.rep_point fstp DWORD PTR 4[ebp].PlaneData.rep_point fstp DWORD PTR 8[ebp].PlaneData.rep_point mov al, BYTE PTR 0[ecx].nRegion mov bl, BYTE PTR 4[ecx].nRegion mov ecx, DWORD PTR 4[ebp].pnVertexIDs mov edx, DWORD PTR [gpXVertices] lea ecx, DWORD PTR [ecx+ecx*4] lea ecx, DWORD PTR [edx+ecx*8] mov ah, BYTE PTR 0[ecx].nRegion mov bh, BYTE PTR 4[ecx].nRegion cmp al, ah jl _1_1 ; xchg al, ah mov dl, al mov al, ah mov ah, dl _1_1: cmp bl, bh jl _1_2 ; xchg bl, bh mov dl, bl mov bl, bh mov bh, dl _1_2: mov ecx, DWORD PTR 8[ebp].pnVertexIDs mov edx, DWORD PTR [gpXVertices] lea ecx, DWORD PTR [ecx+ecx*4] lea ecx, DWORD PTR [edx+ecx*8] mov dl, BYTE PTR 0[ecx].nRegion mov dh, BYTE PTR 4[ecx].nRegion cmp al, dl jl _2_1 mov al, dl jmp _2_2 _2_1: cmp ah, dl jg _2_2 mov ah, dl _2_2: cmp bl, dh jl _3_1 mov bl, dh jmp _3_2 _3_1: cmp bh, dh jg _3_2 mov bh, dh _3_2: // pXExtra->pE[0] = gpXEdges + pFace->pnEdgeIDs[0]; // pXExtra->pE[1] = gpXEdges + pFace->pnEdgeIDs[1]; // pXExtra->pE[2] = gpXEdges + pFace->pnEdgeIDs[2]; mov edx, DWORD PTR gpXEdges mov ecx, DWORD PTR 0[ebp].pnEdgeIDs shl ecx, 4 add ecx, edx mov DWORD PTR 0[esi].pE, ecx mov ecx, DWORD PTR 4[ebp].pnEdgeIDs shl ecx, 4 add ecx, edx mov DWORD PTR 4[esi].pE, ecx mov ecx, DWORD PTR 8[ebp].pnEdgeIDs shl ecx, 4 add ecx, edx mov DWORD PTR 8[esi].pE, ecx // pXExtra->nEdges = pFace->nVertices; mov ecx, DWORD PTR [ebp].nVertices mov DWORD PTR [esi].nEdges, ecx // 4 sides? cmp ecx, 4 jne _5_2 // pXExtra->pE[3] = gpXEdges + pFace->pnEdgeIDs[3]; mov ecx, DWORD PTR 12[ebp].pnEdgeIDs shl ecx, 4 add ecx, edx mov DWORD PTR 12[esi].pE, ecx mov ecx, DWORD PTR 12[ebp].pnVertexIDs mov edx, DWORD PTR [gpXVertices] lea ecx, DWORD PTR [ecx+ecx*4] lea ecx, DWORD PTR [edx+ecx*8] mov dl, BYTE PTR 0[ecx].nRegion mov dh, BYTE PTR 4[ecx].nRegion cmp al, dl jl _4_1 mov al, dl jmp _4_2 _4_1: cmp ah, dl jg _4_2 mov ah, dl _4_2: cmp bl, dh jl _5_1 mov bl, dh jmp _5_2 _5_1: cmp bh, dh jg _5_2 mov bh, dh _5_2: // pXExtra->ZClipped = FALSE; xor ecx, ecx mov DWORD PTR [esi].ZClipped, ecx // pXExtra->RegionsRect.FirstXRegion = n32MinX; // pXExtra->RegionsRect.FirstYRegion = n32MinY; // pXExtra->RegionsRect.LastXRegion = n32MaxX; // pXExtra->RegionsRect.LastYRegion = n32MaxY; mov BYTE PTR 4[esi + 0], al mov BYTE PTR 4[esi + 4], ah mov BYTE PTR 4[esi + 8], bl mov BYTE PTR 4[esi + 12], bh // increment pointers and loop add esi, SIZE XMESHEXTRA add edi, SIZE TRANSFORMED_PLANE_STRUCT dec DWORD PTR [NumRemaining] jnz PFV_loop pop ebx pop edi pop esi pop ebp PFV_exit: } #else /* // Step through the remaining faces determining the regions of the screen // they lie in */ for(k = NumRemaining; k != 0; k--, pXPlane++, pXExtra++) { const FACE *pFace; /* // Get access to the ORIGINAL face */ pFace = pXExtra->pOrigFace; pXExtra->nEdges = pFace->nVertices; /* // Check that we have the correct number of vertices */ ASSERT ((pFace->nVertices == 3) || (pFace->nVertices == 4)); /* // Work out the regions the face covers // // First get pointers to the first three vertices */ pVa = gpXVertices + pFace->pnVertexIDs[0]; pVb = gpXVertices + pFace->pnVertexIDs[1]; pVc = gpXVertices + pFace->pnVertexIDs[2]; /* // copy projected rep point coords. All points are visible, // so the first vertex will do nicely. */ { /* // Use temporary variables because this will convince // a compiler that pVa->vScreenSpace and pXPlane->projRepPoint // dont overlap, and hence can be done in parallel */ float tmp1, tmp2; tmp1 = pVa->vScreenSpace[0]; tmp2 = pVa->vScreenSpace[1]; pXPlane->projRepPoint[0] = tmp1; pXPlane->projRepPoint[1] = tmp2; } /* // Set up a world space rep point (which would be used // by the shading routine // // OPTIMISATION. The pFace->PlaneData.rep_point should // be set when the mesh face is created/modified. SJF */ VecCopy (pVa->pvVertex, (float*) pFace->PlaneData.rep_point); VecCopy (pVa->vWorldSpace, pXPlane->repPnt); /* // Get the extremes of the first 2 points */ if(pVa->nRegion[0] < pVb->nRegion[0]) { n32MinX = pVa->nRegion[0]; n32MaxX = pVb->nRegion[0]; } else { n32MinX = pVb->nRegion[0]; n32MaxX = pVa->nRegion[0]; } if(pVa->nRegion[1] < pVb->nRegion[1]) { n32MinY = pVa->nRegion[1]; n32MaxY = pVb->nRegion[1]; } else { n32MinY = pVb->nRegion[1]; n32MaxY = pVa->nRegion[1]; } /* // Look at the third point */ CHOOSE_MINMAX (pVc->nRegion[0], n32MinX, n32MaxX); CHOOSE_MINMAX (pVc->nRegion[1], n32MinY, n32MaxY); /* // Save the pointers to the first 3 transformed edges */ pXExtra->pE[0] = gpXEdges + pFace->pnEdgeIDs[0]; pXExtra->pE[1] = gpXEdges + pFace->pnEdgeIDs[1]; pXExtra->pE[2] = gpXEdges + pFace->pnEdgeIDs[2]; /* // Is there a 4th point */ if (pFace->nVertices == 4) { pVd = gpXVertices + pFace->pnVertexIDs[3]; CHOOSE_MINMAX (pVd->nRegion[0], n32MinX, n32MaxX); CHOOSE_MINMAX (pVd->nRegion[1], n32MinY, n32MaxY); /* // At the same time store the 4th edge */ pXExtra->pE[3] = gpXEdges + pFace->pnEdgeIDs[3]; }/*end if 4th pointers */ /* // Store the results */ pXExtra->RegionsRect.FirstXRegion = n32MinX; pXExtra->RegionsRect.FirstYRegion = n32MinY; pXExtra->RegionsRect.LastXRegion = n32MaxX; pXExtra->RegionsRect.LastYRegion = n32MaxY; /* check they aren't back to front */ ASSERT ( n32MinX <= n32MaxX); ASSERT ( n32MinY <= n32MaxY); /* check face is on screen */ DPF((DBG_MESSAGE,"RnGlobalProjMatRegionBoxOnScreen = %d", RnGlobalProjMatRegionBoxOnScreen(&(pXExtra->RegionsRect)))); /* // Because of the crap plane limit on Midas3, we need // sort sort of heuristic for rejecting some faces. // Look at the "length" of the edge AB */ #if ISPTSP pXExtra->ApproxSize = sfabs(pVa->vScreenSpace[0] - pVc->vScreenSpace[0]) + sfabs(pVa->vScreenSpace[1] - pVc->vScreenSpace[1]); #endif /* // For the cases when this is translucent, give a 1/Z depth // Note that this is a waste WRT divisions... but // this stuff will all be re-written for version 3.1 of SGL */ if(pFace->nVertices == 4) { pXExtra->NearZ = 4.0f / (pVa->vWorldSpace[2]+pVb->vWorldSpace[2]+ pVc->vWorldSpace[2]+pVd->vWorldSpace[2]); } else { pXExtra->NearZ = 3.0f / (pVa->vWorldSpace[2]+pVb->vWorldSpace[2]+ pVc->vWorldSpace[2]); } /* // It's not Z clipped. */ pXExtra->ZClipped = FALSE; }/*end for k*/ #endif SGL_TIME_STOP(TRANSFORM_FACES_ALL_TIME) return NumRemaining; } /************************************************************************** * Function Name : ProcessFacesPartlyVisible (LOCAL FUNCTION) * Inputs : pFace - pointer to start of an array of input face data * numFaces - the number of faces to process * pTransform - pointer to the transformation * * Outputs : pTransformedPlanes - the planes/faces after transformation * pExtras - the rest of the data needed for * * Returns : The number of planes/polys NOT rejected. (IE Not * back-face culled) * * As for ProcessFacesVisible, except the faces do NOT * have to be onscreen, and may go through the foreground * clipping plane **************************************************************************/ static int ProcessFacesPartlyVisible (const FACE **ppFace, int numFaces, const TRANSFORM_STRUCT *pTransform, PXMESHEXTRA pXExtra, TRANSFORMED_PLANE_STRUCT *pXPlane, const CONV_SHADING_STRUCT **ppShadingData, const CONV_TEXTURE_UNION **ppTextureData, const CONV_POINTS_STRUCT **ppPointsData) { int k; int AnyClipped; int NumRemaining; sgl_int32 n32MinX, n32MinY, n32MaxX, n32MaxY; PTRANSVERTEX pVa, pVb, pVc, pVd; float invForegroundDistance; PROJECTION_MATRIX_STRUCT * const pProjMat = RnGlobalGetProjMat (); invForegroundDistance = pProjMat->invForegroundDistance; /* // First of all, transform, cull, and calculate sabre parameters for // the faces. */ NumRemaining = TransformAndComputeSabreParamsPartlyVisible(ppFace, numFaces, pTransform, pXExtra, pXPlane, ppShadingData, ppTextureData, ppPointsData); ASSERT((NumRemaining >= 0) && (NumRemaining <= numFaces)); SGL_TIME_START(TRANSFORM_FACES_PARTLY_TIME) /* // Step through the remaining faces determining the regions of the screen // they lie in */ for(k = NumRemaining; k != 0; k--, pXPlane++, pXExtra++) { const FACE *pFace; /* // Get access to the ORIGINAL face */ pFace = pXExtra->pOrigFace; pXExtra->nEdges = pFace->nVertices; /* // Check that we have the correct number of vertices */ ASSERT ((pFace->nVertices == 3) || (pFace->nVertices == 4)); /* // First get pointers to the first three vertices, and the // 4th if this is a quad. */ pVa = gpXVertices + pFace->pnVertexIDs[0]; pVb = gpXVertices + pFace->pnVertexIDs[1]; pVc = gpXVertices + pFace->pnVertexIDs[2]; /* // Store the pointers to the edges */ pXExtra->pE[0] = gpXEdges + pFace->pnEdgeIDs[0]; pXExtra->pE[1] = gpXEdges + pFace->pnEdgeIDs[1]; pXExtra->pE[2] = gpXEdges + pFace->pnEdgeIDs[2]; /* // Also see if any of the vertices were clipped. */ AnyClipped = pVa->Flags | pVb->Flags | pVc->Flags; if(pFace->nVertices == 4) { pVd = gpXVertices + pFace->pnVertexIDs[3]; AnyClipped |= pVd->Flags; /* // save pointer to the 4th edge */ pXExtra->pE[3] = gpXEdges + pFace->pnEdgeIDs[3]; } /*/////////////////////// // If the face is entirely on screen, handle it in // exactly the same way as the All visible code /////////////////////// */ if((AnyClipped & CLIPPED_FLAGS)==0) { /* // copy projected rep point coords. Any vertex is valid, // so choose the first. */ pXPlane->projRepPoint[0] = pVa->vScreenSpace[0]; pXPlane->projRepPoint[1] = pVa->vScreenSpace[1]; /* // Set up a world space rep point (which would be used // by the shading routine // // OPTIMISATION. The pFace->PlaneData.rep_point should // be set when the mesh face is created/modified. SJF */ VecCopy (pVa->pvVertex, (float*) pFace->PlaneData.rep_point); VecCopy (pVa->vWorldSpace, pXPlane->repPnt); /* // Work out the regions the face covers // // Get the extremes of the first 2 points */ if(pVa->nRegion[0] < pVb->nRegion[0]) { n32MinX = pVa->nRegion[0]; n32MaxX = pVb->nRegion[0]; } else { n32MinX = pVb->nRegion[0]; n32MaxX = pVa->nRegion[0]; } if(pVa->nRegion[1] < pVb->nRegion[1]) { n32MinY = pVa->nRegion[1]; n32MaxY = pVb->nRegion[1]; } else { n32MinY = pVb->nRegion[1]; n32MaxY = pVa->nRegion[1]; } /* // Look at the third point */ CHOOSE_MINMAX (pVc->nRegion[0], n32MinX, n32MaxX); CHOOSE_MINMAX (pVc->nRegion[1], n32MinY, n32MaxY); /* // Is there a 4th point */ if (pFace->nVertices == 4) { CHOOSE_MINMAX (pVd->nRegion[0], n32MinX, n32MaxX); CHOOSE_MINMAX (pVd->nRegion[1], n32MinY, n32MaxY); }/*end if 4th pointers */ /* // Store the results */ pXExtra->RegionsRect.FirstXRegion = n32MinX; pXExtra->RegionsRect.FirstYRegion = n32MinY; pXExtra->RegionsRect.LastXRegion = n32MaxX; pXExtra->RegionsRect.LastYRegion = n32MaxY; /* check they aren't back to front */ ASSERT ( n32MinX <= n32MaxX); ASSERT ( n32MinY <= n32MaxY); /* check face is on screen */ #if DEBUG if(!RnGlobalProjMatRegionBoxOnScreen(&(pXExtra->RegionsRect))) { DPF ((DBG_MESSAGE, "RnGlobalProjMatRegionBoxOnScreen Failed\n")); } #endif /* // Because of the crap plane limit on Midas3, we need // sort sort of heuristic for rejecting some faces. // Look at the "length" of the edge AB */ #if ISPTSP pXExtra->ApproxSize = sfabs(pVa->vScreenSpace[0] - pVc->vScreenSpace[0]) + sfabs(pVa->vScreenSpace[1] - pVc->vScreenSpace[1]); #endif /* // For the cases when this is translucent, give a 1/Z depth // Note that this is a waste WRT divisions... but // this stuff will all be re-written for version 3.1 of SGL */ if(pFace->nVertices == 4) { pXExtra->NearZ = 4.0f / (pVa->vWorldSpace[2]+pVb->vWorldSpace[2]+ pVc->vWorldSpace[2]+pVd->vWorldSpace[2]); } else { pXExtra->NearZ = 3.0f / (pVa->vWorldSpace[2]+pVb->vWorldSpace[2]+ pVc->vWorldSpace[2]); } /* // It's not Z clipped. */ pXExtra->ZClipped = FALSE; } /*/////////////////////// // ELSE if any of the points were on the wrong side of // the law .... /////////////////////// */ else if(AnyClipped & CLIPPED_Z) { /* // OK, face goes through the foreground plane, we will use // the bounding box routine to find out which regions the // face goes in. This is not blindingly efficient, but // hey, this should crop up too often. */ BBOX_MINMAX_STRUCT BBox; DPF ((DBG_VERBOSE, "Using behind the eye region bbox method ...")); VecCopy (pVa->vWorldSpace, BBox.boxMin); VecCopy (pVa->vWorldSpace, BBox.boxMax); CHOOSE_MINMAX (pVb->vWorldSpace[0], BBox.boxMin[0], BBox.boxMax[0]); CHOOSE_MINMAX (pVb->vWorldSpace[1], BBox.boxMin[1], BBox.boxMax[1]); CHOOSE_MINMAX (pVb->vWorldSpace[2], BBox.boxMin[2], BBox.boxMax[2]); CHOOSE_MINMAX (pVc->vWorldSpace[0], BBox.boxMin[0], BBox.boxMax[0]); CHOOSE_MINMAX (pVc->vWorldSpace[1], BBox.boxMin[1], BBox.boxMax[1]); CHOOSE_MINMAX (pVc->vWorldSpace[2], BBox.boxMin[2], BBox.boxMax[2]); if (pFace->nVertices == 4) { CHOOSE_MINMAX(pVd->vWorldSpace[0],BBox.boxMin[0],BBox.boxMax[0]); CHOOSE_MINMAX(pVd->vWorldSpace[1],BBox.boxMin[1],BBox.boxMax[1]); CHOOSE_MINMAX(pVd->vWorldSpace[2],BBox.boxMin[2],BBox.boxMax[2]); } /* // Is this off screen? // // if so compact up the lists (this is really nasty!) BUT // I think this will be a reasonably rare case. // // Guess we'll just have to see when we profile... */ if (!RnDetermineRegionsFromBBox (&BBox, &pXExtra->RegionsRect)) { PXMESHEXTRA pNewExtras; TRANSFORMED_PLANE_STRUCT *pNewXPlane; int j; DPF ((DBG_MESSAGE,"Part ZCLIPPED OFFscreen:Shift down:%d",k-1)); pNewExtras = pXExtra; pNewXPlane = pXPlane; /* // Step through the number of planes we haven't yet looked at */ for(j = k - 1; j != 0; j--, pNewExtras++, pNewXPlane++) { /* // Copy the next one up down to this point */ *pNewExtras = *(pNewExtras+1); *pNewXPlane = *(pNewXPlane+1); }/*end for*/ /* // Move the pointers down one spot to compensate for the // add that will happen at the end of the loops :) */ pXExtra --; pXPlane --; NumRemaining --; ASSERT(NumRemaining >= 0); } /* // Else this is on screen (well probably 8) ) */ else { PTRANSVERTEX pBestVert; float fRepZ, fTotalZ; /* check they aren't back to front */ ASSERT (pXExtra->RegionsRect.FirstXRegion <= pXExtra->RegionsRect.LastXRegion); ASSERT (pXExtra->RegionsRect.FirstYRegion <= pXExtra->RegionsRect.LastYRegion); /* // look for furthest away rep point */ fRepZ = pVa->vWorldSpace[2]; pBestVert = pVa; if(pVb->vWorldSpace[2] > fRepZ) { fRepZ = pVb->vWorldSpace[2]; pBestVert = pVb; } if(pVc->vWorldSpace[2] > fRepZ) { fRepZ = pVc->vWorldSpace[2]; pBestVert = pVc; } if((pFace->nVertices == 4) &&( pVd->vWorldSpace[2] > fRepZ)) { fRepZ = pVd->vWorldSpace[2]; pBestVert = pVd; } /* // NOTE We MUST have found one in front of the clipping plane */ #if DEBUG if(!(fRepZ >= (pProjMat->invForegroundDistance) )) { DPF ((DBG_WARNING, "Rep Z infront of Foreground\n")); } #endif /* // copy the rep point's data */ VecCopy (pBestVert->pvVertex, (float*) pFace->PlaneData.rep_point); VecCopy (pBestVert->vWorldSpace, pXPlane->repPnt); pXPlane->projRepPoint[0] = pBestVert->vScreenSpace[0]; pXPlane->projRepPoint[1] = pBestVert->vScreenSpace[1]; /* // Because of the crap plane limit on Midas3, we need // sort sort of heuristic for rejecting some faces. // Just make it large for this case */ #if ISPTSP pXExtra->ApproxSize = 1000; #endif /* // For the cases when this is translucent, give a 1/Z depth // Note that this is a waste WRT divisions... but // this stuff will all be re-written for version 3.1 of SGL */ if(pFace->nVertices == 4) { fTotalZ = pVa->vWorldSpace[2]+pVb->vWorldSpace[2]+ pVc->vWorldSpace[2]+pVd->vWorldSpace[2]; if(fTotalZ !=0.0f) { pXExtra->NearZ = 4.0f /fTotalZ; } else { pXExtra->NearZ = invForegroundDistance; } } else { fTotalZ = pVa->vWorldSpace[2]+pVb->vWorldSpace[2]+ pVc->vWorldSpace[2]; if(fTotalZ !=0.0f) { pXExtra->NearZ = 3.0f /fTotalZ; } else { pXExtra->NearZ = invForegroundDistance; } } /* // Set a flag on the face to indicate that it is Z clipped. // This indicates if we need to add a clipping plane */ pXExtra->ZClipped = TRUE; }/*end else the funny poly is on screen*/ } /*/////////////////////// // Else SOME of the points are off screen. BUT NONE are Z clipped /////////////////////// */ else { /*static c = 0;*/ /* // Work out the regions the face covers // // Get the extremes of the first 2 points */ if(pVa->nRegion[0] < pVb->nRegion[0]) { n32MinX = pVa->nRegion[0]; n32MaxX = pVb->nRegion[0]; } else { n32MinX = pVb->nRegion[0]; n32MaxX = pVa->nRegion[0]; } if(pVa->nRegion[1] < pVb->nRegion[1]) { n32MinY = pVa->nRegion[1]; n32MaxY = pVb->nRegion[1]; } else { n32MinY = pVb->nRegion[1]; n32MaxY = pVa->nRegion[1]; } /* // Look at the third point */ CHOOSE_MINMAX (pVc->nRegion[0], n32MinX, n32MaxX); CHOOSE_MINMAX (pVc->nRegion[1], n32MinY, n32MaxY); /* // Is there a 4th point */ if (pFace->nVertices == 4) { CHOOSE_MINMAX (pVd->nRegion[0], n32MinX, n32MaxX); CHOOSE_MINMAX (pVd->nRegion[1], n32MinY, n32MaxY); }/*end if 4th pointers */ /* // Store the results */ pXExtra->RegionsRect.FirstXRegion = n32MinX; pXExtra->RegionsRect.FirstYRegion = n32MinY; pXExtra->RegionsRect.LastXRegion = n32MaxX; pXExtra->RegionsRect.LastYRegion = n32MaxY; /* check they aren't back to front */ ASSERT ( n32MinX <= n32MaxX); ASSERT ( n32MinY <= n32MaxY); /* check face is on screen */ #if DEBUG if(!RnGlobalProjMatRegionBoxOnScreen(&(pXExtra->RegionsRect))) { DPF ((DBG_MESSAGE, "RnGlobalProjMatRegionBoxOnScreen Failed\n")); } #endif /* //Now look for a Rep Point, basically first see if there // is one that is on screen */ if(/*(++c%2) ||*/ ((pVa->Flags & CLIPPED_FLAGS) == 0)) { DPF((DBG_VERBOSE, "Choosing Vert A as rep")); pXPlane->projRepPoint[0] = pVa->vScreenSpace[0]; pXPlane->projRepPoint[1] = pVa->vScreenSpace[1]; VecCopy (pVa->pvVertex, (float*) pFace->PlaneData.rep_point); VecCopy (pVa->vWorldSpace, pXPlane->repPnt); } else if((pVb->Flags & CLIPPED_FLAGS) == 0) { DPF((DBG_VERBOSE, "Choosing Vert B as rep")); pXPlane->projRepPoint[0] = pVb->vScreenSpace[0]; pXPlane->projRepPoint[1] = pVb->vScreenSpace[1]; VecCopy (pVb->pvVertex, (float*) pFace->PlaneData.rep_point); VecCopy (pVb->vWorldSpace, pXPlane->repPnt); } else if((pVc->Flags & CLIPPED_FLAGS) == 0) { DPF((DBG_VERBOSE, "Choosing Vert C as rep")); pXPlane->projRepPoint[0] = pVc->vScreenSpace[0]; pXPlane->projRepPoint[1] = pVc->vScreenSpace[1]; VecCopy (pVc->pvVertex, (float*) pFace->PlaneData.rep_point); VecCopy (pVc->vWorldSpace, pXPlane->repPnt); } else if((pFace->nVertices == 4)&&(pVd->Flags & CLIPPED_FLAGS) == 0) { DPF((DBG_VERBOSE, "Choosing Vert D as rep")); pXPlane->projRepPoint[0] = pVd->vScreenSpace[0]; pXPlane->projRepPoint[1] = pVd->vScreenSpace[1]; VecCopy (pVd->pvVertex, (float*) pFace->PlaneData.rep_point); VecCopy (pVd->vWorldSpace, pXPlane->repPnt); } /* // They are all off screen. */ else { PTRANSVERTEX pV; if (pVa->vWorldSpace[2] > pVb->vWorldSpace[2]) { if (pVa->vWorldSpace[2] > pVc->vWorldSpace[2]) { pV = pVa; } else { pV = pVc; } } else { if (pVb->vWorldSpace[2] > pVc->vWorldSpace[2]) { pV = pVb; } else { pV = pVc; } } if ((pFace->nVertices == 4) && (pVd->vWorldSpace[2] > pV->vWorldSpace[2])) { pV = pVd; } pXPlane->projRepPoint[0] = pV->vScreenSpace[0]; pXPlane->projRepPoint[1] = pV->vScreenSpace[1]; VecCopy (pV->pvVertex, (float*) pFace->PlaneData.rep_point); VecCopy (pV->vWorldSpace, pXPlane->repPnt); } /* // Because of the crap plane limit on Midas3, we need // sort sort of heuristic for rejecting some faces. // Look at the "length" of the edge AB */ #if ISPTSP pXExtra->ApproxSize = sfabs(pVa->vScreenSpace[0] - pVb->vScreenSpace[0]) + sfabs(pVa->vScreenSpace[1] - pVb->vScreenSpace[1]); #endif /* // For the cases when this is translucent, give a 1/Z depth // Note that this is a waste WRT divisions... but // this stuff will all be re-written for version 3.1 of SGL */ if(pFace->nVertices == 4) { pXExtra->NearZ = 4.0f / (pVa->vWorldSpace[2]+pVb->vWorldSpace[2]+ pVc->vWorldSpace[2]+pVd->vWorldSpace[2]); } else { pXExtra->NearZ = 3.0f / (pVa->vWorldSpace[2]+pVb->vWorldSpace[2]+ pVc->vWorldSpace[2]); } /* // It's not Z clipped. */ pXExtra->ZClipped = FALSE; }/* End Else all corners off screen */ }/*end for k*/ SGL_TIME_STOP(TRANSFORM_FACES_PARTLY_TIME) return NumRemaining; } /************************************************************************** * Function Name : CreatePointData (LOCAL FUNCTION) * pXExtra - pointer to the first of the Extra Data for faces * numFaces - the number of faces to process * * Outputs : pPointsData - an array of point data * pXPlane - array of transformed (INPUT/OUTPUT) * Returns : NOTHING * * NOTE NOTE NOTE: THIS ROUTINE IS A STOP GAP MEASURE., THE SET UP OF THIS * DATA SHOULD BE DONE IN DLMESH!!!!!!!!! **************************************************************************/ #if 0 static void CreatePointData(PXMESHEXTRA pXExtra, int numFaces, CONV_POINTS_STRUCT *pPointsData, TRANSFORMED_PLANE_STRUCT *pXPlane) { const FACE * pFace; PTRANSVERTEX pVa, pVb, pVc; for(/*NOTHING*/; numFaces != 0; numFaces --, pXExtra++, pPointsData++, pXPlane++) { /* // Get the pointer to the face data */ pFace = pXExtra->pOrigFace; /* // Get the pointer to the face data */ pXPlane->pPointsData = pPointsData; /* // Get pointers to the vertices on this face */ pVa = gpXVertices + pFace->pnVertexIDs[0]; pVb = gpXVertices + pFace->pnVertexIDs[1]; pVc = gpXVertices + pFace->pnVertexIDs[2]; /* // Compute the stuff which should have been done in dlmesh */ VecCopy(pVa->pvVertex, pPointsData->pt1); VecSub (pVb->pvVertex, pVa->pvVertex, pPointsData->pt2_delta); VecSub (pVc->pvVertex, pVa->pvVertex, pPointsData->pt3_delta); }/*end for*/ } #endif /************************************************************************** * Function Name : CreateSmoothShadingDataVisible(LOCAL FUNCTION) * * * Outputs : * * **************************************************************************/ static void CreateSmoothShadingDataVisible (PXMESHEXTRA pXExtra, int numFaces, TRANSFORMED_PLANE_STRUCT *pXPlane) { const FACE * pFace; PTRANSVERTEX pVa, pVb, pVc; CONV_SHADING_STRUCT *pS; for(/*NOTHING*/; numFaces != 0; numFaces --, pXExtra++, pXPlane++) { float fDet; /* // Get the pointer to the face data */ pFace = pXExtra->pOrigFace; if (pFace->PlaneData.flags & pf_smooth_shad) { /* // Get the pointer to the shading data */ pS = (CONV_SHADING_STRUCT*) pXPlane->pShadingData; /* // Get pointers to the vertices on this face */ pVa = gpXVertices + pFace->pnVertexIDs[0]; pVb = gpXVertices + pFace->pnVertexIDs[1]; pVc = gpXVertices + pFace->pnVertexIDs[2]; #define fX0 pVa->vScreenSpace[0] #define fX1 pVb->vScreenSpace[0] #define fX2 pVc->vScreenSpace[0] #define fY0 pVa->vScreenSpace[1] #define fY1 pVb->vScreenSpace[1] #define fY2 pVc->vScreenSpace[1] fDet = fX0*fY1 - fX0*fY2 - fX1*fY0 + fX1*fY2 + fX2*fY0 - fX2*fY1; /* // Calculate 1/determinant: */ #if defined(MIDAS_ARCADE) /* MIDAS Arcade gets FP execeptions if we use 1.0e-20f. 1.0e-3f seems to be okay */ if (sfabs (fDet) > 1.0e-3f) #else if (sfabs (fDet) > 1.0e-20f) #endif { pS->f1OverDet = 1.0f / fDet; /* // pPre->fAdjoint is a constant zero offset */ pS->fAdjoint[0][0] = fY1-fY2; pS->fAdjoint[0][1] = fY2-fY0; pS->fAdjoint[0][2] = fY0-fY1; pS->fAdjoint[1][0] = fX2-fX1; pS->fAdjoint[1][1] = fX0-fX2; pS->fAdjoint[1][2] = fX1-fX0; pS->fRepDeltaX = 0.0f; pS->fRepDeltaY = 0.0f; } #undef fX0 #undef fX1 #undef fX2 #undef fY0 #undef fY1 #undef fY2 } }/*end for*/ } /************************************************************************** * Function Name : ExtrapolateScreenPos(LOCAL FUNCTION) * * Inputs : pVClipped A vertex that is Z clipped * pVOK A vertex which is NOT * * Outputs : PretendProj A "screen" position for the clipped * vertex. This is obtained by clipping the * line joing the two vertices, getting its * Screen position. By THEN extrapolating the line * between the projected screen coord of the OK * vertex and clipped point, we should get a * pseudo pos for our original bad vertex. * **************************************************************************/ static void ExtrapolateScreenPos( const PTRANSVERTEX pVClipped, const PTRANSVERTEX pVOk, sgl_2d_vec PretendProj, float foregroundDistance, float invForegroundDistance, float SxDash, float SyDash, float OxDash, float OyDash) { float fBehind, fZdelta, fScale; float fX, fY; /* // First intersect the line between the vertices in world space // with clipping plane */ fZdelta = pVOk->vWorldSpace[2] - pVClipped->vWorldSpace[2]; fBehind = foregroundDistance - pVClipped->vWorldSpace[2]; ASSERT(fZdelta >= 0.0f); ASSERT(fBehind >= 0.0f); #if defined(MIDAS_ARCADE) /* MIDAS Arcade gets FP execeptions if we use 1.0e-20f. 1.0e-3f seems to be okay */ if(fZdelta > 1.0E-3f) #else if(fZdelta > 1.0E-20f) #endif { fScale = fBehind / (fZdelta); } else { fScale = fBehind * 1.0E20f; } /* // Get the World space pos of the clipped value */ fX = pVClipped->vWorldSpace[0] + fScale * (pVOk->vWorldSpace[0] - pVClipped->vWorldSpace[0]); fY = pVClipped->vWorldSpace[1] + fScale * (pVOk->vWorldSpace[1] - pVClipped->vWorldSpace[1]); /* // Get the screen space pos of the clipped value */ fX = (SxDash * fX * invForegroundDistance) + OxDash; fY = (SyDash * fY * invForegroundDistance) + OyDash; /* // Now interpolate BACK to where the pseudo bad vertex will end up */ fBehind = (1.0f - fScale); #if defined(MIDAS_ARCADE) /* MIDAS Arcade gets FP execeptions if we use 1.0e-20f. 1.0e-3f seems to be okay */ if(fBehind > 1.0E-3f) { fBehind = 1.0f / fBehind; } else { fBehind = 1.0E-3f; } #else if(fBehind > 1.0E-20f) { fBehind = 1.0f / fBehind; } else { fBehind = 1.0E-20f; } #endif PretendProj[0] = (fX - fScale * pVOk->vScreenSpace[0]) * fBehind; PretendProj[1] = (fY - fScale * pVOk->vScreenSpace[1]) * fBehind; } /************************************************************************** * Function Name : CreateSmoothShadingDataPartlyVisible(LOCAL FUNCTION) * * * Outputs : * * Generates the input to the smooth shading function, when * there is a chance of the faces being Z clipped. * **************************************************************************/ #define Vec2dCopy(x,y) y[0]=x[0];y[1]=x[1]; static void CreateSmoothShadingDataPartlyVisible (PXMESHEXTRA pXExtra, int numFaces, TRANSFORMED_PLANE_STRUCT *pXPlane, sgl_bool bIsTextureWrapping, const TRANSFORM_STRUCT *pTransform) { const FACE * pFace; PTRANSVERTEX pVa, pVb, pVc; CONV_SHADING_STRUCT *pS; float foregroundDistance, invForegroundDistance, SxDash, SyDash, OxDash, OyDash; PROJECTION_MATRIX_STRUCT * const pProjMat = RnGlobalGetProjMat (); foregroundDistance = pProjMat->foregroundDistance; invForegroundDistance = pProjMat->invForegroundDistance; SxDash = pProjMat->SxDash; SyDash = pProjMat->SyDash; OxDash = pProjMat->OxDash; OyDash = pProjMat->OyDash; for(/*NOTHING*/; numFaces != 0; numFaces --, pXExtra++, pXPlane++) { float fDet; /* // Get the pointer to the face data */ pFace = pXExtra->pOrigFace; if (pFace->PlaneData.flags & pf_smooth_shad) { /* // Get the pointer to the shading data */ pS = (CONV_SHADING_STRUCT*) pXPlane->pShadingData; /* // Get pointers to the vertices on this face */ pVa = gpXVertices + pFace->pnVertexIDs[0]; pVb = gpXVertices + pFace->pnVertexIDs[1]; pVc = gpXVertices + pFace->pnVertexIDs[2]; /* // If any of vertices A, B, or C are Z clipped, then can't // use the usual Non-clipped code. */ if ((pVa->Flags | pVb->Flags | pVc->Flags) & CLIPPED_Z) { /* // This holds the projected position of the vertices AND OR // clipped positions */ sgl_2d_vec proj[3]; float dist; PTRANSVERTEX pVfurthest; /* // This code needs to come up with "new" screen positions // for any of A,B, or C that are clipped. To do this, // first choose the vertex that is furthest away */ if(pVa->vWorldSpace[2] > pVb->vWorldSpace[2]) { dist = pVa->vWorldSpace[2]; pVfurthest = pVa; } else { dist = pVb->vWorldSpace[2]; pVfurthest = pVb; } if(dist < pVc->vWorldSpace[2]) { dist = pVc->vWorldSpace[2]; pVfurthest = pVc; } if(pFace->nVertices == 4) { PTRANSVERTEX pVd; pVd = gpXVertices + pFace->pnVertexIDs[3]; if(dist < pVd->vWorldSpace[2]) { dist = pVd->vWorldSpace[2]; pVfurthest = pVd; } } /* // The furthest vertex CANT be zclipped. We wouldnt be here // otherwise. */ ASSERT(!(pVfurthest->Flags& CLIPPED_Z)) /* // For each vertex that is Z clipped, come up with an // "extrapolated" screen position for it, otherwise just use // the screen position it's current got */ if(pVa->Flags & CLIPPED_Z) { ExtrapolateScreenPos(pVa, pVfurthest, proj[0], foregroundDistance, invForegroundDistance, SxDash, SyDash, OxDash, OyDash); } else { Vec2dCopy (pVa->vScreenSpace, proj[0]); } if(pVb->Flags & CLIPPED_Z) { ExtrapolateScreenPos(pVb, pVfurthest, proj[1], foregroundDistance, invForegroundDistance, SxDash, SyDash, OxDash, OyDash); } else { Vec2dCopy (pVb->vScreenSpace, proj[1]); } if(pVc->Flags & CLIPPED_Z) { ExtrapolateScreenPos(pVc, pVfurthest, proj[2], foregroundDistance, invForegroundDistance, SxDash, SyDash, OxDash, OyDash); } else { Vec2dCopy (pVc->vScreenSpace, proj[2]); } /* // Come up with the adjoint matrix of the screen positions */ #define fX0 proj[0][0] #define fX1 proj[1][0] #define fX2 proj[2][0] #define fY0 proj[0][1] #define fY1 proj[1][1] #define fY2 proj[2][1] fDet = fX0*fY1 - fX0*fY2 - fX1*fY0 + fX1*fY2 + fX2*fY0 - fX2*fY1; /* // Calculate 1/determinant: */ #if defined(MIDAS_ARCADE) /* MIDAS Arcade gets FP execeptions if we use 1.0e-20f. 1.0e-3f seems to be okay */ if (sfabs (fDet) > 1.0e-3f) { pS->f1OverDet = 1.0f / fDet; } else if(fDet > 0.0f) { pS->f1OverDet = 1.0e-3f; } else { pS->f1OverDet = -1.0e-3f; } #else if (sfabs (fDet) > 1.0e-20f) { pS->f1OverDet = 1.0f / fDet; } else if(fDet > 0.0f) { pS->f1OverDet = 1.0e-20f; } else { pS->f1OverDet = -1.0e-20f; } #endif /* // pPre->fAdjoint is a constant zero offset */ pS->fAdjoint[0][0] = fY1-fY2; pS->fAdjoint[0][1] = fY2-fY0; pS->fAdjoint[0][2] = fY0-fY1; pS->fAdjoint[1][0] = fX2-fX1; pS->fAdjoint[1][1] = fX0-fX2; pS->fAdjoint[1][2] = fX1-fX0; pS->fRepDeltaX = pXPlane->projRepPoint[0] - proj[0][0]; pS->fRepDeltaY = pXPlane->projRepPoint[1] - proj[0][1]; #undef fX0 #undef fX1 #undef fX2 #undef fY0 #undef fY1 #undef fY2 } /* // Else No Z clipping to worry us. Just use A, B, & C directly */ else { #define fX0 pVa->vScreenSpace[0] #define fX1 pVb->vScreenSpace[0] #define fX2 pVc->vScreenSpace[0] #define fY0 pVa->vScreenSpace[1] #define fY1 pVb->vScreenSpace[1] #define fY2 pVc->vScreenSpace[1] fDet = fX0*fY1 - fX0*fY2 - fX1*fY0 + fX1*fY2 + fX2*fY0 - fX2*fY1; /* // Calculate 1/determinant: */ #if defined(MIDAS_ARCADE) /* MIDAS Arcade gets FP execeptions if we use 1.0e-20f. 1.0e-3f seems to be okay */ if (sfabs (fDet) > 1.0e-3f) { pS->f1OverDet = 1.0f / fDet; } else if(fDet > 0.0f) { pS->f1OverDet = 1.0e-3f; } else { pS->f1OverDet = -1.0e-3f; } #else if (sfabs (fDet) > 1.0e-20f) { pS->f1OverDet = 1.0f / fDet; } else if(fDet > 0.0f) { pS->f1OverDet = 1.0e-20f; } else { pS->f1OverDet = -1.0e-20f; } #endif /* // pPre->fAdjoint is a constant zero offset */ pS->fAdjoint[0][0] = fY1-fY2; pS->fAdjoint[0][1] = fY2-fY0; pS->fAdjoint[0][2] = fY0-fY1; pS->fAdjoint[1][0] = fX2-fX1; pS->fAdjoint[1][1] = fX0-fX2; pS->fAdjoint[1][2] = fX1-fX0; pS->fRepDeltaX = pXPlane->projRepPoint[0] - pVa->vScreenSpace[0]; pS->fRepDeltaY = pXPlane->projRepPoint[1] - pVa->vScreenSpace[1]; #undef fX0 #undef fX1 #undef fX2 #undef fY0 #undef fY1 #undef fY2 } } }/*end for*/ } /************************************************************************** * Function Name : RnProcessMeshNode * Inputs : pMesh- pointer to the convex primitive node * * Outputs : None * Input/Output : pState- pointer to a master state stack "frame" * Returns : None * Global Used : See description * * Description : This does (or at least organises) all the processing * of a mesh node - from rejecting/accepting, transformation * projection, shading, and giving to the hardware management * side of things. * **************************************************************************/ void RnProcessMeshNode (const MESH_NODE_STRUCT *pMesh, MASTER_STATE_STRUCT *pState, int nCurrTransSetID) { int nEdges, nVertices; int m; const FACE *pFace; #if DEBUG int FaceNumber = 0; #endif #if DEBUG || PRE_CULL int nFaces; #endif const CONV_SHADING_STRUCT *pShadingData; const CONV_TEXTURE_UNION *pTextureData; const CONV_POINTS_STRUCT *pPointsData; PMESHMATERIAL pLocMatEnt; /* // If we have REAL local materials, then we must take a copy // of the global material state. */ MATERIAL_STATE_STRUCT LocalMaterialState, *pMaterialState; sgl_bool bZClipped; sgl_bool bMustTextWrap; sgl_bool bIsSmoothShaded; TEST_BOX_ENUM BoxCase; PROJECTION_MATRIX_STRUCT * const pProjMat = RnGlobalGetProjMat (); SGL_TIME_START(TRIVIAL_REJECTION_TIME) /* // First test if the mesh is likely to be on screen. If not, exit. // // transform the bounding box into world space, and compare it against // the viewing pyramid */ TransformBBox(pState->pTransformState, &pMesh->CentBBox, &BBoxMinmax); BoxCase = RnTestBoxWithCamera (&BBoxMinmax, TRUE, &bZClipped); SGL_TIME_STOP(TRIVIAL_REJECTION_TIME) if(BoxCase ==TB_BOX_OFFSCREEN) { DPF ((DBG_VERBOSE, "Mesh invisible")); /* if only we could do this for all objects */ return; } /* // Set up local variables etc */ ASSERT (gpXVertices); ASSERT (pMesh); ASSERT (pState); SGL_TIME_START(MESH_NODE_TIME) /* // if there are no faces, then get out of here! */ if(pMesh->nEdges <= 0) { return; } /* Set bilinear filtering mode. * This is the best place to do this. The relevent bilinear * filtering setting will be set for all subsequent mesh objects. */ if (pState->pQualityState->flags & qf_texture_filtering) { pProjMat->eFilterType = pState->pQualityState->eFilterType; } /* Set dithering mode. */ if (pState->pQualityState->flags & qf_dithering) { pProjMat->bDithering = TRUE; } else { pProjMat->bDithering = FALSE; } pShadingData = pMesh->pShadingData; pTextureData = pMesh->pTextureData; pPointsData = pMesh->pPointsData; ASSERT (pMesh->pVertexData); ASSERT (pMesh->pEdgeData); ASSERT (pMesh->Faces); /* // Set up the global face culling mode for this mesh */ if(! pState->pTransformState->has_neg_scaling) { keepAntiClock = (pMesh->CullMode != sgl_cull_anticlock); keepClockwise = (pMesh->CullMode != sgl_cull_clockwise); } else { keepClockwise = (pMesh->CullMode != sgl_cull_anticlock); keepAntiClock = (pMesh->CullMode != sgl_cull_clockwise); } #if PRE_CULL switch (pMesh->CullMode) { case sgl_cull_anticlock: { CullMode = 0x00000000; break; } case sgl_cull_clockwise: { CullMode = 0x80000000; break; } default: { CullMode = 0xFFFFFFFF; break; } } #endif nVertices = pMesh->nVertices; nEdges = pMesh->nEdges; #if DEBUG || PRE_CULL nFaces = ListGetItemsInList (pMesh->Faces); #endif if (nVertices > gnXVertices) { PTRANSVERTEX pNew; #if PRE_CULL sgl_uint8 *pNewIndex; #endif pNew = SGLMalloc (sizeof (TRANSVERTEX) * nVertices); if (pNew) { DPF ((DBG_WARNING, "Bumping up static vertex array to %d", nVertices)); SGLFree (gpXVertices); gpXVertices = pNew; gnXVertices = nVertices; } else { DPF ((DBG_ERROR, "Unable to bump up static vertex array to %d - not rendering mesh", nVertices)); SGL_TIME_STOP(MESH_NODE_TIME) return ; } #if PRE_CULL pNewIndex = SGLMalloc (sizeof (sgl_uint8) * nVertices); if (pNewIndex) { DPF ((DBG_WARNING, "Bumping up static vertex index array to %d", nVertices)); SGLFree (gpXVertexIndex); gpXVertexIndex = pNewIndex; } else { DPF ((DBG_ERROR, "Unable to bump up static vertex index array to %d - not rendering mesh", nVertices)); SGL_TIME_STOP(MESH_NODE_TIME) return ; } #endif } if (nEdges > gnXEdges) { PTRANSEDGE pNew; #if PRE_CULL sgl_uint8 *pNewIndex; #endif pNew = SGLMalloc ( sizeof (TRANSEDGE) * nEdges); if (pNew) { DPF ((DBG_WARNING, "Bumping up static edge array to %d", nEdges)); SGLFree(gpXEdges); gpXEdges = pNew; gnXEdges = nEdges; } else { DPF ((DBG_ERROR, "Unable to bump up static edge array to %d - not rendering mesh", nEdges)); SGL_TIME_STOP(MESH_NODE_TIME) return ; } #if PRE_CULL pNewIndex = SGLMalloc ( sizeof (sgl_uint8) * nEdges); if (pNewIndex) { DPF ((DBG_WARNING, "Bumping up static edge index array to %d", nEdges)); SGLFree(gpXEdgeIndex); gpXEdgeIndex = pNewIndex; } else { DPF((DBG_ERROR, "Unable to bump up static edge index array to %d - not rendering mesh", nEdges)); SGL_TIME_STOP(MESH_NODE_TIME) return ; } #endif } /* // We must have a valid mesh */ #if DEBUG if (!nVertices || !nFaces || !nEdges) { DPF ((DBG_ERROR, "RnProcessMeshNode: Bad mesh: %d vertices, %d faces, %d edges", nVertices, nFaces, nEdges)); } #endif /* // Do we need to update the local projection matrix */ if(!RnGlobalLocalProjMatIsValid()) { DPF((DBG_MESSAGE, "Update LT mat")); RnUpdateLocalProjectionMatrix(pState->pTransformState); } /* // Do we have any "real" local materials? If we do, make a local // copy of the global one, and set up a pointer to it */ ASSERT(ListGetItemsInList(pMesh->Materials) > 0); if(pMesh->HasLocalMaterials) { LocalMaterialState = *pState->pMaterialState; pMaterialState = &LocalMaterialState; } /* // Else we arent going to modify the global materials // structure, so just use it (ie get a pointer to it) */ else { pMaterialState = pState->pMaterialState; }/*end if/else local materials*/ #if PRE_CULL SGL_TIME_SUSPEND(MESH_NODE_TIME) PreprocessFacesVisible (nVertices, nEdges, nFaces, ListFindItemFast (pMesh->Vertices, 0), ListFindItemFast (pMesh->Faces, 0), pState->pTransformState); SGL_TIME_RESUME(MESH_NODE_TIME) #endif /* // Determine if we have to do any texture wrapping */ bMustTextWrap =(pMaterialState->texture_flags & MASK_TEXTURE) && (pMaterialState->texture_flags & SMAP_BITS) && (pMaterialState->texture_flags & OMAP_BITS) && !(pMesh->ORedPlaneFlags & pf_pre_mapped); /* // is any part of the mesh smooth shaded? and is smooth shading enabled */ bIsSmoothShaded = (pMesh->ORedPlaneFlags & pf_smooth_shad) && (pState->pQualityState->flags & qf_smooth_shading); /* // Process the vertices of the mesh. Determine which routine to // use by the flag returned from the bounding box routine */ if(BoxCase == TB_BOX_ALL_ONSCREEN) { DPF ((DBG_VERBOSE, "Mesh completely visible")); /* // transform all vertices to world space and project it to // screen space */ SGL_TIME_SUSPEND(MESH_NODE_TIME) ProcessVerticesAllVisible (pMesh->pVertexData, nVertices, pState->pTransformState); SGL_TIME_RESUME(MESH_NODE_TIME) } else { DPF ((DBG_VERBOSE, "Mesh partly visible")); ASSERT(BoxCase == TB_BOX_PART_ONSCREEN); /* // transform all vertices to world space and clip. If a vertex is // visible, transform it to screen space // // NOTE if all the vertices are visible, then we can upgrade to // the completely on-screen case, which is faster. */ SGL_TIME_SUSPEND(MESH_NODE_TIME) BoxCase = ProcessVerticesPartlyVisible (pMesh->pVertexData, nVertices, pState->pTransformState); SGL_TIME_RESUME(MESH_NODE_TIME) /* // If the mesh IS offscreen... then get out of here */ if(BoxCase ==TB_BOX_OFFSCREEN) { DPF ((DBG_VERBOSE, "Mesh invisible")); /* if only we could do this for all objects */ SGL_TIME_STOP(MESH_NODE_TIME) return; } } /* // Process the Edges and faces of the mesh. NOTE. I am hoping the // compiler is smart enough to notice that in the previous case where // "BoxCase == TB_BOX_ALL_ONSCREEN" ie for the vertices, that it will // notice the value has not changed and short circuit the test. GCC will // do this, so I hope other compilers will as well. SJF */ if(BoxCase == TB_BOX_ALL_ONSCREEN) { DPF ((DBG_VERBOSE, "Mesh completely visible AGAIN")); /* // The next thing to do is process all the edges working out their // sabre parameters. Direction will have to be decided later, should // be a matter of negating if the opposite sense is desired. // Should be able to tell according to order the vertices are // specified on the edge. */ SGL_TIME_SUSPEND(MESH_NODE_TIME) ProcessEdgesAllVisible (pMesh->pEdgeData, nEdges); SGL_TIME_RESUME(MESH_NODE_TIME) /* // Step through all the "local" materials. Note even if there // aren't any real local materials, the first one always refers // to the number of planes affected by the global material. // // Furthermore, each material can refer to a maximum of // SGL_MAX_PLANES surfaces. This reduces the amount of testing we // have to do during this routine. // */ pFace = ListFindItemFast (pMesh->Faces, 0); pLocMatEnt = ListFindItemFast (pMesh->Materials, 0); for(m = ListGetItemsInList(pMesh->Materials); m!=0; m--, pLocMatEnt++) { int numProjected; /* // Update the material with this new material if necessary // // If the pointer is NULL then no changes are to be made. */ if(pLocMatEnt->pMaterial != NULL) { RnProcessMaterialNode( pLocMatEnt->pMaterial, pMaterialState, pState); } ASSERT(pLocMatEnt->nMaterialUsage >= 0); ASSERT(pLocMatEnt->nMaterialUsage <= SGL_MAX_INTERNAL_PLANES); /* // Do the faces affected by the material // // First cull/project/etc the faces, and return the number // that remain. */ SGL_TIME_SUSPEND(MESH_NODE_TIME) numProjected = ProcessFacesVisible (&pFace, pLocMatEnt->nMaterialUsage, pState->pTransformState, gXExtras, GlobalTransformedPlanes, &pShadingData, &pTextureData, &pPointsData); SGL_TIME_RESUME(MESH_NODE_TIME) #if DEBUG FaceNumber += pLocMatEnt->nMaterialUsage; #endif /* // if all the faces were rejected, go to the next group */ if(numProjected == 0) { continue; } #if 0 /* // if we are doing texture wrapping then create point data */ if (bMustTextWrap) { CreatePointData (gXExtras, numProjected, gPointsData, GlobalTransformedPlanes); } #endif #if 1 /* // if we are doing smooth shading then create shading data */ SGL_TIME_SUSPEND(MESH_NODE_TIME) if (bIsSmoothShaded) { CreateSmoothShadingDataVisible (gXExtras, numProjected, GlobalTransformedPlanes); } SGL_TIME_RESUME(MESH_NODE_TIME) #endif /* // Now shade the remaining planes */ SGL_TIME_SUSPEND(MESH_NODE_TIME) if (!DoPlaneStuff (pMesh, numProjected, pState, pMaterialState, nCurrTransSetID)) { break; } SGL_TIME_RESUME(MESH_NODE_TIME) }/*end for step through the materials*/ } /* // ELSE PARTLY OnScreen */ else { DPF ((DBG_VERBOSE, "Mesh partly visible AGAIN")); ASSERT(BoxCase == TB_BOX_PART_ONSCREEN); /* // If we are here then we should have a partially transformed list // of vertices. If the vertex is visible, we should have screen coords, // and region info calculated. If invisible, we should have world // coordinates, a reasonable halfway house should we wish to work out // where the point is in screen coords later (such as working out data // for partially offscreen edge). The next thing to do is process all // the edges to work out their sabre parameters. Direction will have // to be decided later, should be a matter of negating if the // opposite sense is desired. Should be able to tell according to // the direction the face walks the edge. */ SGL_TIME_SUSPEND(MESH_NODE_TIME) ProcessEdgesPartlyVisible (pMesh->pEdgeData, nEdges); SGL_TIME_RESUME(MESH_NODE_TIME) /* // Step through all the "local" materials. Note even if there // aren't any real local materials, the first one always refers // to the number of planes affected by the global material. // // Furthermore, each material can refer to a maximum of // SGL_MAX_PLANES surfaces. This reduces the amount of testing we // have to do during this routine. // */ pFace = ListFindItemFast (pMesh->Faces, 0); pLocMatEnt = ListFindItemFast (pMesh->Materials, 0); for(m = ListGetItemsInList(pMesh->Materials); m!=0; m--, pLocMatEnt++) { int numProjected; /* // Update the material with this new material if necessary // // If the pointer is NULL then no changes are to be made. */ if(pLocMatEnt->pMaterial != NULL) { RnProcessMaterialNode( pLocMatEnt->pMaterial, pMaterialState, pState); } ASSERT(pLocMatEnt->nMaterialUsage >= 0); ASSERT(pLocMatEnt->nMaterialUsage <= SGL_MAX_INTERNAL_PLANES); /* // Do the faces affected by the material // // First cull/project/etc the faces, and return the number // that remain. */ numProjected = ProcessFacesPartlyVisible (&pFace, pLocMatEnt->nMaterialUsage, pState->pTransformState, gXExtras, GlobalTransformedPlanes, &pShadingData, &pTextureData, &pPointsData); /* // if all the faces were rejected, go to the next group */ if(numProjected == 0) { continue; } #if 0 /* // if we are doing texture wrapping then create point data */ if (bMustTextWrap) { CreatePointData (gXExtras, numProjected, gPointsData, GlobalTransformedPlanes); } #endif #if 1 /* // if we are doing smooth shading then create shading data */ if (bIsSmoothShaded) { CreateSmoothShadingDataPartlyVisible (gXExtras, numProjected, GlobalTransformedPlanes, bMustTextWrap, pState->pTransformState); } #endif /* // Now shade the remaining planes */ SGL_TIME_SUSPEND(MESH_NODE_TIME) if (!DoPlaneStuff (pMesh, numProjected, pState, pMaterialState, nCurrTransSetID)) { break; } SGL_TIME_RESUME(MESH_NODE_TIME) }/*end for step through the materials*/ }/*end else partly on screen */ SGL_TIME_STOP(MESH_NODE_TIME) } /************************************************************************** * Function Name : RnCTPreProcessMeshNode * Inputs : pMesh- pointer to the convex primitive node * pState- pointer to a master state stack "frame" * ppCachedTexture - pointer to cached texture struct. * Outputs : None * Input/Output : * Returns : None * Global Used : See description * * Description : This tries to work out if any cached textures are used * by the mesh, and if so, marks their useage/size etc. * **************************************************************************/ void RnCTPreProcessMeshNode(const MESH_NODE_STRUCT * pMesh, MASTER_STATE_STRUCT *pState, void *pCachedTexture) { int size,YSize, i; PMESHMATERIAL pLocMatEnt; PROJECTION_MATRIX_STRUCT * const pProjMat = RnGlobalGetProjMat (); /* // Transformed Bounding box (if any) in world Coordinates */ BBOX_MINMAX_STRUCT bboxInWC; /* // The regions the box spans */ REGIONS_RECT_STRUCT Regions; int BoxCase; sgl_bool bZClipped; /* // First, if there are definitely NO cached textures affecting this // mesh, get out of here */ if((pCachedTexture== NULL) && !pMesh->HasLocalMaterials) { return; } /* // If the quality flags say there is no texture - get out as well */ if(! pState->pQualityState->flags & qf_textures) { return; } /* // Ok decide if the mesh is onscreen, and how much of the screen // it covers. // // First transform into world space */ TransformBBox(pState->pTransformState, &pMesh->CentBBox, &bboxInWC); BoxCase = RnTestBoxWithCamera (&bboxInWC, TRUE, &bZClipped); if (BoxCase == TB_BOX_OFFSCREEN) { /* // Get out of here */ DPF((DBG_VERBOSE, "BBox Offscreen:")); return; } else { int Res = RnDetermineRegionsFromBBox(&bboxInWC, &Regions); ASSERT (Res != 0); } /* // Ok map these into sizes */ size= (Regions.LastXRegion - Regions.FirstXRegion +1) * pProjMat->RegionInfo.XSize; YSize= (Regions.LastYRegion - Regions.FirstYRegion +1) * pProjMat->RegionInfo.YSize; if(YSize > size) { size = YSize; } /* // Now step through the materials used, (including the first) and // set up any cacheable textures. NOTE this doesnt check to see if // the texture IS actually used, but who cares - it's close enough */ if(pCachedTexture != NULL) { MarkCachedTextureUsed(pCachedTexture, size); } pLocMatEnt = ListFindItemFast (pMesh->Materials, 0); for(i = ListGetItemsInList(pMesh->Materials); i != 0; i--, pLocMatEnt++) { void * pPreviousCText; pPreviousCText = pCachedTexture; /* // Update using this material // NOTE: Ignore null material entries. */ if(pLocMatEnt->pMaterial!=NULL) { RnCTPreprocessMaterialNode(pLocMatEnt->pMaterial, pState, &pCachedTexture); } /* // if the texture has changed, and we still have a cached texture, // mark it as used */ if((pPreviousCText != pCachedTexture) &&(pCachedTexture != NULL)) { MarkCachedTextureUsed(pCachedTexture, size); } }/*end for*/ } /* // END OF FILE */
e50bceb823f8ebd034b6409e1b220d4ed708bc38
2ed0ca7920c77a3283a2b223a3d03b93358cc986
/pepper/apps/hashget_micro.c
af70f0818416a82aa4faae282a3a8c80cdb8e597
[ "BSD-3-Clause", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
pepper-project/pequin
a363c7ae1fe098eb52c3f188d84ff1688dce703f
db440e8f99fc214f76c6e691dc7fbdc190eb73a4
refs/heads/master
2022-05-13T22:50:39.532896
2022-04-05T22:32:30
2022-04-05T22:32:30
60,874,766
127
45
NOASSERTION
2020-09-28T23:30:29
2016-06-10T20:23:47
C
UTF-8
C
false
false
361
c
hashget_micro.c
#include <stdint.h> #include <db.h> #define NUM_BITS_TO_GET 128 #define NUM_INTS_TO_GET (NUM_BITS_TO_GET)/32 struct In { void placeholder; }; struct Out {uint32_t result[NUM_INTS_TO_GET]; }; /* Microbenchmark to measure the cost of hashget. */ void compute(struct In *input, struct Out *output){ hash_t digest = *NULL_HASH; hashget(output, &digest); }
e999cab5d7c2b4b8aa79046a4565b31552122088
ae31542273a142210a1ff30fb76ed9d45d38eba9
/src/include/executor/nodeDynamicIndexOnlyscan.h
088c57fdbc6f3cbf05f3897d7760aee40c028a61
[ "Apache-2.0", "LicenseRef-scancode-generic-cla", "PostgreSQL", "OpenSSL", "LicenseRef-scancode-stream-benchmark", "ISC", "LicenseRef-scancode-openssl", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-ssleay-windows", "BSD-2-Clause", "Python-2.0" ]
permissive
greenplum-db/gpdb
8334837bceb2d5d51a684500793d11b190117c6a
2c0f8f0fb24a2d7a7da114dc80f5f5a2712fca50
refs/heads/main
2023-08-22T02:03:03.806269
2023-08-21T22:59:53
2023-08-22T01:17:10
44,781,140
6,417
2,082
Apache-2.0
2023-09-14T20:33:42
2015-10-23T00:25:17
C
UTF-8
C
false
false
780
h
nodeDynamicIndexOnlyscan.h
/*------------------------------------------------------------------------- * * nodeDynamicIndexOnlyScan.h * * Copyright (C) 2023 VMware, Inc. or its affiliates. All Rights Reserved. * * * IDENTIFICATION * src/include/executor/nodeDynamicIndexOnlyscan.h * *------------------------------------------------------------------------- */ #ifndef NODEDYNAMICINDEXONLYSCAN_H #define NODEDYNAMICINDEXONLYSCAN_H #include "nodes/execnodes.h" extern DynamicIndexScanState *ExecInitDynamicIndexOnlyScan(DynamicIndexOnlyScan *node, EState *estate, int eflags); extern TupleTableSlot *ExecDynamicIndexOnlyScan(PlanState *node); extern void ExecEndDynamicIndexOnlyScan(DynamicIndexScanState *node); extern void ExecReScanDynamicIndexOnly(DynamicIndexScanState *node); #endif
bc978c4059ee8562f8d3c0de57e6ffcc383581ae
2f58e877a1e317cab8ccadd03e001bbe561ed191
/src/ngx_stream_lua_exception.c
c1aaed323428b00c3bc20e174a94dc05f11ae8c9
[ "BSD-2-Clause", "LicenseRef-scancode-warranty-disclaimer", "BSD-3-Clause" ]
permissive
openresty/stream-lua-nginx-module
8b054bba72fd743b04d95cb1abe1b42f200382a1
d23c27819d3199d96fdcde2b56cf3e8610e207f2
refs/heads/master
2023-08-31T17:28:07.097731
2023-08-23T00:38:52
2023-08-23T00:38:52
49,554,190
734
261
BSD-2-Clause
2023-09-07T08:59:13
2016-01-13T06:23:38
C
UTF-8
C
false
false
1,478
c
ngx_stream_lua_exception.c
/* * !!! DO NOT EDIT DIRECTLY !!! * This file was automatically generated from the following template: * * src/subsys/ngx_subsys_lua_exception.c.tt2 */ /* * Copyright (C) Xiaozhe Wang (chaoslawful) * Copyright (C) Yichun Zhang (agentzh) */ #ifndef DDEBUG #define DDEBUG 0 #endif #include "ddebug.h" #include "ngx_stream_lua_exception.h" #include "ngx_stream_lua_util.h" /* longjmp mark for restoring nginx execution after Lua VM crashing */ jmp_buf ngx_stream_lua_exception; /** * Override default Lua panic handler, output VM crash reason to nginx error * log, and restore execution to the nearest jmp-mark. * * @param L Lua state pointer * @retval Long jump to the nearest jmp-mark, never returns. * @note nginx request pointer should be stored in Lua thread's globals table * in order to make logging working. * */ int ngx_stream_lua_atpanic(lua_State *L) { #ifdef NGX_LUA_ABORT_AT_PANIC abort(); #else u_char *s = NULL; size_t len = 0; if (lua_type(L, -1) == LUA_TSTRING) { s = (u_char *) lua_tolstring(L, -1, &len); } if (s == NULL) { s = (u_char *) "unknown reason"; len = sizeof("unknown reason") - 1; } ngx_log_stderr(0, "lua atpanic: Lua VM crashed, reason: %*s", len, s); ngx_quit = 1; /* restore nginx execution */ NGX_LUA_EXCEPTION_THROW(1); /* impossible to reach here */ #endif } /* vi:set ft=c ts=4 sw=4 et fdm=marker: */
5e6def24425fd646533bb1c27dda09cc9447277c
d61b532db0d3e08818338cfaac530a1ced1ffe3b
/lang/cem/libcc/headers/grp.h
20d2af56a7cda0d847fcdeeefcdbcb989e4c057f
[ "LicenseRef-scancode-other-permissive" ]
permissive
davidgiven/ack
61049c7a8e95ff61a77b1edd3c22bb290720e276
db5a32c68c4a60ca26a3927a799ea662b5b2b0e5
refs/heads/default
2023-08-29T07:33:12.771205
2023-07-08T20:17:27
2023-07-08T20:17:27
37,686,316
376
74
NOASSERTION
2023-07-08T20:17:28
2015-06-18T21:33:42
C
UTF-8
C
false
false
541
h
grp.h
/* $Id$ */ /* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ #ifndef _GRP_H #define _GRP_H struct group { char *gr_name; /* the name of the group */ char *gr_passwd; /* the group passwd */ int gr_gid; /* the numerical group ID */ char **gr_mem; /* a vector of pointers to the members */ }; extern struct group *getgrgid(); extern struct group *getgrnam(); extern struct group *getgrent(); #endif /* _GRP_H */
81a07bcfb05af673f9fb4b338ed36659fe9ad2b9
c9bc99866cfab223c777cfb741083be3e9439d81
/module/smcf/src/mod_smcf.c
e86baa5fea276a7699b0d0ffb681ec815eb399f7
[ "BSD-3-Clause" ]
permissive
ARM-software/SCP-firmware
4738ca86ce42d82588ddafc2226a1f353ff2c797
f6bcca436768359ffeadd84d65e8ea0c3efc7ef1
refs/heads/master
2023-09-01T16:13:36.962036
2023-08-17T13:00:20
2023-08-31T07:43:37
134,399,880
211
165
NOASSERTION
2023-09-13T14:27:10
2018-05-22T10:35:56
C
UTF-8
C
false
false
14,498
c
mod_smcf.c
/* * Arm SCP/MCP Software * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * * Description: * System Monitoring Control Framwork. */ #include "smcf_data.h" #include <mod_smcf.h> #include <fwk_core.h> #include <fwk_event.h> #include <fwk_id.h> #include <fwk_interrupt.h> #include <fwk_log.h> #include <fwk_mm.h> #include <fwk_module.h> #ifdef BUILD_HAS_NOTIFICATION # include <fwk_notification.h> #endif /* SMCF module event indexes */ enum pd_event_idx { SMCF_NEW_DATA_SAMPLE, SMCF_EVENT_COUNT }; /* New data sample event identifier */ static const fwk_id_t smcf_event_id_new_data_sample = FWK_ID_EVENT_INIT(FWK_MODULE_IDX_SMCF, SMCF_NEW_DATA_SAMPLE); /* Element context */ struct smcf_element_ctx { /* Context Domain ID */ fwk_id_t domain_id; /* Element config */ const struct mod_smcf_element_config *config; /* MGI register */ struct smcf_mgi_reg *mgi; /* Number of monitors for this MGI */ uint32_t monitor_count; /* Current sample type */ uint32_t sample_type; /* Data attributes */ struct smcf_data_attr data_attr; }; /* Module context */ struct smcf_ctx { /* Table of the element contexts */ struct smcf_element_ctx *element_ctx_table; /* Number of MGI domains */ size_t element_ctx_table_size; }; struct smcf_interrupt_methods { /* Check if the interrupt source */ bool (*is_irq_triggered)(struct smcf_mgi_reg *smcf_mgi); /* Interrupt clear method */ void (*clear_irq)(struct smcf_mgi_reg *smcf_mgi); /* Interrupt handler */ void (*irq_handler)(struct smcf_element_ctx *element_ctx); }; static struct smcf_ctx mod_ctx; static struct smcf_element_ctx *get_domain_ctx(fwk_id_t domain_id) { uint32_t idx = fwk_id_get_element_idx(domain_id); if (idx >= mod_ctx.element_ctx_table_size) { return NULL; } return &mod_ctx.element_ctx_table[idx]; } static int smcf_start_data_sample(fwk_id_t element_id) { struct smcf_element_ctx *element_ctx; element_ctx = get_domain_ctx(element_id); if (element_ctx == NULL) { return FWK_E_PARAM; } mgi_enable_sample(element_ctx->mgi); return FWK_SUCCESS; } static int smcf_validate_tag( struct smcf_element_ctx *element_ctx, struct mod_smcf_buffer tag_buffer) { uint32_t tag_length; if (tag_buffer.ptr == NULL) { return FWK_E_PARAM; } tag_length = smcf_data_get_tag_length(element_ctx->data_attr.header); if (tag_length == 0) { return FWK_E_SUPPORT; } if (tag_buffer.size < tag_length) { return FWK_E_NOMEM; } return FWK_SUCCESS; } static int smcf_get_element_data( fwk_id_t monitor_id, struct mod_smcf_buffer data_buffer, struct mod_smcf_buffer tag_buffer) { struct smcf_element_ctx *element_ctx; unsigned int monitor_index; uint32_t dest_size; int status; if ((data_buffer.size == 0) || (data_buffer.ptr == NULL)) { return FWK_E_PARAM; } if (!fwk_module_is_valid_sub_element_id(monitor_id)) { return FWK_E_PARAM; } element_ctx = get_domain_ctx(monitor_id); if (element_ctx == NULL) { return FWK_E_PARAM; } monitor_index = fwk_id_get_sub_element_idx(monitor_id); dest_size = smcf_data_get_data_buffer_size(element_ctx->data_attr); if (data_buffer.size < dest_size) { return FWK_E_NOMEM; } if (tag_buffer.size == 0) { tag_buffer.ptr = NULL; } else { status = smcf_validate_tag(element_ctx, tag_buffer); if (status != FWK_SUCCESS) { return status; } } return smcf_data_get_data( element_ctx->data_attr, monitor_index, data_buffer.ptr, tag_buffer.ptr); } static void sample_data_set_complete_handler( struct smcf_element_ctx *element_ctx) { struct fwk_event_light req; int status; req = (struct fwk_event_light){ .target_id = element_ctx->domain_id, .source_id = element_ctx->domain_id, .id = smcf_event_id_new_data_sample, }; status = fwk_put_event(&req); if (status != FWK_SUCCESS) { FWK_TRACE("[SMCF] Send data sample event failed!"); } } static void no_handler_for_this_interrupt_source( struct smcf_element_ctx *element_ctx) { FWK_TRACE("[SMCF] Interrupt received but the event is not handled"); } static void (*mgi_interrupt_manager_table[SMCF_MGI_IRQ_SOURCE_MAX])( struct smcf_element_ctx *element_ctx) = { [SMCF_MGI_IRQ_SOURCE_SMP_CMP] = sample_data_set_complete_handler, [SMCF_MGI_IRQ_SOURCE_MON_EN] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_MON_MODE] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_CMD_RECV] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_ERR] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_MON_TRIG] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_IN_TRIG] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_CFG] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_DATA_WR] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_ALT0] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_ALT1] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_ALT2] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_ALT3] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_ALT4] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_ALT5] = no_handler_for_this_interrupt_source, [SMCF_MGI_IRQ_SOURCE_ALT6] = no_handler_for_this_interrupt_source, }; static void smcf_mgi_interrupt_handler( struct smcf_element_ctx *element_ctx, uint32_t interrupt_source) { if (mgi_interrupt_manager_table[interrupt_source] != NULL) { mgi_interrupt_manager_table[interrupt_source](element_ctx); } mgi_interrupt_source_clear(element_ctx->mgi, interrupt_source); } static void smcf_interrupt_handlers(uintptr_t element_ctx_param) { struct smcf_element_ctx *element_ctx = (struct smcf_element_ctx *)element_ctx_param; struct smcf_mgi_reg *mgi = element_ctx->mgi; uint32_t interrupt_source; for (interrupt_source = 0; interrupt_source < SMCF_MGI_IRQ_SOURCE_MAX; interrupt_source++) { if (mgi_is_the_source_triggered_the_interrupt(mgi, interrupt_source)) { smcf_mgi_interrupt_handler(element_ctx, interrupt_source); } } } static int smcf_external_module_handle_the_interrupt_api(fwk_id_t element_id) { struct smcf_element_ctx *element_ctx; element_ctx = get_domain_ctx(element_id); if (element_ctx == NULL) { return FWK_E_PARAM; } smcf_interrupt_handlers((uintptr_t)element_ctx); return FWK_SUCCESS; } static int smcf_mli_config_mode_validate( fwk_id_t mli_id, uint32_t mode_value, uint32_t mode_index) { struct smcf_element_ctx *element_ctx; uint32_t num_mode_entries; uint32_t num_mode_bits; if (!fwk_module_is_valid_sub_element_id(mli_id)) { return FWK_E_PARAM; } element_ctx = get_domain_ctx(mli_id); num_mode_entries = mgi_get_number_of_mode_registers(element_ctx->mgi); if (mode_index + 1 > (num_mode_entries)) { return FWK_E_RANGE; } num_mode_bits = mgi_get_number_of_bits_in_mode_registers(element_ctx->mgi); if (num_mode_bits == SMCF_MGI_MODE_MAX_WORD_LEN) { return FWK_SUCCESS; } else if (mode_value > ((1U << num_mode_bits) - 1U)) { return FWK_E_DATA; } return FWK_SUCCESS; } static int smcf_mli_config_mode_set( fwk_id_t mli_id, uint32_t mode_value, uint32_t mode_index) { int status = FWK_SUCCESS; uint32_t mli_index = fwk_id_get_sub_element_idx(mli_id); struct smcf_element_ctx *element_ctx = get_domain_ctx(mli_id); status = mgi_enable_program_mode(element_ctx->mgi, mli_index); if (status != FWK_SUCCESS) { return status; } status = mgi_set_monitor_mode(element_ctx->mgi, mode_index, mode_value); return status; } static int smcf_mli_config_mode( fwk_id_t mli_id, uint32_t mode_value, uint32_t mode_index) { int status = FWK_SUCCESS; status = smcf_mli_config_mode_validate(mli_id, mode_value, mode_index); if (status != FWK_SUCCESS) { return FWK_SUCCESS; } status = smcf_mli_config_mode_set(mli_id, mode_value, mode_index); return status; } static uint32_t smcf_get_group_id(fwk_id_t monitor_group_id) { struct smcf_element_ctx *element_ctx; element_ctx = get_domain_ctx(monitor_group_id); return smcf_data_get_group_id(element_ctx->data_attr); } static const struct smcf_data_api data_api = { .start_data_sampling = smcf_start_data_sample, .get_data = smcf_get_element_data, }; static const struct smcf_control_api control_api = { .config_mode = smcf_mli_config_mode, .get_group_id = smcf_get_group_id, }; static const struct smcf_monitor_group_interrupt_api smcf_interrupt_api = { .handle_interrupt = smcf_external_module_handle_the_interrupt_api, }; static int smcf_mod_init( fwk_id_t module_id, unsigned int mgi_count, const void *unused) { mod_ctx.element_ctx_table = fwk_mm_calloc(mgi_count, sizeof(struct smcf_element_ctx)); mod_ctx.element_ctx_table_size = mgi_count; return FWK_SUCCESS; } static int smcf_element_init_config_sample_type( struct smcf_element_ctx *element_ctx) { int status; switch (element_ctx->config->sample_type) { case SMCF_SAMPLE_TYPE_MANUAL: status = mgi_set_sample_type(element_ctx->mgi, SMCF_MGI_SAMPLE_TYPE_MANUAL); break; case SMCF_SAMPLE_TYPE_PERIODIC: status = mgi_set_sample_type( element_ctx->mgi, SMCF_MGI_SAMPLE_TYPE_PERIODIC); break; case SMCF_SAMPLE_TYPE_DATA_READ: status = mgi_set_sample_type( element_ctx->mgi, SMCF_MGI_SAMPLE_TYPE_DATA_READ); break; case SMCF_SAMPLE_TYPE_TRIGGER_INPUT: status = mgi_set_sample_type( element_ctx->mgi, SMCF_MGI_SAMPLE_TYPE_TRIGGER_INPUT); break; default: return FWK_E_PANIC; } if (status != FWK_SUCCESS) { element_ctx->sample_type = SMCF_SAMPLE_TYPE_MANUAL; } else { element_ctx->sample_type = element_ctx->config->sample_type; } return status; } static int smcf_element_init_set_data_attributes(struct smcf_element_ctx *ctx) { ctx->data_attr.num_of_data = mgi_number_of_data_values_per_monitor(ctx->mgi); ctx->data_attr.data_width = mgi_monitor_data_width(ctx->mgi); ctx->data_attr.packed = mgi_is_data_packed(ctx->mgi); return smcf_data_set_data_address( ctx->mgi, ctx->config->data_config, &ctx->data_attr); } static void smcf_enable_interrupt(struct smcf_element_ctx *element_ctx) { uint32_t interrupt_source; for (interrupt_source = 0; interrupt_source < SMCF_MGI_IRQ_SOURCE_MAX; interrupt_source++) { if (mgi_interrupt_manager_table[interrupt_source] != NULL) { mgi_interrupt_source_unmask(element_ctx->mgi, interrupt_source); } } } static void smcf_element_init_setup_interrupt( struct smcf_element_ctx *element_ctx) { if (element_ctx->config->irq == FWK_INTERRUPT_NONE) { return; } fwk_interrupt_set_isr_param( element_ctx->config->irq, smcf_interrupt_handlers, (uintptr_t)element_ctx); smcf_enable_interrupt(element_ctx); } static int smcf_element_init( fwk_id_t element_id, unsigned int sub_element_count, const void *data) { const struct mod_smcf_element_config *config = data; struct smcf_element_ctx *ctx; int status; ctx = get_domain_ctx(element_id); ctx->domain_id = element_id; ctx->config = config; ctx->mgi = (struct smcf_mgi_reg *)(config->reg_base); if (sub_element_count != mgi_get_num_of_monitors(ctx->mgi)) { return FWK_E_PARAM; } ctx->monitor_count = sub_element_count; status = smcf_element_init_config_sample_type(ctx); if (status != FWK_SUCCESS) { return status; } smcf_element_init_set_data_attributes(ctx); smcf_element_init_setup_interrupt(ctx); return mgi_enable_all_monitor(ctx->mgi); } static int smcf_process_bind_request( fwk_id_t source_id, fwk_id_t target_id, fwk_id_t api_id, const void **api) { struct smcf_element_ctx *element_ctx; switch (fwk_id_get_api_idx(api_id)) { case MOD_SMCF_API_IDX_DATA: *api = &data_api; break; case MOD_SMCF_API_IDX_CONTROL: *api = &control_api; break; case MOD_SMCF_API_IDX_INTERRUPT: if (!fwk_id_is_type(target_id, FWK_ID_TYPE_ELEMENT)) { return FWK_E_ACCESS; } element_ctx = get_domain_ctx(target_id); smcf_enable_interrupt(element_ctx); *api = &smcf_interrupt_api; break; default: return FWK_E_RANGE; } return FWK_SUCCESS; } #ifdef BUILD_HAS_NOTIFICATION static int smcf_new_data_sample_ready_notify(void) { unsigned int subscribers_count; struct fwk_event new_data_event = { .id = mod_smcf_notification_id_new_data_sample_ready, .response_requested = false, .source_id = FWK_ID_NONE }; return fwk_notification_notify(&new_data_event, &subscribers_count); } #endif static int smcf_process_event( const struct fwk_event *event, struct fwk_event *resp_event) { struct smcf_element_ctx *ctx = get_domain_ctx(event->target_id); int status = FWK_SUCCESS; if (ctx == NULL) { return FWK_E_PARAM; } /* * local SMCF event */ if (fwk_id_is_equal(event->id, smcf_event_id_new_data_sample)) { FWK_TRACE("[SMCF] New data sample event received"); #ifdef BUILD_HAS_NOTIFICATION status = smcf_new_data_sample_ready_notify(); #endif } return status; } const struct fwk_module module_smcf = { .type = FWK_MODULE_TYPE_DRIVER, .api_count = (unsigned int)MOD_SMCF_API_IDX_COUNT, .event_count = (unsigned int)SMCF_EVENT_COUNT, #ifdef BUILD_HAS_NOTIFICATION .notification_count = (unsigned int)MOD_SMCF_NOTIFY_IDX_COUNT, #endif .init = smcf_mod_init, .element_init = smcf_element_init, .process_bind_request = smcf_process_bind_request, .process_event = smcf_process_event, };
152b4917c6f4632a89921f52f80d66e14809220b
4bc2917f4d2b3ba4a6aacf79f0416f4cfa6043d9
/src/sys.c
e8d24ae051cc6d234e0bde3a3308765fd4aef266
[ "MIT" ]
permissive
JuliaLang/julia
2f19bb09e45ce61dfa6bae100c304e2966d66fd2
631b5c39b72d91bec33262e14ce96f74de9aa7b6
refs/heads/master
2023-09-01T17:51:37.307168
2023-09-01T14:14:08
2023-09-01T14:14:08
1,644,196
45,311
7,095
MIT
2023-09-14T20:13:23
2011-04-21T07:01:50
Julia
UTF-8
C
false
false
22,067
c
sys.c
// This file is a part of Julia. License is MIT: https://julialang.org/license /* sys.c I/O and operating system utility functions */ #include <sys/stat.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <signal.h> #include <fcntl.h> #include "julia.h" #include "julia_internal.h" #ifdef _OS_WINDOWS_ #include <psapi.h> #else #include <unistd.h> #if !defined(_SC_NPROCESSORS_ONLN) || defined(_OS_FREEBSD_) || defined(_OS_DARWIN_) // try secondary location for _SC_NPROCESSORS_ONLN, or for HW_AVAILCPU on BSDs #include <sys/sysctl.h> #endif #include <sys/wait.h> #include <sys/ptrace.h> #include <sys/mman.h> #include <dlfcn.h> #include <grp.h> // For `struct termios` #include <termios.h> #endif #ifndef _OS_WINDOWS_ // for getrusage #include <sys/types.h> #include <sys/time.h> #include <sys/resource.h> #endif #ifdef __APPLE__ #include <mach-o/dyld.h> #include <mach-o/nlist.h> #include <sys/types.h> // for jl_raise_debugger #elif !defined(_OS_WINDOWS_) #include <link.h> #endif #ifdef __SSE__ #include <xmmintrin.h> #endif #ifdef _COMPILER_MSAN_ENABLED_ #include <sanitizer/msan_interface.h> #endif #include "julia_assert.h" #ifdef __cplusplus extern "C" { #endif JL_DLLEXPORT int jl_sizeof_off_t(void) { return sizeof(off_t); } #ifndef _OS_WINDOWS_ JL_DLLEXPORT int jl_sizeof_mode_t(void) { return sizeof(mode_t); } JL_DLLEXPORT int jl_ftruncate(int fd, int64_t length) { return ftruncate(fd, (off_t)length); } JL_DLLEXPORT int64_t jl_lseek(int fd, int64_t offset, int whence) { return lseek(fd, (off_t)offset, whence); } JL_DLLEXPORT ssize_t jl_pwrite(int fd, const void *buf, size_t count, int64_t offset) { return pwrite(fd, buf, count, (off_t)offset); } JL_DLLEXPORT void *jl_mmap(void *addr, size_t length, int prot, int flags, int fd, int64_t offset) { return mmap(addr, length, prot, flags, fd, (off_t)offset); } #else JL_DLLEXPORT int64_t jl_lseek(HANDLE fd, int64_t offset, int whence) { LARGE_INTEGER tell; tell.QuadPart = offset; if (SetFilePointerEx(fd, tell, &tell, whence) == 0) return -1; return tell.QuadPart; } #endif JL_DLLEXPORT int jl_sizeof_ios_t(void) { return sizeof(ios_t); } JL_DLLEXPORT long jl_ios_fd(ios_t *s) { return s->fd; } JL_DLLEXPORT int32_t jl_nb_available(ios_t *s) { return (int32_t)(s->size - s->bpos); } // --- dir/file stuff --- JL_DLLEXPORT int jl_sizeof_uv_fs_t(void) { return sizeof(uv_fs_t); } JL_DLLEXPORT char *jl_uv_fs_t_ptr(uv_fs_t *req) { return (char*)req->ptr; } JL_DLLEXPORT char *jl_uv_fs_t_path(uv_fs_t *req) { return (char*)req->path; } // --- stat --- JL_DLLEXPORT int jl_sizeof_stat(void) { return sizeof(uv_stat_t); } JL_DLLEXPORT int32_t jl_stat(const char *path, char *statbuf) JL_NOTSAFEPOINT { uv_fs_t req; int ret; // Ideally one would use the statbuf for the storage in req, but // it's not clear that this is possible using libuv ret = uv_fs_stat(unused_uv_loop_arg, &req, path, NULL); if (ret == 0) memcpy(statbuf, req.ptr, sizeof(uv_stat_t)); uv_fs_req_cleanup(&req); return ret; } JL_DLLEXPORT int32_t jl_lstat(const char *path, char *statbuf) { uv_fs_t req; int ret; ret = uv_fs_lstat(unused_uv_loop_arg, &req, path, NULL); if (ret == 0) memcpy(statbuf, req.ptr, sizeof(uv_stat_t)); uv_fs_req_cleanup(&req); return ret; } JL_DLLEXPORT int32_t jl_fstat(uv_os_fd_t fd, char *statbuf) { uv_fs_t req; int ret; ret = uv_fs_fstat(unused_uv_loop_arg, &req, fd, NULL); if (ret == 0) memcpy(statbuf, req.ptr, sizeof(uv_stat_t)); uv_fs_req_cleanup(&req); return ret; } JL_DLLEXPORT unsigned int jl_stat_dev(char *statbuf) { return ((uv_stat_t*)statbuf)->st_dev; } JL_DLLEXPORT unsigned int jl_stat_ino(char *statbuf) { return ((uv_stat_t*)statbuf)->st_ino; } JL_DLLEXPORT unsigned int jl_stat_mode(char *statbuf) { return ((uv_stat_t*)statbuf)->st_mode; } JL_DLLEXPORT unsigned int jl_stat_nlink(char *statbuf) { return ((uv_stat_t*)statbuf)->st_nlink; } JL_DLLEXPORT unsigned int jl_stat_uid(char *statbuf) { return ((uv_stat_t*)statbuf)->st_uid; } JL_DLLEXPORT unsigned int jl_stat_gid(char *statbuf) { return ((uv_stat_t*)statbuf)->st_gid; } JL_DLLEXPORT unsigned int jl_stat_rdev(char *statbuf) { return ((uv_stat_t*)statbuf)->st_rdev; } JL_DLLEXPORT uint64_t jl_stat_size(char *statbuf) { return ((uv_stat_t*)statbuf)->st_size; } JL_DLLEXPORT uint64_t jl_stat_blksize(char *statbuf) { return ((uv_stat_t*)statbuf)->st_blksize; } JL_DLLEXPORT uint64_t jl_stat_blocks(char *statbuf) { return ((uv_stat_t*)statbuf)->st_blocks; } /* // atime is stupid, let's not support it JL_DLLEXPORT double jl_stat_atime(char *statbuf) { uv_stat_t *s; s = (uv_stat_t*)statbuf; return (double)s->st_atim.tv_sec + (double)s->st_atim.tv_nsec * 1e-9; } */ JL_DLLEXPORT double jl_stat_mtime(char *statbuf) { uv_stat_t *s; s = (uv_stat_t*)statbuf; return (double)s->st_mtim.tv_sec + (double)s->st_mtim.tv_nsec * 1e-9; } JL_DLLEXPORT double jl_stat_ctime(char *statbuf) { uv_stat_t *s; s = (uv_stat_t*)statbuf; return (double)s->st_ctim.tv_sec + (double)s->st_ctim.tv_nsec * 1e-9; } JL_DLLEXPORT unsigned long jl_getuid(void) { #ifdef _OS_WINDOWS_ return -1; #else return getuid(); #endif } JL_DLLEXPORT unsigned long jl_geteuid(void) { #ifdef _OS_WINDOWS_ return -1; #else return geteuid(); #endif } // --- buffer manipulation --- JL_DLLEXPORT jl_array_t *jl_take_buffer(ios_t *s) { size_t n; jl_array_t *a; if (s->buf == &s->local[0]) { // small data case. copies, but this can be avoided using the // technique of jl_readuntil below. a = jl_pchar_to_array(s->buf, s->size); ios_trunc(s, 0); } else { char *b = ios_take_buffer(s, &n); a = jl_ptr_to_array_1d(jl_array_uint8_type, b, n-1, 1); } return a; } // str: if 1 return a string, otherwise return a Vector{UInt8} // chomp: // 0 - keep delimiter // 1 - remove 1 byte delimiter // 2 - remove 2 bytes \r\n if present JL_DLLEXPORT jl_value_t *jl_readuntil(ios_t *s, uint8_t delim, uint8_t str, uint8_t chomp) { jl_array_t *a; // manually inlined common case char *pd = (char*)memchr(s->buf + s->bpos, delim, (size_t)(s->size - s->bpos)); if (pd) { size_t n = pd - (s->buf + s->bpos) + 1; size_t nchomp = 0; if (chomp) { nchomp = chomp == 2 ? ios_nchomp(s, n) : 1; } if (str) { jl_value_t *str = jl_pchar_to_string(s->buf + s->bpos, n - nchomp); s->bpos += n; return str; } a = jl_alloc_array_1d(jl_array_uint8_type, n - nchomp); memcpy(jl_array_data(a), s->buf + s->bpos, n - nchomp); s->bpos += n; } else { a = jl_alloc_array_1d(jl_array_uint8_type, 80); ios_t dest; ios_mem(&dest, 0); ios_setbuf(&dest, (char*)a->data, 80, 0); size_t n = ios_copyuntil(&dest, s, delim, 1); if (chomp && n > 0 && dest.buf[n - 1] == delim) { n--; if (chomp == 2 && n > 0 && dest.buf[n - 1] == '\r') { n--; } int truncret = ios_trunc(&dest, n); // it should always be possible to truncate dest assert(truncret == 0); (void)truncret; // ensure the variable is used to avoid warnings } if (dest.buf != a->data) { a = jl_take_buffer(&dest); } else { a->length = n; a->nrows = n; ((char*)a->data)[n] = '\0'; } if (str) { JL_GC_PUSH1(&a); jl_value_t *st = jl_array_to_string(a); JL_GC_POP(); return st; } } return (jl_value_t*)a; } // read up to buflen bytes, including delim, into buf. returns number of bytes read. JL_DLLEXPORT size_t jl_readuntil_buf(ios_t *s, uint8_t delim, uint8_t *buf, size_t buflen) { // manually inlined common case size_t avail = (size_t)(s->size - s->bpos); if (avail > buflen) avail = buflen; char *pd = (char*)memchr(s->buf + s->bpos, delim, avail); if (pd) { size_t n = pd - (s->buf + s->bpos) + 1; memcpy(buf, s->buf + s->bpos, n); s->bpos += n; return n; } else { size_t total = avail; memcpy(buf, s->buf + s->bpos, avail); s->bpos += avail; if (avail == buflen) return total; // code derived from ios_copyuntil while (!ios_eof(s)) { avail = ios_readprep(s, 160); // read LINE_CHUNK_SIZE if (avail == 0) break; if (total+avail > buflen) avail = buflen-total; char *pd = (char*)memchr(s->buf+s->bpos, delim, avail); if (pd == NULL) { memcpy(buf+total, s->buf+s->bpos, avail); s->bpos += avail; total += avail; if (buflen == total) return total; } else { size_t ntowrite = pd - (s->buf+s->bpos) + 1; memcpy(buf+total, s->buf+s->bpos, ntowrite); s->bpos += ntowrite; total += ntowrite; return total; } } s->_eof = 1; return total; } } JL_DLLEXPORT int jl_ios_buffer_n(ios_t *s, const size_t n) { size_t space, ret; do { space = (size_t)(s->size - s->bpos); ret = ios_readprep(s, n); if (space == ret && ret < n) return 1; } while (ret < n); return 0; } JL_DLLEXPORT uint64_t jl_ios_get_nbyte_int(ios_t *s, const size_t n) { assert(n <= 8); uint64_t x = 0; uint8_t *buf = (uint8_t*)&s->buf[s->bpos]; if (n == 8) { // expecting loop unrolling optimization for (size_t i = 0; i < 8; i++) x |= (uint64_t)buf[i] << (i << 3); } else if (n >= 4) { // expecting loop unrolling optimization for (size_t i = 0; i < 4; i++) x |= (uint64_t)buf[i] << (i << 3); for (size_t i = 4; i < n; i++) x |= (uint64_t)buf[i] << (i << 3); } else { for (size_t i = 0; i < n; i++) x |= (uint64_t)buf[i] << (i << 3); } s->bpos += n; return x; } // -- syscall utilities -- JL_DLLEXPORT int jl_errno(void) JL_NOTSAFEPOINT { return errno; } JL_DLLEXPORT void jl_set_errno(int e) JL_NOTSAFEPOINT { errno = e; } // -- get the number of CPU threads (logical cores) -- #ifdef _OS_WINDOWS_ typedef DWORD (WINAPI *GAPC)(WORD); #ifndef ALL_PROCESSOR_GROUPS #define ALL_PROCESSOR_GROUPS 0xffff #endif #endif // Apple's M1 processor is a big.LITTLE style processor, with 4x "performance" // cores, and 4x "efficiency" cores. Because Julia expects to be able to run // things like heavy linear algebra workloads on all cores, it's best for us // to only spawn as many threads as there are performance cores. Once macOS // 12 is released, we'll be able to query the multiple "perf levels" of the // cores of a CPU (see this PR [0] to pytorch/cpuinfo for an example) but // until it's released, we will just recognize the M1 by its CPU family // identifier, then subtract how many efficiency cores we know it has. JL_DLLEXPORT int jl_cpu_threads(void) JL_NOTSAFEPOINT { #if defined(HW_AVAILCPU) && defined(HW_NCPU) size_t len = 4; int32_t count; int nm[2] = {CTL_HW, HW_AVAILCPU}; sysctl(nm, 2, &count, &len, NULL, 0); if (count < 1) { nm[1] = HW_NCPU; sysctl(nm, 2, &count, &len, NULL, 0); if (count < 1) { count = 1; } } #if defined(__APPLE__) && defined(_CPU_AARCH64_) //MacOS 12 added a way to query performance cores char buf[7]; len = 7; sysctlbyname("kern.osrelease", buf, &len, NULL, 0); if (buf[0] > 1 && buf[1] > 0){ len = 4; sysctlbyname("hw.perflevel0.physicalcpu", &count, &len, NULL, 0); } else { int32_t family = 0; len = 4; sysctlbyname("hw.cpufamily", &family, &len, NULL, 0); if (family >= 1 && count > 1) { if (family == CPUFAMILY_ARM_FIRESTORM_ICESTORM) { // We know the Apple M1 has 4 efficiency cores, so subtract them out. count -= 4; } } } #endif return count; #elif defined(_SC_NPROCESSORS_ONLN) long count = sysconf(_SC_NPROCESSORS_ONLN); if (count < 1) return 1; return count; #elif defined(_OS_WINDOWS_) //Try to get WIN7 API method GAPC gapc; if (jl_dlsym(jl_kernel32_handle, "GetActiveProcessorCount", (void **)&gapc, 0)) { return gapc(ALL_PROCESSOR_GROUPS); } else { //fall back on GetSystemInfo SYSTEM_INFO info; GetSystemInfo(&info); return info.dwNumberOfProcessors; } #else #warning "cpu core detection not defined for this platform" return 1; #endif } JL_DLLEXPORT int jl_effective_threads(void) JL_NOTSAFEPOINT { int cpu = jl_cpu_threads(); int masksize = uv_cpumask_size(); if (masksize < 0 || jl_running_under_rr(0)) return cpu; uv_thread_t tid = uv_thread_self(); char *cpumask = (char *)calloc(masksize, sizeof(char)); int err = uv_thread_getaffinity(&tid, cpumask, masksize); if (err) { free(cpumask); jl_safe_printf("WARNING: failed to get thread affinity (%s %d)\n", uv_err_name(err), err); return cpu; } int n = 0; for (size_t i = 0; i < masksize; i++) { n += cpumask[i]; } free(cpumask); return n < cpu ? n : cpu; } // -- high resolution timers -- // Returns time in nanosec JL_DLLEXPORT uint64_t jl_hrtime(void) JL_NOTSAFEPOINT { return uv_hrtime(); } // -- iterating the environment -- #ifdef __APPLE__ #include <crt_externs.h> #else #if !defined(_OS_WINDOWS_) || defined(_COMPILER_GCC_) extern char **environ; #endif #endif JL_DLLEXPORT jl_value_t *jl_environ(int i) { #ifdef __APPLE__ char **environ = *_NSGetEnviron(); #endif char *env = environ[i]; return env ? jl_pchar_to_string(env, strlen(env)) : jl_nothing; } // -- child process status -- #if defined _OS_WINDOWS_ /* Native Woe32 API. */ #include <process.h> #define waitpid(pid,statusp,options) _cwait (statusp, pid, WAIT_CHILD) #define WAIT_T int #define WTERMSIG(x) ((x) & 0xff) /* or: SIGABRT ?? */ #define WCOREDUMP(x) 0 #define WEXITSTATUS(x) (((x) >> 8) & 0xff) /* or: (x) ?? */ #define WIFSIGNALED(x) (WTERMSIG (x) != 0) /* or: ((x) == 3) ?? */ #define WIFEXITED(x) (WTERMSIG (x) == 0) /* or: ((x) != 3) ?? */ #define WIFSTOPPED(x) 0 #define WSTOPSIG(x) 0 //Is this correct? #endif int jl_process_exited(int status) { return WIFEXITED(status); } int jl_process_signaled(int status) { return WIFSIGNALED(status); } int jl_process_stopped(int status) { return WIFSTOPPED(status); } int jl_process_exit_status(int status) { return WEXITSTATUS(status); } int jl_process_term_signal(int status) { return WTERMSIG(status); } int jl_process_stop_signal(int status) { return WSTOPSIG(status); } // -- access to std filehandles -- JL_STREAM *JL_STDIN = (JL_STREAM*)STDIN_FILENO; JL_STREAM *JL_STDOUT = (JL_STREAM*)STDOUT_FILENO; JL_STREAM *JL_STDERR = (JL_STREAM*)STDERR_FILENO; JL_DLLEXPORT JL_STREAM *jl_stdin_stream(void) { return JL_STDIN; } JL_DLLEXPORT JL_STREAM *jl_stdout_stream(void) { return JL_STDOUT; } JL_DLLEXPORT JL_STREAM *jl_stderr_stream(void) { return JL_STDERR; } JL_DLLEXPORT int jl_termios_size(void) { #if defined(_OS_WINDOWS_) return 0; #else return sizeof(struct termios); #endif } // -- processor native alignment information -- JL_DLLEXPORT void jl_native_alignment(uint_t *int8align, uint_t *int16align, uint_t *int32align, uint_t *int64align, uint_t *float32align, uint_t *float64align) { *int8align = __alignof(uint8_t); *int16align = __alignof(uint16_t); *int32align = __alignof(uint32_t); *int64align = __alignof(uint64_t); *float32align = __alignof(float); *float64align = __alignof(double); } JL_DLLEXPORT jl_value_t *jl_is_char_signed(void) { return ((char)255) < 0 ? jl_true : jl_false; } // -- misc sysconf info -- #ifdef _OS_WINDOWS_ static long cachedPagesize = 0; JL_DLLEXPORT long jl_getpagesize(void) { if (!cachedPagesize) { SYSTEM_INFO systemInfo; GetSystemInfo (&systemInfo); cachedPagesize = systemInfo.dwPageSize; } return cachedPagesize; } #else JL_DLLEXPORT long jl_getpagesize(void) { long page_size = sysconf(_SC_PAGESIZE); assert(page_size != -1); return page_size; } #endif #ifdef _OS_WINDOWS_ static long cachedAllocationGranularity = 0; JL_DLLEXPORT long jl_getallocationgranularity(void) JL_NOTSAFEPOINT { if (!cachedAllocationGranularity) { SYSTEM_INFO systemInfo; GetSystemInfo (&systemInfo); cachedAllocationGranularity = systemInfo.dwAllocationGranularity; } return cachedAllocationGranularity; } #else JL_DLLEXPORT long jl_getallocationgranularity(void) JL_NOTSAFEPOINT { return jl_getpagesize(); } #endif JL_DLLEXPORT long jl_SC_CLK_TCK(void) { #ifndef _OS_WINDOWS_ return sysconf(_SC_CLK_TCK); #else return 0; #endif } // Takes a handle (as returned from dlopen()) and returns the absolute path to the image loaded JL_DLLEXPORT const char *jl_pathname_for_handle(void *handle) { if (!handle) return NULL; #ifdef __APPLE__ // Iterate through all images currently in memory for (int32_t i = _dyld_image_count() - 1; i >= 0 ; i--) { // dlopen() each image, check handle const char *image_name = _dyld_get_image_name(i); void *probe_lib = jl_load_dynamic_library(image_name, JL_RTLD_DEFAULT | JL_RTLD_NOLOAD, 0); jl_dlclose(probe_lib); // If the handle is the same as what was passed in (modulo mode bits), return this image name if (((intptr_t)handle & (-4)) == ((intptr_t)probe_lib & (-4))) return image_name; } #elif defined(_OS_WINDOWS_) wchar_t *pth16 = (wchar_t*)malloc_s(32768 * sizeof(*pth16)); // max long path length DWORD n16 = GetModuleFileNameW((HMODULE)handle, pth16, 32768); if (n16 <= 0) { free(pth16); return NULL; } pth16[n16] = L'\0'; DWORD n8 = WideCharToMultiByte(CP_UTF8, 0, pth16, -1, NULL, 0, NULL, NULL); if (n8 == 0) { free(pth16); return NULL; } char *filepath = (char*)malloc_s(++n8); if (!WideCharToMultiByte(CP_UTF8, 0, pth16, -1, filepath, n8, NULL, NULL)) { free(pth16); free(filepath); return NULL; } free(pth16); return filepath; #else // Linux, FreeBSD, ... struct link_map *map; dlinfo(handle, RTLD_DI_LINKMAP, &map); #ifdef _COMPILER_MSAN_ENABLED_ __msan_unpoison(&map,sizeof(struct link_map*)); if (map) { __msan_unpoison(map, sizeof(struct link_map)); __msan_unpoison_string(map->l_name); } #endif if (map) return map->l_name; #endif return NULL; } #ifdef _OS_WINDOWS_ // Get a list of all the modules in this process. JL_DLLEXPORT int jl_dllist(jl_array_t *list) { DWORD cb, cbNeeded; HMODULE *hMods = NULL; unsigned int i; cbNeeded = 1024 * sizeof(*hMods); do { cb = cbNeeded; hMods = (HMODULE*)realloc_s(hMods, cb); if (!EnumProcessModulesEx(GetCurrentProcess(), hMods, cb, &cbNeeded, LIST_MODULES_ALL)) { free(hMods); return FALSE; } } while (cb < cbNeeded); for (i = 0; i < cbNeeded / sizeof(HMODULE); i++) { const char *path = jl_pathname_for_handle(hMods[i]); if (path == NULL) continue; jl_array_grow_end((jl_array_t*)list, 1); jl_value_t *v = jl_cstr_to_string(path); free((char*)path); jl_array_ptr_set(list, jl_array_dim0(list) - 1, v); } free(hMods); return TRUE; } #endif JL_DLLEXPORT void jl_raise_debugger(void) { #if defined(_OS_WINDOWS_) if (IsDebuggerPresent() == 1) DebugBreak(); #else raise(SIGTRAP); #endif // _OS_WINDOWS_ } JL_DLLEXPORT jl_sym_t *jl_get_UNAME(void) JL_NOTSAFEPOINT { return jl_symbol(JL_BUILD_UNAME); } JL_DLLEXPORT jl_sym_t *jl_get_ARCH(void) JL_NOTSAFEPOINT { return jl_symbol(JL_BUILD_ARCH); } JL_DLLEXPORT size_t jl_maxrss(void) { #if defined(_OS_WINDOWS_) PROCESS_MEMORY_COUNTERS counter; GetProcessMemoryInfo( GetCurrentProcess( ), &counter, sizeof(counter) ); return (size_t)counter.PeakWorkingSetSize; // FIXME: `rusage` is available on OpenBSD, DragonFlyBSD and NetBSD as well. // All of them return `ru_maxrss` in kilobytes. #elif defined(_OS_LINUX_) || defined(_OS_DARWIN_) || defined (_OS_FREEBSD_) struct rusage rusage; getrusage( RUSAGE_SELF, &rusage ); #if defined(_OS_LINUX_) || defined(_OS_FREEBSD_) return (size_t)(rusage.ru_maxrss * 1024); #else return (size_t)rusage.ru_maxrss; #endif #else return (size_t)0; #endif } // Simple `rand()` like function, with global seed and added thread-safety // (but slow and insecure) static _Atomic(uint64_t) g_rngseed; JL_DLLEXPORT uint64_t jl_rand(void) JL_NOTSAFEPOINT { uint64_t max = UINT64_MAX; uint64_t rngseed0 = jl_atomic_load_relaxed(&g_rngseed); uint64_t rngseed; uint64_t rnd; do { rngseed = rngseed0; rnd = cong(max, &rngseed); } while (!jl_atomic_cmpswap_relaxed(&g_rngseed, &rngseed0, rngseed)); return rnd; } JL_DLLEXPORT void jl_srand(uint64_t rngseed) JL_NOTSAFEPOINT { jl_atomic_store_relaxed(&g_rngseed, rngseed); } void jl_init_rand(void) JL_NOTSAFEPOINT { uint64_t rngseed; if (uv_random(NULL, NULL, &rngseed, sizeof(rngseed), 0, NULL)) { ios_puts("WARNING: Entropy pool not available to seed RNG; using ad-hoc entropy sources.\n", ios_stderr); rngseed = uv_hrtime(); rngseed ^= int64hash(uv_os_getpid()); } jl_srand(rngseed); srand(rngseed); } #ifdef __cplusplus } #endif
3b7dd7643fb4f7a00e54d5d2ccc3e9f67c6c4ca5
ae7b140df7d6c7e8edb68339e397800414c18f34
/Microcontrollers/STM32/GPIO/LED/main.c
bfd6ccbec649b5f5636a12c00ca1d422b22a7cd2
[]
no_license
Embetronicx/Tutorials
6fbcf5a3eda4bc52166ce982b4fc4b456c91ac7e
e9a9d0cd35aa5c183fe01d6f90f7cb3df15a9abf
refs/heads/master
2022-12-04T09:04:57.211573
2022-11-16T11:13:16
2022-11-16T11:13:16
96,311,774
168
268
null
null
null
null
UTF-8
C
false
false
2,030
c
main.c
/***************************************************************************//** * \file main.c * * \details Setting all the Ports (A, B, C, D, and E) as output * and toggling them with some random delay * * \author EmbeTronicX * * \This code is verified with proteus simulation * *******************************************************************************/ #include "stm32f4xx.h" #define DELAY_COUNT ( 30000 ) //delay count /***************************************************************************//** \details Providing Delay by running empty for loop \return void \retval none *******************************************************************************/ static void delay( void ) { uint32_t i = 0; for( i=0; i<=DELAY_COUNT; i++ ); } /***************************************************************************//** \details The main function. It should not return. \return void \retval none *******************************************************************************/ int main(void){ //Enable the AHB clock all GPIO ports SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOAEN); SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOBEN); SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN); SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN); //set all Port A to Port E as output GPIOA->MODER = 0x55555555; GPIOB->MODER = 0x55555555; GPIOC->MODER = 0x55555555; GPIOD->MODER = 0x55555555; GPIOE->MODER = 0x55555555; //Endless loop while(1){ //Turn ON the LED of all the ports GPIOA->BSRR = 0x0000FFFF; GPIOB->BSRR = 0x0000FFFF; GPIOC->BSRR = 0x0000FFFF; GPIOD->BSRR = 0x0000FFFF; GPIOE->BSRR = 0x0000FFFF; delay(); //Turn OFF the LED of all the ports GPIOA->BSRR = 0xFFFF0000; GPIOB->BSRR = 0xFFFF0000; GPIOC->BSRR = 0xFFFF0000; GPIOD->BSRR = 0xFFFF0000; GPIOE->BSRR = 0xFFFF0000; delay(); } }
2af7d39c98ce9ae24f12be79a975ee4384522126
c26d7b0ed875357278e61627da2da0650da77986
/src/libtermlib/tc1.c
e5071edc326ec3445ed8df494fea061b9f348823
[ "BSD-3-Clause" ]
permissive
RetroBSD/retrobsd
5343d9e3c424637fc3ad5b03fe720b2744490025
486f81f6abff01c7dcc207235cd2979b226a95ff
refs/heads/master
2023-09-02T23:12:05.110883
2023-07-07T18:41:40
2023-07-07T18:41:40
18,598,087
282
59
BSD-3-Clause
2023-07-18T07:35:36
2014-04-09T13:25:46
C
UTF-8
C
false
false
549
c
tc1.c
/* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * tc1 [term] * dummy program to test termlib. * gets entry, counts it, and prints it. */ #include <stdio.h> char buf[1024]; char *getenv(); main(argc, argv) char **argv; { char *p; int rc; if (argc < 2) p = getenv("TERM"); else p = argv[1]; rc = tgetent(buf,p); printf("tgetent returns %d, len=%d, text=\n'%s'\n",rc,strlen(buf),buf); }
f77fc4804a8cf54f99d26f48e13bd393cfeb303e
32be357e08164f0434174b4402b1a63a09be7d55
/CosBase/tests/src/properties.h
51a9a22da772149a579042a182ba9a7ae53c494f
[ "Apache-2.0" ]
permissive
CObjectSystem/COS
e4a4c284c870b875e5fb949282a6d3cffa58a771
fc2f3ed275d2291d3fb2499fa3572dcfe3dd9db2
refs/heads/master
2023-07-24T21:13:15.083070
2023-01-08T15:31:16
2023-01-08T15:31:16
2,830,240
341
49
Apache-2.0
2023-07-22T09:55:49
2011-11-22T19:16:13
C
UTF-8
C
false
false
2,003
h
properties.h
#ifndef COS_TESTS_PROPERTY_H #define COS_TESTS_PROPERTY_H /** * C Object System * COS testsuites - properties definitions * * Copyright 2006+ Laurent Deniau <laurent.deniau@gmail.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. */ defproperty(p00); defproperty(p01); defproperty(p02); defproperty(p03); defproperty(p04); defproperty(p05); defproperty(p06); defproperty(p07); defproperty(p08); defproperty(p09); defproperty(p10); defproperty(p11); defproperty(p12); defproperty(p13); defproperty(p14); defproperty(p15); defproperty(p16); defproperty(p17); defproperty(p18); defproperty(p19); defproperty(p20); defproperty(p21); defproperty(p22); defproperty(p23); defproperty(p24); defproperty(p25); defproperty(p26); defproperty(p27); defproperty(p28); defproperty(p29); defproperty(p30); defproperty(p31); defproperty(p32); defproperty(p33); defproperty(p34); defproperty(p35); defproperty(p36); defproperty(p37); defproperty(p38); defproperty(p39); defproperty(p40); defproperty(p41); defproperty(p42); defproperty(p43); defproperty(p44); defproperty(p45); defproperty(p46); defproperty(p47); defproperty(p48); defproperty(p49); defproperty(p50); defproperty(p51); defproperty(p52); defproperty(p53); defproperty(p54); defproperty(p55); defproperty(p56); defproperty(p57); defproperty(p58); defproperty(p59); defproperty(p60); defproperty(p61); defproperty(p62); defproperty(p63); defproperty(p64); defproperty (prop); defproperty((prop)subprop); #endif // COS_TESTS_PROPERTY_H
366153b746ec5d6def04802373478ce59fe05f74
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
/Engine/Source/ThirdParty/MCPP/mcpp-2.7.2/cpp-test/test-t/ifdef63.h
85aac0e6be3fb0785ed30a7c83d34e2463b79806
[ "MIT", "LicenseRef-scancode-proprietary-license", "BSD-2-Clause", "BSD-3-Clause" ]
permissive
windystrife/UnrealEngine_NVIDIAGameWorks
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
b50e6338a7c5b26374d66306ebc7807541ff815e
refs/heads/4.18-GameWorks
2023-03-11T02:50:08.471040
2022-01-13T20:50:29
2022-01-13T20:50:29
124,100,479
262
179
MIT
2022-12-16T05:36:38
2018-03-06T15:44:09
C++
UTF-8
C
false
false
1,222
h
ifdef63.h
/* ifdef63.h */ #ifdef X20 #else #ifdef X21 #else #ifdef X22 #else #ifdef X23 #else #ifdef X24 #else #ifdef X25 #else #ifdef X26 #else #ifdef X27 #else #ifdef X28 #else #ifdef X29 #else #ifdef X2A #else #ifdef X2B #else #ifdef X2C #else #ifdef X2D #else #ifdef X2E #else #ifdef X2F #else #ifdef X30 #else #ifdef X31 #else #ifdef X32 #else #ifdef X33 #else #ifdef X34 #else #ifdef X35 #else #ifdef X36 #else #ifdef X37 #else #ifdef X38 #else #ifdef X39 #else #ifdef X3A #else #ifdef X3B #else #ifdef X3C #else #ifdef X3D #else #ifdef X3E #else #ifdef X3F ifdef_nest = 0x3f; #endif /* X3F */ #endif /* X3E */ #endif /* X3D */ #endif /* X3C */ #endif /* X3B */ #endif /* X3A */ #endif /* X39 */ #endif /* X38 */ #endif /* X37 */ #endif /* X36 */ #endif /* X35 */ #endif /* X34 */ #endif /* X33 */ #endif /* X32 */ #endif /* X31 */ #endif /* X30 */ #endif /* X2F */ #endif /* X2E */ #endif /* X2D */ #endif /* X2C */ #endif /* X2B */ #endif /* X2A */ #endif /* X29 */ #endif /* X28 */ #endif /* X27 */ #endif /* X26 */ #endif /* X25 */ #endif /* X24 */ #endif /* X23 */ #endif /* X22 */ #endif /* X21 */ #endif /* X20 */
4a477918f899851f2478b6811e85fc67d79db8ca
4d78977ee7a816f97134d92b5826e929fb56c571
/include/port/system.h
af53dbb431fb3233d4812b94b10331845c028926
[ "MIT" ]
permissive
ireader/sdk
312e3ebdd4b0f694977236efab012d75cbd4bdd1
9fb240206c4d925d12be5b29aeb94c7884ea8262
refs/heads/master
2023-09-01T17:49:04.171634
2023-07-22T01:56:22
2023-07-22T01:56:22
11,940,320
394
250
MIT
2022-05-01T08:18:58
2013-08-07T03:16:47
C
UTF-8
C
false
false
799
h
system.h
#ifndef _port_system_h_ #define _port_system_h_ #ifdef __cplusplus extern "C" { #endif int system_reboot(void); int system_shutdown(void); // 2012-08-17 16:50:43.345 int system_gettime(char time[24]); // system_settime("2012-08-17 16:50:43"); // system_settime("2012-08-17 16:50:43.345"); int system_settime(const char* time); int system_ntp_enable(int enable); int system_ntp_status(int *enable); #if !(defined(_WIN32) || defined(_WIN64)) int system_ntp_setconfigpath(const char* path); int system_ntp_getconfigpath(char* path, int pathLen); #endif // servers: server1;server2 // servers: 0.cn.pool.ntp.org;1.cn.pool.ntp.org int system_ntp_getserver(char* servers, int serversLen); int system_ntp_setserver(const char *servers); #ifdef __cplusplus } #endif #endif /* !_port_system_h_ */
4a2aa75869c8be1360cbb5e9d0ce0c59c13966c5
5c1625afdb9a9964cca81d0e1a9c44e70f5e769a
/tests/externals/tinyssh/crypto_sign_ed25519.h
e777efa1e3ba6cdd2dfc72807fe2c417e9a61506
[ "BSD-3-Clause", "CC0-1.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
LoupVaillant/Monocypher
6a225147b3fd3671c1e3c9caf1fa2828bc3d874a
3a9557427201e78026048547988bbb582fe64f4a
refs/heads/master
2023-09-06T07:21:54.777041
2023-09-05T21:02:44
2023-09-05T21:02:44
97,625,830
583
87
NOASSERTION
2023-02-25T12:42:47
2017-07-18T17:28:53
C
UTF-8
C
false
false
1,118
h
crypto_sign_ed25519.h
#ifndef crypto_sign_ed25519_H #define crypto_sign_ed25519_H #define crypto_sign_ed25519_tinyssh_SECRETKEYBYTES 64 #define crypto_sign_ed25519_tinyssh_PUBLICKEYBYTES 32 #define crypto_sign_ed25519_tinyssh_BYTES 64 extern int crypto_sign_ed25519_tinyssh(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *); extern int crypto_sign_ed25519_tinyssh_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *); extern int crypto_sign_ed25519_tinyssh_keypair(unsigned char *,unsigned char *); #define crypto_sign_ed25519 crypto_sign_ed25519_tinyssh #define crypto_sign_ed25519_open crypto_sign_ed25519_tinyssh_open #define crypto_sign_ed25519_keypair crypto_sign_ed25519_tinyssh_keypair #define crypto_sign_ed25519_BYTES crypto_sign_ed25519_tinyssh_BYTES #define crypto_sign_ed25519_PUBLICKEYBYTES crypto_sign_ed25519_tinyssh_PUBLICKEYBYTES #define crypto_sign_ed25519_SECRETKEYBYTES crypto_sign_ed25519_tinyssh_SECRETKEYBYTES #define crypto_sign_ed25519_IMPLEMENTATION "tinyssh" #define crypto_sign_ed25519_VERSION "-" #endif
9141aaea01890e2a3d0f604d3eb1de10b1433d82
7744859512f027ef0da8b1bde0f8518e631b98eb
/soh/assets/objects/object_ani/object_ani.h
b61feda0fa8c3ad875b3b0928318278aff91dc60
[]
no_license
HarbourMasters/Shipwright
7f70b9470e4f9a117f3fe2d6e4deb776b8742182
0e7c6585239c0d7ea2c039b8b8cb7eaedf8928a9
refs/heads/develop
2023-08-31T20:50:56.253521
2023-08-30T17:34:06
2023-08-30T17:34:06
472,575,717
2,104
459
null
2023-09-14T20:29:01
2022-03-22T01:42:52
C
UTF-8
C
false
false
5,257
h
object_ani.h
#pragma once #include "align_asset_macro.h" #define dgRoofManSkel "__OTR__objects/object_ani/gRoofManSkel" static const ALIGN_ASSET(2) char gRoofManSkel[] = dgRoofManSkel; #define dgRoofManWaistDL "__OTR__objects/object_ani/gRoofManWaistDL" static const ALIGN_ASSET(2) char gRoofManWaistDL[] = dgRoofManWaistDL; #define dgRoofManLeftThighDL "__OTR__objects/object_ani/gRoofManLeftThighDL" static const ALIGN_ASSET(2) char gRoofManLeftThighDL[] = dgRoofManLeftThighDL; #define dgRoofManLeftLegDL "__OTR__objects/object_ani/gRoofManLeftLegDL" static const ALIGN_ASSET(2) char gRoofManLeftLegDL[] = dgRoofManLeftLegDL; #define dgRoofManLeftFootDL "__OTR__objects/object_ani/gRoofManLeftFootDL" static const ALIGN_ASSET(2) char gRoofManLeftFootDL[] = dgRoofManLeftFootDL; #define dgRoofManRightThighDL "__OTR__objects/object_ani/gRoofManRightThighDL" static const ALIGN_ASSET(2) char gRoofManRightThighDL[] = dgRoofManRightThighDL; #define dgRoofManRightLegDL "__OTR__objects/object_ani/gRoofManRightLegDL" static const ALIGN_ASSET(2) char gRoofManRightLegDL[] = dgRoofManRightLegDL; #define dgRoofManRightFootDL "__OTR__objects/object_ani/gRoofManRightFootDL" static const ALIGN_ASSET(2) char gRoofManRightFootDL[] = dgRoofManRightFootDL; #define dgRoofManTorsoDL "__OTR__objects/object_ani/gRoofManTorsoDL" static const ALIGN_ASSET(2) char gRoofManTorsoDL[] = dgRoofManTorsoDL; #define dgRoofManLeftUpperArmDL "__OTR__objects/object_ani/gRoofManLeftUpperArmDL" static const ALIGN_ASSET(2) char gRoofManLeftUpperArmDL[] = dgRoofManLeftUpperArmDL; #define dgRoofManLeftForearmDL "__OTR__objects/object_ani/gRoofManLeftForearmDL" static const ALIGN_ASSET(2) char gRoofManLeftForearmDL[] = dgRoofManLeftForearmDL; #define dgRoofManLeftHandDL "__OTR__objects/object_ani/gRoofManLeftHandDL" static const ALIGN_ASSET(2) char gRoofManLeftHandDL[] = dgRoofManLeftHandDL; #define dgRoofManRightUpperArmDL "__OTR__objects/object_ani/gRoofManRightUpperArmDL" static const ALIGN_ASSET(2) char gRoofManRightUpperArmDL[] = dgRoofManRightUpperArmDL; #define dgRoofManRightForearmDL "__OTR__objects/object_ani/gRoofManRightForearmDL" static const ALIGN_ASSET(2) char gRoofManRightForearmDL[] = dgRoofManRightForearmDL; #define dgRoofManRightHandDL "__OTR__objects/object_ani/gRoofManRightHandDL" static const ALIGN_ASSET(2) char gRoofManRightHandDL[] = dgRoofManRightHandDL; #define dgRoofManHeadDL "__OTR__objects/object_ani/gRoofManHeadDL" static const ALIGN_ASSET(2) char gRoofManHeadDL[] = dgRoofManHeadDL; #define dgRoofMan1TLUT "__OTR__objects/object_ani/gRoofMan1TLUT" static const ALIGN_ASSET(2) char gRoofMan1TLUT[] = dgRoofMan1TLUT; #define dgRoofMan2TLUT "__OTR__objects/object_ani/gRoofMan2TLUT" static const ALIGN_ASSET(2) char gRoofMan2TLUT[] = dgRoofMan2TLUT; #define dgRoofManHandBackTex "__OTR__objects/object_ani/gRoofManHandBackTex" static const ALIGN_ASSET(2) char gRoofManHandBackTex[] = dgRoofManHandBackTex; #define dgRoofManForearmGradientTex "__OTR__objects/object_ani/gRoofManForearmGradientTex" static const ALIGN_ASSET(2) char gRoofManForearmGradientTex[] = dgRoofManForearmGradientTex; #define dgRoofManThighGradientTex "__OTR__objects/object_ani/gRoofManThighGradientTex" static const ALIGN_ASSET(2) char gRoofManThighGradientTex[] = dgRoofManThighGradientTex; #define dgRoofManSandalBuckleTex "__OTR__objects/object_ani/gRoofManSandalBuckleTex" static const ALIGN_ASSET(2) char gRoofManSandalBuckleTex[] = dgRoofManSandalBuckleTex; #define dgRoofManTrouserPatternTex "__OTR__objects/object_ani/gRoofManTrouserPatternTex" static const ALIGN_ASSET(2) char gRoofManTrouserPatternTex[] = dgRoofManTrouserPatternTex; #define dgRoofManSkinGradientTex "__OTR__objects/object_ani/gRoofManSkinGradientTex" static const ALIGN_ASSET(2) char gRoofManSkinGradientTex[] = dgRoofManSkinGradientTex; #define dgRoofManEarTex "__OTR__objects/object_ani/gRoofManEarTex" static const ALIGN_ASSET(2) char gRoofManEarTex[] = dgRoofManEarTex; #define dgRoofManHairTex "__OTR__objects/object_ani/gRoofManHairTex" static const ALIGN_ASSET(2) char gRoofManHairTex[] = dgRoofManHairTex; #define dgRoofManEyeOpenTex "__OTR__objects/object_ani/gRoofManEyeOpenTex" static const ALIGN_ASSET(2) char gRoofManEyeOpenTex[] = dgRoofManEyeOpenTex; #define dgRoofManEyeHalfTex "__OTR__objects/object_ani/gRoofManEyeHalfTex" static const ALIGN_ASSET(2) char gRoofManEyeHalfTex[] = dgRoofManEyeHalfTex; #define dgRoofManEyeClosedTex "__OTR__objects/object_ani/gRoofManEyeClosedTex" static const ALIGN_ASSET(2) char gRoofManEyeClosedTex[] = dgRoofManEyeClosedTex; #define dgRoofManKnockbackAnim "__OTR__objects/object_ani/gRoofManKnockbackAnim" static const ALIGN_ASSET(2) char gRoofManKnockbackAnim[] = dgRoofManKnockbackAnim; #define dgRoofManGettingUpAfterKnockbackAnim "__OTR__objects/object_ani/gRoofManGettingUpAfterKnockbackAnim" static const ALIGN_ASSET(2) char gRoofManGettingUpAfterKnockbackAnim[] = dgRoofManGettingUpAfterKnockbackAnim; #define dgRoofManIdleAnim "__OTR__objects/object_ani/gRoofManIdleAnim" static const ALIGN_ASSET(2) char gRoofManIdleAnim[] = dgRoofManIdleAnim; #define dobject_aniTex_0011D8 "__OTR__objects/object_ani/object_aniTex_0011D8" static const ALIGN_ASSET(2) char object_aniTex_0011D8[] = dobject_aniTex_0011D8;
3ae6b7c1413224d56a0d3cae1d99799c43ee41c1
e19509bd2548f173aa492d7498812afa28fcfbb5
/src/acodec/wavpack.c
97132afe03cc4e0e533d4dd19d242066c5edffe1
[ "BSD-2-Clause" ]
permissive
stsaz/fmedia
ef28a25e88ef50411014cfc7faef8813a67cf486
6f6d05fde4a6eba2f1fa0d9e194cd2b405258c3e
refs/heads/master
2023-08-19T20:30:03.512098
2023-07-24T16:37:33
2023-07-24T16:37:33
36,122,394
194
28
BSD-2-Clause
2022-07-19T15:09:24
2015-05-23T12:32:52
C
UTF-8
C
false
false
2,837
c
wavpack.c
/** WavPack input. Copyright (c) 2015 Simon Zolin */ #include <fmedia.h> #include <acodec/alib3-bridge/wavpack.h> #include <format/mmtag.h> static const fmed_core *core; //FMEDIA MODULE static const void* wvpk_iface(const char *name); static int wvpk_sig(uint signo); static void wvpk_destroy(void); static const fmed_mod fmed_wvpk_mod = { .ver = FMED_VER_FULL, .ver_core = FMED_VER_CORE, &wvpk_iface, &wvpk_sig, &wvpk_destroy }; FF_EXP const fmed_mod* fmed_getmod(const fmed_core *_core) { core = _core; return &fmed_wvpk_mod; } static const fmed_filter wvpk_dec_iface; static const void* wvpk_iface(const char *name) { if (ffsz_eq(name, "decode")) return &wvpk_dec_iface; return NULL; } static int wvpk_sig(uint signo) { return 0; } static void wvpk_destroy(void) { } typedef struct wvpk_dec { ffwvpack_dec wv; uint frsize; uint sample_rate; uint outdata_delayed :1; } wvpk_dec; static void* wvpk_dec_create(fmed_filt *d) { wvpk_dec *w = ffmem_new(wvpk_dec); ffwvpk_dec_open(&w->wv); return w; } static void wvpk_dec_free(void *ctx) { wvpk_dec *w = ctx; ffwvpk_dec_close(&w->wv); ffmem_free(w); } static int wvpk_dec_decode(void *ctx, fmed_filt *d) { wvpk_dec *w = ctx; if (w->outdata_delayed) { w->outdata_delayed = 0; if ((int64)d->audio.seek != FMED_NULL) { return FMED_RMORE; } } if ((d->flags & FMED_FFWD) && (int64)d->audio.seek != FMED_NULL) { ffwvpk_dec_seek(&w->wv, ffpcm_samples(d->audio.seek, w->sample_rate)); } int r = ffwvpk_decode(&w->wv, &d->data_in, &d->data_out, d->audio.pos); switch (r) { case FFWVPK_RHDR: { const struct ffwvpk_info *info = ffwvpk_dec_info(&w->wv); dbglog(core, d->trk, "wvpk", "lossless:%u compression:%u MD5:%16xb" , (int)info->lossless , info->comp_level , info->md5); d->audio.decoder = "WavPack"; d->audio.fmt.format = info->format; d->audio.fmt.channels = info->channels; d->audio.fmt.sample_rate = info->sample_rate; d->audio.fmt.ileaved = 1; w->sample_rate = info->sample_rate; d->audio.bitrate = ffpcm_brate(d->input.size, d->audio.total, info->sample_rate); d->datatype = "pcm"; w->frsize = ffpcm_size(info->format, info->channels); w->outdata_delayed = 1; d->data_out.len = 0; return FMED_RDATA; } case FFWVPK_RDATA: break; case FFWVPK_RMORE: if (d->flags & FMED_FLAST) { d->outlen = 0; return FMED_RDONE; } return FMED_RMORE; case FFWVPK_RERR: errlog(core, d->trk, "wvpk", "ffwvpk_decode(): %s", ffwvpk_dec_error(&w->wv)); return FMED_RERR; default: FF_ASSERT(0); return FMED_RERR; } dbglog(core, d->trk, "wvpk", "decoded %L samples (%U)" , (size_t)d->data_out.len / w->frsize, (int64)w->wv.samp_idx); d->audio.pos = w->wv.samp_idx; return FMED_RDATA; } static const fmed_filter wvpk_dec_iface = { wvpk_dec_create, wvpk_dec_decode, wvpk_dec_free };
269b304a0083f0dbd7915dd2362bbae5ddf7a9b3
ae90aa32e949a5eab9665f526f886f05860161d2
/code/c/03-asm/06-globalcall/globalCall.c
77369265b0d7b4e620c74e7ae01d3a7d62a6b9cc
[ "CC-BY-SA-3.0", "MIT" ]
permissive
cccbook/sp
4097ab760cfb013b689dc4739a439de29d85d324
aff23e6b18ba6221022b14b024fd562427c46d9a
refs/heads/master
2022-05-22T03:31:33.324045
2019-06-06T07:04:37
2019-06-06T07:04:37
156,299,694
257
96
MIT
2022-03-19T08:48:32
2018-11-05T23:56:37
Assembly
UTF-8
C
false
false
136
c
globalCall.c
#include <stdio.h> int a=5, b=8, c=1; void add() { c = a + b; } int main() { add(); printf("add(5, 8)=%d\n", c); return 0; }
0c1d1333287d47e095d05869e31e4243cee4f7b3
e1cddfd754d952134e72dfd03522c5ea4fb6008e
/src/vnet/fib/fib.h
ec97c565b811154ba282c7a0abce4d11d1a24d79
[ "Apache-2.0" ]
permissive
FDio/vpp
0ad30fa1bec2975ffa6b66b45c9f4f32163123b6
f234b0d4626d7e686422cc9dfd25958584f4931e
refs/heads/master
2023-08-31T16:09:04.068646
2022-03-14T09:49:15
2023-08-31T09:50:00
96,556,718
1,048
630
Apache-2.0
2023-06-21T05:39:17
2017-07-07T16:29:40
C
UTF-8
C
false
false
33,399
h
fib.h
/* * Copyright (c) 2016 Cisco and/or its affiliates. * 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. */ /** * \brief * A IP v4/6 independent FIB. * * The main functions provided by the FIB are as follows; * * - source priorities * * A route can be added to the FIB by more than entity or source. Sources * include, but are not limited to, API, CLI, LISP, MAP, etc (for the full list * see fib_entry.h). Each source provides the forwarding information (FI) that * is has determined as required for that route. Since each source determines the * FI using different best path and loop prevention algorithms, it is not * correct for the FI of multiple sources to be combined. Instead the FIB must * choose to use the FI from only one source. This choose is based on a static * priority assignment. For example; * IF a prefix is added as a result of interface configuration: * set interface address 192.168.1.1/24 GigE0 * and then it is also added from the CLI * ip route 192.168.1.1/32 via 2.2.2.2/32 * then the 'interface' source will prevail, and the route will remain as * 'local'. * The requirement of the FIB is to always install the FI from the winning * source and thus to maintain the FI added by losing sources so it can be * installed should the winning source be withdrawn. * * - adj-fib maintenance * * When ARP or ND discover a neighbour on a link an adjacency forms for the * address of that neighbour. It is also required to insert a route in the * appropriate FIB table, corresponding to the VRF for the link, an entry for * that neighbour. This entry is often referred to as an adj-fib. Adj-fibs * have a dedicated source; 'ADJ'. * The priority of the ADJ source is lower than most. This is so the following * config; * set interface address 192.168.1.1/32 GigE0 * ip arp 192.168.1.2 GigE0 dead.dead.dead * ip route add 192.168.1.2 via 10.10.10.10 GigE1 * will forward traffic for 192.168.1.2 via GigE1. That is the route added * by the control plane is favoured over the adjacency discovered by ARP. * The control plane, with its associated authentication, is considered the * authoritative source. * To counter the nefarious addition of adj-fib, through the nefarious injection * of adjacencies, the FIB is also required to ensure that only adj-fibs whose * less specific covering prefix is connected are installed in forwarding. This * requires the use of 'cover tracking', where a route maintains a dependency * relationship with the route that is its less specific cover. When this cover * changes (i.e. there is a new covering route) or the forwarding information * of the cover changes, then the covered route is notified. * * Overlapping sub-nets are not supported, so no adj-fib has multiple paths. * The control plane is expected to remove a prefix configured for an interface * before the interface changes VRF. * So while the following config is accepted: * set interface address 192.168.1.1/32 GigE0 * ip arp 192.168.1.2 GigE0 dead.dead.dead * set interface ip table GigE0 2 * it does not result in the desired behaviour. * * - attached export. * * Further to adj-fib maintenance above consider the following config: * set interface address 192.168.1.1/24 GigE0 * ip route add table 2 192.168.1.0/24 GigE0 * Traffic destined for 192.168.1.2 in table 2 will generate an ARP request * on GigE0. However, since GigE0 is in table 0, all adj-fibs will be added in * FIB 0. Hence all hosts in the sub-net are unreachable from table 2. To resolve * this, all adj-fib and local prefixes are exported (i.e. copied) from the * 'export' table 0, to the 'import' table 2. There can be many import tables * for a single export table. * * - recursive route resolution * * A recursive route is of the form: * 1.1.1.1/32 via 10.10.10.10 * i.e. a route for which no egress interface is provided. In order to forward * traffic to 1.1.1.1/32 the FIB must therefore first determine how to forward * traffic to 10.10.10.10/32. This is recursive resolution. * Recursive resolution, just like normal resolution, proceeds via a longest * prefix match for the 'via-address' 10.10.10.10. Note it is only possible * to add routes via an address (i.e. a /32 or /128) not via a shorter mask * prefix. There is no use case for the latter. * Since recursive resolution proceeds via a longest prefix match, the entry * in the FIB that will resolve the recursive route, termed the via-entry, may * change as other routes are added to the FIB. Consider the recursive * route shown above, and this non-recursive route: * 10.10.10.0/24 via 192.168.16.1 GigE0 * The entry for 10.10.10.0/24 is thus the resolving via-entry. If this entry is * modified, to say; * 10.10.10.0/24 via 192.16.1.3 GigE0 * Then packet for 1.1.1.1/32 must also be sent to the new next-hop. * Now consider the addition of; * 10.10.10.0/28 via 192.168.16.2 GigE0 * The more specific /28 is a better longest prefix match and thus becomes the * via-entry. Removal of the /28 means the resolution will revert to the /24. * The tracking to the changes in recursive resolution is the requirement of * the FIB. When the forwarding information of the via-entry changes a back-walk * is used to update dependent recursive routes. When new routes are added to * the table the cover tracking feature provides the necessary notifications to * the via-entry routes. * The adjacency constructed for 1.1.1.1/32 will be a recursive adjacency * whose next adjacency will be contributed from the via-entry. Maintaining * the validity of this recursive adjacency is a requirement of the FIB. * * - recursive loop avoidance * * Consider this set of routes: * 1.1.1.1/32 via 2.2.2.2 * 2.2.2.2/32 via 3.3.3.3 * 3.3.3.3/32 via 1.1.1.1 * this is termed a recursion loop - all of the routes in the loop are * unresolved in so far as they do not have a resolving adjacency, but each * is resolved because the via-entry is known. It is important here to note * the distinction between the control-plane objects and the data-plane objects * (more details in the implementation section). The control plane objects must * allow the loop to form (i.e. the graph becomes cyclic), however, the * data-plane absolutely must not allow the loop to form, otherwise the packet * would loop indefinitely and never egress the device - meltdown would follow. * The control plane must allow the loop to form, because when the loop breaks, * all members of the loop need to be updated. Forming the loop allows the * dependencies to be correctly setup to allow this to happen. * There is no limit to the depth of recursion supported by VPP so: * 9.9.9.100/32 via 9.9.9.99 * 9.9.9.99/32 via 9.9.9.98 * 9.9.9.98/32 via 9.9.9.97 * ... turtles, turtles, turtles ... * 9.9.9.1/32 via 10.10.10.10 Gig0 * is supported to as many layers of turtles is desired, however, when * back-walking a graph (in this case from 9.9.9.1/32 up toward 9.9.9.100/32) * a FIB needs to differentiate the case where the recursion is deep versus * the case where the recursion is looped. A simple method, employed by VPP FIB, * is to limit the number of steps. VPP FIB limit is 16. Typical BGP scenarios * in the wild do not exceed 3 (BGP Inter-AS option C). * * - Fast Convergence * * After a network topology change, the 'convergence' time, is the time taken * for the router to complete a transition to forward traffic using the new * topology. The convergence time is therefore a summation of the time to; * - detect the failure. * - calculate the new 'best path' information * - download the new best paths to the data-plane. * - install those best best in data-plane forwarding. * The last two points are of relevance to VPP architecture. The download API is * binary and batch, details are not discussed here. There is no HW component to * programme, installation time is bounded by the memory allocation and table * lookup and insert access times. * * 'Fast' convergence refers to a set of technologies that a FIB can employ to * completely or partially restore forwarding whilst the convergence actions * listed above are ongoing. Fast convergence technologies are further * sub-divided into Prefix Independent Convergence (PIC) and Loop Free * Alternate path Fast re-route (LFA-FRR or sometimes called IP-FRR) which * affect recursive and non-recursive routes respectively. * * LFA-FRR * * Consider the network topology below: * * C * / \ * X -- A --- B - Y * | | * D F * \ / * E * * all links are equal cost, traffic is passing from X to Y. the best path is * X-A-B-Y. There are two alternative paths, one via C and one via E. An * alternate path is considered to be loop free if no other router on that path * would forward the traffic back to the sender. Consider router C, its best * path to Y is via B, so if A were to send traffic destined to Y to C, then C * would forward that traffic to B - this is a loop-free alternate path. In * contrast consider router D. D's shortest path to Y is via A, so if A were to * send traffic destined to Y via D, then D would send it back to A; this is * not a loop-free alternate path. There are several points of note; * - we are considering the pre-failure routing topology * - any equal-cost multi-path between A and B is also a LFA path. * - in order for A to calculate LFA paths it must be aware of the best-path * to Y from the perspective of D. These calculations are thus limited to * routing protocols that have a full view of the network topology, i.e. * link-state DB protocols like OSPF or an SDN controller. LFA protected * prefixes are thus non-recursive. * * LFA is specified as a 1 to 1 redundancy; a primary path has only one LFA * (a.k.a. backup) path. To my knowledge this limitation is one of complexity * in the calculation of and capacity planning using a 1-n redundancy. * * In the event that the link A-B fails, the alternate path via C can be used. * In order to provide 'fast' failover in the event of a failure, the control * plane will download both the primary and the backup path to the FIB. It is * then a requirement of the FIB to perform the failover (a.k.a cutover) from * the primary to the backup path as quickly as possible, and particularly * without any other control-plane intervention. The expectation is cutover is * less than 50 milli-seconds - a value allegedly from the VOIP QoS. Note that * cutover time still includes the fault detection time, which in a vitalised * environment could be the dominant factor. Failure detection can be either a * link down, which will affect multiple paths on a multi-access interface, or * via a specific path heartbeat (i.e. BFD). * At this time VPP does not support LFA, that is it does not support the * installation of a primary and backup path[s] for a route. However, it does * support ECMP, and VPP FIB is designed to quickly remove failed paths from * the ECMP set, however, it does not insert shared objects specific to the * protected resource into the forwarding object graph, since this would incur * a forwarding/performance cost. Failover time is thus route number dependent. * Details are provided in the implementation section below. * * PIC * * PIC refers to the concept that the converge time should be independent of * the number of prefixes/routes that are affected by the failure. PIC is * therefore most appropriate when considering networks with large number of * prefixes, i.e. BGP networks and thus recursive prefixes. There are several * flavours of PIC covering different locations of protection and failure * scenarios. An outline is given below, see the literature for more details: * * Y/16 - CE1 -- PE1---\ * | \ P1---\ * | \ PE3 -- CE3 - X/16 * | - P2---/ * Y/16 - CE2 -- PE2---/ * * CE = customer edge, PE = provider edge. external-BGP runs between customer * and provider, internal-BGP runs between provider and provider. * * 1) iBGP PIC-core: consider traffic from CE1 to X/16 via CE3. On PE1 there is * are routes; * X/16 (and hundreds of thousands of others like it) * via PE3 * and * PE3/32 (its loopback address) * via 10.0.0.1 Link0 (this is P1) * via 10.1.1.1 Link1 (this is P2) * the failure is the loss of link0 or link1 * As in all PIC scenarios, in order to provide prefix independent convergence * it must be that the route for X/16 (and all other routes via PE3) do not * need to be updated in the FIB. The FIB therefore needs to update a single * object that is shared by all routes - once this shared object is updated, * then all routes using it will be instantly updated to use the new forwarding * information. In this case the shared object is the resolving route via PE3. * Once the route via PE3 is updated via IGP (OSPF) convergence, then all * recursive routes that resolve through it are also updated. VPP FIB * implements this scenario via a recursive-adjacency. the X/16 and it sibling * routes share a recursive-adjacency that links to/points at/stacks on the * normal adjacency contributed by the route for PE3. Once this shared * recursive adj is re-linked then all routes are switched to using the new * forwarding information. This is shown below; * * pre-failure; * X/16 --> R-ADJ-1 --> ADJ-1-PE3 (multi-path via P1 and P2) * * post-failure: * X/16 --> R-ADJ-1 --> ADJ-2-PE3 (single path via P1) * * note that R-ADJ-1 (the recursive adj) remains in the forwarding graph, * therefore X/16 (and all its siblings) is not updated. * X/16 and its siblings share the recursive adj since they share the same * path-list. It is the path-list object that contributes the recursive-adj * (see next section for more details) * * * 2) iBGP PIC-edge; Traffic from CE3 to Y/16. On PE3 there is are routes; * Y/16 (and hundreds of thousands of others like it) * via PE1 * via PE2 * and * PE1/32 (PE1's loopback address) * via 10.0.2.2 Link0 (this is P1) * PE2/32 (PE2's loopback address) * via 10.0.3.3 Link1 (this is P2) * * the failure is the loss of reachability to PE2. this could be either the * loss of the link P2-PE2 or the loss of the node PE2. This is detected either * by the withdrawal of the PE2's loopback route or by some form of failure * detection (i.e. BFD). * VPP FIB again provides PIC via the use of the shared recursive-adj. Y/16 and * its siblings will again share a path-list for the list {PE1,PE2}, this * path-list will contribute a multi-path-recursive-adj, i.e. a multi-path-adj * with each choice therein being another adj; * * Y/16 -> RM-ADJ --> ADJ1 (for PE1) * --> ADJ2 (for PE2) * * when the route for PE1 is withdrawn then the multi-path-recursive-adjacency * is updated to be; * * Y/16 --> RM-ADJ --> ADJ1 (for PE1) * --> ADJ1 (for PE1) * * that is both choices in the ECMP set are the same and thus all traffic is * forwarded to PE1. Eventually the control plane will download a route update * for Y/16 to be via PE1 only. At that time the situation will be: * * Y/16 -> R-ADJ --> ADJ1 (for PE1) * * In the scenario above we assumed that PE1 and PE2 are ECMP for Y/16. eBGP * PIC core is also specified for the case were one PE is primary and the other * backup - VPP FIB does not support that case at this time. * * 3) eBGP PIC Edge; Traffic from CE3 to Y/16. On PE1 there is are routes; * Y/16 (and hundreds of thousands of others like it) * via CE1 (primary) * via PE2 (backup) * and * CE1 (this is an adj-fib) * via 11.0.0.1 Link0 (this is CE1) << this is an adj-fib * PE2 (PE2's loopback address) * via 10.0.5.5 Link1 (this is link PE1-PE2) * the failure is the loss of link0 to CE1. The failure can be detected by FIB * either as a link down event or by the control plane withdrawing the connected * prefix on the link0 (say 10.0.5.4/30). The latter works because the resolving * entry is an adj-fib, so removing the connected will withdraw the adj-fib, and * hence the recursive path becomes unresolved. The former is faster, * particularly in the case of Inter-AS option A where there are many VLAN * sub-interfaces on the PE-CE link, one for each VRF, and so the control plane * must remove the connected prefix for each sub-interface to trigger PIC in * each VRF. Note though that total PIC cutover time will depend on VRF scale * with either trigger. * Primary and backup paths in this eBGP PIC-edge scenario are calculated by * BGP. Each peer is configured to always advertise its best external path to * its iBGP peers. Backup paths therefore send traffic from the PE back into the * core to an alternate PE. A PE may have multiple external paths, i.e. multiple * directly connected CEs, it may also have multiple backup PEs, however there * is no correlation between the two, so unlike LFA-FRR, the redundancy model is * N-M; N primary paths are backed-up by M backup paths - only when all primary * paths fail, then the cutover is performed onto the M backup paths. Note that * PE2 must be suitably configured to forward traffic on its external path that * was received from PE1. VPP FIB does not support external-internal-BGP (eiBGP) * load-balancing. * * As with LFA-FRR the use of primary and backup paths is not currently * supported, however, the use of a recursive-multi-path-adj, and a suitably * constrained hashing algorithm to choose from the primary or backup path sets, * would again provide the necessary shared object and hence the prefix scale * independent cutover. * * Astute readers will recognise that both of the eBGP PIC scenarios refer only * to a BGP free core. * * Fast convergence implementation options come in two flavours: * 1) Insert switches into the data-path. The switch represents the protected * resource. If the switch is 'on' the primary path is taken, otherwise * the backup path is taken. Testing the switch in the data-path comes with * an associated performance cost. A given packet may encounter more than * one protected resource as it is forwarded. This approach minimises * cutover times as packets will be forwarded on the backup path as soon * as the protected resource is detected to be down and the single switch * is tripped. However, it comes at a performance cost, which increases * with each shared resource a packet encounters in the data-path. * This approach is thus best suited to LFA-FRR where the protected routes * are non-recursive (i.e. encounter few shared resources) and the * expectation on cutover times is more stringent (<50msecs). * 2) Update shared objects. Identify objects in the data-path, that are * required to be present whether or not fast convergence is required (i.e. * adjacencies) that can be shared by multiple routes. Create a dependency * between these objects at the protected resource. When the protected * resource fails, each of the shared objects is updated in a way that all * users of it see a consistent change. This approach incurs no performance * penalty as the data-path structure is unchanged, however, the cutover * times are longer as more work is required when the resource fails. This * scheme is thus more appropriate to recursive prefixes (where the packet * will encounter multiple protected resources) and to fast-convergence * technologies where the cutover times are less stringent (i.e. PIC). * * Implementation: * --------------- * * Due to the requirements outlined above, not all routes known to FIB * (e.g. adj-fibs) are installed in forwarding. However, should circumstances * change, those routes will need to be added. This adds the requirement that * a FIB maintains two tables per-VRF, per-AF (where a 'table' is indexed by * prefix); the forwarding and non-forwarding tables. * * For DP speed in VPP we want the lookup in the forwarding table to directly * result in the ADJ. So the two tables; one contains all the routes (a * lookup therein yields a fib_entry_t), the other contains only the forwarding * routes (a lookup therein yields an ip_adjacency_t). The latter is used by the * DP. * This trades memory for forwarding performance. A good trade-off in VPP's * expected operating environments. * * Note these tables are keyed only by the prefix (and since there 2 two * per-VRF, implicitly by the VRF too). The key for an adjacency is the * tuple:{next-hop, address (and it's AF), interface, link/ether-type}. * consider this curious, but allowed, config; * * set int ip addr 10.0.0.1/24 Gig0 * set ip arp Gig0 10.0.0.2 dead.dead.dead * # a host in that sub-net is routed via a better next hop (say it avoids a * # big L2 domain) * ip route add 10.0.0.2 Gig1 192.168.1.1 * # this recursive should go via Gig1 * ip route add 1.1.1.1/32 via 10.0.0.2 * # this non-recursive should go via Gig0 * ip route add 2.2.2.2/32 via Gig0 10.0.0.2 * * for the last route, the lookup for the path (via {Gig0, 10.0.0.2}) in the * prefix table would not yield the correct result. To fix this we need a * separate table for the adjacencies. * * - FIB data structures; * * fib_entry_t: * - a representation of a route. * - has a prefix. * - it maintains an array of path-lists that have been contributed by the * different sources * - install an adjacency in the forwarding table contributed by the best * source's path-list. * * fib_path_list_t: * - a list of paths * - path-lists may be shared between FIB entries. The path-lists are thus * kept in a DB. The key is the combined description of the paths. We share * path-lists when it will aid convergence to do so. Adding path-lists to * this DB that are never shared, or are not shared by prefixes that are * not subject to PIC, will increase the size of the DB unnecessarily and * may lead to increased search times due to hash collisions. * - the path-list contributes the appropriate adj for the entry in the * forwarding table. The adj can be 'normal', multi-path or recursive, * depending on the number of paths and their types. * - since path-lists are shared there is only one instance of the multi-path * adj that they [may] create. As such multi-path adjacencies do not need a * separate DB. * The path-list with recursive paths and the recursive adjacency that it * contributes forms the backbone of the fast convergence architecture (as * described previously). * * fib_path_t: * - a description of how to forward the traffic (i.e. via {Gig1, K}). * - the path describes the intent on how to forward. This differs from how * the path resolves. I.e. it might not be resolved at all (since the * interface is deleted or down). * - paths have different types, most notably recursive or non-recursive. * - a fib_path_t will contribute the appropriate adjacency object. It is from * these contributions that the DP graph/chain for the route is built. * - if the path is recursive and a recursion loop is detected, then the path * will contribute the special DROP adjacency. This way, whilst the control * plane graph is looped, the data-plane graph does not. * * we build a graph of these objects; * * fib_entry_t -> fib_path_list_t -> fib_path_t -> ... * * for recursive paths: * * fib_path_t -> fib_entry_t -> .... * * for non-recursive paths * * fib_path_t -> ip_adjacency_t -> interface * * These objects, which constitute the 'control plane' part of the FIB are used * to represent the resolution of a route. As a whole this is referred to as the * control plane graph. There is a separate DP graph to represent the forwarding * of a packet. In the DP graph each object represents an action that is applied * to a packet as it traverses the graph. For example, a lookup of a IP address * in the forwarding table could result in the following graph: * * recursive-adj --> multi-path-adj --> interface_A * --> interface_B * * A packet traversing this FIB DP graph would thus also traverse a VPP node * graph of: * * ipX_recursive --> ipX_rewrite --> interface_A_tx --> etc * * The taxonomy of objects in a FIB graph is as follows, consider; * * A --> * B --> D * C --> * * Where A,B and C are (for example) routes that resolve through D. * parent; D is the parent of A, B, and C. * children: A, B, and C are children of D. * sibling: A, B and C are siblings of one another. * * All shared objects in the FIB are reference counted. Users of these objects * are thus expected to use the add_lock/unlock semantics (as one would * normally use malloc/free). * * WALKS * * It is necessary to walk/traverse the graph forwards (entry to interface) to * perform a collapse or build a recursive adj and backwards (interface * to entry) to perform updates, i.e. when interface state changes or when * recursive route resolution updates occur. * A forward walk follows simply by navigating an object's parent pointer to * access its parent object. For objects with multiple parents (e.g. a * path-list), each parent is walked in turn. * To support back-walks direct dependencies are maintained between objects, * i.e. in the relationship, {A, B, C} --> D, then object D will maintain a list * of 'pointers' to its children {A, B, C}. Bare C-language pointers are not * allowed, so a pointer is described in terms of an object type (i.e. entry, * path-list, etc) and index - this allows the object to be retrieved from the * appropriate pool. A list is maintained to achieve fast convergence at scale. * When there are millions or recursive prefixes, it is very inefficient to * blindly walk the tables looking for entries that were affected by a given * topology change. The lowest hanging fruit when optimising is to remove * actions that are not required, so all back-walks only traverse objects that * are directly affected by the change. * * PIC Core and fast-reroute rely on FIB reacting quickly to an interface * state change to update the multi-path-adjacencies that use this interface. * An example graph is shown below: * * E_a --> * E_b --> PL_2 --> P_a --> Interface_A * ... --> P_c -\ * E_k --> \ * Interface_K * / * E_l --> / * E_m --> PL_1 --> P_d -/ * ... --> P_f --> Interface_F * E_z --> * * E = fib_entry_t * PL = fib_path_list_t * P = fib_path_t * The subscripts are arbitrary and serve only to distinguish object instances. * This CP graph result in the following DP graph: * * M-ADJ-2 --> Interface_A * \ * -> Interface_K * / * M-ADJ-1 --> Interface_F * * M-ADJ = multi-path-adjacency. * * When interface K goes down a back-walk is started over its dependants in the * control plane graph. This back-walk will reach PL_1 and PL_2 and result in * the calculation of new adjacencies that have interface K removed. The walk * will continue to the entry objects and thus the forwarding table is updated * for each prefix with the new adjacency. The DP graph then becomes: * * ADJ-3 --> Interface_A * * ADJ-4 --> Interface_F * * The eBGP PIC scenarios described above relied on the update of a path-list's * recursive-adjacency to provide the shared point of cutover. This is shown * below * * E_a --> * E_b --> PL_2 --> P_a --> E_44 --> PL_a --> P_b --> Interface_A * ... --> P_c -\ * E_k --> \ * \ * E_1 --> PL_k -> P_k --> Interface_K * / * E_l --> / * E_m --> PL_1 --> P_d -/ * ... --> P_f --> E_55 --> PL_e --> P_e --> Interface_E * E_z --> * * The failure scenario is the removal of entry E_1 and thus the paths P_c and * P_d become unresolved. To achieve PIC the two shared recursive path-lists, * PL_1 and PL_2 must be updated to remove E_1 from the recursive-multi-path- * adjacencies that they contribute, before any entry E_a to E_z is updated. * This means that as the update propagates backwards (right to left) in the * graph it must do so breadth first not depth first. Note this approach leads * to convergence times that are dependent on the number of path-list and so * the number of combinations of egress PEs - this is desirable as this * scale is considerably lower than the number of prefixes. * * If we consider another section of the graph that is similar to the one * shown above where there is another prefix E_2 in a similar position to E_1 * and so also has many dependent children. It is reasonable to expect that a * particular network failure may simultaneously render E_1 and E_2 unreachable. * This means that the update to withdraw E_2 is download immediately after the * update to withdraw E_1. It is a requirement on the FIB to not spend large * amounts of time in a back-walk whilst processing the update for E_1, i.e. the * back-walk must not reach as far as E_a and its siblings. Therefore, after the * back-walk has traversed one generation (breadth first) to update all the * path-lists it should be suspended/back-ground and further updates allowed * to be handled. Once the update queue is empty, the suspended walks can be * resumed. Note that in the case that multiple updates affect the same entry * (say E_1) then this will trigger multiple similar walks, these are merged, * so each child is updated only once. * In the presence of more layers of recursion PIC is still a desirable * feature. Consider an extension to the diagram above, where more recursive * routes (E_100 -> E_200) are added as children of E_a: * * E_100 --> * E_101 --> PL_3 --> P_j-\ * ... \ * E_199 --> E_a --> * E_b --> PL_2 --> P_a --> E_44 --> ...etc.. * ... --> P_c -\ * E_k \ * E_1 --> ...etc.. * / * E_l --> / * E_m --> PL_1 --> P_d -/ * ... --> P_e --> E_55 --> ...etc.. * E_z --> * * To achieve PIC for the routes E_100->E_199, PL_3 needs to be updated before * E_b -> E_z, a breadth first traversal at each level would not achieve this. * Instead the walk must proceed intelligently. Children on PL_2 are sorted so * those Entry objects that themselves have children appear first in the list, * those without later. When an entry object is walked that has children, a * walk of its children is pushed to the front background queue. The back * ground queue is a priority queue. As the breadth first traversal proceeds * across the dependent entry object E_a to E_k, when the first entry that does * not have children is reached (E_b), the walk is suspended and placed at the * back of the queue. Following this prioritisation method shared path-list * updates are performed before all non-resolving entry objects. * The CPU/core/thread that handles the updates is the same thread that handles * the back-walks. Handling updates has a higher priority than making walk * progress, so a walk is required to be interruptable/suspendable when new * updates are available. * !!! TODO - this section describes how walks should be not how they are !!! * * In the diagram above E_100 is an IP route, however, VPP has no restrictions * on the type of object that can be a dependent of a FIB entry. Children of * a FIB entry can be (and are) GRE & VXLAN tunnels endpoints, L2VPN LSPs etc. * By including all object types into the graph and extending the back-walk, we * can thus deliver fast convergence to technologies that overlay on an IP * network. * * If having read all the above carefully you are still thinking; 'i don't need * all this %&$* i have a route only I know about and I just need to jam it in', * then fib_table_entry_special_add() is your only friend. */ #ifndef __FIB_H__ #define __FIB_H__ #include <vnet/fib/fib_table.h> #include <vnet/fib/fib_entry.h> #endif
725dea6191469fd7fe735379a6703ce8e1f4fc51
3b955b6c1122d6caea1175b24bea7b22aa5b9069
/libs/libtim/interface/xskin_c.c
b97cdf1fd11686b2008f6f2853f50d389c4f8c7c
[]
no_license
yoyofr/modizer
52930c995424c6243859008d1b5e84b5fcda1aa4
68457a14344208bf1ca1660b3952aa59dff3aaea
refs/heads/master
2023-04-30T00:43:18.365195
2023-04-17T08:47:41
2023-04-17T08:47:41
3,095,707
110
43
null
2021-03-20T17:29:09
2012-01-03T17:06:30
C
UTF-8
C
false
false
13,425
c
xskin_c.c
/* TiMidity++ -- MIDI to WAVE converter and player Copyright (C) 1999-2004 Masanao Izumo <iz@onicos.co.jp> Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi> 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA xskin interface by Daisuke nagano <breeze_geo@geocities.co.jp> */ #ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <math.h> #include <sys/time.h> #ifndef NO_STRING_H #include <string.h> #else #include <strings.h> #endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif /* HAVE_UNISTD_H */ #include "timidity.h" #include "common.h" #include "instrum.h" #include "playmidi.h" #include "readmidi.h" #include "output.h" #include "controls.h" #include "miditrace.h" #include "xskin.h" #define MSGWINDOW static void ctl_total_time(int tt); static void ctl_master_volume(int mv); static void ctl_current_time(int secs, int v); static void ctl_lyric(int lyricid); static int ctl_open(int using_stdin, int using_stdout); static void ctl_close(void); static int ctl_read(int32 *valp); static int cmsg(int type, int verbosity_level, char *fmt, ...); static int ctl_pass_playing_list(int number_of_files, char *list_of_files[]); static void ctl_event(CtlEvent *e); static void ctl_speana_data(double *val, int size); static void initialize_exp_hz_table( void ); static void xskin_pipe_open(void); void xskin_pipe_write(char *); static int xskin_pipe_ready(void); int xskin_pipe_read(char *,int); static int isspeanaenabled; static unsigned char *speana_buf; static double exp_hz_table[SPE_W+1]; static int xskin_ready = 0; #define FFTSIZE 1024 /* same as "soudspec.c" */ #define NCOLOR 64 /* same as "soudspec.c" */ #define DEFAULT_ZOOM (44100.0/1024.0*4.0) /* tekito---- */ #define CTL_LAST_STATUS -1 /**********************************************/ /* export the interface functions */ #define ctl xskin_control_mode ControlMode ctl= { "skin interface", 'i', "skin", 1,0,0, 0, ctl_open, ctl_close, ctl_pass_playing_list, ctl_read, NULL, cmsg, ctl_event }; static char local_buf[300]; static int pipe_in_fd,pipe_out_fd=-1; /***********************************************************************/ /* Put controls on the pipe */ /***********************************************************************/ static int cmsg(int type, int verbosity_level, char *fmt, ...) { va_list ap; if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) && ctl.verbosity<verbosity_level) return 0; va_start(ap, fmt); #ifdef MSGWINDOW if(!xskin_ready) #endif { vfprintf(stderr, fmt, ap); fprintf(stderr, NLS); va_end(ap); return 0; } vsnprintf(local_buf+2,100,fmt,ap); if(pipe_out_fd==-1) { fputs(local_buf + 2, stderr); fputs(NLS, stderr); } else { local_buf[0]='L'; local_buf[1]=' '; xskin_pipe_write(local_buf); } va_end(ap); return 0; } /*ARGSUSED*/ static void ctl_total_time(int tt) { static int previous_total_time=-1; int sec,min; sec=tt/play_mode->rate; min = sec/60; sec-= min*60; if ( tt!=previous_total_time ) { previous_total_time=tt; sprintf(local_buf,"A %d",min*60+sec); xskin_pipe_write(local_buf); } return; } /*ARGSUSED*/ static void ctl_master_volume(int mv) { static int lastvol = CTL_LAST_STATUS; if ( mv != lastvol ) { if ( mv == CTL_LAST_STATUS ) mv = lastvol; else lastvol = mv; sprintf( local_buf, "V %d", mv ); xskin_pipe_write(local_buf); } return; } static void ctl_current_time(int sec, int v) { static int previous_sec=-1; if (sec!=previous_sec) { previous_sec=sec; sprintf(local_buf,"T %02d:%02d",sec/60,sec%60); xskin_pipe_write(local_buf); } } static void ctl_lyric(int lyricid) { char *lyric; static int lyric_col = 2; static char lyric_buf[300]; lyric = event2string(lyricid); if(lyric != NULL) { if(lyric[0] == ME_KARAOKE_LYRIC) { if(lyric[1] == '/' || lyric[1] == '\\') { lyric_buf[0] = 'L'; lyric_buf[1] = ' '; snprintf(lyric_buf + 2, sizeof (lyric_buf) - 2, "%s", lyric + 2); xskin_pipe_write(lyric_buf); lyric_col = strlen(lyric + 2) + 2; } else if(lyric[1] == '@') { lyric_buf[0] = 'L'; lyric_buf[1] = ' '; if(lyric[2] == 'L') snprintf(lyric_buf + 2, sizeof (lyric_buf) - 2, "Language: %s", lyric + 3); else if(lyric[2] == 'T') snprintf(lyric_buf + 2, sizeof (lyric_buf) - 2, "Title: %s", lyric + 3); else snprintf(lyric_buf + 2, sizeof (lyric_buf) - 2, "%s", lyric + 1); xskin_pipe_write(lyric_buf); } else { lyric_buf[0] = 'L'; lyric_buf[1] = ' '; snprintf(lyric_buf + lyric_col, sizeof (lyric_buf) - lyric_col, "%s", lyric + 1); xskin_pipe_write(lyric_buf); lyric_col += strlen(lyric + 1); } } else { if(lyric[0] == ME_CHORUS_TEXT || lyric[0] == ME_INSERT_TEXT) lyric_col = 0; snprintf(lyric_buf + lyric_col, sizeof (lyric_buf) - lyric_col, "%s", lyric + 1); xskin_pipe_write(lyric_buf); } } } static void ctl_speana_data(double *val, int size) { /* 0 <= val[n] <= (AMP*NCOLOR) */ /* AMP and NCOLOR are defined in soundspec.c */ /* By default, AMP*NCOLOR = 1.0*64 */ /* size = FFTSIZE/2 = 512 */ /* FFTSIZE is also defined in soundspec.c */ /* val[n] is the value of FFTed audio data */ #ifdef SUPPORT_SOUNDSPEC int i; int tx,x; double px; double s,a; int n; if ( isspeanaenabled ) { px=0.0; speana_buf[0] = (unsigned char)val[0]; for ( i=1 ; i<SPE_W-1 ; i++ ) { s=0.0; n=0; tx=exp_hz_table[i]; x=(int)px; do { a=val[x]; s += a + (tx-x)*(val[x+1]-a); n++; x++; } while ( x<tx ); s/=n; s*=16; if ( s<0 ) s=0; if ( s>=NCOLOR ) s=NCOLOR-1; speana_buf[i] = (unsigned char)(256*s/NCOLOR); px=tx; } speana_buf[SPE_W-1] = val[FFTSIZE/2-1]; xskin_pipe_write( "W" ); } #endif /* SUPPORT_SOUNDSPEC */ return; } /*ARGSUSED*/ static int ctl_open(int using_stdin, int using_stdout) { ctl.opened=1; initialize_exp_hz_table(); /* The child process won't come back from this call */ xskin_pipe_open(); return 0; } static void ctl_close(void) { if (ctl.opened) { xskin_pipe_write("Q"); ctl.opened=0; pipe_out_fd=-1; xskin_ready = 0; } } static int exitflag=0,randomflag=0,repeatflag=0,selectflag=0; /*ARGSUSED*/ static int ctl_blocking_read(int32 *valp /* Now, valp is not used */ ) { xskin_pipe_read(local_buf,sizeof(local_buf)); for (;;) { switch (local_buf[0]) { case 'P' : return RC_LOAD_FILE; case 'U' : return RC_TOGGLE_PAUSE; case 'S' : return RC_QUIT; case 'N' : return RC_NEXT; case 'B' : return RC_REALLY_PREVIOUS; case 'R' : repeatflag=atoi(local_buf+2);return RC_NONE; case 'D' : randomflag=atoi(local_buf+2);return RC_QUIT; case 'L' : selectflag=atoi(local_buf+2);return RC_QUIT; case 'V' : *valp =atoi(local_buf+2);return RC_CHANGE_VOLUME; #ifdef SUPPORT_SOUNDSPEC case 'W' : return RC_TOGGLE_CTL_SPEANA; #endif case 'Q' : default : exitflag=1;return RC_QUIT; } } } static int ctl_read(int32 *valp) { if (xskin_pipe_ready()<=0) return RC_NONE; return ctl_blocking_read(valp); } static void shuffle(int n,int *a) { int i,j,tmp; for (i=0;i<n;i++) { j=int_rand(n); tmp=a[i]; a[i]=a[j]; a[j]=tmp; } } static int ctl_pass_playing_list(int number_of_files, char *list_of_files[]) { int current_no,command,i; int32 val; int *file_table; char **titles; char *p; /* Wait prepare 'interface' */ xskin_pipe_read(local_buf,sizeof(local_buf)); if (strcmp("READY",local_buf)) return; xskin_ready = 1; /* receive shared memory buffer */ xskin_pipe_read(local_buf, sizeof(local_buf)); if (strcmp("ERROR",local_buf)) { int shmid; isspeanaenabled=1; shmid = atoi(local_buf); speana_buf = (unsigned char *)shmat(shmid,0,0); } else { isspeanaenabled=0; } /* Make title string */ titles=(char **)safe_malloc(number_of_files*sizeof(char *)); for (i=0;i<number_of_files;i++) { p=strrchr(list_of_files[i],'/'); if (p==NULL) { p=list_of_files[i]; } else p++; sprintf(local_buf,"%d. %s",i+1,p); titles[i]=(char *)safe_malloc(strlen(local_buf)+1); strcpy(titles[i],local_buf); } /* Send title string */ sprintf(local_buf,"%d",number_of_files); xskin_pipe_write(local_buf); for (i=0;i<number_of_files;i++) xskin_pipe_write(titles[i]); /* Make the table of play sequence */ file_table=(int *)safe_malloc(number_of_files*sizeof(int)); for (i=0;i<number_of_files;i++) file_table[i]=i; /* Draw the title of the first file */ current_no=0; sprintf(local_buf,"F %s",titles[file_table[0]]); xskin_pipe_write(local_buf); command=ctl_blocking_read(&val); /* Main loop */ for (;;) { /* Play file */ if (command==RC_LOAD_FILE) { sprintf(local_buf,"F %s",titles[file_table[current_no]]); xskin_pipe_write(local_buf); command=play_midi_file(list_of_files[file_table[current_no]]); } else { /* Quit timidity*/ if (exitflag) return 0; /* Stop playing */ if (command==RC_QUIT) { sprintf(local_buf,"T 00:00"); xskin_pipe_write(local_buf); /* Shuffle the table */ if (randomflag) { current_no=0; if (randomflag==1) { shuffle(number_of_files,file_table); randomflag=0; command=RC_LOAD_FILE; continue; } randomflag=0; for (i=0;i<number_of_files;i++) file_table[i]=i; sprintf(local_buf,"F %s",titles[file_table[current_no]]); xskin_pipe_write(local_buf); } /* Play the selected file */ if (selectflag) { for (i=0;i<number_of_files;i++) if (file_table[i]==selectflag-1) break; if (i!=number_of_files) current_no=i; selectflag=0; command=RC_LOAD_FILE; continue; } /* After the all file played */ } else if (command==RC_TUNE_END || command==RC_ERROR) { if (current_no+1<number_of_files) { current_no++; command=RC_LOAD_FILE; continue; /* Repeat */ } else if (repeatflag) { current_no=0; command=RC_LOAD_FILE; continue; /* Off the play button */ } else { xskin_pipe_write("O"); } /* Play the next */ } else if (command==RC_NEXT) { if (current_no+1<number_of_files) current_no++; command=RC_LOAD_FILE; continue; /* Play the previous */ } else if (command==RC_REALLY_PREVIOUS) { if (current_no>0) current_no--; command=RC_LOAD_FILE; continue; } command=ctl_blocking_read(&val); } } return 0; } /* ------ Pipe handlers ----- */ extern void xskin_start_interface(int); static void xskin_pipe_open(void) { int cont_inter[2],inter_cont[2]; if (pipe(cont_inter)<0 || pipe(inter_cont)<0) exit(1); if (fork()==0) { close(cont_inter[1]); close(inter_cont[0]); pipe_in_fd=cont_inter[0]; pipe_out_fd=inter_cont[1]; xskin_start_interface(pipe_in_fd); } close(cont_inter[0]); close(inter_cont[1]); pipe_in_fd=inter_cont[0]; pipe_out_fd=cont_inter[1]; } void xskin_pipe_write(char *buf) { write(pipe_out_fd,buf,strlen(buf)); write(pipe_out_fd,"\n",1); } static int xskin_pipe_ready(void) { fd_set fds; static struct timeval tv; int cnt; FD_ZERO(&fds); FD_SET(pipe_in_fd,&fds); tv.tv_sec=0; tv.tv_usec=0; if((cnt=select(pipe_in_fd+1,&fds,NULL,NULL,&tv))<0) return -1; return cnt > 0 && FD_ISSET(pipe_in_fd, &fds) != 0; } int xskin_pipe_read(char *buf,int bufsize) { int i; bufsize--; for (i=0;i<bufsize;i++) { read(pipe_in_fd,buf+i,1); if (buf[i]=='\n') break; } buf[i]=0; return 0; } int xskin_pipe_read_direct(int32 *buf, int bufsize) { read( pipe_in_fd, buf, bufsize ); return 0; } static void ctl_event(CtlEvent *e) { switch(e->type) { case CTLE_PLAY_START: ctl_total_time((int)e->v1); break; case CTLE_CURRENT_TIME: ctl_current_time((int)e->v1, (int)e->v2); break; case CTLE_MASTER_VOLUME: ctl_master_volume((int)e->v1); break; case CTLE_LYRIC: ctl_lyric((int)e->v1); break; #ifdef SUPPORT_SOUNDSPEC case CTLE_SPEANA: ctl_speana_data((double *)e->v1, (int)e->v2); break; #endif /* SUPPORT_SOUNDSPEC */ } } /* * interface_<id>_loader(); */ ControlMode *interface_i_loader(void) { return &ctl; } static void initialize_exp_hz_table( void ) { int i; double r, x, w; w = (double)play_mode->rate * 0.5 / DEFAULT_ZOOM; r = exp(log(w) * (1.0/SPE_W)); w = (FFTSIZE/2.0) / (w - 1.0); for(i = 0, x = 1.0; i <= SPE_W; i++, x *= r) exp_hz_table[i] = (x - 1.0) * w; }
444f565e9a9a074b8b9aa1577cb9bed32013b778
f0a2768eee431c20ea9f4c2c589fdb7ea878f62f
/platform/pmfx.h
3f34de69f74d597dc7c297e13e734070cb9411a4
[ "MIT" ]
permissive
polymonster/pmfx-shader
5c7f58f8325e7ce1d8c41bc76d9d261b23b01921
86e04a766885f3ac9946af0b14c9e500d2671a7d
refs/heads/master
2023-07-07T08:30:21.884207
2023-07-02T10:50:40
2023-07-02T10:50:40
195,820,234
337
13
MIT
2023-04-19T10:09:16
2019-07-08T13:43:01
Python
UTF-8
C
false
false
215
h
pmfx.h
#define chebyshev_normalize( V ) (V.xyz / max( max(abs(V.x), abs(V.y)), abs(V.z) )) #define max3(v) max(max(v.x, v.y),v.z) #define max4(v) max(max(max(v.x, v.y),v.z), v.w) #define PI 3.14159265358979323846264
215dd1515b19c93e5ed5b1930022cd43ea51318c
33377c4d113cf9ea1338077af6bd645f3c5796b3
/extensions/android/ringlibsdl/project/jni/freetype-2.4.12/src/autofit/afglobal.c
bcdec50e30890641769f19f46fe7ecea693adc9b
[ "LicenseRef-scancode-free-unknown", "MIT", "FTL" ]
permissive
ring-lang/ring
56f55111f751b0274d4f588871f806a8c2734dea
2081d2efb41c9dacd49b7a6944b9ca332638ba64
refs/heads/master
2023-09-04T16:54:44.309452
2023-09-03T10:28:57
2023-09-03T10:28:57
54,633,811
1,360
555
MIT
2023-08-03T01:48:24
2016-03-24T10:29:27
C
UTF-8
C
false
false
8,416
c
afglobal.c
/***************************************************************************/ /* */ /* afglobal.c */ /* */ /* Auto-fitter routines to compute global hinting values (body). */ /* */ /* Copyright 2003-2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "afglobal.h" #include "afdummy.h" #include "aflatin.h" #include "afcjk.h" #include "afindic.h" #include "afpic.h" #include "aferrors.h" #ifdef FT_OPTION_AUTOFIT2 #include "aflatin2.h" #endif #ifndef FT_CONFIG_OPTION_PIC /* when updating this table, don't forget to update */ /* AF_SCRIPT_CLASSES_COUNT and autofit_module_class_pic_init */ /* populate this list when you add new scripts */ static AF_ScriptClass const af_script_classes[] = { &af_dummy_script_class, #ifdef FT_OPTION_AUTOFIT2 &af_latin2_script_class, #endif &af_latin_script_class, &af_cjk_script_class, &af_indic_script_class, NULL /* do not remove */ }; #endif /* !FT_CONFIG_OPTION_PIC */ /* Compute the script index of each glyph within a given face. */ static FT_Error af_face_globals_compute_script_coverage( AF_FaceGlobals globals ) { FT_Error error = FT_Err_Ok; FT_Face face = globals->face; FT_CharMap old_charmap = face->charmap; FT_Byte* gscripts = globals->glyph_scripts; FT_UInt ss; FT_UInt i; /* the value AF_SCRIPT_NONE means `uncovered glyph' */ FT_MEM_SET( globals->glyph_scripts, AF_SCRIPT_NONE, globals->glyph_count ); error = FT_Select_Charmap( face, FT_ENCODING_UNICODE ); if ( error ) { /* * Ignore this error; we simply use the fallback script. * XXX: Shouldn't we rather disable hinting? */ error = FT_Err_Ok; goto Exit; } /* scan each script in a Unicode charmap */ for ( ss = 0; AF_SCRIPT_CLASSES_GET[ss]; ss++ ) { AF_ScriptClass clazz = AF_SCRIPT_CLASSES_GET[ss]; AF_Script_UniRange range; if ( clazz->script_uni_ranges == NULL ) continue; /* * Scan all Unicode points in the range and set the corresponding * glyph script index. */ for ( range = clazz->script_uni_ranges; range->first != 0; range++ ) { FT_ULong charcode = range->first; FT_UInt gindex; gindex = FT_Get_Char_Index( face, charcode ); if ( gindex != 0 && gindex < (FT_ULong)globals->glyph_count && gscripts[gindex] == AF_SCRIPT_NONE ) gscripts[gindex] = (FT_Byte)ss; for (;;) { charcode = FT_Get_Next_Char( face, charcode, &gindex ); if ( gindex == 0 || charcode > range->last ) break; if ( gindex < (FT_ULong)globals->glyph_count && gscripts[gindex] == AF_SCRIPT_NONE ) gscripts[gindex] = (FT_Byte)ss; } } } /* mark ASCII digits */ for ( i = 0x30; i <= 0x39; i++ ) { FT_UInt gindex = FT_Get_Char_Index( face, i ); if ( gindex != 0 && gindex < (FT_ULong)globals->glyph_count ) gscripts[gindex] |= AF_DIGIT; } Exit: /* * By default, all uncovered glyphs are set to the fallback script. * XXX: Shouldn't we disable hinting or do something similar? */ if ( globals->module->fallback_script != AF_SCRIPT_NONE ) { FT_Long nn; for ( nn = 0; nn < globals->glyph_count; nn++ ) { if ( ( gscripts[nn] & ~AF_DIGIT ) == AF_SCRIPT_NONE ) { gscripts[nn] &= ~AF_SCRIPT_NONE; gscripts[nn] |= globals->module->fallback_script; } } } FT_Set_Charmap( face, old_charmap ); return error; } FT_LOCAL_DEF( FT_Error ) af_face_globals_new( FT_Face face, AF_FaceGlobals *aglobals, AF_Module module ) { FT_Error error; FT_Memory memory; AF_FaceGlobals globals = NULL; memory = face->memory; if ( FT_ALLOC( globals, sizeof ( *globals ) + face->num_glyphs * sizeof ( FT_Byte ) ) ) goto Exit; globals->face = face; globals->glyph_count = face->num_glyphs; globals->glyph_scripts = (FT_Byte*)( globals + 1 ); globals->module = module; error = af_face_globals_compute_script_coverage( globals ); if ( error ) { af_face_globals_free( globals ); globals = NULL; } globals->increase_x_height = AF_PROP_INCREASE_X_HEIGHT_MAX; Exit: *aglobals = globals; return error; } FT_LOCAL_DEF( void ) af_face_globals_free( AF_FaceGlobals globals ) { if ( globals ) { FT_Memory memory = globals->face->memory; FT_UInt nn; for ( nn = 0; nn < AF_SCRIPT_MAX; nn++ ) { if ( globals->metrics[nn] ) { AF_ScriptClass clazz = AF_SCRIPT_CLASSES_GET[nn]; FT_ASSERT( globals->metrics[nn]->clazz == clazz ); if ( clazz->script_metrics_done ) clazz->script_metrics_done( globals->metrics[nn] ); FT_FREE( globals->metrics[nn] ); } } globals->glyph_count = 0; globals->glyph_scripts = NULL; /* no need to free this one! */ globals->face = NULL; FT_FREE( globals ); } } FT_LOCAL_DEF( FT_Error ) af_face_globals_get_metrics( AF_FaceGlobals globals, FT_UInt gindex, FT_UInt options, AF_ScriptMetrics *ametrics ) { AF_ScriptMetrics metrics = NULL; FT_UInt gidx; AF_ScriptClass clazz; FT_UInt script = options & 15; const FT_Offset script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) / sizeof ( AF_SCRIPT_CLASSES_GET[0] ); FT_Error error = FT_Err_Ok; if ( gindex >= (FT_ULong)globals->glyph_count ) { error = FT_THROW( Invalid_Argument ); goto Exit; } gidx = script; if ( gidx == 0 || gidx + 1 >= script_max ) gidx = globals->glyph_scripts[gindex] & AF_SCRIPT_NONE; clazz = AF_SCRIPT_CLASSES_GET[gidx]; if ( script == 0 ) script = clazz->script; metrics = globals->metrics[clazz->script]; if ( metrics == NULL ) { /* create the global metrics object if necessary */ FT_Memory memory = globals->face->memory; if ( FT_ALLOC( metrics, clazz->script_metrics_size ) ) goto Exit; metrics->clazz = clazz; metrics->globals = globals; if ( clazz->script_metrics_init ) { error = clazz->script_metrics_init( metrics, globals->face ); if ( error ) { if ( clazz->script_metrics_done ) clazz->script_metrics_done( metrics ); FT_FREE( metrics ); goto Exit; } } globals->metrics[clazz->script] = metrics; } Exit: *ametrics = metrics; return error; } FT_LOCAL_DEF( FT_Bool ) af_face_globals_is_digit( AF_FaceGlobals globals, FT_UInt gindex ) { if ( gindex < (FT_ULong)globals->glyph_count ) return (FT_Bool)( globals->glyph_scripts[gindex] & AF_DIGIT ); return (FT_Bool)0; } /* END */
ef1e48465145989c569335f385f303e24dbaa167
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/kern/kern_crashme.c
4dc60cacad003b7b31316b178f559288821f3ff3
[]
no_license
NetBSD/src
1a9cbc22ed778be638b37869ed4fb5c8dd616166
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
refs/heads/trunk
2023-08-31T13:24:58.105962
2023-08-27T15:50:47
2023-08-27T15:50:47
88,439,547
656
348
null
2023-07-20T20:07:24
2017-04-16T20:03:43
null
UTF-8
C
false
false
8,855
c
kern_crashme.c
/* $NetBSD: kern_crashme.c,v 1.11 2023/07/07 12:34:26 riastradh Exp $ */ /* * Copyright (c) 2018, 2019 Matthew R. Green * All rights reserved. * * 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. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. */ /* * kern_crashme.c: special debugging routines, designed for debugging * kernel crashes. * * supports crashme sysctl nodes, to test various ways the system can * panic or crash. you can add and remove nodes. */ #ifdef _KERNEL_OPT #include "opt_ddb.h" #endif #include <sys/param.h> #include <sys/sysctl.h> #include <sys/systm.h> #include <sys/kthread.h> #include <sys/kmem.h> #include <sys/mutex.h> #include <sys/crashme.h> #include <sys/intr.h> #ifdef DDB #include <ddb/ddb.h> #endif #define DPRINTF(fmt, ...) \ printf("%s:%d: " fmt "\n", __func__, __LINE__, ## __VA_ARGS__) static int crashme_sysctl_forwarder(SYSCTLFN_PROTO); static int crashme_panic(int); static int crashme_null_deref(int); static int crashme_null_jump(int); #ifdef DDB static int crashme_ddb(int); #endif #ifdef LOCKDEBUG static int crashme_kernel_lock_spinout(int); #endif static int crashme_mutex_recursion(int); static int crashme_spl_spinout(int); static int crashme_kpreempt_spinout(int); #define CMNODE(name, lname, func) \ { \ .cn_name = name, \ .cn_longname = lname, \ .cn_fn = func, \ } static crashme_node nodes[] = { CMNODE("panic", "plain old panic", crashme_panic), CMNODE("null_deref", "null dereference", crashme_null_deref), CMNODE("null_jump", "jump to null", crashme_null_jump), #ifdef DDB CMNODE("ddb", "enter ddb directly", crashme_ddb), #endif #ifdef LOCKDEBUG CMNODE("kernel_lock_spinout", "infinite loop under kernel lock", crashme_kernel_lock_spinout), #endif CMNODE("mutex_recursion", "enter the same mutex twice", crashme_mutex_recursion), CMNODE("spl_spinout", "infinite loop at raised spl", crashme_spl_spinout), CMNODE("kpreempt_spinout", "infinite loop with kpreempt disabled", crashme_kpreempt_spinout), }; static crashme_node *first_node; static kmutex_t crashme_lock; static int crashme_root = -1; static bool crashme_enable = 0; /* * add a crashme node dynamically. return -1 on failure, 0 on success. */ int crashme_add(crashme_node *ncn) { int rv = -1; crashme_node *cn; crashme_node *last = NULL; const struct sysctlnode *cnode; if (crashme_root == -1) return -1; mutex_enter(&crashme_lock); for (cn = first_node; cn; last = cn, cn = cn->cn_next) { if (strcmp(cn->cn_name, ncn->cn_name) == 0) break; } if (!cn) { ncn->cn_next = NULL; rv = sysctl_createv(NULL, 0, NULL, &cnode, CTLFLAG_PERMANENT | CTLFLAG_READWRITE, CTLTYPE_INT, ncn->cn_name, SYSCTL_DESCR(ncn->cn_longname), crashme_sysctl_forwarder, 0, NULL, 0, CTL_DEBUG, crashme_root, CTL_CREATE, CTL_EOL); /* don't insert upon failure */ if (rv == 0) { ncn->cn_sysctl = cnode->sysctl_num; if (last) last->cn_next = ncn; if (first_node == NULL) first_node = ncn; } } mutex_exit(&crashme_lock); return rv == 0 ? 0 : -1; } /* * remove a crashme node. return -1 on failure, 0 on success. */ int crashme_remove(crashme_node *rcn) { crashme_node *cn, *prev = NULL; mutex_enter(&crashme_lock); for (cn = first_node; cn; prev = cn, cn = cn->cn_next) { int rv; if (cn != rcn) continue; if (cn == first_node) first_node = cn->cn_next; if (prev) prev->cn_next = cn->cn_next; if ((rv = sysctl_destroyv(NULL, CTL_DEBUG, crashme_root, cn->cn_sysctl, CTL_EOL)) == 0) printf("%s: unable to remove %s from sysctl\n", __func__, cn->cn_name); break; } mutex_exit(&crashme_lock); if (cn == NULL) return -1; return 0; } /* * list or execute a crashme node */ static int crashme_sysctl_forwarder(SYSCTLFN_ARGS) { struct sysctlnode node; crashme_node *cn; int error, arg = 0; for (cn = first_node; cn; cn = cn->cn_next) { if (cn->cn_sysctl == rnode->sysctl_num) break; } if (!cn) { return EINVAL; } node = *rnode; node.sysctl_data = &arg; error = sysctl_lookup(SYSCTLFN_CALL(&node)); if (error || newp == NULL) return (error); if (!crashme_enable) return EACCES; DPRINTF("invoking \"%s\" (%s)", cn->cn_name, cn->cn_longname); if ((*cn->cn_fn)(arg) != 0) panic("crashme on %s failed!\n", cn->cn_name); return 0; } /* * register the various nodes with sysctl. */ SYSCTL_SETUP(selfdebug_crashme, "sysctl crashme setup") { const struct sysctlnode *rnode; int rv; size_t n; mutex_init(&crashme_lock, MUTEX_DEFAULT, IPL_NONE); KASSERT(crashme_root == -1); rv = sysctl_createv(NULL, 0, NULL, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "crashme", SYSCTL_DESCR("Crashme options"), NULL, 0, NULL, 0, CTL_DEBUG, CTL_CREATE, CTL_EOL); if (rv != 0) { printf("%s: failed to create sysctl debug.crashme: %d\n", __func__, rv); return; } crashme_root = rnode->sysctl_num; rv = sysctl_createv(NULL, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_BOOL, "crashme_enable", SYSCTL_DESCR("Enable crashme"), NULL, 0, &crashme_enable, 0, CTL_DEBUG, CTL_CREATE, CTL_EOL); if (rv != 0) printf("%s: failed to create sysctl debug.crashme_enable:" " %d\n", __func__, rv); for (n = 0; n < __arraycount(nodes); n++) { if (crashme_add(&nodes[n])) printf("%s: failed to create sysctl" " debug.crashme.%s\n", __func__, nodes[n].cn_name); } } /* * actual panic functions below */ static int crashme_panic(int flags) { panic("crashme plain old panic"); return -1; } static int crashme_null_deref(int flags) { *(volatile char *)0 = 0; return -1; } static int crashme_null_jump(int flags) { void (*volatile f)(int) = NULL; (*f)(flags); /* make sure to have a nontrivial return address here */ return -1; } #ifdef DDB static int crashme_ddb(int flags) { Debugger(); return 0; } #endif #ifdef LOCKDEBUG static int crashme_kernel_lock_spinout(int flags) { KERNEL_LOCK(1, NULL); for (;;) __insn_barrier(); KERNEL_UNLOCK_ONE(NULL); return 0; } #endif static int crashme_mutex_recursion(int flags) { kmutex_t crashme_spinlock; switch (flags) { case 0: return 0; case 1: default: /* * printf makes the return address of the first * mutex_enter call a little more obvious, so the line * number of the _return address_ for the first * mutex_enter doesn't confusingly point at the second * mutex_enter. */ mutex_enter(&crashme_lock); printf("%s: locked once\n", __func__); mutex_enter(&crashme_lock); printf("%s: locked twice\n", __func__); return -1; case 2: mutex_init(&crashme_spinlock, MUTEX_DEFAULT, IPL_VM); printf("%s: initialized\n", __func__); mutex_enter(&crashme_spinlock); printf("%s: locked once\n", __func__); mutex_enter(&crashme_spinlock); printf("%s: locked twice\n", __func__); return -1; } } static int crashme_spl_spinout(int flags) { int s; printf("%s: raising ipl to %d\n", __func__, flags); s = splraiseipl(makeiplcookie(flags)); printf("%s: raised ipl to %d, s=%d\n", __func__, flags, s); for (;;) __insn_barrier(); printf("%s: exited infinite loop!?\n", __func__); splx(s); printf("%s: lowered ipl to s=%d\n", __func__, s); return 0; } static int crashme_kpreempt_spinout(int flags) { kpreempt_disable(); printf("%s: disabled kpreemption\n", __func__); for (;;) __insn_barrier(); printf("%s: exited infinite loop!?\n", __func__); kpreempt_enable(); printf("%s: re-enabled kpreemption\n", __func__); return 0; }
e8bcd75ed3152d9ca73cd2cbfc1e2024a67aa8be
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/x11/xtar/patches/patch-common_pipe.c
344b8362bd52dbf3a803e05c7c1a467a8af15780
[]
no_license
NetBSD/pkgsrc
a0732c023519650ef821ab89c23ab6ab59e25bdb
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
refs/heads/trunk
2023-09-01T07:40:12.138283
2023-09-01T05:25:19
2023-09-01T05:25:19
88,439,572
321
138
null
2023-07-12T22:34:14
2017-04-16T20:04:15
null
UTF-8
C
false
false
365
c
patch-common_pipe.c
$NetBSD: patch-common_pipe.c,v 1.2 2022/01/07 13:02:31 nia Exp $ - Fix implicit declaration warnings. --- common/pipe.c.orig 1995-05-09 08:06:46.000000000 +0000 +++ common/pipe.c @@ -23,7 +23,10 @@ #include <errno.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <fcntl.h> +#include <unistd.h> #include "magic.h" #include "str.h"
8bf42d00ad6314e2e7564aa6be84bbf10e7a4c1f
e3a97b316fdf07b170341da206163a865f9e812c
/sprokit/processes/examples/process_template/template_type_traits.h
791bae2ee0b7cc4eb84fda0052e436d2859f6362
[ "BSD-3-Clause" ]
permissive
Kitware/kwiver
09133ede9d05c33212839cc29d396aa8ca21baaf
a422409b83f78f31cda486e448e8009513e75427
refs/heads/master
2023-08-28T10:41:58.077148
2023-07-28T21:18:52
2023-07-28T21:18:52
23,229,909
191
92
NOASSERTION
2023-06-26T17:18:20
2014-08-22T15:22:20
C++
UTF-8
C
false
false
2,352
h
template_type_traits.h
// This file is part of KWIVER, and is distributed under the // OSI-approved BSD 3-Clause License. See top-level LICENSE file or // https://github.com/Kitware/kwiver/blob/master/LICENSE for details. //++ rename include guard based on the applicatiopn #ifndef TEMPLATE_TYPE_TRAITS_H #define TEMPLATE_TYPE_TRAITS_H #include <sprokit/process/trait_utils.h> /* * A type trait is used to bind a local trait name to a application wide * canonical type name string to a c++ type name. This is useful way * to establish names for types that are used throughout a sprokit * pipeline. * * Type traits should name a logical or semantic type not a physical * or logical type. This essential for verifying the semantics of a * pipeline. For example, GSD is usually a double but the trait name * should be \b gsd with a type double. It is a really bad idea to * name type traits based on the concrete builtin fundamental type * such as double or int. * * The canonical type name is a string that will be used to identify * the type and is used to verify the compatibility of process ports * when making connections. Only ports with the same canonical type * name can be connected. * * For small systems, these names can specify the logical data item * passing through the ports. For larger systems, it may make sense to * establish a hierarchical name space. One way to do this is to * separate the levels with a ':' character as shown in the * examples. Using qualified names reduces the chance of name * collisions when two subsystems pick the same logical name for * different underlying types. */ // ================================================================ // // Create type traits for common pipeline types. // These are types that are passed through the pipeline. // ( type-trait-name, "canonical_type_name", concrete-type ) // create_type_trait( frame_number, "template:frame-number", int ); // ================================================================ // // Create port traits for common port types. These trait names are // used in declaring ports in a process and moving data to/from the // port. // // ( port-name, type-trait-name, "port-description" ) // create_port_trait( video_frame_number, frame_number, "Sequential number of video frame." ); #endif /* TEMPLATE_TYPE_TRAITS_H */
4db2009418191c6698c4cda657cc9ce515a3cf07
e842372699fbba5e42708fc18de4cc775377e5d0
/fs_mgr/libfstab/logging_macros.h
7ea1b7720a54b47342dac876ed16ddfc581a6fd4
[ "MIT" ]
permissive
aosp-mirror/platform_system_core
cd1921c7e87396ef99ff46332aa34512977c58a4
18560efc308f9c345915dd4d5fa1a2939fcf5ebc
refs/heads/master
2023-08-28T05:09:18.711274
2023-08-25T17:07:42
2023-08-25T17:07:42
65,923
610
877
NOASSERTION
2023-05-13T20:56:01
2008-10-21T18:21:04
C++
UTF-8
C
false
false
1,453
h
logging_macros.h
/* * Copyright (C) 2023 The Android Open Source Project * * 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 #include <android-base/logging.h> #define FSTAB_TAG "[libfstab] " /* The CHECK() in logging.h will use program invocation name as the tag. * Thus, the log will have prefix "init: " when libfs_mgr is statically * linked in the init process. This might be opaque when debugging. * Append a library name tag at the end of the abort message to aid debugging. */ #define FSTAB_CHECK(x) CHECK(x) << "in " << FSTAB_TAG // Logs a message to kernel #define LINFO LOG(INFO) << FSTAB_TAG #define LWARNING LOG(WARNING) << FSTAB_TAG #define LERROR LOG(ERROR) << FSTAB_TAG #define LFATAL LOG(FATAL) << FSTAB_TAG // Logs a message with strerror(errno) at the end #define PINFO PLOG(INFO) << FSTAB_TAG #define PWARNING PLOG(WARNING) << FSTAB_TAG #define PERROR PLOG(ERROR) << FSTAB_TAG #define PFATAL PLOG(FATAL) << FSTAB_TAG
36d627f71930c0f06066431e205ddb86e04a92ed
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/sound/oss/sound_calls.h
87d8ad4a0340e763a018254886a1484c8696606a
[ "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
3,489
h
sound_calls.h
/* * DMA buffer calls */ int DMAbuf_open(int dev, int mode); int DMAbuf_release(int dev, int mode); int DMAbuf_getwrbuffer(int dev, char **buf, int *size, int dontblock); int DMAbuf_getrdbuffer(int dev, char **buf, int *len, int dontblock); int DMAbuf_rmchars(int dev, int buff_no, int c); int DMAbuf_start_output(int dev, int buff_no, int l); int DMAbuf_move_wrpointer(int dev, int l); /* int DMAbuf_ioctl(int dev, unsigned int cmd, void __user *arg, int local); */ void DMAbuf_init(int dev, int dma1, int dma2); void DMAbuf_deinit(int dev); int DMAbuf_start_dma (int dev, unsigned long physaddr, int count, int dma_mode); void DMAbuf_inputintr(int dev); void DMAbuf_outputintr(int dev, int underflow_flag); struct dma_buffparms; int DMAbuf_space_in_queue (int dev); int DMAbuf_activate_recording (int dev, struct dma_buffparms *dmap); int DMAbuf_get_buffer_pointer (int dev, struct dma_buffparms *dmap, int direction); void DMAbuf_launch_output(int dev, struct dma_buffparms *dmap); unsigned int DMAbuf_poll(struct file *file, int dev, poll_table *wait); void DMAbuf_start_devices(unsigned int devmask); void DMAbuf_reset (int dev); int DMAbuf_sync (int dev); /* * System calls for /dev/dsp and /dev/audio (audio.c) */ int audio_read (int dev, struct file *file, char __user *buf, int count); int audio_write (int dev, struct file *file, const char __user *buf, int count); int audio_open (int dev, struct file *file); void audio_release (int dev, struct file *file); int audio_ioctl (int dev, struct file *file, unsigned int cmd, void __user *arg); void audio_init_devices (void); void reorganize_buffers (int dev, struct dma_buffparms *dmap, int recording); /* * System calls for the /dev/sequencer */ int sequencer_read (int dev, struct file *file, char __user *buf, int count); int sequencer_write (int dev, struct file *file, const char __user *buf, int count); int sequencer_open (int dev, struct file *file); void sequencer_release (int dev, struct file *file); int sequencer_ioctl (int dev, struct file *file, unsigned int cmd, void __user *arg); unsigned int sequencer_poll(int dev, struct file *file, poll_table * wait); void sequencer_init (void); void sequencer_unload (void); void sequencer_timer(unsigned long dummy); int note_to_freq(int note_num); unsigned long compute_finetune(unsigned long base_freq, int bend, int range, int vibrato_bend); void seq_input_event(unsigned char *event, int len); void seq_copy_to_input (unsigned char *event, int len); /* * System calls for the /dev/midi */ int MIDIbuf_read (int dev, struct file *file, char __user *buf, int count); int MIDIbuf_write (int dev, struct file *file, const char __user *buf, int count); int MIDIbuf_open (int dev, struct file *file); void MIDIbuf_release (int dev, struct file *file); int MIDIbuf_ioctl (int dev, struct file *file, unsigned int cmd, void __user *arg); unsigned int MIDIbuf_poll(int dev, struct file *file, poll_table * wait); int MIDIbuf_avail(int dev); void MIDIbuf_bytes_received(int dev, unsigned char *buf, int count); /* From soundcard.c */ void request_sound_timer (int count); void sound_stop_timer(void); void conf_printf(char *name, struct address_info *hw_config); void conf_printf2(char *name, int base, int irq, int dma, int dma2); /* From sound_timer.c */ void sound_timer_interrupt(void); void sound_timer_syncinterval(unsigned int new_usecs); /* From midi_synth.c */ void do_midi_msg (int synthno, unsigned char *msg, int mlen);
026b815b680ba10b40b0b2654d6bdf466a2c4cb9
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/Infineon/libraries/IFX_PSOC6_HAL/mtb-hal-cat1/source/cyhal_audio_common.c
530e9997241ec21033408948b0d19144b1325df0
[ "GPL-1.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "Zlib", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
105,589
c
cyhal_audio_common.c
/******************************************************************************* * File Name: cyhal_audio_common.c * * Description: * Provides common functionality for the I2S and TDM audio drivers. * ******************************************************************************** * \copyright * Copyright 2018-2022 Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation * * SPDX-License-Identifier: Apache-2.0 * * 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 <math.h> #include <stdlib.h> #include <string.h> // For memset #include "cyhal_clock.h" #include "cyhal_gpio.h" #include "cyhal_hw_resources.h" #include "cyhal_hwmgr.h" #include "cyhal_utils.h" #include "cyhal_irq_impl.h" #include "cyhal_dma.h" #include "cyhal_syspm.h" #include "cy_device.h" #include "cyhal_audio_common.h" #include "cyhal_system.h" #if (CYHAL_DRIVER_AVAILABLE_I2S || CYHAL_DRIVER_AVAILABLE_TDM) #if defined(__cplusplus) extern "C" { #endif #if defined(COMPONENT_CAT2) /* PDL register naming varies slightly between CAT1 and CAT2 */ #define REG_I2S_CTL(base) I2S_CTL(base) #define REG_I2S_CLOCK_CTL(base) I2S_CLOCK_CTL(base) #define REG_I2S_TX_CTL(base) I2S_TX_CTL(base) #define REG_I2S_TX_FIFO_CTL(base) I2S_TX_FIFO_CTL(base) #else #define _CYHAL_AUDIOSS_TX_SLAVE_AVAILABLE #define _CYHAL_AUDIOSS_TX_WATCHDOG_AVAILABLE /* Some devices have an extra layer of hierarchy in their parameters */ #if defined(AUDIOSS0_I2S_I2S) #define AUDIOSS0_I2S (AUDIOSS0_I2S_I2S) #endif #if defined(AUDIOSS1_I2S_I2S) #define AUDIOSS1_I2S (AUDIOSS1_I2S_I2S) #endif #if defined(AUDIOSS2_I2S_I2S) #define AUDIOSS2_I2S (AUDIOSS2_I2S_I2S) #endif #endif #define _CYHAL_AUDIOSS_MAX_CHANNEL_LENGTH (32u) #if defined(CY_IP_MXAUDIOSS) static cy_rslt_t _cyhal_audioss_length_to_pdl(uint8_t user_length, cy_en_i2s_len_t *pdl_length, const _cyhal_audioss_t *obj); static uint8_t _cyhal_audioss_length_from_pdl(cy_en_i2s_len_t pdl_length); #define _CYHAL_AUDIOSS_FIFO_DEPTH (256) #define _CYHAL_AUDIOSS_TX_SCK_MAP cyhal_pin_map_audioss_tx_sck #define _CYHAL_AUDIOSS_TX_WS_MAP cyhal_pin_map_audioss_tx_ws #define _CYHAL_AUDIOSS_TX_SDO_MAP cyhal_pin_map_audioss_tx_sdo #define _CYHAL_AUDIOSS_DRIVE_MODE_TX_SCK CYHAL_PIN_MAP_DRIVE_MODE_AUDIOSS_TX_SCK #define _CYHAL_AUDIOSS_DRIVE_MODE_TX_WS CYHAL_PIN_MAP_DRIVE_MODE_AUDIOSS_TX_WS #define _CYHAL_AUDIOSS_DRIVE_MODE_TX_SDO CYHAL_PIN_MAP_DRIVE_MODE_AUDIOSS_TX_SDO #if defined(_CYHAL_AUDIOSS_RX_ENABLED) #define _CYHAL_AUDIOSS_RX_SCK_MAP cyhal_pin_map_audioss_rx_sck #define _CYHAL_AUDIOSS_RX_WS_MAP cyhal_pin_map_audioss_rx_ws #define _CYHAL_AUDIOSS_RX_SDI_MAP cyhal_pin_map_audioss_rx_sdi #define _CYHAL_AUDIOSS_DRIVE_MODE_RX_SCK CYHAL_PIN_MAP_DRIVE_MODE_AUDIOSS_RX_SCK #define _CYHAL_AUDIOSS_DRIVE_MODE_RX_WS CYHAL_PIN_MAP_DRIVE_MODE_AUDIOSS_RX_WS #define _CYHAL_AUDIOSS_DRIVE_MODE_RX_SDI CYHAL_PIN_MAP_DRIVE_MODE_AUDIOSS_RX_SDI #endif static I2S_Type *const _cyhal_audioss_base[] = { #if (CY_IP_MXAUDIOSS_INSTANCES == 1 && defined(AUDIOSS_I2S) && AUDIOSS_I2S) I2S, #elif (CY_IP_MXAUDIOSS_INSTANCES >= 1 && ((defined(AUDIOSS_I2S_I2S) && AUDIOSS_I2S_I2S) || (defined(AUDIOSS0_I2S) && AUDIOSS0_I2S) || (defined(AUDIOSS0_I2S_I2S) && AUDIOSS0_I2S_I2S))) I2S0, #endif #if (CY_IP_MXAUDIOSS_INSTANCES >= 2 && ((defined(AUDIOSS1_I2S) && AUDIOSS1_I2S) || (defined(AUDIOSS1_I2S_I2S) && AUDIOSS1_I2S_I2S))) I2S1, #endif #if (CY_IP_MXAUDIOSS_INSTANCES >= 3 && ((defined(AUDIOSS2_I2S) && AUDIOSS2_I2S) || (defined(AUDIOSS2_I2S_I2S) && AUDIOSS2_I2S_I2S))) I2S2, #endif #if (CY_IP_MXS40AUDIOSS_INSTANCES > 2) #warning Unhandled audioss instance count #endif }; #if (!defined(COMPONENT_CAT2)) #define _CYHAL_AUDIOSS_TRIGGERS_AVAILABLE #if defined(_CYHAL_AUDIOSS_RX_ENABLED) static const cyhal_source_t _cyhal_audioss_rx_trigger[] = { #if (CY_IP_MXAUDIOSS_INSTANCES == 1 && defined(AUDIOSS_I2S) && AUDIOSS_I2S) CYHAL_TRIGGER_AUDIOSS_TR_I2S_RX_REQ, #elif (CY_IP_MXAUDIOSS_INSTANCES >= 1 && defined(AUDIOSS0_I2S) && AUDIOSS0_I2S) CYHAL_TRIGGER_AUDIOSS0_TR_I2S_RX_REQ, #endif #if (CY_IP_MXAUDIOSS_INSTANCES >= 2 && defined(AUDIOSS1_I2S) && AUDIOSS1_I2S) CYHAL_TRIGGER_AUDIOSS1_TR_I2S_RX_REQ, #endif #if (CY_IP_MXAUDIOSS_INSTANCES >= 2 && defined(AUDIOSS2_I2S) && AUDIOSS2_I2S) CYHAL_TRIGGER_AUDIOSS2_TR_I2S_RX_REQ, #endif #if (CY_IP_MXS40AUDIOSS_INSTANCES > 3) #warning Unhandled audioss instance count #endif }; #endif static const cyhal_source_t _cyhal_audioss_tx_trigger[] = { #if (CY_IP_MXAUDIOSS_INSTANCES == 1 && defined(AUDIOSS_I2S) && AUDIOSS_I2S) CYHAL_TRIGGER_AUDIOSS_TR_I2S_TX_REQ, #elif (CY_IP_MXAUDIOSS_INSTANCES >= 1 && defined(AUDIOSS0_I2S) && AUDIOSS0_I2S) CYHAL_TRIGGER_AUDIOSS0_TR_I2S_TX_REQ, #endif #if (CY_IP_MXAUDIOSS_INSTANCES >= 2 && defined(AUDIOSS1_I2S) && AUDIOSS1_I2S) CYHAL_TRIGGER_AUDIOSS1_TR_I2S_TX_REQ, #endif #if (CY_IP_MXAUDIOSS_INSTANCES >= 3 && defined(AUDIOSS2_I2S) && AUDIOSS2_I2S) CYHAL_TRIGGER_AUDIOSS2_TR_I2S_TX_REQ, #endif #if (CY_IP_MXS40AUDIOSS_INSTANCES > 3) #warning Unhandled audioss instance count #endif }; #endif static _cyhal_audioss_t* _cyhal_audioss_config_structs[CY_IP_MXAUDIOSS_INSTANCES]; static const _cyhal_system_irq_t _cyhal_audioss_irq_n[] = { #if (CY_IP_MXAUDIOSS_INSTANCES == 1 && (defined(AUDIOSS_I2S) && AUDIOSS_I2S || defined(AUDIOSS_I2S_I2S) && AUDIOSS_I2S_I2S)) // Without index suffix audioss_interrupt_i2s_IRQn, #elif (CY_IP_MXAUDIOSS_INSTANCES >= 1 && defined(AUDIOSS0_I2S) && AUDIOSS0_I2S) audioss_0_interrupt_i2s_IRQn, #endif #if (CY_IP_MXAUDIOSS_INSTANCES >= 2 && defined(AUDIOSS1_I2S) && AUDIOSS1_I2S) audioss_1_interrupt_i2s_IRQn, #endif #if (CY_IP_MXAUDIOSS_INSTANCES >= 3 && defined(AUDIOSS2_I2S) && AUDIOSS2_I2S) audioss_2_interrupt_i2s_IRQn, #endif #if (CY_IP_MXS40AUDIOSS_INSTANCES > 3) #warning Unhandled audioss instance count #endif }; static uint8_t _cyhal_audioss_get_block_from_irqn(_cyhal_system_irq_t irqn) { switch (irqn) { #if !defined(CY_CPU_CORTEX_M4) || (CY_CPU_CORTEX_M4) || defined(COMPONENT_CAT1C) #if (CY_IP_MXAUDIOSS_INSTANCES == 1 && (defined(AUDIOSS_I2S) && AUDIOSS_I2S || defined(AUDIOSS_I2S_I2S) && AUDIOSS_I2S_I2S)) // Without index suffix case audioss_interrupt_i2s_IRQn: return 0; #elif (CY_IP_MXAUDIOSS_INSTANCES >= 1 && defined(AUDIOSS0_I2S) && AUDIOSS0_I2S) case audioss_0_interrupt_i2s_IRQn: return 0; #endif #if (CY_IP_MXAUDIOSS_INSTANCES >= 2 && defined(AUDIOSS1_I2S) && AUDIOSS1_I2S) case audioss_1_interrupt_i2s_IRQn: return 1; #endif #if (CY_IP_MXAUDIOSS_INSTANCES >= 3 && defined(AUDIOSS2_I2S) && AUDIOSS2_I2S) case audioss_2_interrupt_i2s_IRQn: return 2; #endif #if (CY_IP_MXS40AUDIOSS_INSTANCES > 3) #warning Unhandled audioss instance count #endif #endif /* (CY_CPU_CORTEX_M4) */ default: CY_ASSERT(false); // Should never be called with a non-I2S IRQn return 0; } } #if defined(COMPONENT_CAT2) /* PSoCâ„¢ 4 uses a PCLK */ #define _CYHAL_AUDIOSS_USES_PCLK static const en_clk_dst_t _cyhal_audioss_clock[] = { #if (CY_IP_MXAUDIOSS_INSTANCES == 1) PCLK_AUDIOSS_CLOCK_POS_I2S_EN, #else #warning Unhandled audioss instance count #endif }; #endif static void _cyhal_audioss_irq_handler(void); typedef cy_stc_i2s_config_t _cyhal_audioss_pdl_config_t; #elif defined(CY_IP_MXTDM) && (CY_IP_MXTDM_INSTANCES > 0) #define _CYHAL_AUDIOSS_FIFO_DEPTH (128) #define _CYHAL_AUDIOSS_TX_SCK_MAP cyhal_pin_map_tdm_tdm_tx_sck #define _CYHAL_AUDIOSS_TX_WS_MAP cyhal_pin_map_tdm_tdm_tx_fsync #define _CYHAL_AUDIOSS_TX_SDO_MAP cyhal_pin_map_tdm_tdm_tx_sd #define _CYHAL_AUDIOSS_TX_MCK_MAP cyhal_pin_map_tdm_tdm_tx_mck #define _CYHAL_AUDIOSS_RX_SCK_MAP cyhal_pin_map_tdm_tdm_rx_sck #define _CYHAL_AUDIOSS_RX_WS_MAP cyhal_pin_map_tdm_tdm_rx_fsync #define _CYHAL_AUDIOSS_RX_SDI_MAP cyhal_pin_map_tdm_tdm_rx_sd #define _CYHAL_AUDIOSS_RX_MCK_MAP cyhal_pin_map_tdm_tdm_rx_mck #define _CYHAL_AUDIOSS_DRIVE_MODE_TX_SCK CYHAL_PIN_MAP_DRIVE_MODE_TDM_TDM_TX_SCK #define _CYHAL_AUDIOSS_DRIVE_MODE_TX_WS CYHAL_PIN_MAP_DRIVE_MODE_TDM_TDM_TX_FSYNC #define _CYHAL_AUDIOSS_DRIVE_MODE_TX_SDO CYHAL_PIN_MAP_DRIVE_MODE_TDM_TDM_TX_SD #define _CYHAL_AUDIOSS_DRIVE_MODE_RX_SCK CYHAL_PIN_MAP_DRIVE_MODE_TDM_TDM_RX_SCK #define _CYHAL_AUDIOSS_DRIVE_MODE_RX_WS CYHAL_PIN_MAP_DRIVE_MODE_TDM_TDM_RX_FSYNC #define _CYHAL_AUDIOSS_DRIVE_MODE_RX_SDI CYHAL_PIN_MAP_DRIVE_MODE_TDM_TDM_RX_SD /* Per cy_en_tdm_clock_sel_t, only TX mclk_in is selectable for both. * This is probably a bug in the PDL, will be updated as necessary * following the resolution of DRIVERS-5376 */ #define Cy_I2S_Init Cy_AudioTDM_Init #define Cy_I2S_DeInit Cy_AudioTDM_DeInit static cy_rslt_t _cyhal_audioss_length_to_pdl(uint8_t user_length, cy_en_tdm_ws_t *pdl_length, const _cyhal_audioss_t *obj); static uint8_t _cyhal_audioss_length_from_pdl(cy_en_tdm_ws_t pdl_length); static TDM_Type *const _cyhal_audioss_base[] = { #if defined (TDM0) TDM0, #endif #if defined (TDM1) TDM1, #endif }; static const uint8_t _cyhal_audioss_max_channels[] = { #if (CY_IP_MXTDM_INSTANCES == 1) #if (TDM_NR == 1) TDM_NR_CH_NR, #elif (TDM_NR == 2) TDM_NR0_CH_NR, TDM_NR1_CH_NR, #else #warning Unhandled TDM struct count #endif #elif (CY_IP_MXTDM_INSTANCES == 2) #if (TDM_NR == 2) TDM_NR_CH_NR, #else #warning Unhandled TDM struct count #endif #else #warning Unhandled tdm instance count #endif }; #if !defined (COMPONENT_CAT5) #define _CYHAL_AUDIOSS_USES_PCLK static const en_clk_dst_t _cyhal_audioss_clock[] = { #if (CY_IP_MXTDM_INSTANCES == 1) PCLK_TDM0_CLK_IF_SRSS0, #else #warning Unhandled tdm instance count #endif }; #define _CYHAL_AUDIOSS_TRIGGERS_AVAILABLE static const cyhal_source_t _cyhal_audioss_rx_trigger[] = { #if (CY_IP_MXTDM_INSTANCES == 1) CYHAL_TRIGGER_TDM_TR_RX_REQ0, #else #warning Unhandled tdm instance count #endif }; static const cyhal_source_t _cyhal_audioss_tx_trigger[] = { #if (CY_IP_MXTDM_INSTANCES == 1) CYHAL_TRIGGER_TDM_TR_TX_REQ0, #else #warning Unhandled tdm instance count #endif }; #endif /* !defined (COMPONENT_CAT5) */ static _cyhal_audioss_t* _cyhal_audioss_config_structs[CY_IP_MXTDM_INSTANCES]; // These structures will most probably be cleaned up a bit once we have more details // on TDM interrupts for Hatchet1. Seems like there are no separate lines for tx and // rx interrupts but it will be confirmed once we have a working patch. static const _cyhal_system_irq_t _cyhal_audioss_tx_irq_n[] = { #if defined (TDM0) #if defined(COMPONENT_CAT5) tdm_0_interrupts_IRQn, #else tdm_0_interrupts_tx_0_IRQn, #endif #endif #if defined (TDM1) #if defined(COMPONENT_CAT5) tdm_1_interrupts_IRQn, #else tdm_1_interrupts_tx_0_IRQn, #endif #endif }; static const _cyhal_system_irq_t _cyhal_audioss_rx_irq_n[] = { #if defined (TDM0) #if defined(COMPONENT_CAT5) tdm_0_interrupts_IRQn, #else tdm_0_interrupts_rx_0_IRQn, #endif #endif #if defined (TDM1) #if defined(COMPONENT_CAT5) tdm_1_interrupts_IRQn, #else tdm_1_interrupts_rx_0_IRQn, #endif #endif }; static uint8_t _cyhal_audioss_get_block_from_irqn(_cyhal_system_irq_t irqn) { #if defined (TDM0) #if defined (COMPONENT_CAT5) if (irqn == tdm_0_interrupts_IRQn) #else if ((irqn == tdm_0_interrupts_tx_0_IRQn) || (irqn == tdm_0_interrupts_rx_0_IRQn)) #endif return 0; #endif #if defined (TDM1) #if defined (COMPONENT_CAT5) if (irqn == tdm_1_interrupts_IRQn) #else if ((irqn == tdm_1_interrupts_tx_0_IRQn) || (irqn == tdm_1_interrupts_rx_0_IRQn)) #endif return 1; #endif CY_ASSERT(false); // Should never be called with a non-TDM IRQn return 0; } #if defined (COMPONENT_CAT5) static void _cyhal_audioss_irq_handler(UINT8 instance, BOOL8 rx_int); static void _cyhal_audioss_irq_handler_rx(_cyhal_system_irq_t irqn); static void _cyhal_audioss_irq_handler_tx(_cyhal_system_irq_t irqn); #else static void _cyhal_audioss_irq_handler_rx(void); static void _cyhal_audioss_irq_handler_tx(void); #endif typedef cy_stc_tdm_config_t _cyhal_audioss_pdl_config_t; #else #error "Unrecognized audio IP" #endif static void _cyhal_audioss_update_enabled_events(_cyhal_audioss_t* obj); static void _cyhal_audioss_process_event(_cyhal_audioss_t *obj, uint32_t event); #if defined(_CYHAL_AUDIOSS_RX_ENABLED) static void _cyhal_audioss_update_rx_trigger_level(_cyhal_audioss_t* obj); static uint32_t _cyhal_audioss_read_fifo(_cyhal_audioss_t *obj); #if (CYHAL_DRIVER_AVAILABLE_DMA) static cy_rslt_t _cyhal_audioss_dma_perform_rx(_cyhal_audioss_t *obj); static void _cyhal_audioss_dma_handler_rx(void *callback_arg, cyhal_dma_event_t event); #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ #endif /* defined(_CYHAL_AUDIOSS_RX_ENABLED) */ static uint32_t _cyhal_audioss_disable_events(_cyhal_audioss_t *obj, bool tx); static void _cyhal_audioss_restore_events(_cyhal_audioss_t *obj, bool tx, uint32_t old_events); #if (CYHAL_DRIVER_AVAILABLE_DMA) static cy_rslt_t _cyhal_audioss_dma_perform_tx(_cyhal_audioss_t *obj); static void _cyhal_audioss_dma_handler_tx(void *callback_arg, cyhal_dma_event_t event); static uint8_t _cyhal_audioss_rounded_word_length(_cyhal_audioss_t *obj, bool is_tx); #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ static bool _cyhal_audioss_pm_callback(cyhal_syspm_callback_state_t state, cyhal_syspm_callback_mode_t mode, void* callback_arg); static cy_rslt_t _cyhal_audioss_populate_pdl_config(_cyhal_audioss_t *obj, _cyhal_audioss_pdl_config_t* pdl_config, const _cyhal_audioss_config_t* hal_cfg, uint16_t sclk_div_rx, uint16_t sclk_div_tx, bool rx_en, bool tx_en, bool mclk_rx, bool mclk_tx); static void _cyhal_audioss_reconstruct_pdl_config(_cyhal_audioss_t *obj, _cyhal_audioss_pdl_config_t* pdl_config); static cy_rslt_t _cyhal_audioss_compute_sclk_div(_cyhal_audioss_t *obj, uint32_t sample_rate_hz, uint32_t mclk_hz, uint8_t channel_length, uint8_t num_channels, uint16_t *sclk_div); static uint32_t _cyhal_audioss_get_num_in_fifo(_cyhal_audioss_t *obj, bool is_tx); static void _cyhal_audioss_write_fifo(_cyhal_audioss_t *obj, uint32_t value); cy_rslt_t _cyhal_audioss_init_clock(_cyhal_audioss_t *obj, const cyhal_clock_t* clk, bool all_mclk) { cy_rslt_t result = CY_RSLT_SUCCESS; if (clk != NULL) { obj->clock = *clk; } else if (false == all_mclk) // No need to reserve a clock if we're using the mclk pin { // The hardware is generally going to be hardwired to an hfclk (or equivalent dedicated clock), // which has very limited divider options. In the event that we're hooked up a PERI divider, // we don't have any particular expectations about its width - so just ask for 16-bit or larger result = _cyhal_utils_allocate_clock(&(obj->clock), &(obj->resource), CYHAL_CLOCK_BLOCK_PERIPHERAL_16BIT, true); if(CY_RSLT_SUCCESS == result) { obj->is_clock_owned = true; result = cyhal_clock_set_enabled(&(obj->clock), true, true); } } #if defined(_CYHAL_AUDIOSS_USES_PCLK) // If we're not using MCLK, and we're using a peri divider, hook it up to ourself bool any_mclk = (0u != obj->mclk_hz_tx); #if defined(_CYHAL_AUDIOSS_RX_ENABLED) any_mclk = any_mclk || (0u != obj->mclk_hz_rx); #endif if (CY_RSLT_SUCCESS == result && false == any_mclk && obj->clock.block != CYHAL_CLOCK_BLOCK_HF) { en_clk_dst_t pclk = _cyhal_audioss_clock[obj->resource.block_num]; if (CY_SYSCLK_SUCCESS != _cyhal_utils_peri_pclk_assign_divider(pclk, &(obj->clock))) result = obj->interface->err_clock; } #endif return result; } cy_rslt_t _cyhal_audioss_init_pdl(_cyhal_audioss_t *obj, const _cyhal_audioss_pdl_config_t* pdl_config) { cy_rslt_t result = (cy_rslt_t)Cy_I2S_Init(obj->base, pdl_config); #if defined(CY_IP_MXTDM) if(CY_RSLT_SUCCESS == result) { // PDL init doesn't automatically enable the RX-TX sub-blocks if(pdl_config->tx_config->enable) { Cy_AudioTDM_EnableTx(&obj->base->TDM_TX_STRUCT); } if(pdl_config->rx_config->enable) { Cy_AudioTDM_EnableRx(&obj->base->TDM_RX_STRUCT); } } #endif return result; } cy_rslt_t _cyhal_audioss_init_hw(_cyhal_audioss_t *obj, const _cyhal_audioss_pdl_config_t* pdl_config) { #if defined(CY_IP_MXAUDIOSS) obj->base = _cyhal_audioss_base[obj->resource.block_num]; #elif defined(CY_IP_MXTDM) obj->base = &(_cyhal_audioss_base[obj->resource.block_num]->TDM_STRUCT[obj->resource.channel_num]); #endif cy_rslt_t result = _cyhal_audioss_init_pdl(obj, pdl_config); if (CY_RSLT_SUCCESS == result) { #if defined(CY_IP_MXAUDIOSS) && defined(_CYHAL_AUDIOSS_RX_ENABLED) obj->user_fifo_level_rx = pdl_config->rxFifoTriggerLevel; #elif defined(CY_IP_MXTDM) obj->user_fifo_level_rx = pdl_config->rx_config->fifoTriggerLevel; #endif /* No way to explicitly clear the FIFO on the TDM IP, but * it is cleared as a side effect of the FIFO being disabled * which it should be both at startup and after a free/init cycle */ #if defined(CY_IP_MXAUDIOSS) #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(pdl_config->txEnabled) { Cy_I2S_ClearTxFifo(obj->base); } if(pdl_config->rxEnabled) { Cy_I2S_ClearRxFifo(obj->base); } #else Cy_I2S_ClearTxFifo(obj->base); #endif #endif obj->pm_callback.states = (cyhal_syspm_callback_state_t)(CYHAL_SYSPM_CB_CPU_DEEPSLEEP | CYHAL_SYSPM_CB_SYSTEM_HIBERNATE); obj->pm_callback.callback = &_cyhal_audioss_pm_callback; obj->pm_callback.next = NULL; obj->pm_callback.args = (void*)obj; obj->pm_callback.ignore_modes = (cyhal_syspm_callback_mode_t)(CYHAL_SYSPM_BEFORE_TRANSITION | CYHAL_SYSPM_AFTER_DS_WFI_TRANSITION); obj->pm_transition_ready = false; #if (CYHAL_DRIVER_AVAILABLE_SYSPM) _cyhal_syspm_register_peripheral_callback(&(obj->pm_callback)); #endif /* (CYHAL_DRIVER_AVAILABLE_SYSPM) */ _cyhal_audioss_config_structs[obj->resource.block_num] = obj; #if defined(CY_IP_MXAUDIOSS) _cyhal_irq_register(_cyhal_audioss_irq_n[obj->resource.block_num], CYHAL_ISR_PRIORITY_DEFAULT, _cyhal_audioss_irq_handler); _cyhal_irq_enable(_cyhal_audioss_irq_n[obj->resource.block_num]); #elif defined(CY_IP_MXTDM) #if defined (COMPONENT_CAT5) Cy_AudioTDM_RegisterInterruptCallback(obj->base, _cyhal_audioss_irq_handler); Cy_AudioTDM_EnableInterrupt(obj->base); // Enables both TX and RX #endif _cyhal_irq_register(_cyhal_audioss_rx_irq_n[obj->resource.block_num], CYHAL_ISR_PRIORITY_DEFAULT, (cy_israddress)_cyhal_audioss_irq_handler_rx); _cyhal_irq_enable(_cyhal_audioss_rx_irq_n[obj->resource.block_num]); _cyhal_irq_register(_cyhal_audioss_tx_irq_n[obj->resource.block_num], CYHAL_ISR_PRIORITY_DEFAULT, (cy_israddress)_cyhal_audioss_irq_handler_tx ); _cyhal_irq_enable(_cyhal_audioss_tx_irq_n[obj->resource.block_num]); #else #error "Unrecognized audio IP" #endif } return result; } cy_rslt_t _cyhal_audioss_init(_cyhal_audioss_t *obj, const _cyhal_audioss_pins_t* tx_pins, const _cyhal_audioss_pins_t* rx_pins, const _cyhal_audioss_config_t* config, cyhal_clock_t* clk, const _cyhal_audioss_interface_t* interface) { CY_ASSERT(NULL != obj); memset(obj, 0, sizeof(_cyhal_audioss_t)); /* Explicitly marked not allocated resources as invalid to prevent freeing them. */ obj->resource.type = CYHAL_RSC_INVALID; obj->pin_tx_sck = CYHAL_NC_PIN_VALUE; obj->pin_tx_ws = CYHAL_NC_PIN_VALUE; obj->pin_tx_sdo = CYHAL_NC_PIN_VALUE; obj->pin_tx_mclk = CYHAL_NC_PIN_VALUE; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) obj->pin_rx_sck = CYHAL_NC_PIN_VALUE; obj->pin_rx_ws = CYHAL_NC_PIN_VALUE; obj->pin_rx_sdi = CYHAL_NC_PIN_VALUE; obj->pin_rx_mclk = CYHAL_NC_PIN_VALUE; #endif obj->interface = interface; obj->channel_length_tx = config->channel_length; obj->word_length_tx = config->word_length; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) obj->channel_length_rx = config->channel_length; obj->word_length_rx = config->word_length; #endif /* * We will update this to owned later if appropriate - for now set to false * so we don't try to free if we fail before allocating a clock */ obj->is_clock_owned = false; obj->user_enabled_events = 0u; obj->callback_data.callback = NULL; obj->callback_data.callback_arg = NULL; obj->async_mode = CYHAL_ASYNC_SW; obj->async_tx_buff = NULL; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) obj->async_rx_buff = NULL; #endif obj->tx_dma.resource.type = CYHAL_RSC_INVALID; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) obj->rx_dma.resource.type = CYHAL_RSC_INVALID; #endif cy_rslt_t result = CY_RSLT_SUCCESS; /* Determine which I2S instance to use */ const cyhal_resource_pin_mapping_t *tx_sck_map = (NULL != tx_pins) ? _CYHAL_UTILS_GET_RESOURCE(tx_pins->sck, _CYHAL_AUDIOSS_TX_SCK_MAP) : NULL; const cyhal_resource_pin_mapping_t *tx_ws_map = (NULL != tx_pins) ? _CYHAL_UTILS_GET_RESOURCE(tx_pins->ws, _CYHAL_AUDIOSS_TX_WS_MAP) : NULL; const cyhal_resource_pin_mapping_t *tx_sdo_map = (NULL != tx_pins) ? _CYHAL_UTILS_GET_RESOURCE(tx_pins->data, _CYHAL_AUDIOSS_TX_SDO_MAP) : NULL; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) const cyhal_resource_pin_mapping_t *rx_sck_map = (NULL != rx_pins) ? _CYHAL_UTILS_GET_RESOURCE(rx_pins->sck, _CYHAL_AUDIOSS_RX_SCK_MAP) : NULL; const cyhal_resource_pin_mapping_t *rx_ws_map = (NULL != rx_pins) ? _CYHAL_UTILS_GET_RESOURCE(rx_pins->ws, _CYHAL_AUDIOSS_RX_WS_MAP) : NULL; const cyhal_resource_pin_mapping_t *rx_sdi_map = (NULL != rx_pins) ? _CYHAL_UTILS_GET_RESOURCE(rx_pins->data, _CYHAL_AUDIOSS_RX_SDI_MAP) : NULL; #endif const cyhal_resource_pin_mapping_t *mclk_map_rx = NULL; const cyhal_resource_pin_mapping_t *mclk_map_tx = NULL; #if !defined(_CYHAL_AUDIOSS_RX_ENABLED) if(rx_pins != NULL) { result = interface->err_not_supported; } #endif #if !defined(_CYHAL_AUDIOSS_TX_SLAVE_AVAILABLE) if(config->is_tx_slave) { result = interface->err_not_supported; } #endif #if defined(CY_IP_MXAUDIOSS) if(NULL != tx_pins && NULL != rx_pins && tx_pins->mclk != rx_pins->mclk) { /* RX and TX must share the same MCLK pin (or lack thereof) on this IP */ result = obj->interface->err_invalid_pin; } mclk_map_rx = (NULL != rx_pins) ? _CYHAL_UTILS_GET_RESOURCE(rx_pins->mclk, cyhal_pin_map_audioss_clk_i2s_if) : NULL; mclk_map_tx = (NULL != tx_pins) /* If non-null, we know the mclk pins must be the same, so can reuse the rx value */ ? ((NULL != mclk_map_rx) ? mclk_map_rx : _CYHAL_UTILS_GET_RESOURCE(tx_pins->mclk, cyhal_pin_map_audioss_clk_i2s_if)) : NULL; uint8_t mclk_tx_dm = CYHAL_PIN_MAP_DRIVE_MODE_AUDIOSS_CLK_I2S_IF; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) uint8_t mclk_rx_dm = CYHAL_PIN_MAP_DRIVE_MODE_AUDIOSS_CLK_I2S_IF; #endif #elif defined(CY_IP_MXTDM) mclk_map_rx = (NULL != rx_pins) ? _CYHAL_UTILS_GET_RESOURCE(rx_pins->mclk, _CYHAL_AUDIOSS_RX_MCK_MAP) : NULL; mclk_map_tx = (NULL != tx_pins) ? _CYHAL_UTILS_GET_RESOURCE(tx_pins->mclk, _CYHAL_AUDIOSS_TX_MCK_MAP) : NULL; uint8_t mclk_tx_dm = (uint8_t)CYHAL_PIN_MAP_DRIVE_MODE_TDM_TDM_TX_MCK; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) uint8_t mclk_rx_dm = (uint8_t)CYHAL_PIN_MAP_DRIVE_MODE_TDM_TDM_RX_MCK; #endif #endif #if defined(CY_IP_MXAUDIOSS) cyhal_resource_t rsc_type = CYHAL_RSC_I2S; #elif defined(CY_IP_MXTDM) cyhal_resource_t rsc_type = CYHAL_RSC_TDM; #endif if(CY_RSLT_SUCCESS == result && NULL != tx_pins) /* It is valid to leave either tx or rx empty */ { if(NULL != tx_sck_map && NULL != tx_ws_map && NULL != tx_sdo_map && _cyhal_utils_map_resources_equal_all(3, tx_sck_map, tx_ws_map, tx_sdo_map)) { _CYHAL_UTILS_ASSIGN_RESOURCE(obj->resource, rsc_type, tx_sck_map); } else { result = obj->interface->err_invalid_pin; } } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(CY_RSLT_SUCCESS == result && NULL != rx_pins) { if(NULL == rx_sck_map || NULL == rx_ws_map || NULL == rx_sdi_map || (false == _cyhal_utils_map_resources_equal_all(3, rx_sck_map, rx_ws_map, rx_sdi_map))) { result = obj->interface->err_invalid_pin; } else { if((obj->resource.type != CYHAL_RSC_INVALID) && (false == _cyhal_utils_map_resource_equal(&(obj->resource), rx_sck_map, false))) { /* TX pins and RX pins don't map to the same instance */ result = obj->interface->err_invalid_pin; } _CYHAL_UTILS_ASSIGN_RESOURCE(obj->resource, rsc_type, rx_sck_map); } } #endif if(CYHAL_RSC_INVALID == obj->resource.type) /* If this happens it means neither rx nor tx was specified */ { result = obj->interface->err_invalid_pin; } if(CY_RSLT_SUCCESS == result && NULL != rx_pins && CYHAL_NC_PIN_VALUE != rx_pins->mclk ) { if(NULL == mclk_map_rx || (false == _cyhal_utils_map_resource_equal(&(obj->resource), mclk_map_rx, false))) { result = obj->interface->err_invalid_pin; } } if(CY_RSLT_SUCCESS == result && NULL != tx_pins && CYHAL_NC_PIN_VALUE != tx_pins->mclk ) { if(NULL == mclk_map_tx || (false == _cyhal_utils_map_resource_equal(&(obj->resource), mclk_map_tx, false))) { result = obj->interface->err_invalid_pin; } } #if defined(CY_IP_MXAUDIOSS) const uint8_t MAX_CHANNELS = 8u; /* I2S will already have limited to a lower count */ #elif defined(CY_IP_MXTDM) const uint8_t MAX_CHANNELS = _cyhal_audioss_max_channels[obj->resource.block_num]; #endif if(CY_RSLT_SUCCESS == result && config->num_channels > MAX_CHANNELS) { result = obj->interface->err_invalid_arg; } #if defined(CY_IP_MXAUDIOSS) // This IP doesn't support disabling individual channels, just reducing the overall count for(size_t i = 0; i < sizeof(config->channel_mask) * 8 /* bits per byte */; ++i) { bool chan_enabled = (0u != (config->channel_mask & ((uint32_t)1u << i))); bool is_selected_channel = (i < config->num_channels); if(is_selected_channel != chan_enabled) { result = obj->interface->err_invalid_arg; break; } } #endif if(CY_RSLT_SUCCESS == result) { result = cyhal_hwmgr_reserve(&(obj->resource)); } if(CY_RSLT_SUCCESS != result) { // If we aren't successful by here, we didn't manage to reserve the hardware resource, // so mark it as invalid to ensure it isn't incorrectly freed. obj->resource.type = CYHAL_RSC_INVALID; } uint8_t dm_tx_sck, dm_tx_ws; #if defined (COMPONENT_CAT5) dm_tx_sck = (config->is_tx_slave) ? CYHAL_PIN_MAP_DRIVE_MODE_TDM_SLAVE : _CYHAL_AUDIOSS_DRIVE_MODE_TX_SCK; dm_tx_ws = (config->is_tx_slave) ? CYHAL_PIN_MAP_DRIVE_MODE_TDM_SLAVE : _CYHAL_AUDIOSS_DRIVE_MODE_TX_WS; #else dm_tx_sck = _CYHAL_AUDIOSS_DRIVE_MODE_TX_SCK; dm_tx_ws = _CYHAL_AUDIOSS_DRIVE_MODE_TX_WS; #endif /* Reserve the pins */ if(CY_RSLT_SUCCESS == result && NULL != tx_pins) { result = _cyhal_utils_reserve_and_connect(tx_sck_map, dm_tx_sck); if(CY_RSLT_SUCCESS == result) { obj->pin_tx_sck = tx_pins->sck; result = _cyhal_utils_reserve_and_connect(tx_ws_map, dm_tx_ws); } if(CY_RSLT_SUCCESS == result) { obj->pin_tx_ws = tx_pins->ws; result = _cyhal_utils_reserve_and_connect(tx_sdo_map, (uint8_t)_CYHAL_AUDIOSS_DRIVE_MODE_TX_SDO); } if(CY_RSLT_SUCCESS == result) { obj->pin_tx_sdo = tx_pins->data; } #if defined(_CYHAL_AUDIOSS_TX_SLAVE_AVAILABLE) && !defined (COMPONENT_CAT5) // In slave mode, the clock and word select pins are inputs if(CY_RSLT_SUCCESS == result && config->is_tx_slave) { result = cyhal_gpio_configure(obj->pin_tx_sck, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_NONE); if(CY_RSLT_SUCCESS == result) { result = cyhal_gpio_configure(obj->pin_tx_ws, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_NONE); } } #endif } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(CY_RSLT_SUCCESS == result && NULL != rx_pins) { result = _cyhal_utils_reserve_and_connect(rx_sdi_map, (uint8_t)_CYHAL_AUDIOSS_DRIVE_MODE_RX_SDI); #if defined (COMPONENT_CAT5) if(CY_RSLT_SUCCESS == result) { obj->pin_rx_sdi = rx_pins->data; obj->pin_rx_sck = rx_pins->sck; // The SCK and WS are tied to the TX on this device obj->pin_rx_ws = rx_pins->ws; } #else if(CY_RSLT_SUCCESS == result) { obj->pin_rx_sdi = rx_pins->data; result = _cyhal_utils_reserve_and_connect(rx_sck_map, (uint8_t)_CYHAL_AUDIOSS_DRIVE_MODE_RX_SCK); } if(CY_RSLT_SUCCESS == result) { obj->pin_rx_sck = rx_pins->sck; result = _cyhal_utils_reserve_and_connect(rx_ws_map, (uint8_t)_CYHAL_AUDIOSS_DRIVE_MODE_RX_WS); } if(CY_RSLT_SUCCESS == result) { obj->pin_rx_ws = rx_pins->ws; } // In slave mode, the clock and word select pins are inputs if(CY_RSLT_SUCCESS == result && config->is_rx_slave) { result = cyhal_gpio_configure(obj->pin_rx_sck, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_NONE); if(CY_RSLT_SUCCESS == result) { result = cyhal_gpio_configure(obj->pin_rx_ws, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_NONE); } } #endif } #endif bool has_mclk = NULL != mclk_map_rx || NULL != mclk_map_tx; if(CY_RSLT_SUCCESS == result && has_mclk) { if(config->mclk_hz == 0) { // Must specify mclk frequency when using mclk result = obj->interface->err_invalid_arg; } else { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(NULL != mclk_map_rx) { result = _cyhal_utils_reserve_and_connect(mclk_map_rx, mclk_rx_dm); if(CY_RSLT_SUCCESS == result) { obj->pin_rx_mclk = mclk_map_rx->pin; obj->mclk_hz_rx = config->mclk_hz; } } #endif if(CY_RSLT_SUCCESS == result && NULL != mclk_map_tx) { /* Don't try to reserve twice if rx and tx mclk are the same pin */ if(NULL == mclk_map_rx || mclk_map_tx->pin != mclk_map_rx->pin) { result = _cyhal_utils_reserve_and_connect(mclk_map_tx, mclk_tx_dm); } if(CY_RSLT_SUCCESS == result) { obj->pin_tx_mclk = mclk_map_tx->pin; obj->mclk_hz_tx = config->mclk_hz; } } } } if(CY_RSLT_SUCCESS == result && false == has_mclk) { // Must not specify mclk frequency when mclk pin is not in use if(config->mclk_hz != 0) { result = obj->interface->err_invalid_arg; } } /* In this init flow rx and tx have the same lengths so we just need to check tx */ if(CY_RSLT_SUCCESS == result && obj->word_length_tx > obj->channel_length_tx) { // Word length must be less than or equal to channel length result = obj->interface->err_invalid_arg; } if(CY_RSLT_SUCCESS == result && obj->channel_length_tx > _CYHAL_AUDIOSS_MAX_CHANNEL_LENGTH) { // Channel length on MXAUDIOSS is more restricted than this, but that is // checked in populate_pdl_config. There is also a lower bound of 4 // on MXTDM but that is taken care of by the check above because // 8 bits is the smallest word length we support. result = obj->interface->err_invalid_arg; } if (CY_RSLT_SUCCESS == result) { bool all_mclk = (NULL == rx_pins || CYHAL_NC_PIN_VALUE != rx_pins->mclk) && (NULL == tx_pins || CYHAL_NC_PIN_VALUE != tx_pins->mclk); result = _cyhal_audioss_init_clock(obj, clk, all_mclk); } uint16_t sclk_div_tx = 0; uint16_t sclk_div_rx = 0; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(CY_RSLT_SUCCESS == result && NULL != rx_pins) { result = _cyhal_audioss_compute_sclk_div(obj, config->sample_rate_hz, obj->mclk_hz_rx, obj->channel_length_rx, config->num_channels, &sclk_div_rx); } #endif if(CY_RSLT_SUCCESS == result && NULL != tx_pins) { result = _cyhal_audioss_compute_sclk_div(obj, config->sample_rate_hz, obj->mclk_hz_tx, obj->channel_length_tx, config->num_channels, &sclk_div_tx); } _cyhal_audioss_pdl_config_t pdl_config; memset(&pdl_config, 0, sizeof(pdl_config)); #if defined(CY_IP_MXTDM) cy_stc_tdm_config_tx_t tx_config = {0}; cy_stc_tdm_config_rx_t rx_config = {0}; pdl_config.tx_config = &tx_config; pdl_config.rx_config = &rx_config; #endif if (CY_RSLT_SUCCESS == result) { bool tx_en = (CYHAL_NC_PIN_VALUE != obj->pin_tx_sdo); bool tx_mclk = (CYHAL_NC_PIN_VALUE != obj->pin_tx_mclk); #if defined(_CYHAL_AUDIOSS_RX_ENABLED) bool rx_en = (CYHAL_NC_PIN_VALUE != obj->pin_rx_sdi); bool rx_mclk = (CYHAL_NC_PIN_VALUE != obj->pin_rx_mclk); #else bool rx_en = false; bool rx_mclk = false; #endif result = _cyhal_audioss_populate_pdl_config(obj, &pdl_config, config, sclk_div_rx, sclk_div_tx, rx_en, tx_en, rx_mclk, tx_mclk); } if (CY_RSLT_SUCCESS == result) { result = _cyhal_audioss_init_hw(obj, &pdl_config); } if (CY_RSLT_SUCCESS != result) { _cyhal_audioss_free(obj); } return result; } cy_rslt_t _cyhal_audioss_init_cfg(_cyhal_audioss_t *obj, const _cyhal_audioss_configurator_t *cfg, const _cyhal_audioss_interface_t* interface) { CY_ASSERT(NULL != obj); memset(obj, 0, sizeof(_cyhal_audioss_t)); obj->owned_by_configurator = true; obj->resource = *cfg->resource; obj->mclk_hz_tx = cfg->mclk_hz_tx; obj->interface = interface; obj->async_mode = CYHAL_ASYNC_SW; obj->tx_dma.resource.type = CYHAL_RSC_INVALID; #if defined(CY_IP_MXAUDIOSS) obj->channel_length_tx = _cyhal_audioss_length_from_pdl(cfg->config->txChannelLength); obj->word_length_tx = _cyhal_audioss_length_from_pdl(cfg->config->txWordLength); #if defined(_CYHAL_AUDIOSS_RX_ENABLED) obj->channel_length_rx = _cyhal_audioss_length_from_pdl(cfg->config->rxChannelLength); obj->word_length_rx = _cyhal_audioss_length_from_pdl(cfg->config->rxWordLength); #endif #elif defined(CY_IP_MXTDM) obj->channel_length_tx = cfg->config->tx_config->channelSize; obj->word_length_tx = _cyhal_audioss_length_from_pdl(cfg->config->tx_config->wordSize); obj->channel_length_rx = cfg->config->rx_config->channelSize; obj->word_length_rx = _cyhal_audioss_length_from_pdl(cfg->config->rx_config->wordSize); #endif obj->pin_tx_sck = CYHAL_NC_PIN_VALUE; obj->pin_tx_ws = CYHAL_NC_PIN_VALUE; obj->pin_tx_sdo = CYHAL_NC_PIN_VALUE; obj->pin_tx_mclk = CYHAL_NC_PIN_VALUE; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) obj->rx_dma.resource.type = CYHAL_RSC_INVALID; obj->pin_rx_sck = CYHAL_NC_PIN_VALUE; obj->pin_rx_ws = CYHAL_NC_PIN_VALUE; obj->pin_rx_sdi = CYHAL_NC_PIN_VALUE; obj->pin_rx_mclk = CYHAL_NC_PIN_VALUE; #endif #if defined(CY_IP_MXAUDIOSS) bool all_mclk = (0u != obj->mclk_hz_tx); /* No separate rx/tx clock selection */ #elif defined(CY_IP_MXTDM) bool all_mclk = ((false == cfg->config->rx_config->enable) || (CY_TDM_SEL_MCLK_IN == cfg->config->rx_config->clkSel)) && ((false == cfg->config->tx_config->enable) || (CY_TDM_SEL_MCLK_IN == cfg->config->tx_config->clkSel)); #endif cy_rslt_t result = _cyhal_audioss_init_clock(obj, cfg->clock, all_mclk); if(CY_RSLT_SUCCESS == result) { result = _cyhal_audioss_init_hw(obj, cfg->config); } if(CY_RSLT_SUCCESS != result) { _cyhal_audioss_free(obj); } return result; } void _cyhal_audioss_free(_cyhal_audioss_t *obj) { CY_ASSERT(NULL != obj); if(CYHAL_RSC_INVALID != obj->resource.type) { #if defined(CY_IP_MXAUDIOSS) _cyhal_system_irq_t irqn = _cyhal_audioss_irq_n[obj->resource.block_num]; _cyhal_irq_free(irqn); #elif defined(CY_IP_MXTDM) _cyhal_system_irq_t irqn = _cyhal_audioss_rx_irq_n[obj->resource.block_num]; _cyhal_irq_free(irqn); irqn = _cyhal_audioss_tx_irq_n[obj->resource.block_num]; _cyhal_irq_free(irqn); #endif #if (CYHAL_DRIVER_AVAILABLE_SYSPM) _cyhal_syspm_unregister_peripheral_callback(&(obj->pm_callback)); #endif /* (CYHAL_DRIVER_AVAILABLE_SYSPM) */ if(NULL != obj->base) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) _cyhal_audioss_stop_rx(obj); #endif _cyhal_audioss_stop_tx(obj); #if defined(CY_IP_MXTDM) Cy_AudioTDM_DisableTx(&obj->base->TDM_TX_STRUCT); Cy_AudioTDM_DisableRx(&obj->base->TDM_RX_STRUCT); #endif } if(false == obj->owned_by_configurator) { cyhal_hwmgr_free(&(obj->resource)); } obj->base = NULL; obj->resource.type = CYHAL_RSC_INVALID; } /* Need to check this before we start releasing because release_if_used * sets the pin to NC once it is done */ #if defined(_CYHAL_AUDIOSS_RX_ENABLED) bool different_mclk = (obj->pin_rx_mclk != obj->pin_tx_mclk); #endif _cyhal_utils_release_if_used(&(obj->pin_tx_sck)); _cyhal_utils_release_if_used(&(obj->pin_tx_ws)); _cyhal_utils_release_if_used(&(obj->pin_tx_sdo)); _cyhal_utils_release_if_used(&(obj->pin_tx_mclk)); #if defined(_CYHAL_AUDIOSS_RX_ENABLED) _cyhal_utils_release_if_used(&(obj->pin_rx_sck)); _cyhal_utils_release_if_used(&(obj->pin_rx_ws)); _cyhal_utils_release_if_used(&(obj->pin_rx_sdi)); if(different_mclk) { _cyhal_utils_release_if_used(&(obj->pin_rx_mclk)); } #endif if(obj->is_clock_owned) { cyhal_clock_free(&(obj->clock)); } #if (CYHAL_DRIVER_AVAILABLE_DMA) #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(CYHAL_RSC_INVALID != obj->rx_dma.resource.type) { cyhal_dma_free(&obj->rx_dma); } #endif /* defined(_CYHAL_AUDIOSS_RX_ENABLED) */ if(CYHAL_RSC_INVALID != obj->tx_dma.resource.type) { cyhal_dma_free(&obj->tx_dma); } #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ } static uint8_t _cyhal_audioss_fifo_trigger_level(_cyhal_audioss_t* obj, bool is_tx) { #if defined(CY_IP_MXAUDIOSS) #if defined(_CYHAL_AUDIOSS_RX_ENABLED) return is_tx ? (uint8_t)_FLD2VAL(I2S_TX_FIFO_CTL_TRIGGER_LEVEL, REG_I2S_TX_FIFO_CTL(obj->base)) : (uint8_t)_FLD2VAL(I2S_RX_FIFO_CTL_TRIGGER_LEVEL, REG_I2S_RX_FIFO_CTL(obj->base)); #else CY_UNUSED_PARAMETER(is_tx); return (uint8_t)_FLD2VAL(I2S_TX_FIFO_CTL_TRIGGER_LEVEL, REG_I2S_TX_FIFO_CTL(obj->base)); #endif #elif defined(CY_IP_MXTDM) return is_tx ? (uint8_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_FIFO_CTL_TRIGGER_LEVEL, TDM_STRUCT_TX_FIFO_CTL(&obj->base->TDM_TX_STRUCT)) : (uint8_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_FIFO_CTL_TRIGGER_LEVEL, TDM_STRUCT_RX_FIFO_CTL(&obj->base->TDM_RX_STRUCT)); #endif } static bool _cyhal_audioss_is_direction_enabled(_cyhal_audioss_t *obj, bool is_tx) { #if defined(CY_IP_MXAUDIOSS) return is_tx ? (0u != (REG_I2S_CTL(obj->base) & I2S_CTL_TX_ENABLED_Msk)) : (0u != (REG_I2S_CTL(obj->base) & I2S_CTL_RX_ENABLED_Msk)); #elif defined(CY_IP_MXTDM) return is_tx ? (0u != (TDM_STRUCT_TX_CTL(&obj->base->TDM_TX_STRUCT) & TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_CTL_ENABLED_Msk)) : (0u != (TDM_STRUCT_RX_CTL(&obj->base->TDM_RX_STRUCT) & TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_CTL_ENABLED_Msk)); #endif } /* Note: This function is called prior to PDL init, and again from set_sample_rate. This means that * it cannot safely query either register values (which may not be initialized), nor pin values (which * are not populated in the configurator init flow) */ static cy_rslt_t _cyhal_audioss_compute_sclk_div(_cyhal_audioss_t *obj, uint32_t sample_rate_hz, uint32_t mclk_hz, uint8_t channel_length, uint8_t num_channels, uint16_t *sclk_div) { #if defined(CY_IP_MXAUDIOSS) const uint8_t SCLK_INCREMENT = 1; const uint8_t MIN_SCLK_DIVIDER = 1; const uint8_t MAX_SCLK_DIVIDER = 64; // Divider value internal to the I2S block #elif defined(CY_IP_MXTDM) const uint8_t MIN_SCLK_DIVIDER = 2; const uint8_t SCLK_INCREMENT = 2; // Per PDL, should be set to an even value to ensure 50/50 duty cycle const uint16_t MAX_SCLK_DIVIDER = 256; // Divider value internal to the I2S block #endif const cyhal_clock_tolerance_t SCLK_TOLERANCE = { .type = CYHAL_TOLERANCE_PERCENT, .value = 1 }; uint32_t sclk_target = sample_rate_hz * channel_length * num_channels; *sclk_div = 0; if(obj->is_clock_owned) { // Try each of the divider values that we support internally, and see whether any of them gets us // within our tolerance of a frequency that our source clock can provide. for(uint16_t i = MIN_SCLK_DIVIDER; i <= MAX_SCLK_DIVIDER; i += SCLK_INCREMENT) { #if defined(CY_IP_MXAUDIOSS) // This IP has a hard-wired 8x divider uint32_t desired_source_freq = sclk_target * i * 8; #elif defined(CY_IP_MXTDM) uint32_t desired_source_freq = sclk_target * i; #endif cy_rslt_t freq_result = _cyhal_utils_set_clock_frequency(&(obj->clock), desired_source_freq, &SCLK_TOLERANCE); if(CY_RSLT_SUCCESS == freq_result) { *sclk_div = i; break; } } } else // Using user-provided clock, or using the mclk pin { // We can't change the clock, so just check if it's within tolerance #if defined(CY_IP_MXAUDIOSS) uint32_t desired_divided_freq = sclk_target * 8; // I2S hw has a hard-wired 8x divider #elif defined(CY_IP_MXTDM) uint32_t desired_divided_freq = sclk_target; #endif uint32_t actual_source_freq = (0u != mclk_hz) ? mclk_hz : cyhal_clock_get_frequency(&obj->clock); uint32_t best_divider = (actual_source_freq + (desired_divided_freq / 2)) / desired_divided_freq; // Round to nearest divider #if !defined (COMPONENT_CAT5) uint32_t desired_source_freq = desired_divided_freq * best_divider; uint32_t diff = (uint32_t)abs(_cyhal_utils_calculate_tolerance(SCLK_TOLERANCE.type, desired_source_freq, actual_source_freq)); if(diff <= SCLK_TOLERANCE.value && best_divider <= MAX_SCLK_DIVIDER) { *sclk_div = (uint16_t)best_divider; } #else // Tolerance check cannot be reliably done on this device. Therefore skip it. *sclk_div = best_divider; #endif } return (0 == *sclk_div) ? obj->interface->err_clock : CY_RSLT_SUCCESS; } cy_rslt_t _cyhal_audioss_set_sample_rate(_cyhal_audioss_t *obj, uint32_t sample_rate_hz) { uint16_t sclk_div_tx = 0; _cyhal_audioss_pdl_config_t pdl_config; memset(&pdl_config, 0, sizeof(pdl_config)); #if defined(CY_IP_MXTDM) cy_stc_tdm_config_tx_t tx_config; cy_stc_tdm_config_rx_t rx_config; pdl_config.tx_config = &tx_config; pdl_config.rx_config = &rx_config; #endif _cyhal_audioss_reconstruct_pdl_config(obj, &pdl_config); #if defined(CY_IP_MXAUDIOSS) #if defined(_CYHAL_AUDIOSS_RX_ENABLED) uint8_t rx_channels = pdl_config.rxChannels; #endif uint8_t tx_channels = pdl_config.txChannels; #elif defined(CY_IP_MXTDM) uint8_t rx_channels = pdl_config.rx_config->channelNum; uint8_t tx_channels = pdl_config.tx_config->channelNum; #endif /* _CYHAL_AUDIOSS_RX_ENABLED */ cy_rslt_t result = _cyhal_audioss_compute_sclk_div(obj, sample_rate_hz, obj->mclk_hz_tx, obj->channel_length_tx, tx_channels, &sclk_div_tx); #if defined(_CYHAL_AUDIOSS_RX_ENABLED) uint16_t sclk_div_rx = 0; if(CY_RSLT_SUCCESS == result) { result = _cyhal_audioss_compute_sclk_div(obj, sample_rate_hz, obj->mclk_hz_rx, obj->channel_length_rx, rx_channels, &sclk_div_rx); } #endif /* _CYHAL_AUDIOSS_RX_ENABLED */ if(CY_RSLT_SUCCESS == result) { #if defined(CY_IP_MXAUDIOSS) pdl_config.clkDiv = (uint8_t)(sclk_div_tx); #elif defined(CY_IP_MXTDM) pdl_config.tx_config->clkDiv = sclk_div_tx; pdl_config.rx_config->clkDiv = sclk_div_rx; #endif Cy_I2S_DeInit(obj->base); result = _cyhal_audioss_init_pdl(obj, &pdl_config); } return result; } void _cyhal_audioss_enable_event(_cyhal_audioss_t *obj, uint32_t event, uint8_t intr_priority, bool enable) { CY_ASSERT(NULL != obj); if (enable) { obj->user_enabled_events |= event; } else { obj->user_enabled_events &= ~event; } _cyhal_audioss_update_enabled_events(obj); #if defined(CY_IP_MXAUDIOSS) _cyhal_system_irq_t irqn = _cyhal_audioss_irq_n[obj->resource.block_num]; _cyhal_irq_set_priority(irqn, intr_priority); #elif defined(CY_IP_MXTDM) _cyhal_system_irq_t irqn = _cyhal_audioss_tx_irq_n[obj->resource.block_num]; _cyhal_irq_set_priority(irqn, intr_priority); irqn = _cyhal_audioss_rx_irq_n[obj->resource.block_num]; _cyhal_irq_set_priority(irqn, intr_priority); #endif } cy_rslt_t _cyhal_audioss_start_tx(_cyhal_audioss_t *obj) { if (obj->pm_transition_ready) { return CYHAL_SYSPM_RSLT_ERR_PM_PENDING; } #if defined(CY_IP_MXAUDIOSS) Cy_I2S_EnableTx(obj->base); #elif defined(CY_IP_MXTDM) Cy_AudioTDM_ActivateTx(&obj->base->TDM_TX_STRUCT); #endif return CY_RSLT_SUCCESS; } cy_rslt_t _cyhal_audioss_stop_tx(_cyhal_audioss_t *obj) { #if defined(CY_IP_MXAUDIOSS) Cy_I2S_DisableTx(obj->base); #elif defined(CY_IP_MXTDM) // Not disable - that is more aggressive than we want Cy_AudioTDM_DeActivateTx(&obj->base->TDM_TX_STRUCT); #endif return CY_RSLT_SUCCESS; } cy_rslt_t _cyhal_audioss_clear_tx(_cyhal_audioss_t *obj) { #if defined(CY_IP_MXAUDIOSS) Cy_I2S_ClearTxFifo(obj->base); #elif defined(CY_IP_MXTDM) /* No way to explicitly clear the FIFO, so disable and re-enable * which will clear the FIFO as a side effect, while retaining * all other configuration */ bool was_active = _cyhal_audioss_is_tx_enabled(obj); Cy_AudioTDM_DisableTx(&obj->base->TDM_TX_STRUCT); Cy_AudioTDM_EnableTx(&obj->base->TDM_TX_STRUCT); if(was_active) { Cy_AudioTDM_ActivateTx(&obj->base->TDM_TX_STRUCT); } #endif return CY_RSLT_SUCCESS; } cy_rslt_t _cyhal_audioss_start_rx(_cyhal_audioss_t *obj) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if (obj->pm_transition_ready) { return CYHAL_SYSPM_RSLT_ERR_PM_PENDING; } #if defined(CY_IP_MXAUDIOSS) Cy_I2S_EnableRx(obj->base); #elif defined(CY_IP_MXTDM) Cy_AudioTDM_ActivateRx(&obj->base->TDM_RX_STRUCT); #endif return CY_RSLT_SUCCESS; #else return obj->interface->err_not_supported; #endif } cy_rslt_t _cyhal_audioss_stop_rx(_cyhal_audioss_t *obj) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) #if defined(CY_IP_MXAUDIOSS) Cy_I2S_DisableRx(obj->base); #elif defined(CY_IP_MXTDM) // Not disable - that is more aggressive than we want Cy_AudioTDM_DeActivateRx(&obj->base->TDM_RX_STRUCT); #endif return CY_RSLT_SUCCESS; #else return obj->interface->err_not_supported; #endif } cy_rslt_t _cyhal_audioss_clear_rx(_cyhal_audioss_t *obj) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) #if defined(CY_IP_MXAUDIOSS) Cy_I2S_ClearRxFifo(obj->base); #elif defined(CY_IP_MXTDM) /* No way to explicitly clear the FIFO, so disable and re-enable * which will clear the FIFO as a side effect, while retaining * all other configuration */ bool was_active = _cyhal_audioss_is_rx_enabled(obj); Cy_AudioTDM_DisableRx(&obj->base->TDM_RX_STRUCT); Cy_AudioTDM_EnableRx(&obj->base->TDM_RX_STRUCT); if(was_active) { Cy_AudioTDM_ActivateRx(&obj->base->TDM_RX_STRUCT); } #endif return CY_RSLT_SUCCESS; #else return obj->interface->err_not_supported; #endif } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) // Reads until empty, then updates the length and buffer address to their new locations static void _cyhal_audioss_read_until_empty(_cyhal_audioss_t *obj, void** buffer, size_t* length) { // The buffer is the smallest type that will hold the word length // The structure of this function deliberately accepts duplication of the outer loop // structure in order to avoid having to recheck the word length every time around, // because this function is in a performance sensitive code path. if(obj->word_length_rx <= 8) { uint8_t *cast_buffer = (uint8_t*)(*buffer); while(*length > 0 && _cyhal_audioss_get_num_in_fifo(obj, false) > 0) { *cast_buffer = (uint8_t)_cyhal_audioss_read_fifo(obj); ++cast_buffer; --(*length); } *buffer = (void*)cast_buffer; } else if(obj->word_length_rx <= 16) { uint16_t *cast_buffer = (uint16_t*)(*buffer); while(*length > 0 && _cyhal_audioss_get_num_in_fifo(obj, false) > 0) { *cast_buffer = (uint16_t)_cyhal_audioss_read_fifo(obj); ++cast_buffer; --(*length); } *buffer = (void*)cast_buffer; } else { CY_ASSERT(obj->word_length_rx <= 32); uint32_t *cast_buffer = (uint32_t*)(*buffer); while(*length > 0 && _cyhal_audioss_get_num_in_fifo(obj, false) > 0) { *cast_buffer = _cyhal_audioss_read_fifo(obj); ++cast_buffer; --(*length); } *buffer = (void*)cast_buffer; } } #endif cy_rslt_t _cyhal_audioss_read(_cyhal_audioss_t *obj, void *data, size_t* length) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) CY_ASSERT(NULL != obj); if (obj->pm_transition_ready) { return CYHAL_SYSPM_RSLT_ERR_PM_PENDING; } size_t remaining = *length; _cyhal_audioss_read_until_empty(obj, &data, &remaining); *length -= remaining; return CY_RSLT_SUCCESS; #else CY_UNUSED_PARAMETER(data); CY_UNUSED_PARAMETER(length); return obj->interface->err_not_supported; #endif } static void _cyhal_audioss_write_until_full(_cyhal_audioss_t *obj, const void** buffer, size_t *length) { // The buffer is the smallest type that will hold the word length // The structure of this function deliberately accepts duplication of the outer loop // structure in order to avoid having to recheck the word length every time around, // because this function is in a performance sensitive code path. if(obj->word_length_tx <= 8) { const uint8_t *cast_buffer = (const uint8_t*)(*buffer); while(*length > 0 && _cyhal_audioss_get_num_in_fifo(obj, true) < _CYHAL_AUDIOSS_FIFO_DEPTH) { _cyhal_audioss_write_fifo(obj, *cast_buffer); ++cast_buffer; --(*length); } *buffer = (void*)cast_buffer; } else if(obj->word_length_tx <= 16) { const uint16_t *cast_buffer = (const uint16_t*)(*buffer); while(*length > 0 && _cyhal_audioss_get_num_in_fifo(obj, true) < _CYHAL_AUDIOSS_FIFO_DEPTH) { _cyhal_audioss_write_fifo(obj, *cast_buffer); ++cast_buffer; --(*length); } *buffer = (void*)cast_buffer; } else { CY_ASSERT(obj->word_length_tx <= 32); const uint32_t *cast_buffer = (const uint32_t*)(*buffer); while(*length > 0 && _cyhal_audioss_get_num_in_fifo(obj, true) < _CYHAL_AUDIOSS_FIFO_DEPTH) { _cyhal_audioss_write_fifo(obj, *cast_buffer); ++cast_buffer; --(*length); } *buffer = (void*)cast_buffer; } } cy_rslt_t _cyhal_audioss_write(_cyhal_audioss_t *obj, const void *data, size_t *length) { CY_ASSERT(NULL != obj); if (obj->pm_transition_ready) { return CYHAL_SYSPM_RSLT_ERR_PM_PENDING; } size_t remaining = *length; _cyhal_audioss_write_until_full(obj, &data, &remaining); *length -= remaining; return CY_RSLT_SUCCESS; } bool _cyhal_audioss_is_tx_enabled(_cyhal_audioss_t *obj) { CY_ASSERT(NULL != obj); #if defined(CY_IP_MXAUDIOSS) return (0 != (CY_I2S_TX_START & Cy_I2S_GetCurrentState(obj->base))); #elif(defined(CY_IP_MXTDM)) return (0u != (TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_FIFO_CTL_ACTIVE_Msk & obj->base->TDM_TX_STRUCT.TX_FIFO_CTL)); #endif } bool _cyhal_audioss_is_tx_busy(_cyhal_audioss_t *obj) { CY_ASSERT(NULL != obj); return (0 != _cyhal_audioss_get_num_in_fifo(obj, true)) || _cyhal_audioss_is_write_pending(obj); } bool _cyhal_audioss_is_rx_enabled(_cyhal_audioss_t *obj) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) CY_ASSERT(NULL != obj); #if defined(CY_IP_MXAUDIOSS) return (0 != (CY_I2S_RX_START & Cy_I2S_GetCurrentState(obj->base))); #elif(defined(CY_IP_MXTDM)) return (0u != (TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_FIFO_CTL_ACTIVE_Msk & obj->base->TDM_RX_STRUCT.RX_FIFO_CTL)); #endif #else CY_UNUSED_PARAMETER(obj); return false; #endif } bool _cyhal_audioss_is_rx_busy(_cyhal_audioss_t *obj) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) CY_ASSERT(NULL != obj); return (0 != _cyhal_audioss_get_num_in_fifo(obj, false)) || _cyhal_audioss_is_read_pending(obj); #else CY_UNUSED_PARAMETER(obj); return false; #endif } cy_rslt_t _cyhal_audioss_read_async(_cyhal_audioss_t *obj, void *rx, size_t rx_length) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) CY_ASSERT(NULL != obj); if (obj->pm_transition_ready) { return CYHAL_SYSPM_RSLT_ERR_PM_PENDING; } uint32_t savedIntrStatus = cyhal_system_critical_section_enter(); obj->async_rx_buff = rx; obj->async_rx_length = rx_length; cyhal_system_critical_section_exit(savedIntrStatus); switch(obj->async_mode) { case CYHAL_ASYNC_SW: { /* Read as much as we can now, then set up an interrupt to do the rest * This is a potentially long operation but we don't want other I2S operations to * interleave with it. So do a "mini critical section" and disable the interrupts for this block only. */ uint32_t old_events = _cyhal_audioss_disable_events(obj, false); // Safe to cast away volatile here because we're calling read_until_empty from within // a critical section, so it should not change out from under us during this call _cyhal_audioss_read_until_empty(obj, (void**)(&obj->async_rx_buff), (size_t*)(&obj->async_rx_length)); _cyhal_audioss_update_rx_trigger_level(obj); _cyhal_audioss_restore_events(obj, false, old_events); if(obj->async_rx_length > 0) { _cyhal_audioss_update_enabled_events(obj); } else { _cyhal_audioss_process_event(obj, obj->interface->event_rx_complete); } break; } case CYHAL_ASYNC_DMA: { // Don't directly kick off the DMA here - it will be triggered // from the interrupt handler when the FIFO rised above the threshold // (which may have already happened by the time we get here if the // application already had the full or half-full event enabled) _cyhal_audioss_update_rx_trigger_level(obj); _cyhal_audioss_update_enabled_events(obj); break; } default: CY_ASSERT(0); /* Unrecognized async mode */ } return CY_RSLT_SUCCESS; #else CY_UNUSED_PARAMETER(rx); CY_UNUSED_PARAMETER(rx_length); return obj->interface->err_not_supported; #endif } static void _cyhal_audioss_reconstruct_pdl_config(_cyhal_audioss_t *obj, _cyhal_audioss_pdl_config_t* pdl_config) { #if defined(CY_IP_MXAUDIOSS) I2S_Type* base = obj->base; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) pdl_config->txEnabled = _FLD2BOOL(I2S_CTL_TX_ENABLED, REG_I2S_CTL(base)); pdl_config->rxEnabled = _FLD2BOOL(I2S_CTL_RX_ENABLED, REG_I2S_CTL(base)); uint32_t rx_ctl_val = REG_I2S_RX_CTL(base); pdl_config->rxMasterMode = _FLD2BOOL(I2S_RX_CTL_MS, rx_ctl_val); pdl_config->rxAlignment = (cy_en_i2s_alignment_t)_FLD2VAL(I2S_RX_CTL_I2S_MODE, rx_ctl_val); pdl_config->rxWsPulseWidth = (cy_en_i2s_ws_pw_t)_FLD2VAL(I2S_RX_CTL_WS_PULSE, rx_ctl_val); pdl_config->rxWatchdogEnable = _FLD2BOOL(I2S_RX_CTL_WD_EN, rx_ctl_val); pdl_config->rxWatchdogValue = REG_I2S_RX_WATCHDOG(base); pdl_config->rxSdiLatchingTime = _FLD2BOOL(I2S_RX_CTL_B_CLOCK_INV, rx_ctl_val); pdl_config->rxSckoInversion = _FLD2BOOL(I2S_RX_CTL_SCKO_POL, rx_ctl_val); pdl_config->rxSckiInversion = _FLD2BOOL(I2S_RX_CTL_SCKI_POL, rx_ctl_val); /* Register is one less than desired value */ pdl_config->rxChannels = ((uint8_t)_FLD2VAL(I2S_RX_CTL_CH_NR, rx_ctl_val)) + 1; pdl_config->rxChannelLength = (cy_en_i2s_len_t)_FLD2VAL(I2S_RX_CTL_CH_LEN, rx_ctl_val); pdl_config->rxWordLength = (cy_en_i2s_len_t)_FLD2VAL(I2S_RX_CTL_WORD_LEN, rx_ctl_val); pdl_config->rxSignExtension = _FLD2BOOL(I2S_RX_CTL_SCKI_POL, rx_ctl_val); pdl_config->rxFifoTriggerLevel = _cyhal_audioss_fifo_trigger_level(obj, false); #endif /* _CYHAL_AUDIOSS_RX_ENABLED */ #if defined(_CYHAL_AUDIOSS_TX_WATCHDOG_AVAILABLE) pdl_config->txWatchdogEnable = _FLD2BOOL(I2S_TX_CTL_WD_EN, rx_ctl_val);; pdl_config->txWatchdogValue = REG_I2S_TX_WATCHDOG(base); #endif #if defined(_CYHAL_AUDIOSS_TRIGGERS_AVAILABLE) pdl_config->txDmaTrigger = _FLD2BOOL(I2S_TR_CTL_TX_REQ_EN, REG_I2S_TR_CTL(base)); #if defined(_CYHAL_AUDIOSS_RX_ENABLED) pdl_config->rxDmaTrigger = _FLD2BOOL(I2S_TR_CTL_RX_REQ_EN, REG_I2S_TR_CTL(base));; #endif #endif /* _CYHAL_AUDIOSS_RX_ENABLED */ uint32_t tx_ctl_val = REG_I2S_TX_CTL(base); #if defined(_CYHAL_AUDIOSS_TX_SLAVE_AVAILABLE) pdl_config->txMasterMode = _FLD2BOOL(I2S_TX_CTL_MS, tx_ctl_val); pdl_config->txSckiInversion = _FLD2BOOL(I2S_TX_CTL_SCKI_POL, tx_ctl_val); pdl_config->txSdoLatchingTime = _FLD2BOOL(I2S_TX_CTL_B_CLOCK_INV, tx_ctl_val);; #endif /* Register value is 1 less than the desired divider */ pdl_config->clkDiv = ((uint8_t)_FLD2VAL(I2S_CLOCK_CTL_CLOCK_DIV, REG_I2S_CLOCK_CTL(base))) + 1; pdl_config->extClk = _FLD2BOOL(I2S_CLOCK_CTL_CLOCK_SEL, REG_I2S_CLOCK_CTL(base)); /* TDM mode A == channel data starts on rising edge of WS */ pdl_config->txAlignment = (cy_en_i2s_alignment_t)_FLD2VAL(I2S_TX_CTL_I2S_MODE, tx_ctl_val); pdl_config->txWsPulseWidth = (cy_en_i2s_ws_pw_t)_FLD2VAL(I2S_TX_CTL_WS_PULSE, tx_ctl_val); pdl_config->txSckoInversion = _FLD2BOOL(I2S_TX_CTL_SCKO_POL, tx_ctl_val); /* Register is one less than desired value */ pdl_config->txChannels = ((uint8_t)_FLD2VAL(I2S_TX_CTL_CH_NR, tx_ctl_val)) + 1; pdl_config->txChannelLength = (cy_en_i2s_len_t)_FLD2VAL(I2S_TX_CTL_CH_LEN, tx_ctl_val); pdl_config->txWordLength = (cy_en_i2s_len_t)_FLD2VAL(I2S_TX_CTL_WORD_LEN, tx_ctl_val); pdl_config->txOverheadValue = (cy_en_i2s_overhead_t)_FLD2VAL(I2S_TX_CTL_OVHDATA, tx_ctl_val); pdl_config->txFifoTriggerLevel = _cyhal_audioss_fifo_trigger_level(obj, true); #elif defined(CY_IP_MXTDM) TDM_TX_STRUCT_Type* base_tx = &obj->base->TDM_TX_STRUCT; TDM_RX_STRUCT_Type* base_rx = &obj->base->TDM_RX_STRUCT; /* Configure TX */ pdl_config->tx_config->enable = _cyhal_audioss_is_direction_enabled(obj, true); pdl_config->tx_config->masterMode = (cy_en_tdm_device_cfg_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_CTL_MS, TDM_STRUCT_TX_CTL(base_tx)); pdl_config->tx_config->wordSize = (cy_en_tdm_ws_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_CTL_WORD_SIZE, TDM_STRUCT_TX_CTL(base_tx)); pdl_config->tx_config->format = (cy_en_tdm_format_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_CTL_FORMAT, TDM_STRUCT_TX_CTL(base_tx)); uint32_t tx_if_ctl = TDM_STRUCT_TX_IF_CTL(base_tx); /* Divider in the config register is a less than the desired value */ pdl_config->tx_config->clkDiv = (uint16_t)(_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_IF_CTL_CLOCK_DIV, tx_if_ctl) + 1); pdl_config->tx_config->clkSel = (cy_en_tdm_clock_sel_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_IF_CTL_CLOCK_SEL, tx_if_ctl); pdl_config->tx_config->sckPolarity = (cy_en_tdm_sckpolarity_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_IF_CTL_SCK_POLARITY, tx_if_ctl);; pdl_config->tx_config->fsyncPolarity = (cy_en_tdm_fsyncpolarity_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_IF_CTL_FSYNC_POLARITY, tx_if_ctl);; pdl_config->tx_config->fsyncFormat = (cy_en_tdm_fsyncformat_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_IF_CTL_FSYNC_FORMAT, tx_if_ctl); /* Channel size and count in the register are one less than the desired value */ pdl_config->tx_config->channelNum = (uint8_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_IF_CTL_CH_NR, tx_if_ctl) + 1; pdl_config->tx_config->channelSize = (uint8_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_IF_CTL_CH_SIZE, tx_if_ctl) + 1; pdl_config->tx_config->fifoTriggerLevel = _cyhal_audioss_fifo_trigger_level(obj, true); pdl_config->tx_config->chEn = TDM_STRUCT_TX_CH_CTL(base_tx); pdl_config->tx_config->signalInput = _FLD2VAL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_ROUTE_CTL_MODE, TDM_STRUCT_TX_ROUTE_CTL(base_tx)); pdl_config->tx_config->i2sMode = _FLD2BOOL(TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_IF_CTL_I2S_MODE, tx_if_ctl); /* Configure RX */ pdl_config->rx_config->enable = _cyhal_audioss_is_direction_enabled(obj, false); pdl_config->rx_config->masterMode = (cy_en_tdm_device_cfg_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_CTL_MS, TDM_STRUCT_RX_CTL(base_rx)); pdl_config->rx_config->wordSize = (cy_en_tdm_ws_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_CTL_WORD_SIZE, TDM_STRUCT_RX_CTL(base_rx)); pdl_config->rx_config->format = (cy_en_tdm_format_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_CTL_FORMAT, TDM_STRUCT_RX_CTL(base_rx)); uint32_t rx_if_ctl = TDM_STRUCT_RX_IF_CTL(base_rx); /* Divider in the config register is a less than the desired value */ pdl_config->rx_config->clkDiv = (uint16_t)(_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_IF_CTL_CLOCK_DIV, rx_if_ctl) + 1); pdl_config->rx_config->clkSel = (cy_en_tdm_clock_sel_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_IF_CTL_CLOCK_SEL, rx_if_ctl); pdl_config->rx_config->sckPolarity = (cy_en_tdm_sckpolarity_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_IF_CTL_SCK_POLARITY, rx_if_ctl); pdl_config->rx_config->fsyncPolarity = (cy_en_tdm_fsyncpolarity_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_IF_CTL_FSYNC_POLARITY, rx_if_ctl);; pdl_config->rx_config->fsyncFormat = (cy_en_tdm_fsyncformat_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_IF_CTL_FSYNC_FORMAT, rx_if_ctl); /* Channel size and count in the register are one less than the desired value */ pdl_config->rx_config->channelNum = (uint8_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_IF_CTL_CH_NR, rx_if_ctl) + 1; pdl_config->rx_config->channelSize = (uint8_t)_FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_IF_CTL_CH_SIZE, rx_if_ctl) + 1; pdl_config->rx_config->fifoTriggerLevel = _cyhal_audioss_fifo_trigger_level(obj, false); pdl_config->rx_config->chEn = TDM_STRUCT_RX_CH_CTL(base_rx); pdl_config->rx_config->signalInput = _FLD2VAL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_ROUTE_CTL_MODE, TDM_STRUCT_RX_ROUTE_CTL(base_rx)); pdl_config->rx_config->i2sMode = _FLD2BOOL(TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_IF_CTL_I2S_MODE, rx_if_ctl); #else #error "Unrecognized audio IP" #endif } static cy_rslt_t _cyhal_audioss_populate_pdl_config(_cyhal_audioss_t *obj, _cyhal_audioss_pdl_config_t* pdl_config, const _cyhal_audioss_config_t* hal_cfg, uint16_t sclk_div_rx, uint16_t sclk_div_tx, bool rx_en, bool tx_en, bool mclk_rx, bool mclk_tx) { #if defined(CY_IP_MXAUDIOSS) cy_en_i2s_len_t pdl_word_length_tx, pdl_channel_length_tx; cy_rslt_t result = _cyhal_audioss_length_to_pdl(obj->channel_length_tx, &pdl_channel_length_tx, obj); if (CY_RSLT_SUCCESS == result) { result = _cyhal_audioss_length_to_pdl(obj->word_length_tx, &pdl_word_length_tx, obj); } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) cy_en_i2s_len_t pdl_word_length_rx, pdl_channel_length_rx; if (CY_RSLT_SUCCESS == result) { result = _cyhal_audioss_length_to_pdl(obj->channel_length_rx, &pdl_channel_length_rx, obj); } if (CY_RSLT_SUCCESS == result) { result = _cyhal_audioss_length_to_pdl(obj->word_length_rx, &pdl_word_length_rx, obj); } #endif if(CY_RSLT_SUCCESS == result) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) pdl_config->txEnabled = tx_en; pdl_config->rxEnabled = rx_en; pdl_config->rxMasterMode = !hal_cfg->is_rx_slave; pdl_config->rxAlignment = hal_cfg->is_i2s ? CY_I2S_I2S_MODE : CY_I2S_TDM_MODE_A; pdl_config->rxWsPulseWidth = hal_cfg->rx_ws_full ? CY_I2S_WS_ONE_CHANNEL_LENGTH : CY_I2S_WS_ONE_SCK_CYCLE; pdl_config->rxWatchdogEnable = false; pdl_config->rxWatchdogValue = 0u; pdl_config->rxSdiLatchingTime = false; pdl_config->rxSckoInversion = false; pdl_config->rxSckiInversion = false; pdl_config->rxChannels = hal_cfg->num_channels; pdl_config->rxChannelLength = pdl_channel_length_rx; pdl_config->rxWordLength = pdl_word_length_rx; pdl_config->rxSignExtension = false; /* All MSB are filled by zeros, per HAL API specification */ pdl_config->rxFifoTriggerLevel = _CYHAL_AUDIOSS_FIFO_DEPTH / 2 - 1; // Trigger at half full #else CY_UNUSED_PARAMETER(rx_en); CY_UNUSED_PARAMETER(tx_en); #endif #if defined(_CYHAL_AUDIOSS_TX_WATCHDOG_AVAILABLE) pdl_config->txWatchdogEnable = false; pdl_config->txWatchdogValue = 0u; #endif #if defined(_CYHAL_AUDIOSS_TRIGGERS_AVAILABLE) pdl_config->txDmaTrigger = false; #if defined(_CYHAL_AUDIOSS_RX_ENABLED) pdl_config->rxDmaTrigger = false; #endif #endif #if defined(_CYHAL_AUDIOSS_TX_SLAVE_AVAILABLE) pdl_config->txMasterMode = !hal_cfg->is_tx_slave; pdl_config->txSckiInversion = false; pdl_config->txSdoLatchingTime = false; #endif #if defined(_CYHAL_AUDIOSS_RX_ENABLED) /* Should be the same because RX and TX mclk must be the same if they are both enabled */ CY_ASSERT(sclk_div_rx == sclk_div_tx || false == pdl_config->txEnabled || false == pdl_config->rxEnabled); pdl_config->clkDiv = (uint8_t)(pdl_config->txEnabled ? sclk_div_tx : sclk_div_rx); #else CY_UNUSED_PARAMETER(sclk_div_rx); pdl_config->clkDiv = (uint8_t)(sclk_div_tx); #endif pdl_config->extClk = mclk_tx; /* No separate rx/tx mclk selection on this IP */ CY_UNUSED_PARAMETER(mclk_rx); /* TDM mode A == channel data starts on rising edge of WS */ pdl_config->txAlignment = hal_cfg->is_i2s ? CY_I2S_I2S_MODE : CY_I2S_TDM_MODE_A; pdl_config->txWsPulseWidth = hal_cfg->tx_ws_full ? CY_I2S_WS_ONE_CHANNEL_LENGTH : CY_I2S_WS_ONE_SCK_CYCLE; pdl_config->txSckoInversion = false; pdl_config->txChannels = hal_cfg->num_channels; pdl_config->txChannelLength = pdl_channel_length_tx; pdl_config->txWordLength = pdl_word_length_tx; pdl_config->txOverheadValue = CY_I2S_OVHDATA_ZERO; /* Per HAL API specification */ pdl_config->txFifoTriggerLevel = _CYHAL_AUDIOSS_FIFO_DEPTH / 2 + 1; /* Trigger at half empty */ } #elif defined(CY_IP_MXTDM) cy_en_tdm_ws_t pdl_word_length_rx, pdl_word_length_tx; cy_rslt_t result = _cyhal_audioss_length_to_pdl(obj->word_length_tx, &pdl_word_length_tx, obj); if(CY_RSLT_SUCCESS == result) { result = _cyhal_audioss_length_to_pdl(obj->word_length_rx, &pdl_word_length_rx, obj); } if(CY_RSLT_SUCCESS == result) { /* Configure TX */ pdl_config->tx_config->enable = tx_en; pdl_config->tx_config->masterMode = hal_cfg->is_tx_slave ? CY_TDM_DEVICE_SLAVE : CY_TDM_DEVICE_MASTER; pdl_config->tx_config->wordSize = pdl_word_length_tx; pdl_config->tx_config->format = hal_cfg->is_i2s ? CY_TDM_LEFT_DELAYED : CY_TDM_LEFT; pdl_config->tx_config->clkDiv = sclk_div_tx; /* Only clock 0 from the srss hooked up on current hardware */ pdl_config->tx_config->clkSel = mclk_tx ? CY_TDM_SEL_MCLK_IN : CY_TDM_SEL_SRSS_CLK0; pdl_config->tx_config->sckPolarity = CY_TDM_CLK; /* For I2S, frame sync aka word select starts out low */ pdl_config->tx_config->fsyncPolarity = hal_cfg->is_i2s ? CY_TDM_SIGN_INVERTED : CY_TDM_SIGN; pdl_config->tx_config->fsyncFormat = hal_cfg->tx_ws_full ? CY_TDM_CH_PERIOD : CY_TDM_BIT_PERIOD; pdl_config->tx_config->channelNum = hal_cfg->num_channels; pdl_config->tx_config->channelSize = obj->channel_length_tx; pdl_config->tx_config->fifoTriggerLevel = _CYHAL_AUDIOSS_FIFO_DEPTH / 2 + 1; /* Trigger at half empty */ pdl_config->tx_config->chEn = hal_cfg->channel_mask; pdl_config->tx_config->signalInput = 0; /* TX and RX signaling independent */ pdl_config->tx_config->i2sMode = hal_cfg->is_i2s; /* Configure RX */ pdl_config->rx_config->enable = rx_en; pdl_config->rx_config->masterMode = hal_cfg->is_rx_slave ? CY_TDM_DEVICE_SLAVE : CY_TDM_DEVICE_MASTER; pdl_config->rx_config->wordSize = pdl_word_length_rx; pdl_config->rx_config->format = hal_cfg->is_i2s ? CY_TDM_LEFT_DELAYED : CY_TDM_LEFT; pdl_config->rx_config->clkDiv = sclk_div_rx; /* Only clock 0 from the srss hooked up on current hardware */ pdl_config->rx_config->clkSel = mclk_rx ? CY_TDM_SEL_MCLK_IN : CY_TDM_SEL_SRSS_CLK0; pdl_config->rx_config->sckPolarity = CY_TDM_CLK; /* For I2S, frame sync aka word select starts out low */ pdl_config->rx_config->fsyncPolarity = hal_cfg->is_i2s ? CY_TDM_SIGN_INVERTED : CY_TDM_SIGN; pdl_config->rx_config->fsyncFormat = hal_cfg->rx_ws_full ? CY_TDM_CH_PERIOD : CY_TDM_BIT_PERIOD; pdl_config->rx_config->channelNum = hal_cfg->num_channels; pdl_config->rx_config->channelSize = obj->channel_length_rx; pdl_config->rx_config->fifoTriggerLevel = _CYHAL_AUDIOSS_FIFO_DEPTH / 2 + 1; /* Trigger at half empty */ pdl_config->rx_config->chEn = hal_cfg->channel_mask; pdl_config->rx_config->signalInput = 0; /* TX and RX signaling independent */ pdl_config->rx_config->i2sMode = hal_cfg->is_i2s; pdl_config->rx_config->signExtend = CY_ZERO_EXTEND; pdl_config->rx_config->lateSample = false; } #else #error "Unrecognized audio IP" #endif return result; } #if (CYHAL_DRIVER_AVAILABLE_DMA) /* Round up the word length to the next power of 2 * NOTE: This method used only in I2S HAL function related to DMA. * To avoid compilation warning declare this function only when DMA is available */ static uint8_t _cyhal_audioss_rounded_word_length(_cyhal_audioss_t *obj, bool is_tx) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) uint8_t word_length = is_tx ? obj->word_length_tx : obj->word_length_rx; #else CY_UNUSED_PARAMETER(is_tx); uint8_t word_length = obj->word_length_tx; #endif CY_ASSERT(word_length <= 32); if(word_length <= 8) { return 8u; } else if(word_length <= 16) { return 16u; } return 32u; } #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ cy_rslt_t _cyhal_audioss_write_async(_cyhal_audioss_t *obj, const void *tx, size_t tx_length) { CY_ASSERT(NULL != obj); if (obj->pm_transition_ready) { return CYHAL_SYSPM_RSLT_ERR_PM_PENDING; } uint32_t savedIntrStatus = cyhal_system_critical_section_enter(); obj->async_tx_buff = tx; obj->async_tx_length = tx_length; cyhal_system_critical_section_exit(savedIntrStatus); switch(obj->async_mode) { case CYHAL_ASYNC_SW: { /* Write as much as we can now, then set up an interrupt to do the rest * This is a potentially long operation but we don't want other I2S operations to * interleave with it. So do a "mini critical section" and disable the interrupts for this block only. */ uint32_t old_events = _cyhal_audioss_disable_events(obj, true); // Safe to cast away volatile here because we're calling write_until_full from within // a critical section, so it should not change out from under us during this call _cyhal_audioss_write_until_full(obj, (const void**)(&obj->async_tx_buff), (size_t *)(&obj->async_tx_length)); _cyhal_audioss_restore_events(obj, true, old_events); if(obj->async_tx_length > 0) { _cyhal_audioss_update_enabled_events(obj); } else { _cyhal_audioss_process_event(obj, obj->interface->event_tx_complete); } break; } case CYHAL_ASYNC_DMA: { // Don't directly kick off the DMA here - it will be triggered // from the interrupt handler when the FIFO drops below the threshold // (which may have already happened by the time we get here if the // application already had the half-empty or empty event enabled) _cyhal_audioss_update_enabled_events(obj); break; } default: CY_ASSERT(0); /* Unrecognized async mode */ break; } return CY_RSLT_SUCCESS; } cy_rslt_t _cyhal_audioss_set_async_mode(_cyhal_audioss_t *obj, cyhal_async_mode_t mode, uint8_t dma_priority) { CY_ASSERT(NULL != obj); // We don't support swapping the async mode out from under a pending transfer. #if defined(_CYHAL_AUDIOSS_RX_ENABLED) CY_ASSERT(false == _cyhal_audioss_is_read_pending(obj)); #endif CY_ASSERT(false == _cyhal_audioss_is_write_pending(obj)); cy_rslt_t result = CY_RSLT_SUCCESS; if(mode == CYHAL_ASYNC_DMA) { #if (CYHAL_DRIVER_AVAILABLE_DMA) // Reserve a DMA channel for each direction that is enabled if(_cyhal_audioss_is_direction_enabled(obj, true) && CYHAL_RSC_INVALID == obj->tx_dma.resource.type) { /* Reserve a DMA channel for async transmit if tx is enabled */ result = cyhal_dma_init(&obj->tx_dma, CYHAL_DMA_PRIORITY_DEFAULT, CYHAL_DMA_DIRECTION_MEM2PERIPH); cyhal_dma_register_callback(&obj->tx_dma, &_cyhal_audioss_dma_handler_tx, obj); } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(_cyhal_audioss_is_direction_enabled(obj, false) && CYHAL_RSC_INVALID == obj->rx_dma.resource.type) { /* Reserve a DMA channel for async receive if rx is enabled */ result = cyhal_dma_init(&obj->rx_dma, CYHAL_DMA_PRIORITY_DEFAULT, CYHAL_DMA_DIRECTION_PERIPH2MEM); cyhal_dma_register_callback(&obj->rx_dma, &_cyhal_audioss_dma_handler_rx, obj); } #endif /* defined(_CYHAL_AUDIOSS_RX_ENABLED) */ #else CY_ASSERT(0); /* DMA driver is not available */ #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ } else { /* Free the DMA instances if we reserved them but don't need them anymore */ if(CYHAL_RSC_INVALID != obj->tx_dma.resource.type) { #if (CYHAL_DRIVER_AVAILABLE_DMA) cyhal_dma_free(&obj->tx_dma); #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ obj->tx_dma.resource.type = CYHAL_RSC_INVALID; } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(CYHAL_RSC_INVALID != obj->rx_dma.resource.type) { #if (CYHAL_DRIVER_AVAILABLE_DMA) cyhal_dma_free(&obj->rx_dma); #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ obj->rx_dma.resource.type = CYHAL_RSC_INVALID; } #endif /* defined(_CYHAL_AUDIOSS_RX_ENABLED) */ } if(CY_RSLT_SUCCESS == result) { obj->async_mode = mode; obj->async_dma_priority = dma_priority; } return result; } bool _cyhal_audioss_is_read_pending(_cyhal_audioss_t *obj) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) return (NULL != obj->async_rx_buff); #else CY_UNUSED_PARAMETER(obj); return false; #endif } bool _cyhal_audioss_is_write_pending(_cyhal_audioss_t *obj) { return (NULL != obj->async_tx_buff); } cy_rslt_t _cyhal_audioss_abort_read_async(_cyhal_audioss_t *obj) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) uint32_t saved_intr = cyhal_system_critical_section_enter(); obj->async_rx_buff = NULL; _cyhal_audioss_update_enabled_events(obj); cyhal_system_critical_section_exit(saved_intr); return CY_RSLT_SUCCESS; #else return obj->interface->err_not_supported; #endif } cy_rslt_t _cyhal_audioss_abort_write_async(_cyhal_audioss_t *obj) { uint32_t saved_intr = cyhal_system_critical_section_enter(); obj->async_tx_buff = NULL; _cyhal_audioss_update_enabled_events(obj); cyhal_system_critical_section_exit(saved_intr); return CY_RSLT_SUCCESS; } #if defined(CY_IP_MXAUDIOSS) static uint8_t _cyhal_audioss_length_from_pdl(cy_en_i2s_len_t pdl_length) { switch(pdl_length) { case CY_I2S_LEN8: return 8u; case CY_I2S_LEN16: return 16u; case CY_I2S_LEN18: return 18u; case CY_I2S_LEN20: return 20u; case CY_I2S_LEN24: return 24u; case CY_I2S_LEN32: return 32u; default: CY_ASSERT(false); /* Should never get here */ return 32u; } } static cy_rslt_t _cyhal_audioss_length_to_pdl(uint8_t user_length, cy_en_i2s_len_t *pdl_length, const _cyhal_audioss_t *obj) { cy_rslt_t result = CY_RSLT_SUCCESS; switch(user_length) { case 8u: *pdl_length = CY_I2S_LEN8; break; case 16u: *pdl_length = CY_I2S_LEN16; break; case 18u: *pdl_length = CY_I2S_LEN18; break; case 20u: *pdl_length = CY_I2S_LEN20; break; case 24u: *pdl_length = CY_I2S_LEN24; break; case 32u: *pdl_length = CY_I2S_LEN32; break; default: *pdl_length = CY_I2S_LEN32; result = obj->interface->err_invalid_arg; } return result; } #elif defined(CY_IP_MXTDM) static uint8_t _cyhal_audioss_length_from_pdl(cy_en_tdm_ws_t pdl_length) { switch(pdl_length) { case CY_TDM_SIZE_8: return 8u; case CY_TDM_SIZE_10: return 10u; case CY_TDM_SIZE_12: return 12u; case CY_TDM_SIZE_14: return 14u; case CY_TDM_SIZE_16: return 16u; case CY_TDM_SIZE_18: return 18u; case CY_TDM_SIZE_20: return 20u; case CY_TDM_SIZE_24: return 24u; case CY_TDM_SIZE_32: return 32u; default: CY_ASSERT(false); /* Should never get here */ return 32u; } } static cy_rslt_t _cyhal_audioss_length_to_pdl(uint8_t user_length, cy_en_tdm_ws_t *pdl_length, const _cyhal_audioss_t *obj) { cy_rslt_t result = CY_RSLT_SUCCESS; switch(user_length) { case 8u: *pdl_length = CY_TDM_SIZE_8; break; case 10u: *pdl_length = CY_TDM_SIZE_10; break; case 12u: *pdl_length = CY_TDM_SIZE_12; break; case 14u: *pdl_length = CY_TDM_SIZE_14; break; case 16u: *pdl_length = CY_TDM_SIZE_16; break; case 18u: *pdl_length = CY_TDM_SIZE_18; break; case 20u: *pdl_length = CY_TDM_SIZE_20; break; case 24u: *pdl_length = CY_TDM_SIZE_24; break; case 32u: *pdl_length = CY_TDM_SIZE_32; break; default: *pdl_length = CY_TDM_SIZE_32; result = obj->interface->err_invalid_arg; } return result; } #else #error "Unrecognized audio IP" #endif #if defined(CY_IP_MXAUDIOSS) static void _cyhal_audioss_irq_handler(void) { _cyhal_system_irq_t irqn = _cyhal_irq_get_active(); uint8_t block = _cyhal_audioss_get_block_from_irqn(irqn); _cyhal_audioss_t* obj = _cyhal_audioss_config_structs[block]; uint32_t interrupt_status = Cy_I2S_GetInterruptStatusMasked(obj->base); Cy_I2S_ClearInterrupt(obj->base, interrupt_status); uint32_t event = obj->interface->convert_interrupt_cause(interrupt_status); _cyhal_audioss_process_event(obj, event); } #elif defined(CY_IP_MXTDM) #if defined (COMPONENT_CAT5) static void _cyhal_audioss_irq_handler_rx(_cyhal_system_irq_t irqn) { #else static void _cyhal_audioss_irq_handler_rx() { _cyhal_system_irq_t irqn = _cyhal_irq_get_active(); #endif uint8_t block = _cyhal_audioss_get_block_from_irqn(irqn); _cyhal_audioss_t* obj = _cyhal_audioss_config_structs[block]; uint32_t interrupt_status = Cy_AudioTDM_GetRxInterruptStatusMasked(&obj->base->TDM_RX_STRUCT); Cy_AudioTDM_ClearRxInterrupt(&obj->base->TDM_RX_STRUCT, interrupt_status); uint32_t event = obj->interface->convert_interrupt_cause(interrupt_status, false); _cyhal_audioss_process_event(obj, event); } #if defined (COMPONENT_CAT5) static void _cyhal_audioss_irq_handler_tx(_cyhal_system_irq_t irqn) { #else static void _cyhal_audioss_irq_handler_tx() { _cyhal_system_irq_t irqn = _cyhal_irq_get_active(); #endif uint8_t block = _cyhal_audioss_get_block_from_irqn(irqn); _cyhal_audioss_t* obj = _cyhal_audioss_config_structs[block]; uint32_t interrupt_status = Cy_AudioTDM_GetTxInterruptStatusMasked(&obj->base->TDM_TX_STRUCT); Cy_AudioTDM_ClearTxInterrupt(&obj->base->TDM_TX_STRUCT, interrupt_status); uint32_t event = obj->interface->convert_interrupt_cause(interrupt_status, true); _cyhal_audioss_process_event(obj, event); } #if defined (COMPONENT_CAT5) static void _cyhal_audioss_irq_handler(UINT8 instance, BOOL8 rx_int) { (rx_int) ? _cyhal_audioss_irq_handler_rx(instance) : _cyhal_audioss_irq_handler_tx(instance); } #endif #endif static void _cyhal_audioss_update_enabled_events(_cyhal_audioss_t *obj) { uint32_t events = obj->user_enabled_events; if(NULL != obj->async_tx_buff && obj->async_tx_length > 0) { events |= (obj->interface->event_mask_empty | obj->interface->event_mask_half_empty); } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(NULL != obj->async_rx_buff && obj->async_rx_length > 0) { events |= (obj->interface->event_mask_full | obj->interface->event_mask_half_full); } #endif #if defined(CY_IP_MXAUDIOSS) uint32_t mask = obj->interface->convert_to_pdl(events); // The register is 24 bits wide but the hardware pads the value out with 1's when read. // So mask down to just the bits that we actually care about. uint32_t old_mask = Cy_I2S_GetInterruptMask(obj->base) & CY_I2S_INTR_MASK; // Clear the interrupts that are about to be enabled to avoid spurious firing uint32_t new_interrupts = mask & (~old_mask); Cy_I2S_ClearInterrupt(obj->base, new_interrupts); Cy_I2S_SetInterruptMask(obj->base, mask); #elif defined(CY_IP_MXTDM) uint32_t tx_mask = obj->interface->convert_to_pdl(events, true); uint32_t old_tx_mask = Cy_AudioTDM_GetTxInterruptMask(&obj->base->TDM_TX_STRUCT); // Clear the interrupts that are about to be enabled to avoid spurious firing uint32_t new_interrupts_tx = tx_mask & (~old_tx_mask); Cy_AudioTDM_ClearTxInterrupt(&obj->base->TDM_TX_STRUCT, new_interrupts_tx); Cy_AudioTDM_SetTxInterruptMask(&obj->base->TDM_TX_STRUCT, tx_mask); uint32_t rx_mask = obj->interface->convert_to_pdl(events, false); uint32_t old_rx_mask = Cy_AudioTDM_GetRxInterruptMask(&obj->base->TDM_RX_STRUCT); // Clear the interrupts that are about to be enabled to avoid spurious firing uint32_t new_interrupts_rx = rx_mask & (~old_rx_mask); Cy_AudioTDM_ClearRxInterrupt(&obj->base->TDM_RX_STRUCT, new_interrupts_rx); Cy_AudioTDM_SetRxInterruptMask(&obj->base->TDM_RX_STRUCT, rx_mask); #endif } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) static void _cyhal_audioss_update_rx_trigger_level(_cyhal_audioss_t *obj) { // If we're doing an async read and the amount remaining is less than // the standard trigger level, temporarily reduce it so that we get // an interrupt as soon as the amount the user requested is ready uint32_t savedIntrStatus = cyhal_system_critical_section_enter(); uint8_t trigger_level = obj->user_fifo_level_rx; if(NULL != obj->async_rx_buff && obj->async_rx_length < trigger_level && obj->async_rx_length > 0) { trigger_level = obj->async_rx_length; } #if defined(CY_IP_MXAUDIOSS) // Safe to do a blind write of this register because the only other bits are // CLEAR, which is only set temporarily from clear_tx, and FREEZE, which is // never used by this driver (it exists for debugging purposes only) obj->base->RX_FIFO_CTL = (uint32_t) (trigger_level << I2S_RX_FIFO_CTL_TRIGGER_LEVEL_Pos); #elif defined(CY_IP_MXTDM) uint32_t value = obj->base->TDM_RX_STRUCT.RX_FIFO_CTL; value &= ~TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_FIFO_CTL_TRIGGER_LEVEL_Msk; value |= trigger_level << TDM_TDM_STRUCT_TDM_TX_STRUCT_TX_FIFO_CTL_TRIGGER_LEVEL_Pos; obj->base->TDM_RX_STRUCT.RX_FIFO_CTL = value; #endif cyhal_system_critical_section_exit(savedIntrStatus); } #endif static uint32_t _cyhal_audioss_disable_events(_cyhal_audioss_t *obj, bool tx) { #if defined(CY_IP_MXAUDIOSS) CY_UNUSED_PARAMETER(tx); uint32_t old_interrupt_mask = Cy_I2S_GetInterruptMask(obj->base); Cy_I2S_SetInterruptMask(obj->base, 0u); return old_interrupt_mask; #elif defined(CY_IP_MXTDM) uint32_t old_interrupt_mask; if(tx) { old_interrupt_mask = Cy_AudioTDM_GetTxInterruptMask(&obj->base->TDM_TX_STRUCT); Cy_AudioTDM_SetTxInterruptMask(&obj->base->TDM_TX_STRUCT, 0u); } else { old_interrupt_mask = Cy_AudioTDM_GetRxInterruptMask(&obj->base->TDM_RX_STRUCT); Cy_AudioTDM_SetRxInterruptMask(&obj->base->TDM_RX_STRUCT, 0u); } return old_interrupt_mask; #endif } static void _cyhal_audioss_restore_events(_cyhal_audioss_t *obj, bool tx, uint32_t old_events) { #if defined(CY_IP_MXAUDIOSS) CY_UNUSED_PARAMETER(tx); Cy_I2S_SetInterruptMask(obj->base, old_events); #elif defined(CY_IP_MXTDM) if(tx) { Cy_AudioTDM_SetTxInterruptMask(&obj->base->TDM_TX_STRUCT, old_events); } else { Cy_AudioTDM_SetRxInterruptMask(&obj->base->TDM_RX_STRUCT, old_events); } #endif } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) && (CYHAL_DRIVER_AVAILABLE_DMA) static cy_rslt_t _cyhal_audioss_dma_perform_rx(_cyhal_audioss_t *obj) { // We could have received an event after we started the DMA but before it // managed to bring the FIFO below the threshold if(cyhal_dma_is_busy(&(obj->rx_dma))) return CY_RSLT_SUCCESS; /* ISR triggers when we have one more entry in the FIFO than the trigger level */ size_t transfer_size = _cyhal_audioss_fifo_trigger_level(obj, false) + 1; if (transfer_size >= obj->async_rx_length) { transfer_size = obj->async_rx_length; // Only want the user callback to be call on the last dma transfer. cyhal_dma_enable_event(&(obj->rx_dma), CYHAL_DMA_TRANSFER_COMPLETE, obj->async_dma_priority, true); } cyhal_dma_cfg_t dma_cfg = { #if defined(CY_IP_MXAUDIOSS) .src_addr = (uint32_t)(&(obj->base->RX_FIFO_RD)), #elif defined(CY_IP_MXTDM) .src_addr = (uint32_t)(&(obj->base->TDM_RX_STRUCT.RX_FIFO_RD)), #endif .src_increment = 0, .dst_addr = (uint32_t)obj->async_rx_buff, .dst_increment = 1, .transfer_width = _cyhal_audioss_rounded_word_length(obj, false), .length = transfer_size, .burst_size = 0, .action = CYHAL_DMA_TRANSFER_FULL, }; cy_rslt_t result = cyhal_dma_configure(&(obj->rx_dma), &dma_cfg); if(CY_RSLT_SUCCESS == result) { result = cyhal_dma_enable(&(obj->rx_dma)); } // Update the buffer first so that it's guaranteed to be correct whenever the DMA completes if(CY_RSLT_SUCCESS == result) { size_t increment_bytes = transfer_size * (_cyhal_audioss_rounded_word_length(obj, false) / 8); uint32_t savedIntrStatus = cyhal_system_critical_section_enter(); obj->async_rx_buff = (void*)(((uint8_t*) obj->async_rx_buff) + increment_bytes); obj->async_rx_length -= transfer_size; _cyhal_audioss_update_rx_trigger_level(obj); _cyhal_audioss_update_enabled_events(obj); cyhal_system_critical_section_exit(savedIntrStatus); result = cyhal_dma_start_transfer(&(obj->rx_dma)); } return result; } #endif /* defined(_CYHAL_AUDIOSS_RX_ENABLED) && (CYHAL_DRIVER_AVAILABLE_DMA) */ #if (CYHAL_DRIVER_AVAILABLE_DMA) static cy_rslt_t _cyhal_audioss_dma_perform_tx(_cyhal_audioss_t *obj) { // We could have received an event after the DMA brought the FIFO below the // threshold but before the DMA is entirely complete if(cyhal_dma_is_busy(&(obj->tx_dma))) return CY_RSLT_SUCCESS; CY_ASSERT(NULL != obj->async_tx_buff); /* ISR triggers when the FIFO count less than the trigger level */ size_t transfer_size = _cyhal_audioss_fifo_trigger_level(obj, true) + 1; if (transfer_size >= obj->async_tx_length) { transfer_size = obj->async_tx_length; // Only want the user callback to be call on the last dma transfer. cyhal_dma_enable_event(&(obj->tx_dma), CYHAL_DMA_TRANSFER_COMPLETE, obj->async_dma_priority, true); } cyhal_dma_cfg_t dma_cfg = { .src_addr = (uint32_t)obj->async_tx_buff, .src_increment = 1, #if defined(CY_IP_MXAUDIOSS) .dst_addr = (uint32_t)(&(obj->base->TX_FIFO_WR)), #elif defined(CY_IP_MXTDM) .dst_addr = (uint32_t)(&(obj->base->TDM_TX_STRUCT.TX_FIFO_WR)), #endif .dst_increment = 0, .transfer_width = _cyhal_audioss_rounded_word_length(obj, true), .length = transfer_size, .burst_size = 0, .action = CYHAL_DMA_TRANSFER_FULL, }; cy_rslt_t result = cyhal_dma_configure(&(obj->tx_dma), &dma_cfg); if(CY_RSLT_SUCCESS == result) { result = cyhal_dma_enable(&(obj->tx_dma)); } // Update the buffer first so that it's guaranteed to be correct whenever the DMA completes if(CY_RSLT_SUCCESS == result) { size_t increment_bytes = transfer_size * (_cyhal_audioss_rounded_word_length(obj, true) / 8); uint32_t savedIntrStatus = cyhal_system_critical_section_enter(); obj->async_tx_buff = (void*)(((uint8_t*) obj->async_tx_buff) + increment_bytes); obj->async_tx_length -= transfer_size; // Do this after we've updated async_tx_buff/length because once we have kicked // off the final DMA transfer there is no further action we will take on the // half-empty/empty events, and we don't want those to wind upstarving the // DMA complete event _cyhal_audioss_update_enabled_events(obj); cyhal_system_critical_section_exit(savedIntrStatus); result = cyhal_dma_start_transfer(&(obj->tx_dma)); } return result; } #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ static uint32_t _cyhal_audioss_get_num_in_fifo(_cyhal_audioss_t *obj, bool is_tx) { #if defined(CY_IP_MXAUDIOSS) #if defined(_CYHAL_AUDIOSS_RX_ENABLED) return is_tx ? Cy_I2S_GetNumInTxFifo(obj->base) : Cy_I2S_GetNumInRxFifo(obj->base); #else CY_UNUSED_PARAMETER(is_tx); return Cy_I2S_GetNumInTxFifo(obj->base); #endif #elif defined(CY_IP_MXTDM) return is_tx ? Cy_AudioTDM_GetNumInTxFifo(&obj->base->TDM_TX_STRUCT) : Cy_AudioTDM_GetNumInRxFifo(&obj->base->TDM_RX_STRUCT); #endif } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) static uint32_t _cyhal_audioss_read_fifo(_cyhal_audioss_t *obj) { #if defined(CY_IP_MXAUDIOSS) return Cy_I2S_ReadRxData(obj->base); #elif defined(CY_IP_MXTDM) return Cy_AudioTDM_ReadRxData(&obj->base->TDM_RX_STRUCT); #endif } #endif static void _cyhal_audioss_write_fifo(_cyhal_audioss_t *obj, uint32_t value) { #if defined(CY_IP_MXAUDIOSS) Cy_I2S_WriteTxData(obj->base, value); #elif defined(CY_IP_MXTDM) Cy_AudioTDM_WriteTxData(&obj->base->TDM_TX_STRUCT, value); #endif } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) && (CYHAL_DRIVER_AVAILABLE_DMA) /* Callback argument is the I2S instance */ static void _cyhal_audioss_dma_handler_rx(void *callback_arg, cyhal_dma_event_t event) { CY_UNUSED_PARAMETER(event); /* We only hook this handler up when we're doing the final transfer, so send the completed event */ CY_ASSERT(CYHAL_DMA_TRANSFER_COMPLETE == event); _cyhal_audioss_t *obj = (_cyhal_audioss_t*)callback_arg; obj->async_rx_buff = NULL; cyhal_dma_enable_event(&obj->rx_dma, CYHAL_DMA_TRANSFER_COMPLETE, obj->async_dma_priority, false); _cyhal_audioss_process_event(obj, obj->interface->event_rx_complete); } #endif /* defined(_CYHAL_AUDIOSS_RX_ENABLED) && (CYHAL_DRIVER_AVAILABLE_DMA) */ #if (CYHAL_DRIVER_AVAILABLE_DMA) /* Callback argument is the I2S instance */ static void _cyhal_audioss_dma_handler_tx(void *callback_arg, cyhal_dma_event_t event) { CY_UNUSED_PARAMETER(event); /* We only hook this handler up when we're doing the final transfer, so send the completed event */ CY_ASSERT(CYHAL_DMA_TRANSFER_COMPLETE == event); _cyhal_audioss_t *obj = (_cyhal_audioss_t*)callback_arg; obj->async_tx_buff = NULL; cyhal_dma_enable_event(&obj->tx_dma, CYHAL_DMA_TRANSFER_COMPLETE, obj->async_dma_priority, false); _cyhal_audioss_process_event(obj, obj->interface->event_tx_complete); } #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ static void _cyhal_audioss_process_event(_cyhal_audioss_t *obj, uint32_t event) { if(0 != (event & (obj->interface->event_mask_empty | obj->interface->event_mask_half_empty))) { /* We should normally not get the "empty" interrupt during an async transfer because we * should be topping the FIFO back up after each half-empty interrupt. But in case something * delays our response and the FIFO gets all the way to empty, listen for that as well */ uint32_t savedIntrStatus = cyhal_system_critical_section_enter(); if(NULL != obj->async_tx_buff && obj->async_tx_length > 0) { switch(obj->async_mode) { case CYHAL_ASYNC_SW: { /* Write as much as we can out until the FIFO is full * This is a potentially long operation but we don't want other I2S operations to * interleave with it. So switch to a "mini critical section" and disable the * interrupts for this block only while we're copying */ uint32_t old_events = _cyhal_audioss_disable_events(obj, true); cyhal_system_critical_section_exit(savedIntrStatus); // Safe to cast away volatile here because we're calling write_until_full from within // a critical section, so it should not change out from under us during this call _cyhal_audioss_write_until_full(obj, (const void**)(&obj->async_tx_buff), (size_t *)(&obj->async_tx_length)); // Re-enter the global critical section so that the exit below behaves correctly savedIntrStatus = cyhal_system_critical_section_enter(); _cyhal_audioss_restore_events(obj, true, old_events); if(0 == obj->async_tx_length) { /* We finished the async transfer. */ event |= obj->interface->event_tx_complete; } break; } case CYHAL_ASYNC_DMA: { #if (CYHAL_DRIVER_AVAILABLE_DMA) cy_rslt_t result = _cyhal_audioss_dma_perform_tx(obj); CY_UNUSED_PARAMETER(result); CY_ASSERT(CY_RSLT_SUCCESS == result); #else CY_ASSERT(0); /* DMA driver is not available */ #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ break; } default: CY_ASSERT(0); /* Unrecognized async mode */ break; } } cyhal_system_critical_section_exit(savedIntrStatus); } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(0 != (event & (obj->interface->event_mask_full | obj->interface->event_mask_half_full))) { /* Similar to TX, we don't expect to receive the "full" interrupt, but check for it out of caution */ uint32_t savedIntrStatus = cyhal_system_critical_section_enter(); if(NULL != obj->async_rx_buff && obj->async_rx_length > 0) { switch(obj->async_mode) { case CYHAL_ASYNC_SW: { /* Read as much as we can until the FIFO is empty * This is a potentially long operation but we don't want other I2S operations to * interleave with it. So switch to a "mini critical section" and disable the * interrupts for this block only while we're copying */ uint32_t old_events = _cyhal_audioss_disable_events(obj, false); cyhal_system_critical_section_exit(savedIntrStatus); // Safe to cast away volatile here because we're calling read_until_empty from within // a critical section, so it should not change out from under us during this call _cyhal_audioss_read_until_empty(obj, (void**)(&obj->async_rx_buff), (size_t*)(&obj->async_rx_length)); // Re-enter the global critical section so that the exit below behaves correctly savedIntrStatus = cyhal_system_critical_section_enter(); _cyhal_audioss_restore_events(obj, false, old_events); _cyhal_audioss_update_enabled_events(obj); if(0 == obj->async_rx_length) { /* We finished the async transfer. */ event |= obj->interface->event_rx_complete; } break; } case CYHAL_ASYNC_DMA: #if (CYHAL_DRIVER_AVAILABLE_DMA) _cyhal_audioss_dma_perform_rx(obj); #else CY_ASSERT(0); /* DMA driver is not available */ #endif /* (CYHAL_DRIVER_AVAILABLE_DMA) */ break; default: CY_ASSERT(0); /* Unrecognized async mode */ } // During async rx transfers, we may temporarily set the trigger level below half-full. // So make sure that it's a real "half full" and skip propagating to the user if it isn't #if defined(CY_IP_MXAUDIOSS) uint8_t trigger_level = (obj->base->RX_FIFO_CTL & I2S_RX_FIFO_CTL_TRIGGER_LEVEL_Msk) >> I2S_RX_FIFO_CTL_TRIGGER_LEVEL_Pos; #elif defined(CY_IP_MXTDM) uint8_t trigger_level = (obj->base->TDM_RX_STRUCT.RX_FIFO_CTL & TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_FIFO_CTL_TRIGGER_LEVEL_Msk) >> TDM_TDM_STRUCT_TDM_RX_STRUCT_RX_FIFO_CTL_TRIGGER_LEVEL_Pos; #endif if(trigger_level != obj->user_fifo_level_rx) { event &= ~(obj->interface->event_mask_half_full); } } cyhal_system_critical_section_exit(savedIntrStatus); } #endif /* defined(_CYHAL_AUDIOSS_RX_ENABLED) */ /* Mark async transfer as complete if we just finished one. */ if(0 != (event & obj->interface->event_tx_complete)) { obj->async_tx_buff = NULL; _cyhal_audioss_update_enabled_events(obj); } #if defined(_CYHAL_AUDIOSS_RX_ENABLED) if(0 != (event & obj->interface->event_rx_complete)) { obj->async_rx_buff = NULL; _cyhal_audioss_update_enabled_events(obj); } #endif /* defined(_CYHAL_AUDIOSS_RX_ENABLED) */ if(0 != (event & obj->user_enabled_events)) { obj->interface->invoke_user_callback(obj, event & obj->user_enabled_events); } } static bool _cyhal_audioss_pm_callback(cyhal_syspm_callback_state_t state, cyhal_syspm_callback_mode_t mode, void* callback_arg) { _cyhal_audioss_t *obj = (_cyhal_audioss_t *)callback_arg; CY_UNUSED_PARAMETER(state); switch(mode) { case CYHAL_SYSPM_CHECK_READY: { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) bool is_active = _cyhal_audioss_is_rx_enabled(obj) || _cyhal_audioss_is_tx_enabled(obj); obj->pm_transition_ready = !is_active && !(_cyhal_audioss_is_read_pending(obj) || _cyhal_audioss_is_tx_busy(obj)); #else bool is_active = _cyhal_audioss_is_tx_enabled(obj); obj->pm_transition_ready = !is_active && !_cyhal_audioss_is_tx_busy(obj); #endif /* defined(_CYHAL_AUDIOSS_RX_ENABLED) */ return obj->pm_transition_ready; } case CYHAL_SYSPM_CHECK_FAIL: case CYHAL_SYSPM_AFTER_TRANSITION: obj->pm_transition_ready = false; return true; default: return true; } } #if defined(_CYHAL_AUDIOSS_TRIGGERS_AVAILABLE) static cyhal_source_t _cyhal_audioss_calculate_source(_cyhal_audioss_t *obj, bool is_rx) { #if defined(_CYHAL_AUDIOSS_RX_ENABLED) return is_rx ? _cyhal_audioss_rx_trigger[obj->resource.block_num] : _cyhal_audioss_tx_trigger[obj->resource.block_num]; #else CY_UNUSED_PARAMETER(is_rx); return _cyhal_audioss_tx_trigger[obj->resource.block_num]; #endif /* defined(_CYHAL_AUDIOSS_RX_ENABLED) */ } #endif cy_rslt_t _cyhal_audioss_enable_output(_cyhal_audioss_t *obj, bool is_rx, cyhal_source_t *source) { #if defined(_CYHAL_AUDIOSS_TRIGGERS_AVAILABLE) #if defined(CY_IP_MXAUDIOSS) /* On MXTDM the trigger lines are always enabled */ if(is_rx) { REG_I2S_TR_CTL(obj->base) |= I2S_TR_CTL_RX_REQ_EN_Msk; } else { REG_I2S_TR_CTL(obj->base) |= I2S_TR_CTL_TX_REQ_EN_Msk; } #endif /* defined(CY_IP_MXAUDIOSS) */ *source = _cyhal_audioss_calculate_source(obj, is_rx); return CY_RSLT_SUCCESS; #else CY_UNUSED_PARAMETER(is_rx); CY_UNUSED_PARAMETER(source); return obj->interface->err_not_supported; #endif /* defined(_CYHAL_AUDIOSS_TRIGGERS_AVAILABLE) */ } cy_rslt_t _cyhal_audioss_disable_output(_cyhal_audioss_t *obj, bool is_rx) { #if defined(_CYHAL_AUDIOSS_TRIGGERS_AVAILABLE) #if defined(CY_IP_MXAUDIOSS) if(is_rx) { REG_I2S_TR_CTL(obj->base) &= ~I2S_TR_CTL_RX_REQ_EN_Msk; } else { REG_I2S_TR_CTL(obj->base) &= ~I2S_TR_CTL_TX_REQ_EN_Msk; } #else /* On MXTDM the trigger lines are always enabled */ CY_UNUSED_PARAMETER(obj); CY_UNUSED_PARAMETER(is_rx); #endif /* defined(CY_IP_MXAUDIOSS) */ return CY_RSLT_SUCCESS; #else CY_UNUSED_PARAMETER(is_rx); return obj->interface->err_not_supported; #endif /* defined(_CYHAL_AUDIOSS_TRIGGERS_AVAILABLE) */ } #if defined(__cplusplus) } #endif #endif /* CYHAL_DRIVER_AVAILABLE_I2S */
a50a5d7d9cd8f01c3e82b0558a17de1e05c54b2b
693bd39eb66eade67997bc608fe84e76e66eeec2
/mpp/hal/common/h264/hal_h264e_stream_amend.c
7ba468d5e07ea0a4194cddd58e5eb8a6f9d037ae
[]
permissive
HermanChen/mpp
6a1751777b120b764f86e0f34975231054a3c262
0af9b5becc76c4685831214808e124e65543297b
refs/heads/develop
2023-08-17T07:17:49.489974
2023-07-31T08:26:14
2023-08-11T07:38:17
71,088,248
139
79
Apache-2.0
2023-03-08T09:44:01
2016-10-17T01:13:37
C
UTF-8
C
false
false
10,761
c
hal_h264e_stream_amend.c
/* * Copyright 2022 Rockchip Electronics Co. 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. */ #define MODULE_TAG "hal_h264e_amend" #include <stdio.h> #include <string.h> #include <unistd.h> #include "mpp_common.h" #include "mpp_enc_cfg.h" #include "mpp_enc_refs.h" #include "mpp_mem.h" #include "hal_h264e_debug.h" #include "hal_h264e_stream_amend.h" #include "h264e_sps.h" #include "h264e_pps.h" #include "h264e_slice.h" #define START_CODE 0x000001 ///< start_code_prefix_one_3bytes static RK_S32 get_next_nal(RK_U8 *buf, RK_S32 *length) { RK_S32 i, consumed = 0; RK_S32 len = *length; RK_U8 *tmp_buf = buf; /* search start code */ while (len >= 4) { if (tmp_buf[2] == 0) { len--; tmp_buf++; continue; } if (tmp_buf[0] != 0 || tmp_buf[1] != 0 || tmp_buf[2] != 1) { RK_U32 state = (RK_U32) - 1; RK_S32 has_nal = 0; for (i = 0; i < (RK_S32)len; i++) { state = (state << 8) | tmp_buf[i]; if (((state >> 8) & 0xFFFFFF) == START_CODE) { has_nal = 1; i = i - 3; break; } } if (has_nal) { len -= i; tmp_buf += i; consumed = *length - len - 1; break; } consumed = *length; break; } tmp_buf += 3; len -= 3; } *length = *length - consumed; return consumed; } MPP_RET h264e_vepu_stream_amend_init(HalH264eVepuStreamAmend *ctx) { memset(ctx, 0, sizeof(*ctx)); ctx->buf_size = SZ_128K; return MPP_OK; } MPP_RET h264e_vepu_stream_amend_deinit(HalH264eVepuStreamAmend *ctx) { MPP_FREE(ctx->src_buf); MPP_FREE(ctx->dst_buf); return MPP_OK; } MPP_RET h264e_vepu_stream_amend_config(HalH264eVepuStreamAmend *ctx, MppPacket packet, MppEncCfgSet *cfg, H264eSlice *slice, H264ePrefixNal *prefix) { MppEncRefCfgImpl *ref = (MppEncRefCfgImpl *)cfg->ref_cfg; MppEncH264Cfg *h264 = &cfg->codec.h264; MppEncH264HwCfg *hw_cfg = &h264->hw_cfg; if (ref->lt_cfg_cnt || ref->st_cfg_cnt > 1 || hw_cfg->hw_poc_type != h264->poc_type || hw_cfg->hw_log2_max_frame_num_minus4 != h264->log2_max_frame_num) { ctx->enable = 1; ctx->slice_enabled = 0; ctx->diable_split_out = 1; if (NULL == ctx->dst_buf) ctx->dst_buf = mpp_calloc(RK_U8, ctx->buf_size); if (NULL == ctx->src_buf) ctx->src_buf = mpp_calloc(RK_U8, ctx->buf_size); } else { MPP_FREE(ctx->dst_buf); MPP_FREE(ctx->src_buf); h264e_vepu_stream_amend_init(ctx); } slice->pic_order_cnt_type = cfg->codec.h264.poc_type; ctx->slice = slice; if (ref->lt_cfg_cnt || ref->st_cfg_cnt > 1) ctx->prefix = prefix; ctx->packet = packet; ctx->buf_base = mpp_packet_get_length(packet); ctx->old_length = 0; ctx->new_length = 0; return MPP_OK; } MPP_RET h264e_vepu_stream_amend_proc(HalH264eVepuStreamAmend *ctx, MppEncH264HwCfg *hw_cfg) { H264ePrefixNal *prefix = ctx->prefix; H264eSlice *slice = ctx->slice; MppPacket pkt = ctx->packet; RK_U8 *p = mpp_packet_get_pos(pkt); RK_S32 size = mpp_packet_get_size(pkt); RK_S32 base = ctx->buf_base; RK_S32 len = ctx->old_length; RK_S32 hw_len_bit = 0; RK_S32 sw_len_bit = 0; RK_S32 hw_len_byte = 0; RK_S32 sw_len_byte = 0; RK_S32 diff_size = 0; RK_S32 tail_0bit = 0; RK_U8 tail_byte = 0; RK_U8 tail_tmp = 0; RK_U8 *dst_buf = NULL; RK_S32 buf_size; RK_S32 final_len = 0; RK_S32 last_slice = 0; const MppPktSeg *seg = mpp_packet_get_segment_info(pkt); if (seg) { while (seg && seg->type != 1 && seg->type != 5) { seg = seg->next; } } { RK_S32 more_buf = 0; while (len > ctx->buf_size - 16) { ctx->buf_size *= 2; more_buf = 1; } if (more_buf) { MPP_FREE(ctx->src_buf); MPP_FREE(ctx->dst_buf); ctx->src_buf = mpp_malloc(RK_U8, ctx->buf_size); ctx->dst_buf = mpp_malloc(RK_U8, ctx->buf_size); } } memset(ctx->dst_buf, 0, ctx->buf_size); memset(ctx->src_buf, 0, ctx->buf_size); dst_buf = ctx->dst_buf; buf_size = ctx->buf_size; p += base; do { RK_U32 nal_len = 0; tail_0bit = 0; // copy hw stream to stream buffer first if (slice->is_multi_slice) { if ((!seg) || ctx->diable_split_out) { nal_len = get_next_nal(p, &len); last_slice = (len == 0); } else { nal_len = seg->len; len -= seg->len; seg = seg->next; if (!seg || !len) last_slice = 1; } memcpy(ctx->src_buf, p, nal_len); p += nal_len; } else { memcpy(ctx->src_buf, p, len); nal_len = len; last_slice = 1; } hal_h264e_dbg_amend("nal_len %d multi %d last %d prefix %p\n", nal_len, slice->is_multi_slice, last_slice, prefix); if (prefix) { /* add prefix for each slice */ RK_S32 prefix_bit = h264e_slice_write_prefix_nal_unit_svc(prefix, dst_buf, buf_size); prefix_bit = (prefix_bit + 7) / 8; dst_buf += prefix_bit; buf_size -= prefix_bit; final_len += prefix_bit; } H264eSlice slice_rd; memcpy(&slice_rd, slice, sizeof(slice_rd)); /* update slice by hw_cfg */ slice_rd.pic_order_cnt_type = hw_cfg->hw_poc_type; slice_rd.log2_max_frame_num = hw_cfg->hw_log2_max_frame_num_minus4 + 4; if (ctx->reorder) { slice_rd.reorder = ctx->reorder; h264e_reorder_init(slice_rd.reorder); } if (ctx->marking) { slice_rd.marking = ctx->marking; h264e_marking_init(slice_rd.marking); } hw_len_bit = h264e_slice_read(&slice_rd, ctx->src_buf, size); // write new header to header buffer slice->qp_delta = slice_rd.qp_delta; slice->first_mb_in_slice = slice_rd.first_mb_in_slice; if (ctx->reorder) slice->reorder = slice_rd.reorder; if (ctx->marking) slice->marking = slice_rd.marking; sw_len_bit = h264e_slice_write(slice, dst_buf, buf_size); hw_len_byte = (hw_len_bit + 7) / 8; sw_len_byte = (sw_len_bit + 7) / 8; tail_byte = ctx->src_buf[nal_len - 1]; tail_tmp = tail_byte; while (!(tail_tmp & 1) && tail_0bit < 8) { tail_tmp >>= 1; tail_0bit++; } mpp_assert(tail_0bit < 8); // move the reset slice data from src buffer to dst buffer diff_size = h264e_slice_move(dst_buf, ctx->src_buf, sw_len_bit, hw_len_bit, nal_len); hal_h264e_dbg_amend("tail 0x%02x %d hw_hdr %d sw_hdr %d len %d hw_byte %d sw_byte %d diff %d\n", tail_byte, tail_0bit, hw_len_bit, sw_len_bit, nal_len, hw_len_byte, sw_len_byte, diff_size); if (slice->entropy_coding_mode) { memcpy(dst_buf + sw_len_byte, ctx->src_buf + hw_len_byte, nal_len - hw_len_byte); final_len += nal_len - hw_len_byte + sw_len_byte; nal_len = nal_len - hw_len_byte + sw_len_byte; } else { RK_S32 hdr_diff_bit = sw_len_bit - hw_len_bit; RK_S32 bit_len = nal_len * 8 - tail_0bit + hdr_diff_bit; RK_S32 new_len = (bit_len + diff_size * 8 + 7) / 8; hal_h264e_dbg_amend("frm %4d %c len %d bit hw %d sw %d byte hw %d sw %d diff %d -> %d\n", slice->frame_num, (slice->idr_flag ? 'I' : 'P'), nal_len, hw_len_bit, sw_len_bit, hw_len_byte, sw_len_byte, diff_size, new_len); hal_h264e_dbg_amend("%02x %02x %02x %02x -> %02x %02x %02x %02x\n", ctx->src_buf[nal_len - 4], ctx->src_buf[nal_len - 3], ctx->src_buf[nal_len - 2], ctx->src_buf[nal_len - 1], dst_buf[new_len - 4], dst_buf[new_len - 3], dst_buf[new_len - 2], dst_buf[new_len - 1]); nal_len = new_len; final_len += new_len; } if (last_slice) { p = mpp_packet_get_pos(pkt); p += base; memcpy(p, ctx->dst_buf, final_len); if (slice->entropy_coding_mode) { if (final_len < ctx->old_length) memset(p + final_len, 0, ctx->old_length - final_len); } else p[final_len] = 0; break; } dst_buf += nal_len; buf_size -= nal_len; } while (1); ctx->new_length = final_len; return MPP_OK; } MPP_RET h264e_vepu_stream_amend_sync_ref_idc(HalH264eVepuStreamAmend *ctx) { H264eSlice *slice = ctx->slice; MppPacket pkt = ctx->packet; RK_S32 base = ctx->buf_base; RK_S32 len = ctx->old_length; RK_U8 *p = mpp_packet_get_pos(pkt) + base; RK_U8 val = p[4]; RK_S32 hw_nal_ref_idc = (val >> 5) & 0x3; RK_S32 sw_nal_ref_idc = slice->nal_reference_idc; if (hw_nal_ref_idc == sw_nal_ref_idc) return MPP_OK; /* fix nal_ref_idc in all slice */ if (!slice->is_multi_slice) { /* single slice do NOT scan */ val = val & (~0x60); val |= (sw_nal_ref_idc << 5) & 0x60; p[4] = val; return MPP_OK; } /* multi-slice fix each nal_ref_idc */ do { RK_U32 nal_len = get_next_nal(p, &len); val = p[4]; val = val & (~0x60); val |= (sw_nal_ref_idc << 5) & 0x60; p[4] = val; if (len == 0) break; p += nal_len; } while (1); return MPP_OK; }
5b193a3650fe3af9fa435babe4a2510353883665
e7aa99ad96c6e4516be82d4fc041298f5cdc662a
/ext/oj/parser.h
3ffaeb08b558ab94093fbd29f9c12def88e8f124
[ "MIT" ]
permissive
ohler55/oj
50ace2672999ba8aacdc77ce9e9f4f8047ac2b27
b399b8adf7adc95a4844e73520f2ae24dda5639e
refs/heads/develop
2023-08-31T14:53:20.780013
2023-08-16T23:09:55
2023-08-16T23:09:55
3,468,618
2,294
262
MIT
2023-09-11T10:35:24
2012-02-17T09:30:32
C
UTF-8
C
false
false
2,710
h
parser.h
// Copyright (c) 2021 Peter Ohler, All rights reserved. // Licensed under the MIT License. See LICENSE file in the project root for license details. #ifndef OJ_PARSER_H #define OJ_PARSER_H #include <ruby.h> #include <stdbool.h> #include "buf.h" #define TOP_FUN 0 #define ARRAY_FUN 1 #define OBJECT_FUN 2 typedef uint8_t byte; typedef enum { OJ_NONE = '\0', OJ_NULL = 'n', OJ_TRUE = 't', OJ_FALSE = 'f', OJ_INT = 'i', OJ_DECIMAL = 'd', OJ_BIG = 'b', // indicates parser buf is used OJ_STRING = 's', OJ_OBJECT = 'o', OJ_ARRAY = 'a', } ojType; typedef struct _num { long double dub; int64_t fixnum; // holds all digits uint32_t len; int16_t div; // 10^div int16_t exp; uint8_t shift; // shift of fixnum to get decimal bool neg; bool exp_neg; // for numbers as strings, reuse buf } *Num; struct _ojParser; typedef struct _funcs { void (*add_null)(struct _ojParser *p); void (*add_true)(struct _ojParser *p); void (*add_false)(struct _ojParser *p); void (*add_int)(struct _ojParser *p); void (*add_float)(struct _ojParser *p); void (*add_big)(struct _ojParser *p); void (*add_str)(struct _ojParser *p); void (*open_array)(struct _ojParser *p); void (*close_array)(struct _ojParser *p); void (*open_object)(struct _ojParser *p); void (*close_object)(struct _ojParser *p); } *Funcs; typedef struct _ojParser { const char *map; const char *next_map; int depth; unsigned char stack[1024]; // value data struct _num num; struct _buf key; struct _buf buf; struct _funcs funcs[3]; // indexed by XXX_FUN defines void (*start)(struct _ojParser *p); VALUE (*option)(struct _ojParser *p, const char *key, VALUE value); VALUE (*result)(struct _ojParser *p); void (*free)(struct _ojParser *p); void (*mark)(struct _ojParser *p); void *ctx; VALUE reader; char token[8]; long line; long cur; // only set before call to a function long col; int ri; uint32_t ucode; ojType type; // valType bool just_one; } *ojParser; // Create a new parser without setting the delegate. The parser is // wrapped. The parser is (ojParser)DATA_PTR(value) where value is the return // from this function. A delegate must be added before the parser can be // used. Optionally oj_parser_set_options can be called if the options are not // set directly. extern VALUE oj_parser_new(); // Set set the options from a hash (ropts). extern void oj_parser_set_option(ojParser p, VALUE ropts); #endif /* OJ_PARSER_H */
01a3254ed21ee3b5b1d1f712825fea0b8cd0d29c
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/hppa/include/intrdefs.h
79f9c02e51f2ecf1d61e0c8c161f586d20737eba
[]
no_license
NetBSD/src
1a9cbc22ed778be638b37869ed4fb5c8dd616166
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
refs/heads/trunk
2023-08-31T13:24:58.105962
2023-08-27T15:50:47
2023-08-27T15:50:47
88,439,547
656
348
null
2023-07-20T20:07:24
2017-04-16T20:03:43
null
UTF-8
C
false
false
830
h
intrdefs.h
/* $NetBSD: intrdefs.h,v 1.2 2014/05/19 22:47:53 rmind Exp $ */ #ifndef _HPPA_INTRDEFS_H_ #define _HPPA_INTRDEFS_H_ /* Interrupt priority `levels'. */ #define IPL_NONE 7 /* nothing */ #define IPL_SOFTCLOCK 6 /* timeouts */ #define IPL_SOFTBIO 5 /* block I/O */ #define IPL_SOFTNET 4 /* protocol stacks */ #define IPL_SOFTSERIAL 3 /* serial */ #define IPL_VM 2 /* memory allocation, low I/O */ #define IPL_SCHED 1 /* clock, medium I/O */ #define IPL_HIGH 0 /* everything */ #define NIPL 8 /* Interrupt sharing types. */ #define IST_NONE 0 /* none */ #define IST_PULSE 1 /* pulsed */ #define IST_EDGE 2 /* edge-triggered */ #define IST_LEVEL 3 /* level-triggered */ #ifdef MULTIPROCESSOR #define HPPA_IPI_NOP 0 #define HPPA_IPI_HALT 1 #define HPPA_IPI_XCALL 2 #define HPPA_IPI_GENERIC 3 #define HPPA_NIPI 4 #endif #endif
c3c7520997452d306768b5647de5b2df762b4510
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/ft2004/drivers/drv_sdctrl.h
dba34f252525dec74218ff6d10d6f428ef96de45
[ "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
1,201
h
drv_sdctrl.h
/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2021-03-18 Carl the first version */ #ifndef __DRV_SDCTRL_H__ #define __DRV_SDCTRL_H__ #include <rtthread.h> #ifdef __cplusplus extern "C" { #endif #define SDCTR_CMD_IS_COMPLETE_FLG 0x1UL /* Command is complete */ #define SDCTR_WRITE_IS_COMPLETE_FLG 0x2UL #define SDCTR_READ_IS_COMPLETE_FLG 0x4UL #define SDCTR_CMD_IS_ERROR_FLG 0x8UL #define SDCTR_CMD_CRC_IS_ERROR_FLG 0x10UL /* Command CRC error */ #define SDCTR_DMA_IS_ERROR_FLG 0x20UL /* */ #define SDCTR_CARD_REMOVE_FLG 0x40UL /* Card remove */ #define SDCTR_CMD_TIMEOUT_FLG 0x70UL /* command timeout */ #define SDCTR_CMD_RECEIVE_IS_ERROR_FLG 0x80UL /* CMD receive is error */ #ifndef SDCTR_BUFF_SIZE #define SDCTR_BUFF_SIZE (512 * 128) #endif #ifndef SDCTR_ALIGN_LEN #define SDCTR_ALIGN_LEN (32) #endif void ft2004_mmcsd_change(void); rt_bool_t ft2004_card_status(void); rt_err_t ft2004_card_remove_check(rt_int32_t timeout, rt_uint32_t *status); void ft2004_sdctrl_reset(void); #ifdef __cplusplus } #endif #endif // !