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
cb39489ac560e3f0ffabd26a5b3219bbaec3ea0d
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
/src/mono/mono/eglib/test/endian.c
ff40b7d2fce5269ae779325134f0fae5b1d90890
[ "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
929
c
endian.c
#include "test.h" static RESULT test_swap (void) { guint32 a = 0xabcdef01, res32; guint64 b = (((guint64)a) << 32) | a, res64; guint64 b_expect = (((guint64)0x1efcdab) << 32) | 0x01efcdab; guint16 c = 0xabcd, res16; res32 = GUINT32_SWAP_LE_BE (a); if (res32 != 0x01efcdab) return FAILED ("GUINT32_SWAP_LE_BE returned 0x%x", res32); res32 = GUINT32_SWAP_LE_BE (1); if (res32 != 0x1000000) return FAILED ("GUINT32_SWAP_LE_BE returned 0x%x", res32); res64 = GUINT64_SWAP_LE_BE(b); if (res64 != b_expect) return FAILED ("GUINT64_SWAP_LE_BE returned 0x%" PRIx64 " (had=0x%" PRIx64 ")", (guint64)res64, (guint64)b); res16 = GUINT16_SWAP_LE_BE(c); if (res16 != 0xcdab) return FAILED ("GUINT16_SWAP_LE_BE returned 0x%x", (guint32) res16); return OK; } /* * test initialization */ static Test endian_tests [] = { {"swap", test_swap}, {NULL, NULL} }; DEFINE_TEST_GROUP_INIT(endian_tests_init, endian_tests)
294bc24e92c7162fcaaf2fcf46cf8c25d46c7819
55540f3e86f1d5d86ef6b5d295a63518e274efe3
/components/platform/soc/bl702/bl702_std/BSP_Driver/std_drv/src/bl702_sflash_ext.c
fba509518e96d7ea30b25e893c24a3c230640328
[ "Apache-2.0" ]
permissive
bouffalolab/bl_iot_sdk
bc5eaf036b70f8c65dd389439062b169f8d09daa
b90664de0bd4c1897a9f1f5d9e360a9631d38b34
refs/heads/master
2023-08-31T03:38:03.369853
2023-08-16T08:50:33
2023-08-18T09:13:27
307,347,250
244
101
Apache-2.0
2023-08-28T06:29:02
2020-10-26T11:16:30
C
UTF-8
C
false
false
8,823
c
bl702_sflash_ext.c
/** ****************************************************************************** * @file bl702_sflash_ext.c * @version V1.0 * @date * @brief This file is the standard driver c file ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2019 Bouffalo Lab</center></h2> * * 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 Bouffalo Lab 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. * ****************************************************************************** */ #include "bl702_sflash_ext.h" #include "bl702_sf_ctrl.h" #include "l1c_reg.h" /** @addtogroup BL702_Peripheral_Driver * @{ */ /** @addtogroup SFLASH_EXT * @{ */ /** @defgroup SFLASH_EXT_Private_Macros * @{ */ /*@} end of group SFLASH_EXT_Private_Macros */ /** @defgroup SFLASH_EXT_Private_Types * @{ */ /*@} end of group SFLASH_EXT_Private_Types */ /** @defgroup SFLASH_EXT_Private_Variables * @{ */ /*@} end of group SFLASH_EXT_Private_Variables */ /** @defgroup SFLASH_EXT_Global_Variables * @{ */ /*@} end of group SFLASH_EXT_Global_Variables */ /** @defgroup SFLASH_EXT_Private_Fun_Declaration * @{ */ /*@} end of group SFLASH_EXT_Private_Fun_Declaration */ /** @defgroup SFLASH_EXT_Private_Functions * @{ */ /*@} end of group SFLASH_EXT_Private_Functions */ /** @defgroup SFLASH_EXT_Public_Functions * @{ */ /****************************************************************************/ /** * @brief KH25V40 flash write protect set * * @param flashCfg: Serial flash parameter configuration pointer * @param protect: protect area * * @return SUCCESS or ERROR * *******************************************************************************/ __WEAK BL_Err_Type ATTR_TCM_SECTION SFlash_KH25V40_Write_Protect(SPI_Flash_Cfg_Type *flashCfg, SFlash_Protect_Kh25v40_Type protect) { uint32_t stat = 0, ret; SFlash_Read_Reg(flashCfg, 0, (uint8_t *)&stat, 1); if (((stat >> 2) & 0xf) == protect) { return SUCCESS; } stat |= ((protect << 2) & 0xff); ret = SFlash_Write_Enable(flashCfg); if (SUCCESS != ret) { return ERROR; } SFlash_Write_Reg(flashCfg, 0, (uint8_t *)&stat, 1); SFlash_Read_Reg(flashCfg, 0, (uint8_t *)&stat, 1); if (((stat >> 2) & 0xf) == protect) { return SUCCESS; } return ERROR; } /****************************************************************************/ /** * @brief Read flash register with read command * * @param flashCfg: Serial flash parameter configuration pointer * @param readRegCmd: read command * @param regValue: register value pointer to store data * @param regLen: register value length * * @return SUCCESS or ERROR * *******************************************************************************/ __WEAK BL_Err_Type ATTR_TCM_SECTION SFlash_Read_Reg_With_Cmd(SPI_Flash_Cfg_Type *flashCfg, uint8_t readRegCmd, uint8_t *regValue, uint8_t regLen) { uint8_t *const flashCtrlBuf = (uint8_t *)SF_CTRL_BUF_BASE; SF_Ctrl_Cmd_Cfg_Type flashCmd; uint32_t cnt = 0; if (((uint32_t)&flashCmd) % 4 == 0) { BL702_MemSet4((uint32_t *)&flashCmd, 0, sizeof(flashCmd) / 4); } else { BL702_MemSet(&flashCmd, 0, sizeof(flashCmd)); } flashCmd.cmdBuf[0] = readRegCmd << 24; flashCmd.rwFlag = SF_CTRL_READ; flashCmd.nbData = regLen; SF_Ctrl_SendCmd(&flashCmd); while (SET == SF_Ctrl_GetBusyState()) { BL702_Delay_US(1); cnt++; if (cnt > 1000) { return ERROR; } } BL702_MemCpy(regValue, flashCtrlBuf, regLen); return SUCCESS; } /****************************************************************************/ /** * @brief Write flash register with write command * * @param flashCfg: Serial flash parameter configuration pointer * @param writeRegCmd: write command * @param regValue: register value pointer storing data * @param regLen: register value length * * @return SUCCESS or ERROR * *******************************************************************************/ __WEAK BL_Err_Type ATTR_TCM_SECTION SFlash_Write_Reg_With_Cmd(SPI_Flash_Cfg_Type *flashCfg, uint8_t writeRegCmd, uint8_t *regValue, uint8_t regLen) { uint8_t *const flashCtrlBuf = (uint8_t *)SF_CTRL_BUF_BASE; uint32_t cnt = 0; SF_Ctrl_Cmd_Cfg_Type flashCmd; if (((uint32_t)&flashCmd) % 4 == 0) { BL702_MemSet4((uint32_t *)&flashCmd, 0, sizeof(flashCmd) / 4); } else { BL702_MemSet(&flashCmd, 0, sizeof(flashCmd)); } BL702_MemCpy(flashCtrlBuf, regValue, regLen); flashCmd.cmdBuf[0] = writeRegCmd << 24; flashCmd.rwFlag = SF_CTRL_WRITE; flashCmd.nbData = regLen; SF_Ctrl_SendCmd(&flashCmd); /* take 40ms for tw(write status register) as default */ while (SET == SFlash_Busy(flashCfg)) { BL702_Delay_US(100); cnt++; if (cnt > 400) { return ERROR; } } return SUCCESS; } /****************************************************************************//** * @brief Clear flash status register * * @param pFlashCfg: Flash configuration pointer * * @return SUCCESS or ERROR * *******************************************************************************/ BL_Err_Type ATTR_TCM_SECTION SFlash_Clear_Status_Register(SPI_Flash_Cfg_Type *pFlashCfg) { uint32_t ret = 0; uint32_t qeValue = 0; uint32_t regValue = 0; uint32_t readValue = 0; uint8_t readRegValue0 = 0; uint8_t readRegValue1 = 0; if((pFlashCfg->ioMode&0xf)==SF_CTRL_QO_MODE || (pFlashCfg->ioMode&0xf)==SF_CTRL_QIO_MODE){ qeValue = 1; } SFlash_Read_Reg(pFlashCfg, 0, (uint8_t *)&readRegValue0, 1); SFlash_Read_Reg(pFlashCfg, 1, (uint8_t *)&readRegValue1, 1); readValue = (readRegValue0|(readRegValue1<<8)); if ((readValue & (~((1<<(pFlashCfg->qeIndex*8+pFlashCfg->qeBit)) | (1<<(pFlashCfg->busyIndex*8+pFlashCfg->busyBit)) | (1<<(pFlashCfg->wrEnableIndex*8+pFlashCfg->wrEnableBit))))) == 0){ return SUCCESS; } ret = SFlash_Write_Enable(pFlashCfg); if (SUCCESS != ret) { return ERROR; } if (pFlashCfg->qeWriteRegLen == 2) { regValue = (qeValue<<(pFlashCfg->qeIndex*8+pFlashCfg->qeBit)); SFlash_Write_Reg(pFlashCfg, 0, (uint8_t *)&regValue, 2); } else { if (pFlashCfg->qeIndex == 0) { regValue = (qeValue<<pFlashCfg->qeBit); } else { regValue = 0; } SFlash_Write_Reg(pFlashCfg, 0, (uint8_t *)&regValue, 1); ret = SFlash_Write_Enable(pFlashCfg); if (SUCCESS != ret) { return ERROR; } if (pFlashCfg->qeIndex == 1) { regValue = (qeValue<<pFlashCfg->qeBit); } else { regValue = 0; } SFlash_Write_Reg(pFlashCfg, 1, (uint8_t *)&regValue, 1); } return SUCCESS; } /*@} end of group SFLASH_EXT_Public_Functions */ /*@} end of group SFLASH_EXT */ /*@} end of group BL702_Peripheral_Driver */
8ebd9d4f0304047389e9b4fd1c7f96628a82e7b6
50dd46b8ece33f3cdd174284b15d1d51f89669d4
/third_party/edk2/OvmfPkg/Virtio10Dxe/Virtio10.c
9ebb72c76bfdac65f2532b3caa4183d2c68d9881
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "MIT", "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
31,230
c
Virtio10.c
/** @file A non-transitional driver for VirtIo 1.0 PCI devices. Copyright (C) 2016, Red Hat, Inc. Copyright (C) 2017, AMD Inc, All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include <IndustryStandard/Pci.h> #include <IndustryStandard/Virtio.h> #include <Protocol/PciIo.h> #include <Protocol/PciRootBridgeIo.h> #include <Protocol/VirtioDevice.h> #include <Library/BaseMemoryLib.h> #include <Library/DebugLib.h> #include <Library/MemoryAllocationLib.h> #include <Library/PciCapLib.h> #include <Library/PciCapPciIoLib.h> #include <Library/UefiBootServicesTableLib.h> #include <Library/UefiLib.h> #include "Virtio10.h" // // Utility functions // /** Transfer data between the caller and a register in a virtio-1.0 register block. @param[in] PciIo The EFI_PCI_IO_PROTOCOL instance that represents the device. @param[in] Config The "fat pointer" structure that identifies the register block to access. @param[in] Write TRUE if the register should be written, FALSE if the register should be read. @param[in] FieldOffset The offset of the register within the register block. @param[in] FieldSize The size of the register within the register block. Can be one of 1, 2, 4 and 8. Accesses to 8-byte registers are broken up into two 4-byte accesses. @param[in,out] Buffer When Write is TRUE, the register is written with data from Buffer. When Write is FALSE, the caller receives the register value into Buffer. @retval EFI_SUCCESS Register access successful. @retval EFI_INVALID_PARAMETER The register block pointed-to by Config doesn't exist; or FieldOffset and FieldSize would overflow the register block; or FieldSize is invalid. @return Error codes from EFI_PCI_IO_PROTOCOL.(Io|Mem).(Read|Write) member functions. **/ STATIC EFI_STATUS Virtio10Transfer ( IN EFI_PCI_IO_PROTOCOL *PciIo, IN VIRTIO_1_0_CONFIG *Config, IN BOOLEAN Write, IN UINTN FieldOffset, IN UINTN FieldSize, IN OUT VOID *Buffer ) { UINTN Count; EFI_PCI_IO_PROTOCOL_WIDTH Width; EFI_PCI_IO_PROTOCOL_ACCESS *BarType; EFI_PCI_IO_PROTOCOL_IO_MEM Access; if (!Config->Exists || FieldSize > Config->Length || FieldOffset > Config->Length - FieldSize) { return EFI_INVALID_PARAMETER; } Count = 1; switch (FieldSize) { case 1: Width = EfiPciIoWidthUint8; break; case 2: Width = EfiPciIoWidthUint16; break; case 8: Count = 2; // // fall through // case 4: Width = EfiPciIoWidthUint32; break; default: return EFI_INVALID_PARAMETER; } BarType = (Config->BarType == Virtio10BarTypeMem) ? &PciIo->Mem : &PciIo->Io; Access = Write ? BarType->Write : BarType->Read; return Access (PciIo, Width, Config->Bar, Config->Offset + FieldOffset, Count, Buffer); } /** Determine if a PCI BAR is IO or MMIO. @param[in] PciIo The EFI_PCI_IO_PROTOCOL instance that represents the device. @param[in] BarIndex The number of the BAR whose type the caller is interested in. @param[out] BarType On output, a VIRTIO_1_0_BAR_TYPE value that gives the type of the BAR. @retval EFI_SUCCESS The BAR type has been recognized and stored in BarType. @retval EFI_UNSUPPORTED The BAR type couldn't be identified. @return Error codes from EFI_PCI_IO_PROTOCOL.GetBarAttributes(). **/ STATIC EFI_STATUS GetBarType ( IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, OUT VIRTIO_1_0_BAR_TYPE *BarType ) { EFI_STATUS Status; VOID *Resources; Status = PciIo->GetBarAttributes (PciIo, BarIndex, NULL, &Resources); if (EFI_ERROR (Status)) { return Status; } Status = EFI_UNSUPPORTED; if (*(UINT8 *)Resources == ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR) { EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR *Descriptor; Descriptor = Resources; switch (Descriptor->ResType) { case ACPI_ADDRESS_SPACE_TYPE_MEM: *BarType = Virtio10BarTypeMem; Status = EFI_SUCCESS; break; case ACPI_ADDRESS_SPACE_TYPE_IO: *BarType = Virtio10BarTypeIo; Status = EFI_SUCCESS; break; default: break; } } FreePool (Resources); return Status; } /* Traverse the PCI capabilities list of a virtio-1.0 device, and capture the locations of the interesting virtio-1.0 register blocks. @param[in,out] Device The VIRTIO_1_0_DEV structure that identifies the device. On input, the caller is responsible that the Device->PciIo member be live, and that the CommonConfig, NotifyConfig, NotifyOffsetMultiplier and SpecificConfig members be zeroed. On output, said members will have been updated from the PCI capabilities found. @retval EFI_SUCCESS Traversal successful. @return Error codes from PciCapPciIoLib, PciCapLib, and the GetBarType() helper function. */ STATIC EFI_STATUS ParseCapabilities ( IN OUT VIRTIO_1_0_DEV *Device ) { EFI_STATUS Status; PCI_CAP_DEV *PciDevice; PCI_CAP_LIST *CapList; UINT16 VendorInstance; PCI_CAP *VendorCap; Status = PciCapPciIoDeviceInit (Device->PciIo, &PciDevice); if (EFI_ERROR (Status)) { return Status; } Status = PciCapListInit (PciDevice, &CapList); if (EFI_ERROR (Status)) { goto UninitPciDevice; } for (VendorInstance = 0; !EFI_ERROR (PciCapListFindCap (CapList, PciCapNormal, EFI_PCI_CAPABILITY_ID_VENDOR, VendorInstance, &VendorCap)); VendorInstance++) { UINT8 CapLen; VIRTIO_PCI_CAP VirtIoCap; VIRTIO_1_0_CONFIG *ParsedConfig; // // Big enough to accommodate a VIRTIO_PCI_CAP structure? // Status = PciCapRead (PciDevice, VendorCap, OFFSET_OF (EFI_PCI_CAPABILITY_VENDOR_HDR, Length), &CapLen, sizeof CapLen); if (EFI_ERROR (Status)) { goto UninitCapList; } if (CapLen < sizeof VirtIoCap) { // // Too small, move to next. // continue; } // // Read interesting part of capability. // Status = PciCapRead (PciDevice, VendorCap, 0, &VirtIoCap, sizeof VirtIoCap); if (EFI_ERROR (Status)) { goto UninitCapList; } switch (VirtIoCap.ConfigType) { case VIRTIO_PCI_CAP_COMMON_CFG: ParsedConfig = &Device->CommonConfig; break; case VIRTIO_PCI_CAP_NOTIFY_CFG: ParsedConfig = &Device->NotifyConfig; break; case VIRTIO_PCI_CAP_DEVICE_CFG: ParsedConfig = &Device->SpecificConfig; break; default: // // Capability is not interesting. // continue; } // // Save the location of the register block into ParsedConfig. // Status = GetBarType (Device->PciIo, VirtIoCap.Bar, &ParsedConfig->BarType); if (EFI_ERROR (Status)) { goto UninitCapList; } ParsedConfig->Bar = VirtIoCap.Bar; ParsedConfig->Offset = VirtIoCap.Offset; ParsedConfig->Length = VirtIoCap.Length; if (VirtIoCap.ConfigType == VIRTIO_PCI_CAP_NOTIFY_CFG) { // // This capability has an additional field called NotifyOffsetMultiplier; // parse it too. // if (CapLen < sizeof VirtIoCap + sizeof Device->NotifyOffsetMultiplier) { // // Too small, move to next. // continue; } Status = PciCapRead (PciDevice, VendorCap, sizeof VirtIoCap, &Device->NotifyOffsetMultiplier, sizeof Device->NotifyOffsetMultiplier); if (EFI_ERROR (Status)) { goto UninitCapList; } } // // Capability parsed successfully. // ParsedConfig->Exists = TRUE; } ASSERT_EFI_ERROR (Status); UninitCapList: PciCapListUninit (CapList); UninitPciDevice: PciCapPciIoDeviceUninit (PciDevice); return Status; } /** Accumulate the BAR type of a virtio-1.0 register block into a UINT64 attribute map, such that the latter is suitable for enabling IO / MMIO decoding with EFI_PCI_IO_PROTOCOL.Attributes(). @param[in] Config The "fat pointer" structure that identifies the register block. It is allowed for the register block not to exist. @param[in,out] Attributes On output, if the register block exists, EFI_PCI_IO_ATTRIBUTE_MEMORY or EFI_PCI_IO_ATTRIBUTE_IO is OR-ed into Attributes, according to the register block's BAR type. **/ STATIC VOID UpdateAttributes ( IN VIRTIO_1_0_CONFIG *Config, IN OUT UINT64 *Attributes ) { if (Config->Exists) { *Attributes |= (Config->BarType == Virtio10BarTypeMem) ? EFI_PCI_IO_ATTRIBUTE_MEMORY: EFI_PCI_IO_ATTRIBUTE_IO; } } // // VIRTIO_DEVICE_PROTOCOL member functions // STATIC EFI_STATUS EFIAPI Virtio10GetDeviceFeatures ( IN VIRTIO_DEVICE_PROTOCOL *This, OUT UINT64 *DeviceFeatures ) { VIRTIO_1_0_DEV *Dev; UINT32 Selector; UINT32 Features32[2]; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); for (Selector = 0; Selector < 2; ++Selector) { EFI_STATUS Status; // // Select the low or high half of the features. // Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DeviceFeatureSelect), sizeof Selector, &Selector); if (EFI_ERROR (Status)) { return Status; } // // Fetch that half. // Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, FALSE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DeviceFeature), sizeof Features32[Selector], &Features32[Selector]); if (EFI_ERROR (Status)) { return Status; } } *DeviceFeatures = LShiftU64 (Features32[1], 32) | Features32[0]; return EFI_SUCCESS; } STATIC EFI_STATUS EFIAPI Virtio10SetGuestFeatures ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT64 Features ) { VIRTIO_1_0_DEV *Dev; UINT32 Selector; UINT32 Features32[2]; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Features32[0] = (UINT32)Features; Features32[1] = (UINT32)RShiftU64 (Features, 32); for (Selector = 0; Selector < 2; ++Selector) { EFI_STATUS Status; // // Select the low or high half of the features. // Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DriverFeatureSelect), sizeof Selector, &Selector); if (EFI_ERROR (Status)) { return Status; } // // Write that half. // Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DriverFeature), sizeof Features32[Selector], &Features32[Selector]); if (EFI_ERROR (Status)) { return Status; } } return EFI_SUCCESS; } STATIC EFI_STATUS EFIAPI Virtio10SetQueueAddress ( IN VIRTIO_DEVICE_PROTOCOL *This, IN VRING *Ring, IN UINT64 RingBaseShift ) { VIRTIO_1_0_DEV *Dev; EFI_STATUS Status; UINT64 Address; UINT16 Enable; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Address = (UINTN)Ring->Desc; Address += RingBaseShift; Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueDesc), sizeof Address, &Address); if (EFI_ERROR (Status)) { return Status; } Address = (UINTN)Ring->Avail.Flags; Address += RingBaseShift; Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueAvail), sizeof Address, &Address); if (EFI_ERROR (Status)) { return Status; } Address = (UINTN)Ring->Used.Flags; Address += RingBaseShift; Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueUsed), sizeof Address, &Address); if (EFI_ERROR (Status)) { return Status; } Enable = 1; Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueEnable), sizeof Enable, &Enable); return Status; } STATIC EFI_STATUS EFIAPI Virtio10SetQueueSel ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT16 Index ) { VIRTIO_1_0_DEV *Dev; EFI_STATUS Status; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueSelect), sizeof Index, &Index); return Status; } STATIC EFI_STATUS EFIAPI Virtio10SetQueueNotify ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT16 Index ) { VIRTIO_1_0_DEV *Dev; EFI_STATUS Status; UINT16 SavedQueueSelect; UINT16 NotifyOffset; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); // // Read NotifyOffset first. NotifyOffset is queue specific, so we have // to stash & restore the current queue selector around it. // // So, start with saving the current queue selector. // Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, FALSE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueSelect), sizeof SavedQueueSelect, &SavedQueueSelect); if (EFI_ERROR (Status)) { return Status; } // // Select the requested queue. // Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueSelect), sizeof Index, &Index); if (EFI_ERROR (Status)) { return Status; } // // Read the QueueNotifyOff field. // Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, FALSE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueNotifyOff), sizeof NotifyOffset, &NotifyOffset); if (EFI_ERROR (Status)) { return Status; } // // Re-select the original queue. // Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueSelect), sizeof SavedQueueSelect, &SavedQueueSelect); if (EFI_ERROR (Status)) { return Status; } // // We can now kick the queue. // Status = Virtio10Transfer (Dev->PciIo, &Dev->NotifyConfig, TRUE, NotifyOffset * Dev->NotifyOffsetMultiplier, sizeof Index, &Index); return Status; } STATIC EFI_STATUS EFIAPI Virtio10SetQueueAlign ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT32 Alignment ) { return (Alignment == EFI_PAGE_SIZE) ? EFI_SUCCESS : EFI_UNSUPPORTED; } STATIC EFI_STATUS EFIAPI Virtio10SetPageSize ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT32 PageSize ) { return (PageSize == EFI_PAGE_SIZE) ? EFI_SUCCESS : EFI_UNSUPPORTED; } STATIC EFI_STATUS EFIAPI Virtio10GetQueueNumMax ( IN VIRTIO_DEVICE_PROTOCOL *This, OUT UINT16 *QueueNumMax ) { VIRTIO_1_0_DEV *Dev; EFI_STATUS Status; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, FALSE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueSize), sizeof *QueueNumMax, QueueNumMax); return Status; } STATIC EFI_STATUS EFIAPI Virtio10SetQueueNum ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT16 QueueSize ) { EFI_STATUS Status; UINT16 CurrentSize; // // This member function is required for VirtIo MMIO, and a no-op in // VirtIo PCI 0.9.5. In VirtIo 1.0, drivers can theoretically use this // member to reduce memory consumption, but none of our drivers do. So // just check that they set the size that is already in effect. // Status = Virtio10GetQueueNumMax (This, &CurrentSize); if (EFI_ERROR (Status)) { return Status; } return (CurrentSize == QueueSize) ? EFI_SUCCESS : EFI_UNSUPPORTED; } STATIC EFI_STATUS EFIAPI Virtio10GetDeviceStatus ( IN VIRTIO_DEVICE_PROTOCOL *This, OUT UINT8 *DeviceStatus ) { VIRTIO_1_0_DEV *Dev; EFI_STATUS Status; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, FALSE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DeviceStatus), sizeof *DeviceStatus, DeviceStatus); return Status; } STATIC EFI_STATUS EFIAPI Virtio10SetDeviceStatus ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINT8 DeviceStatus ) { VIRTIO_1_0_DEV *Dev; EFI_STATUS Status; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DeviceStatus), sizeof DeviceStatus, &DeviceStatus); return Status; } STATIC EFI_STATUS EFIAPI Virtio10WriteDevice ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN FieldOffset, IN UINTN FieldSize, IN UINT64 Value ) { VIRTIO_1_0_DEV *Dev; EFI_STATUS Status; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Status = Virtio10Transfer (Dev->PciIo, &Dev->SpecificConfig, TRUE, FieldOffset, FieldSize, &Value); return Status; } STATIC EFI_STATUS EFIAPI Virtio10ReadDevice ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN FieldOffset, IN UINTN FieldSize, IN UINTN BufferSize, OUT VOID *Buffer ) { VIRTIO_1_0_DEV *Dev; EFI_STATUS Status; if (FieldSize != BufferSize) { return EFI_INVALID_PARAMETER; } Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Status = Virtio10Transfer (Dev->PciIo, &Dev->SpecificConfig, FALSE, FieldOffset, FieldSize, Buffer); return Status; } STATIC EFI_STATUS EFIAPI Virtio10AllocateSharedPages ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN Pages, IN OUT VOID **HostAddress ) { VIRTIO_1_0_DEV *Dev; EFI_STATUS Status; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Status = Dev->PciIo->AllocateBuffer ( Dev->PciIo, AllocateAnyPages, EfiBootServicesData, Pages, HostAddress, EFI_PCI_ATTRIBUTE_MEMORY_CACHED ); return Status; } STATIC VOID EFIAPI Virtio10FreeSharedPages ( IN VIRTIO_DEVICE_PROTOCOL *This, IN UINTN Pages, IN VOID *HostAddress ) { VIRTIO_1_0_DEV *Dev; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Dev->PciIo->FreeBuffer ( Dev->PciIo, Pages, HostAddress ); } STATIC EFI_STATUS EFIAPI Virtio10MapSharedBuffer ( IN VIRTIO_DEVICE_PROTOCOL *This, IN VIRTIO_MAP_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping ) { EFI_STATUS Status; VIRTIO_1_0_DEV *Dev; EFI_PCI_IO_PROTOCOL_OPERATION PciIoOperation; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); // // Map VIRTIO_MAP_OPERATION to EFI_PCI_IO_PROTOCOL_OPERATION // switch (Operation) { case VirtioOperationBusMasterRead: PciIoOperation = EfiPciIoOperationBusMasterRead; break; case VirtioOperationBusMasterWrite: PciIoOperation = EfiPciIoOperationBusMasterWrite; break; case VirtioOperationBusMasterCommonBuffer: PciIoOperation = EfiPciIoOperationBusMasterCommonBuffer; break; default: return EFI_INVALID_PARAMETER; } Status = Dev->PciIo->Map ( Dev->PciIo, PciIoOperation, HostAddress, NumberOfBytes, DeviceAddress, Mapping ); return Status; } STATIC EFI_STATUS EFIAPI Virtio10UnmapSharedBuffer ( IN VIRTIO_DEVICE_PROTOCOL *This, IN VOID *Mapping ) { EFI_STATUS Status; VIRTIO_1_0_DEV *Dev; Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); Status = Dev->PciIo->Unmap ( Dev->PciIo, Mapping ); return Status; } STATIC CONST VIRTIO_DEVICE_PROTOCOL mVirtIoTemplate = { VIRTIO_SPEC_REVISION (1, 0, 0), 0, // SubSystemDeviceId, filled in dynamically Virtio10GetDeviceFeatures, Virtio10SetGuestFeatures, Virtio10SetQueueAddress, Virtio10SetQueueSel, Virtio10SetQueueNotify, Virtio10SetQueueAlign, Virtio10SetPageSize, Virtio10GetQueueNumMax, Virtio10SetQueueNum, Virtio10GetDeviceStatus, Virtio10SetDeviceStatus, Virtio10WriteDevice, Virtio10ReadDevice, Virtio10AllocateSharedPages, Virtio10FreeSharedPages, Virtio10MapSharedBuffer, Virtio10UnmapSharedBuffer }; // // EFI_DRIVER_BINDING_PROTOCOL member functions // STATIC EFI_STATUS EFIAPI Virtio10BindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { EFI_STATUS Status; EFI_PCI_IO_PROTOCOL *PciIo; PCI_TYPE00 Pci; Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, (VOID **)&PciIo, This->DriverBindingHandle, DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); if (EFI_ERROR (Status)) { return Status; } Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0, sizeof Pci / sizeof (UINT32), &Pci); if (EFI_ERROR (Status)) { goto CloseProtocol; } Status = EFI_UNSUPPORTED; // // Recognize non-transitional modern devices. Also, we'll have to parse the // PCI capability list, so make sure the CapabilityPtr field will be valid. // if (Pci.Hdr.VendorId == VIRTIO_VENDOR_ID && Pci.Hdr.DeviceId >= 0x1040 && Pci.Hdr.DeviceId <= 0x107F && Pci.Hdr.RevisionID >= 0x01 && Pci.Device.SubsystemID >= 0x40 && (Pci.Hdr.Status & EFI_PCI_STATUS_CAPABILITY) != 0) { // // The virtio-vga device is special. It can be driven both as a VGA device // with a linear framebuffer, and through its underlying, modern, // virtio-gpu-pci device, which has no linear framebuffer itself. For // compatibility with guest OSes that insist on inheriting a linear // framebuffer from the firmware, we should leave virtio-vga to // QemuVideoDxe, and support only virtio-gpu-pci here. // // Both virtio-vga and virtio-gpu-pci have DeviceId 0x1050, but only the // former has device class PCI_CLASS_DISPLAY_VGA. // if (Pci.Hdr.DeviceId != 0x1050 || !IS_PCI_VGA (&Pci)) { Status = EFI_SUCCESS; } } CloseProtocol: gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, This->DriverBindingHandle, DeviceHandle); return Status; } STATIC EFI_STATUS EFIAPI Virtio10BindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { VIRTIO_1_0_DEV *Device; EFI_STATUS Status; PCI_TYPE00 Pci; UINT64 SetAttributes; Device = AllocateZeroPool (sizeof *Device); if (Device == NULL) { return EFI_OUT_OF_RESOURCES; } Device->Signature = VIRTIO_1_0_SIGNATURE; CopyMem (&Device->VirtIo, &mVirtIoTemplate, sizeof mVirtIoTemplate); Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, (VOID **)&Device->PciIo, This->DriverBindingHandle, DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); if (EFI_ERROR (Status)) { goto FreeDevice; } Status = Device->PciIo->Pci.Read (Device->PciIo, EfiPciIoWidthUint32, 0, sizeof Pci / sizeof (UINT32), &Pci); if (EFI_ERROR (Status)) { goto ClosePciIo; } Device->VirtIo.SubSystemDeviceId = Pci.Hdr.DeviceId - 0x1040; Status = ParseCapabilities (Device); if (EFI_ERROR (Status)) { goto ClosePciIo; } Status = Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationGet, 0, &Device->OriginalPciAttributes); if (EFI_ERROR (Status)) { goto ClosePciIo; } SetAttributes = (EFI_PCI_IO_ATTRIBUTE_BUS_MASTER | EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE); UpdateAttributes (&Device->CommonConfig, &SetAttributes); UpdateAttributes (&Device->NotifyConfig, &SetAttributes); UpdateAttributes (&Device->SpecificConfig, &SetAttributes); Status = Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationEnable, SetAttributes, NULL); if (EFI_ERROR (Status)) { goto ClosePciIo; } Status = gBS->InstallProtocolInterface (&DeviceHandle, &gVirtioDeviceProtocolGuid, EFI_NATIVE_INTERFACE, &Device->VirtIo); if (EFI_ERROR (Status)) { goto RestorePciAttributes; } return EFI_SUCCESS; RestorePciAttributes: Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet, Device->OriginalPciAttributes, NULL); ClosePciIo: gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, This->DriverBindingHandle, DeviceHandle); FreeDevice: FreePool (Device); return Status; } STATIC EFI_STATUS EFIAPI Virtio10BindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer ) { EFI_STATUS Status; VIRTIO_DEVICE_PROTOCOL *VirtIo; VIRTIO_1_0_DEV *Device; Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, (VOID **)&VirtIo, This->DriverBindingHandle, DeviceHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (EFI_ERROR (Status)) { return Status; } Device = VIRTIO_1_0_FROM_VIRTIO_DEVICE (VirtIo); Status = gBS->UninstallProtocolInterface (DeviceHandle, &gVirtioDeviceProtocolGuid, &Device->VirtIo); if (EFI_ERROR (Status)) { return Status; } Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet, Device->OriginalPciAttributes, NULL); gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, This->DriverBindingHandle, DeviceHandle); FreePool (Device); return EFI_SUCCESS; } STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = { &Virtio10BindingSupported, &Virtio10BindingStart, &Virtio10BindingStop, 0x10, // Version NULL, // ImageHandle, to be overwritten NULL // DriverBindingHandle, to be overwritten }; // // EFI_COMPONENT_NAME_PROTOCOL and EFI_COMPONENT_NAME2_PROTOCOL // implementations // STATIC EFI_UNICODE_STRING_TABLE mDriverNameTable[] = { { "eng;en", L"Virtio 1.0 PCI Driver" }, { NULL, NULL } }; STATIC EFI_COMPONENT_NAME_PROTOCOL mComponentName; STATIC EFI_STATUS EFIAPI Virtio10GetDriverName ( IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName ) { return LookupUnicodeString2 ( Language, This->SupportedLanguages, mDriverNameTable, DriverName, (BOOLEAN)(This == &mComponentName) // Iso639Language ); } STATIC EFI_STATUS EFIAPI Virtio10GetDeviceName ( IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_HANDLE ChildHandle, IN CHAR8 *Language, OUT CHAR16 **ControllerName ) { return EFI_UNSUPPORTED; } STATIC EFI_COMPONENT_NAME_PROTOCOL mComponentName = { &Virtio10GetDriverName, &Virtio10GetDeviceName, "eng" }; STATIC EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = { (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &Virtio10GetDriverName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &Virtio10GetDeviceName, "en" }; // // Entry point of this driver // EFI_STATUS EFIAPI Virtio10EntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { return EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &mDriverBinding, ImageHandle, &mComponentName, &mComponentName2 ); }
1073fe2d2c89521f62ebd24e366ce265e21f15a1
057a475216e9beed41983481aafcaf109bbf58da
/contrib/unixodbc-cmake/linux_x86_64/private/config.h
59cee9e8565b3b3e60c3dff03fa358db052f5143
[ "Apache-2.0" ]
permissive
ClickHouse/ClickHouse
fece5204263a5b4d693854b6039699265f1bb27f
6649328db809d51a694c358571539bc5820464be
refs/heads/master
2023-08-31T18:48:36.615225
2023-08-31T17:51:24
2023-08-31T17:51:24
60,246,359
23,878
5,449
Apache-2.0
2023-09-14T20:10:52
2016-06-02T08:28:18
C++
UTF-8
C
false
false
13,655
h
config.h
/* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Encoding to use for CHAR */ #define ASCII_ENCODING "auto-search" /* Install bindir */ #define BIN_PREFIX "/usr/local/bin" /* Use a semaphore to allow ODBCConfig to display running counts */ /* #undef COLLECT_STATS */ /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ /* #undef CRAY_STACKSEG_END */ /* Define to 1 if using `alloca.c'. */ /* #undef C_ALLOCA */ /* Lib directory */ #define DEFLIB_PATH "/usr/local/lib" /* Using ini cacheing */ #define ENABLE_INI_CACHING /**/ /* Install exec_prefix */ #define EXEC_PREFIX "/usr/local" /* Disable the precise but slow checking of the validity of handles */ /* #undef FAST_HANDLE_VALIDATE */ /* Define to 1 if you have `alloca', as a function or macro. */ #define HAVE_ALLOCA 1 /* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). */ #define HAVE_ALLOCA_H 1 /* Define to 1 if you have the `argz_add' function. */ #define HAVE_ARGZ_ADD 1 /* Define to 1 if you have the `argz_append' function. */ #define HAVE_ARGZ_APPEND 1 /* Define to 1 if you have the `argz_count' function. */ #define HAVE_ARGZ_COUNT 1 /* Define to 1 if you have the `argz_create_sep' function. */ #define HAVE_ARGZ_CREATE_SEP 1 /* Define to 1 if you have the <argz.h> header file. */ #define HAVE_ARGZ_H 1 /* Define to 1 if you have the `argz_insert' function. */ #define HAVE_ARGZ_INSERT 1 /* Define to 1 if you have the `argz_next' function. */ #define HAVE_ARGZ_NEXT 1 /* Define to 1 if you have the `argz_stringify' function. */ #define HAVE_ARGZ_STRINGIFY 1 /* Define to 1 if you have the `atoll' function. */ #define HAVE_ATOLL 1 /* Define to 1 if you have the `closedir' function. */ #define HAVE_CLOSEDIR 1 /* Define to 1 if you have the <crypt.h> header file. */ #define HAVE_CRYPT_H 1 /* Define to 1 if you have the declaration of `cygwin_conv_path', and to 0 if you don't. */ /* #undef HAVE_DECL_CYGWIN_CONV_PATH */ /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. */ #define HAVE_DIRENT_H 1 /* Define if you have the GNU dld library. */ /* #undef HAVE_DLD */ /* Define to 1 if you have the <dld.h> header file. */ /* #undef HAVE_DLD_H */ /* Define to 1 if you have the `dlerror' function. */ #define HAVE_DLERROR 1 /* Define to 1 if you have the <dlfcn.h> header file. */ #define HAVE_DLFCN_H 1 /* Define to 1 if you have the <dl.h> header file. */ /* #undef HAVE_DL_H */ /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ /* #undef HAVE_DOPRNT */ /* Define if you have the _dyld_func_lookup function. */ /* #undef HAVE_DYLD */ /* Define to 1 if you have the `endpwent' function. */ #define HAVE_ENDPWENT 1 /* Define to 1 if the system has the type `error_t'. */ #define HAVE_ERROR_T 1 /* Define to 1 if you have the `ftime' function. */ #define HAVE_FTIME 1 /* Define to 1 if you have the `ftok' function. */ /* #undef HAVE_FTOK */ /* Define to 1 if you have the `getpwuid' function. */ #define HAVE_GETPWUID 1 /* Define to 1 if you have the `gettimeofday' function. */ #define HAVE_GETTIMEOFDAY 1 /* Define to 1 if you have the `getuid' function. */ #define HAVE_GETUID 1 /* Define if you have the iconv() function. */ #define HAVE_ICONV 1 /* Define to 1 if you have the <inttypes.h> header file. */ #define HAVE_INTTYPES_H 1 /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */ #define HAVE_LANGINFO_CODESET 1 /* Define to 1 if you have the <langinfo.h> header file. */ #define HAVE_LANGINFO_H 1 /* Add -lcrypt to lib list */ #define HAVE_LIBCRYPT /**/ /* Define if you have the libdl library or equivalent. */ #define HAVE_LIBDL 1 /* Define if libdlloader will be built on this platform */ #define HAVE_LIBDLLOADER 1 /* Use the -lpth thread library */ /* #undef HAVE_LIBPTH */ /* Use -lpthread threading lib */ #define HAVE_LIBPTHREAD 1 /* Use the -lthread threading lib */ /* #undef HAVE_LIBTHREAD */ /* Define to 1 if you have the <limits.h> header file. */ #define HAVE_LIMITS_H 1 /* Define to 1 if you have the <locale.h> header file. */ #define HAVE_LOCALE_H 1 /* Use rentrant version of localtime */ #define HAVE_LOCALTIME_R 1 /* Define if you have long long */ #define HAVE_LONG_LONG 1 /* Define this if a modern libltdl is already installed */ #define HAVE_LTDL 1 /* Define to 1 if you have the <mach-o/dyld.h> header file. */ /* #undef HAVE_MACH_O_DYLD_H */ /* Define to 1 if you have the <malloc.h> header file. */ #define HAVE_MALLOC_H 1 /* Define to 1 if you have the <memory.h> header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the <msql.h> header file. */ /* #undef HAVE_MSQL_H */ /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ /* #undef HAVE_NDIR_H */ /* Define to 1 if you have the `nl_langinfo' function. */ #define HAVE_NL_LANGINFO 1 /* Define to 1 if you have the `opendir' function. */ #define HAVE_OPENDIR 1 /* Define if libtool can extract symbol lists from object files. */ #define HAVE_PRELOADED_SYMBOLS 1 /* Define to 1 if the system has the type `ptrdiff_t'. */ #define HAVE_PTRDIFF_T 1 /* Define to 1 if you have the `putenv' function. */ #define HAVE_PUTENV 1 /* Define to 1 if you have the <pwd.h> header file. */ #define HAVE_PWD_H 1 /* Define to 1 if you have the `readdir' function. */ #define HAVE_READDIR 1 /* Add readline support */ /* #undef HAVE_READLINE */ /* Define to 1 if you have the <readline/history.h> header file. */ /* #undef HAVE_READLINE_HISTORY_H */ /* Use the scandir lib */ /* #undef HAVE_SCANDIR */ /* Define to 1 if you have the `semget' function. */ /* #undef HAVE_SEMGET */ /* Define to 1 if you have the `semop' function. */ /* #undef HAVE_SEMOP */ /* Define to 1 if you have the `setenv' function. */ #define HAVE_SETENV 1 /* Define to 1 if you have the `setlocale' function. */ #define HAVE_SETLOCALE 1 /* Define if you have the shl_load function. */ /* #undef HAVE_SHL_LOAD */ /* Define to 1 if you have the `shmget' function. */ /* #undef HAVE_SHMGET */ /* Define to 1 if you have the `snprintf' function. */ /* #undef HAVE_SNPRINTF */ /* Define to 1 if you have the `socket' function. */ #define HAVE_SOCKET 1 /* Define to 1 if you have the <stdarg.h> header file. */ #define HAVE_STDARG_H 1 /* Define to 1 if you have the <stddef.h> header file. */ #define HAVE_STDDEF_H 1 /* Define to 1 if you have the <stdint.h> header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the `strcasecmp' function. */ #define HAVE_STRCASECMP 1 /* Define to 1 if you have the `strchr' function. */ #define HAVE_STRCHR 1 /* Define to 1 if you have the `strdup' function. */ #define HAVE_STRDUP 1 /* Define to 1 if you have the `stricmp' function. */ /* #undef HAVE_STRICMP */ /* Define to 1 if you have the <strings.h> header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the <string.h> header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the `strlcat' function. */ /* #undef HAVE_STRLCAT */ /* Define to 1 if you have the `strlcpy' function. */ /* #undef HAVE_STRLCPY */ /* Define to 1 if you have the `strncasecmp' function. */ #define HAVE_STRNCASECMP 1 /* Define to 1 if you have the `strnicmp' function. */ /* #undef HAVE_STRNICMP */ /* Define to 1 if you have the `strstr' function. */ #define HAVE_STRSTR 1 /* Define to 1 if you have the `strtol' function. */ #define HAVE_STRTOL 1 /* Define to 1 if you have the `strtoll' function. */ #define HAVE_STRTOLL 1 /* Define to 1 if you have the <synch.h> header file. */ /* #undef HAVE_SYNCH_H */ /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. */ /* #undef HAVE_SYS_DIR_H */ /* Define to 1 if you have the <sys/dl.h> header file. */ /* #undef HAVE_SYS_DL_H */ /* Define to 1 if you have the <sys/malloc.h> header file. */ /* #undef HAVE_SYS_MALLOC_H */ /* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. */ /* #undef HAVE_SYS_NDIR_H */ /* Define to 1 if you have the <sys/sem.h> header file. */ #define HAVE_SYS_SEM_H 1 /* Define to 1 if you have the <sys/stat.h> header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/timeb.h> header file. */ #define HAVE_SYS_TIMEB_H 1 /* Define to 1 if you have the <sys/time.h> header file. */ #define HAVE_SYS_TIME_H 1 /* Define to 1 if you have the <sys/types.h> header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the `time' function. */ #define HAVE_TIME 1 /* Define to 1 if you have the <time.h> header file. */ #define HAVE_TIME_H 1 /* Define to 1 if you have the <unistd.h> header file. */ #define HAVE_UNISTD_H 1 /* Define to 1 if you have the <varargs.h> header file. */ /* #undef HAVE_VARARGS_H */ /* Define to 1 if you have the `vprintf' function. */ #define HAVE_VPRINTF 1 /* Define to 1 if you have the `vsnprintf' function. */ #define HAVE_VSNPRINTF 1 /* This value is set to 1 to indicate that the system argz facility works */ #define HAVE_WORKING_ARGZ 1 /* Define as const if the declaration of iconv() needs const. */ #define ICONV_CONST /* Install includedir */ #define INCLUDE_PREFIX "/usr/local/include" /* Lib directory */ #define LIB_PREFIX "/usr/local/lib" /* Define if the OS needs help to load dependent libraries for dlopen(). */ /* #undef LTDL_DLOPEN_DEPLIBS */ /* Define to the system default library search path. */ #define LT_DLSEARCH_PATH "/lib:/usr/lib:/usr/lib/x86_64-linux-gnu/libfakeroot:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib32:/usr/lib32" /* The archive extension */ #define LT_LIBEXT "a" /* The archive prefix */ #define LT_LIBPREFIX "lib" /* Define to the extension used for runtime loadable modules, say, ".so". */ #define LT_MODULE_EXT ".so" /* Define to the name of the environment variable that determines the run-time module search path. */ #define LT_MODULE_PATH_VAR "LD_LIBRARY_PATH" /* Define to the sub-directory where libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* Define to the shared library suffix, say, ".dylib". */ /* #undef LT_SHARED_EXT */ /* Define to the shared archive member specification, say "(shr.o)". */ /* #undef LT_SHARED_LIB_MEMBER */ /* Define if you need semundo union */ /* #undef NEED_SEMUNDO_UNION */ /* Define if dlsym() requires a leading underscore in symbol names. */ /* #undef NEED_USCORE */ /* Using OSX */ /* #undef OSXHEADER */ /* Name of package */ #define PACKAGE "unixODBC" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "nick@unixodbc.org" /* Define to the full name of this package. */ #define PACKAGE_NAME "unixODBC" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "unixODBC 2.3.6" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "unixODBC" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "2.3.6" /* Platform is 64 bit */ #define PLATFORM64 /**/ /* Install prefix */ #define PREFIX "/usr/local" /* Using QNX */ /* #undef QNX_LIBLTDL */ /* Shared lib extension */ #define SHLIBEXT ".so" /* The size of `long', as computed by sizeof. */ #define SIZEOF_LONG 8 /* The size of `long int', as computed by sizeof. */ #define SIZEOF_LONG_INT 8 /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ /* #undef STACK_DIRECTION */ /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* don't include unixODBC prefix in driver error messages */ #define STRICT_ODBC_ERROR /**/ /* System file path */ #define SYSTEM_FILE_PATH "/etc" /* Lib path */ #define SYSTEM_LIB_PATH "/usr/local/lib" /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ #define TIME_WITH_SYS_TIME 1 /* Define to 1 if your <sys/time.h> declares `struct tm'. */ /* #undef TM_IN_SYS_TIME */ /* Encoding to use for UNICODE */ #define UNICODE_ENCODING "auto-search" /* Flag that we are not using another DM */ #define UNIXODBC /**/ /* We are building inside the unixODBC source tree */ #define UNIXODBC_SOURCE /**/ /* Version number of package */ #define VERSION "2.3.6" /* Work with IBM drivers that use 32 bit handles on 64 bit platforms */ /* #undef WITH_HANDLE_REDIRECT */ /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. */ /* #undef YYTEXT_POINTER */ /* Build flag for AIX */ /* #undef _ALL_SOURCE */ /* Build flag for AIX */ /* #undef _LONG_LONG */ /* Build flag for AIX */ /* #undef _THREAD_SAFE */ /* Define so that glibc/gnulib argp.h does not typedef error_t. */ /* #undef __error_t_defined */ /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ /* Define to a type to use for 'error_t' if it is not otherwise available. */ /* #undef error_t */ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef gid_t */ /* Define to `unsigned int' if <sys/types.h> does not define. */ /* #undef size_t */ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef uid_t */
ce5764ea051ba448029c6a68bab5ef6d5ae90e95
5ed64b3dd7ebd036e05240969d621d0c307f367a
/rtl-sdr/src/librtlsdr.c
622f985fb8150aeadf3bdc8696dfe2cea86d45d3
[ "MIT", "GPL-2.0-only", "Apache-2.0" ]
permissive
bareboat-necessities/my-bareboat
bb640fa265e29abaa0619368997343195cb347ff
3f72313a1edb175fb1beea4011b406f28bba89bf
refs/heads/master
2023-08-07T22:48:08.712219
2023-07-23T18:25:12
2023-07-23T18:25:12
221,806,712
168
24
Apache-2.0
2023-07-22T21:38:44
2019-11-14T23:45:58
C
UTF-8
C
false
false
47,338
c
librtlsdr.c
/* * rtl-sdr, turns your Realtek RTL2832 based DVB dongle into a SDR receiver * Copyright (C) 2012-2014 by Steve Markgraf <steve@steve-m.de> * Copyright (C) 2012 by Dimitri Stolnikov <horiz0n@gmx.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 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, see <http://www.gnu.org/licenses/>. */ #include <errno.h> #include <signal.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #ifndef _WIN32 #include <unistd.h> #define min(a, b) (((a) < (b)) ? (a) : (b)) #endif #include <libusb.h> /* * All libusb callback functions should be marked with the LIBUSB_CALL macro * to ensure that they are compiled with the same calling convention as libusb. * * If the macro isn't available in older libusb versions, we simply define it. */ #ifndef LIBUSB_CALL #define LIBUSB_CALL #endif /* libusb < 1.0.9 doesn't have libusb_handle_events_timeout_completed */ #ifndef HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED #define libusb_handle_events_timeout_completed(ctx, tv, c) \ libusb_handle_events_timeout(ctx, tv) #endif /* two raised to the power of n */ #define TWO_POW(n) ((double)(1ULL<<(n))) #include "rtl-sdr.h" #include "tuner_e4k.h" #include "tuner_fc0012.h" #include "tuner_fc0013.h" #include "tuner_fc2580.h" #include "tuner_r82xx.h" typedef struct rtlsdr_tuner_iface { /* tuner interface */ int (*init)(void *); int (*exit)(void *); int (*set_freq)(void *, uint32_t freq /* Hz */); int (*set_bw)(void *, int bw /* Hz */); int (*set_gain)(void *, int gain /* tenth dB */); int (*set_if_gain)(void *, int stage, int gain /* tenth dB */); int (*set_gain_mode)(void *, int manual); int (*set_if_freq)(void *, uint32_t freq /* Hz */); } rtlsdr_tuner_iface_t; enum rtlsdr_async_status { RTLSDR_INACTIVE = 0, RTLSDR_CANCELING, RTLSDR_RUNNING }; #define FIR_LEN 16 /* * FIR coefficients. * * The filter is running at XTal frequency. It is symmetric filter with 32 * coefficients. Only first 16 coefficients are specified, the other 16 * use the same values but in reversed order. The first coefficient in * the array is the outer one, the last, the last is the inner one. * First 8 coefficients are 8 bit signed integers, the next 8 coefficients * are 12 bit signed integers. All coefficients have the same weight. * * Default FIR coefficients used for DAB/FM by the Windows driver, * the DVB driver uses different ones */ static const int fir_default[FIR_LEN] = { -54, -36, -41, -40, -32, -14, 14, 53, /* 8 bit signed */ 101, 156, 215, 273, 327, 372, 404, 421 /* 12 bit signed */ }; struct rtlsdr_dev { libusb_context *ctx; struct libusb_device_handle *devh; uint32_t xfer_buf_num; uint32_t xfer_buf_len; struct libusb_transfer **xfer; unsigned char **xfer_buf; rtlsdr_read_async_cb_t cb; void *cb_ctx; enum rtlsdr_async_status async_status; int async_cancel; /* rtl demod context */ uint32_t rate; /* Hz */ uint32_t rtl_xtal; /* Hz */ int fir[FIR_LEN]; int direct_sampling; /* tuner context */ enum rtlsdr_tuner tuner_type; rtlsdr_tuner_iface_t *tuner; uint32_t tun_xtal; /* Hz */ uint32_t freq; /* Hz */ uint32_t offs_freq; /* Hz */ int corr; /* ppm */ int gain; /* tenth dB */ struct e4k_state e4k_s; struct r82xx_config r82xx_c; struct r82xx_priv r82xx_p; /* status */ int dev_lost; int driver_active; unsigned int xfer_errors; int tuner_initialized; int i2c_repeater_on; }; void rtlsdr_set_gpio_bit(rtlsdr_dev_t *dev, uint8_t gpio, int val); /* generic tuner interface functions, shall be moved to the tuner implementations */ int e4000_init(void *dev) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; devt->e4k_s.i2c_addr = E4K_I2C_ADDR; rtlsdr_get_xtal_freq(devt, NULL, &devt->e4k_s.vco.fosc); devt->e4k_s.rtl_dev = dev; return e4k_init(&devt->e4k_s); } int e4000_exit(void *dev) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; return e4k_standby(&devt->e4k_s, 1); } int e4000_set_freq(void *dev, uint32_t freq) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; return e4k_tune_freq(&devt->e4k_s, freq); } int e4000_set_bw(void *dev, int bw) { int r = 0; rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; r |= e4k_if_filter_bw_set(&devt->e4k_s, E4K_IF_FILTER_MIX, bw); r |= e4k_if_filter_bw_set(&devt->e4k_s, E4K_IF_FILTER_RC, bw); r |= e4k_if_filter_bw_set(&devt->e4k_s, E4K_IF_FILTER_CHAN, bw); return r; } int e4000_set_gain(void *dev, int gain) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; int mixgain = (gain > 340) ? 12 : 4; #if 0 int enhgain = (gain - 420); #endif if(e4k_set_lna_gain(&devt->e4k_s, min(300, gain - mixgain * 10)) == -EINVAL) return -1; if(e4k_mixer_gain_set(&devt->e4k_s, mixgain) == -EINVAL) return -1; #if 0 /* enhanced mixer gain seems to have no effect */ if(enhgain >= 0) if(e4k_set_enh_gain(&devt->e4k_s, enhgain) == -EINVAL) return -1; #endif return 0; } int e4000_set_if_gain(void *dev, int stage, int gain) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; return e4k_if_gain_set(&devt->e4k_s, (uint8_t)stage, (int8_t)(gain / 10)); } int e4000_set_gain_mode(void *dev, int manual) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; return e4k_enable_manual_gain(&devt->e4k_s, manual); } int _fc0012_init(void *dev) { return fc0012_init(dev); } int fc0012_exit(void *dev) { return 0; } int fc0012_set_freq(void *dev, uint32_t freq) { /* select V-band/U-band filter */ rtlsdr_set_gpio_bit(dev, 6, (freq > 300000000) ? 1 : 0); return fc0012_set_params(dev, freq, 6000000); } int fc0012_set_bw(void *dev, int bw) { return 0; } int _fc0012_set_gain(void *dev, int gain) { return fc0012_set_gain(dev, gain); } int fc0012_set_gain_mode(void *dev, int manual) { return 0; } int _fc0013_init(void *dev) { return fc0013_init(dev); } int fc0013_exit(void *dev) { return 0; } int fc0013_set_freq(void *dev, uint32_t freq) { return fc0013_set_params(dev, freq, 6000000); } int fc0013_set_bw(void *dev, int bw) { return 0; } int _fc0013_set_gain(void *dev, int gain) { return fc0013_set_lna_gain(dev, gain); } int fc2580_init(void *dev) { return fc2580_Initialize(dev); } int fc2580_exit(void *dev) { return 0; } int _fc2580_set_freq(void *dev, uint32_t freq) { return fc2580_SetRfFreqHz(dev, freq); } int fc2580_set_bw(void *dev, int bw) { return fc2580_SetBandwidthMode(dev, 1); } int fc2580_set_gain(void *dev, int gain) { return 0; } int fc2580_set_gain_mode(void *dev, int manual) { return 0; } int r820t_init(void *dev) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; devt->r82xx_p.rtl_dev = dev; if (devt->tuner_type == RTLSDR_TUNER_R828D) { devt->r82xx_c.i2c_addr = R828D_I2C_ADDR; devt->r82xx_c.rafael_chip = CHIP_R828D; } else { devt->r82xx_c.i2c_addr = R820T_I2C_ADDR; devt->r82xx_c.rafael_chip = CHIP_R820T; } rtlsdr_get_xtal_freq(devt, NULL, &devt->r82xx_c.xtal); devt->r82xx_c.max_i2c_msg_len = 8; devt->r82xx_c.use_predetect = 0; devt->r82xx_p.cfg = &devt->r82xx_c; return r82xx_init(&devt->r82xx_p); } int r820t_exit(void *dev) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; return r82xx_standby(&devt->r82xx_p); } int r820t_set_freq(void *dev, uint32_t freq) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; return r82xx_set_freq(&devt->r82xx_p, freq); } int r820t_set_bw(void *dev, int bw) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; return r82xx_set_bw(&devt->r82xx_p, bw); } int r820t_set_if_freq(void *dev, uint32_t freq) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; return r82xx_set_if_freq(&devt->r82xx_p, freq); } int r820t_set_gain(void *dev, int gain) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; return r82xx_set_gain(&devt->r82xx_p, 1, gain); } int r820t_set_gain_mode(void *dev, int manual) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; return r82xx_set_gain(&devt->r82xx_p, manual, 0); } /* definition order must match enum rtlsdr_tuner */ static rtlsdr_tuner_iface_t tuners[] = { { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL /* dummy for unknown tuners */ }, { e4000_init, e4000_exit, e4000_set_freq, e4000_set_bw, e4000_set_gain, e4000_set_if_gain, e4000_set_gain_mode, NULL }, { _fc0012_init, fc0012_exit, fc0012_set_freq, fc0012_set_bw, _fc0012_set_gain, NULL, fc0012_set_gain_mode, NULL }, { _fc0013_init, fc0013_exit, fc0013_set_freq, fc0013_set_bw, _fc0013_set_gain, NULL, fc0013_set_gain_mode, NULL }, { fc2580_init, fc2580_exit, _fc2580_set_freq, fc2580_set_bw, fc2580_set_gain, NULL, fc2580_set_gain_mode, NULL }, { r820t_init, r820t_exit, r820t_set_freq, r820t_set_bw, r820t_set_gain, NULL, r820t_set_gain_mode, r820t_set_if_freq }, { r820t_init, r820t_exit, r820t_set_freq, r820t_set_bw, r820t_set_gain, NULL, r820t_set_gain_mode, r820t_set_if_freq }, }; typedef struct rtlsdr_dongle { uint16_t vid; uint16_t pid; const char *name; } rtlsdr_dongle_t; /* * Please add your device here and send a patch to osmocom-sdr@lists.osmocom.org */ static rtlsdr_dongle_t known_devices[] = { { 0x0bda, 0x2832, "Generic RTL2832U" }, { 0x0bda, 0x2838, "Generic RTL2832U OEM" }, { 0x0413, 0x6680, "DigitalNow Quad DVB-T PCI-E card" }, { 0x0413, 0x6f0f, "Leadtek WinFast DTV Dongle mini D" }, { 0x0458, 0x707f, "Genius TVGo DVB-T03 USB dongle (Ver. B)" }, { 0x0ccd, 0x00a9, "Terratec Cinergy T Stick Black (rev 1)" }, { 0x0ccd, 0x00b3, "Terratec NOXON DAB/DAB+ USB dongle (rev 1)" }, { 0x0ccd, 0x00b4, "Terratec Deutschlandradio DAB Stick" }, { 0x0ccd, 0x00b5, "Terratec NOXON DAB Stick - Radio Energy" }, { 0x0ccd, 0x00b7, "Terratec Media Broadcast DAB Stick" }, { 0x0ccd, 0x00b8, "Terratec BR DAB Stick" }, { 0x0ccd, 0x00b9, "Terratec WDR DAB Stick" }, { 0x0ccd, 0x00c0, "Terratec MuellerVerlag DAB Stick" }, { 0x0ccd, 0x00c6, "Terratec Fraunhofer DAB Stick" }, { 0x0ccd, 0x00d3, "Terratec Cinergy T Stick RC (Rev.3)" }, { 0x0ccd, 0x00d7, "Terratec T Stick PLUS" }, { 0x0ccd, 0x00e0, "Terratec NOXON DAB/DAB+ USB dongle (rev 2)" }, { 0x1554, 0x5020, "PixelView PV-DT235U(RN)" }, { 0x15f4, 0x0131, "Astrometa DVB-T/DVB-T2" }, { 0x185b, 0x0620, "Compro Videomate U620F"}, { 0x185b, 0x0650, "Compro Videomate U650F"}, { 0x185b, 0x0680, "Compro Videomate U680F"}, { 0x1b80, 0xd393, "GIGABYTE GT-U7300" }, { 0x1b80, 0xd394, "DIKOM USB-DVBT HD" }, { 0x1b80, 0xd395, "Peak 102569AGPK" }, { 0x1b80, 0xd397, "KWorld KW-UB450-T USB DVB-T Pico TV" }, { 0x1b80, 0xd398, "Zaapa ZT-MINDVBZP" }, { 0x1b80, 0xd39d, "SVEON STV20 DVB-T USB & FM" }, { 0x1b80, 0xd3a4, "Twintech UT-40" }, { 0x1b80, 0xd3a8, "ASUS U3100MINI_PLUS_V2" }, { 0x1b80, 0xd3af, "SVEON STV27 DVB-T USB & FM" }, { 0x1b80, 0xd3b0, "SVEON STV21 DVB-T USB & FM" }, { 0x1d19, 0x1101, "Dexatek DK DVB-T Dongle (Logilink VG0002A)" }, { 0x1d19, 0x1102, "Dexatek DK DVB-T Dongle (MSI DigiVox mini II V3.0)" }, { 0x1d19, 0x1103, "Dexatek Technology Ltd. DK 5217 DVB-T Dongle" }, { 0x1d19, 0x1104, "MSI DigiVox Micro HD" }, { 0x1f4d, 0xa803, "Sweex DVB-T USB" }, { 0x1f4d, 0xb803, "GTek T803" }, { 0x1f4d, 0xc803, "Lifeview LV5TDeluxe" }, { 0x1f4d, 0xd286, "MyGica TD312" }, { 0x1f4d, 0xd803, "PROlectrix DV107669" }, }; #define DEFAULT_BUF_NUMBER 15 #define DEFAULT_BUF_LENGTH (16 * 32 * 512) #define DEF_RTL_XTAL_FREQ 28800000 #define MIN_RTL_XTAL_FREQ (DEF_RTL_XTAL_FREQ - 1000) #define MAX_RTL_XTAL_FREQ (DEF_RTL_XTAL_FREQ + 1000) #define CTRL_IN (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN) #define CTRL_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT) #define CTRL_TIMEOUT 300 #define BULK_TIMEOUT 0 #define EEPROM_ADDR 0xa0 enum usb_reg { USB_SYSCTL = 0x2000, USB_CTRL = 0x2010, USB_STAT = 0x2014, USB_EPA_CFG = 0x2144, USB_EPA_CTL = 0x2148, USB_EPA_MAXPKT = 0x2158, USB_EPA_MAXPKT_2 = 0x215a, USB_EPA_FIFO_CFG = 0x2160, }; enum sys_reg { DEMOD_CTL = 0x3000, GPO = 0x3001, GPI = 0x3002, GPOE = 0x3003, GPD = 0x3004, SYSINTE = 0x3005, SYSINTS = 0x3006, GP_CFG0 = 0x3007, GP_CFG1 = 0x3008, SYSINTE_1 = 0x3009, SYSINTS_1 = 0x300a, DEMOD_CTL_1 = 0x300b, IR_SUSPEND = 0x300c, }; enum blocks { DEMODB = 0, USBB = 1, SYSB = 2, TUNB = 3, ROMB = 4, IRB = 5, IICB = 6, }; int rtlsdr_read_array(rtlsdr_dev_t *dev, uint8_t block, uint16_t addr, uint8_t *array, uint8_t len) { int r; uint16_t index = (block << 8); r = libusb_control_transfer(dev->devh, CTRL_IN, 0, addr, index, array, len, CTRL_TIMEOUT); #if 0 if (r < 0) fprintf(stderr, "%s failed with %d\n", __FUNCTION__, r); #endif return r; } int rtlsdr_write_array(rtlsdr_dev_t *dev, uint8_t block, uint16_t addr, uint8_t *array, uint8_t len) { int r; uint16_t index = (block << 8) | 0x10; r = libusb_control_transfer(dev->devh, CTRL_OUT, 0, addr, index, array, len, CTRL_TIMEOUT); #if 0 if (r < 0) fprintf(stderr, "%s failed with %d\n", __FUNCTION__, r); #endif return r; } int rtlsdr_i2c_write_reg(rtlsdr_dev_t *dev, uint8_t i2c_addr, uint8_t reg, uint8_t val) { uint16_t addr = i2c_addr; uint8_t data[2]; data[0] = reg; data[1] = val; return rtlsdr_write_array(dev, IICB, addr, (uint8_t *)&data, 2); } uint8_t rtlsdr_i2c_read_reg(rtlsdr_dev_t *dev, uint8_t i2c_addr, uint8_t reg) { uint16_t addr = i2c_addr; uint8_t data = 0; rtlsdr_write_array(dev, IICB, addr, &reg, 1); rtlsdr_read_array(dev, IICB, addr, &data, 1); return data; } int rtlsdr_i2c_write(rtlsdr_dev_t *dev, uint8_t i2c_addr, uint8_t *buffer, int len) { uint16_t addr = i2c_addr; if (!dev) return -1; return rtlsdr_write_array(dev, IICB, addr, buffer, len); } int rtlsdr_i2c_read(rtlsdr_dev_t *dev, uint8_t i2c_addr, uint8_t *buffer, int len) { uint16_t addr = i2c_addr; if (!dev) return -1; return rtlsdr_read_array(dev, IICB, addr, buffer, len); } uint16_t rtlsdr_read_reg(rtlsdr_dev_t *dev, uint8_t block, uint16_t addr, uint8_t len) { int r; unsigned char data[2]; uint16_t index = (block << 8); uint16_t reg; r = libusb_control_transfer(dev->devh, CTRL_IN, 0, addr, index, data, len, CTRL_TIMEOUT); if (r < 0) fprintf(stderr, "%s failed with %d\n", __FUNCTION__, r); reg = (data[1] << 8) | data[0]; return reg; } int rtlsdr_write_reg(rtlsdr_dev_t *dev, uint8_t block, uint16_t addr, uint16_t val, uint8_t len) { int r; unsigned char data[2]; uint16_t index = (block << 8) | 0x10; if (len == 1) data[0] = val & 0xff; else data[0] = val >> 8; data[1] = val & 0xff; r = libusb_control_transfer(dev->devh, CTRL_OUT, 0, addr, index, data, len, CTRL_TIMEOUT); if (r < 0) fprintf(stderr, "%s failed with %d\n", __FUNCTION__, r); return r; } uint16_t rtlsdr_demod_read_reg(rtlsdr_dev_t *dev, uint8_t page, uint16_t addr, uint8_t len) { int r; unsigned char data[2]; uint16_t index = page; uint16_t reg; addr = (addr << 8) | 0x20; r = libusb_control_transfer(dev->devh, CTRL_IN, 0, addr, index, data, len, CTRL_TIMEOUT); if (r < 0) fprintf(stderr, "%s failed with %d\n", __FUNCTION__, r); reg = (data[1] << 8) | data[0]; return reg; } int rtlsdr_demod_write_reg(rtlsdr_dev_t *dev, uint8_t page, uint16_t addr, uint16_t val, uint8_t len) { int r; unsigned char data[2]; uint16_t index = 0x10 | page; addr = (addr << 8) | 0x20; if (len == 1) data[0] = val & 0xff; else data[0] = val >> 8; data[1] = val & 0xff; r = libusb_control_transfer(dev->devh, CTRL_OUT, 0, addr, index, data, len, CTRL_TIMEOUT); if (r < 0) fprintf(stderr, "%s failed with %d\n", __FUNCTION__, r); rtlsdr_demod_read_reg(dev, 0x0a, 0x01, 1); return (r == len) ? 0 : -1; } void rtlsdr_set_gpio_bit(rtlsdr_dev_t *dev, uint8_t gpio, int val) { uint16_t r; gpio = 1 << gpio; r = rtlsdr_read_reg(dev, SYSB, GPO, 1); r = val ? (r | gpio) : (r & ~gpio); rtlsdr_write_reg(dev, SYSB, GPO, r, 1); } void rtlsdr_set_gpio_output(rtlsdr_dev_t *dev, uint8_t gpio) { int r; gpio = 1 << gpio; r = rtlsdr_read_reg(dev, SYSB, GPD, 1); rtlsdr_write_reg(dev, SYSB, GPO, r & ~gpio, 1); r = rtlsdr_read_reg(dev, SYSB, GPOE, 1); rtlsdr_write_reg(dev, SYSB, GPOE, r | gpio, 1); } void rtlsdr_set_i2c_repeater(rtlsdr_dev_t *dev, int on) { if (on == dev->i2c_repeater_on) return; on = !!on; /* values +2 to force on */ dev->i2c_repeater_on = on; rtlsdr_demod_write_reg(dev, 1, 0x01, on ? 0x18 : 0x10, 1); } int rtlsdr_set_fir(rtlsdr_dev_t *dev) { uint8_t fir[20]; int i; /* format: int8_t[8] */ for (i = 0; i < 8; ++i) { const int val = dev->fir[i]; if (val < -128 || val > 127) { return -1; } fir[i] = val; } /* format: int12_t[8] */ for (i = 0; i < 8; i += 2) { const int val0 = dev->fir[8+i]; const int val1 = dev->fir[8+i+1]; if (val0 < -2048 || val0 > 2047 || val1 < -2048 || val1 > 2047) { return -1; } fir[8+i*3/2] = val0 >> 4; fir[8+i*3/2+1] = (val0 << 4) | ((val1 >> 8) & 0x0f); fir[8+i*3/2+2] = val1; } for (i = 0; i < (int)sizeof(fir); i++) { if (rtlsdr_demod_write_reg(dev, 1, 0x1c + i, fir[i], 1)) return -1; } return 0; } void rtlsdr_init_baseband(rtlsdr_dev_t *dev) { unsigned int i; /* initialize USB */ rtlsdr_write_reg(dev, USBB, USB_SYSCTL, 0x09, 1); rtlsdr_write_reg(dev, USBB, USB_EPA_MAXPKT, 0x0002, 2); rtlsdr_write_reg(dev, USBB, USB_EPA_CTL, 0x1002, 2); /* poweron demod */ rtlsdr_write_reg(dev, SYSB, DEMOD_CTL_1, 0x22, 1); rtlsdr_write_reg(dev, SYSB, DEMOD_CTL, 0xe8, 1); /* reset demod (bit 3, soft_rst) */ rtlsdr_demod_write_reg(dev, 1, 0x01, 0x14, 1); rtlsdr_demod_write_reg(dev, 1, 0x01, 0x10, 1); /* disable spectrum inversion and adjacent channel rejection */ rtlsdr_demod_write_reg(dev, 1, 0x15, 0x00, 1); rtlsdr_demod_write_reg(dev, 1, 0x16, 0x0000, 2); /* clear both DDC shift and IF frequency registers */ for (i = 0; i < 6; i++) rtlsdr_demod_write_reg(dev, 1, 0x16 + i, 0x00, 1); rtlsdr_set_fir(dev); /* enable SDR mode, disable DAGC (bit 5) */ rtlsdr_demod_write_reg(dev, 0, 0x19, 0x05, 1); /* init FSM state-holding register */ rtlsdr_demod_write_reg(dev, 1, 0x93, 0xf0, 1); rtlsdr_demod_write_reg(dev, 1, 0x94, 0x0f, 1); /* disable AGC (en_dagc, bit 0) (this seems to have no effect) */ rtlsdr_demod_write_reg(dev, 1, 0x11, 0x00, 1); /* disable RF and IF AGC loop */ rtlsdr_demod_write_reg(dev, 1, 0x04, 0x00, 1); /* disable PID filter (enable_PID = 0) */ rtlsdr_demod_write_reg(dev, 0, 0x61, 0x60, 1); /* opt_adc_iq = 0, default ADC_I/ADC_Q datapath */ rtlsdr_demod_write_reg(dev, 0, 0x06, 0x80, 1); /* Enable Zero-IF mode (en_bbin bit), DC cancellation (en_dc_est), * IQ estimation/compensation (en_iq_comp, en_iq_est) */ rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1b, 1); /* disable 4.096 MHz clock output on pin TP_CK0 */ rtlsdr_demod_write_reg(dev, 0, 0x0d, 0x83, 1); } int rtlsdr_deinit_baseband(rtlsdr_dev_t *dev) { int r = 0; if (!dev) return -1; rtlsdr_set_i2c_repeater(dev, 0); if (dev->tuner && dev->tuner->exit) { rtlsdr_set_i2c_repeater(dev, 1); r = dev->tuner->exit(dev); /* deinitialize tuner */ rtlsdr_set_i2c_repeater(dev, 0); dev->tuner_initialized = 0; } /* poweroff demodulator and ADCs */ rtlsdr_write_reg(dev, SYSB, DEMOD_CTL, 0x20, 1); return r; } int rtlsdr_set_if_freq(rtlsdr_dev_t *dev, uint32_t freq) { uint32_t rtl_xtal; int32_t if_freq; uint8_t tmp; int r; if (!dev) return -1; rtlsdr_set_i2c_repeater(dev, 0); /* read corrected clock value */ if (rtlsdr_get_xtal_freq(dev, &rtl_xtal, NULL)) return -2; if_freq = (int32_t)(((freq * TWO_POW(22)) / rtl_xtal) * -1); tmp = (if_freq >> 16) & 0x3f; r = rtlsdr_demod_write_reg(dev, 1, 0x19, tmp, 1); tmp = (if_freq >> 8) & 0xff; r |= rtlsdr_demod_write_reg(dev, 1, 0x1a, tmp, 1); tmp = if_freq & 0xff; r |= rtlsdr_demod_write_reg(dev, 1, 0x1b, tmp, 1); /* Tell the R820T driver which IF frequency we are currently using * so that it can choose the optimal IF filter settings. * Works for normal tuning as well as no-mod direct sampling! */ if(dev->tuner_initialized && dev->tuner && dev->tuner->set_if_freq) { rtlsdr_set_i2c_repeater(dev, 1); dev->tuner->set_if_freq(dev, freq); } return r; } int rtlsdr_set_sample_freq_correction(rtlsdr_dev_t *dev, int ppm) { int r = 0; uint8_t tmp; int16_t offs = (int16_t)(ppm * -1 * TWO_POW(24) / 1000000); rtlsdr_set_i2c_repeater(dev, 0); tmp = offs & 0xff; r |= rtlsdr_demod_write_reg(dev, 1, 0x3f, tmp, 1); tmp = (offs >> 8) & 0x3f; r |= rtlsdr_demod_write_reg(dev, 1, 0x3e, tmp, 1); return r; } int rtlsdr_set_xtal_freq(rtlsdr_dev_t *dev, uint32_t rtl_freq, uint32_t tuner_freq) { int r = 0; rtlsdr_set_i2c_repeater(dev, 0); if (!dev) return -1; if (rtl_freq > 0 && (rtl_freq < MIN_RTL_XTAL_FREQ || rtl_freq > MAX_RTL_XTAL_FREQ)) return -2; if (rtl_freq > 0 && dev->rtl_xtal != rtl_freq) { dev->rtl_xtal = rtl_freq; /* update xtal-dependent settings */ if (dev->rate) r = rtlsdr_set_sample_rate(dev, dev->rate); } if (dev->tun_xtal != tuner_freq) { if (0 == tuner_freq) dev->tun_xtal = dev->rtl_xtal; else dev->tun_xtal = tuner_freq; /* read corrected clock value into e4k and r82xx structure */ if (rtlsdr_get_xtal_freq(dev, NULL, &dev->e4k_s.vco.fosc) || rtlsdr_get_xtal_freq(dev, NULL, &dev->r82xx_c.xtal)) return -3; /* update xtal-dependent settings */ if (dev->freq) r = rtlsdr_set_center_freq(dev, dev->freq); } return r; } int rtlsdr_get_xtal_freq(rtlsdr_dev_t *dev, uint32_t *rtl_freq, uint32_t *tuner_freq) { if (!dev) return -1; #define APPLY_PPM_CORR(val,ppm) (((val) * (1.0 + (ppm) / 1e6))) if (rtl_freq) *rtl_freq = (uint32_t) APPLY_PPM_CORR(dev->rtl_xtal, dev->corr); if (tuner_freq) *tuner_freq = (uint32_t) APPLY_PPM_CORR(dev->tun_xtal, dev->corr); return 0; } int rtlsdr_get_usb_strings(rtlsdr_dev_t *dev, char *manufact, char *product, char *serial) { struct libusb_device_descriptor dd; libusb_device *device = NULL; const int buf_max = 256; int r = 0; if (!dev || !dev->devh) return -1; device = libusb_get_device(dev->devh); r = libusb_get_device_descriptor(device, &dd); if (r < 0) return -1; if (manufact) { memset(manufact, 0, buf_max); libusb_get_string_descriptor_ascii(dev->devh, dd.iManufacturer, (unsigned char *)manufact, buf_max); } if (product) { memset(product, 0, buf_max); libusb_get_string_descriptor_ascii(dev->devh, dd.iProduct, (unsigned char *)product, buf_max); } if (serial) { memset(serial, 0, buf_max); libusb_get_string_descriptor_ascii(dev->devh, dd.iSerialNumber, (unsigned char *)serial, buf_max); } return 0; } int rtlsdr_write_eeprom(rtlsdr_dev_t *dev, uint8_t *data, uint8_t offset, uint16_t len) { int r = 0; int i; uint8_t cmd[2]; rtlsdr_set_i2c_repeater(dev, 0); if (!dev) return -1; if ((len + offset) > 256) return -2; for (i = 0; i < len; i++) { cmd[0] = i + offset; r = rtlsdr_write_array(dev, IICB, EEPROM_ADDR, cmd, 1); r = rtlsdr_read_array(dev, IICB, EEPROM_ADDR, &cmd[1], 1); /* only write the byte if it differs */ if (cmd[1] == data[i]) continue; cmd[1] = data[i]; r = rtlsdr_write_array(dev, IICB, EEPROM_ADDR, cmd, 2); if (r != sizeof(cmd)) return -3; /* for some EEPROMs (e.g. ATC 240LC02) we need a delay * between write operations, otherwise they will fail */ #ifdef _WIN32 Sleep(5); #else usleep(5000); #endif } return 0; } int rtlsdr_read_eeprom(rtlsdr_dev_t *dev, uint8_t *data, uint8_t offset, uint16_t len) { int r = 0; int i; rtlsdr_set_i2c_repeater(dev, 0); if (!dev) return -1; if ((len + offset) > 256) return -2; r = rtlsdr_write_array(dev, IICB, EEPROM_ADDR, &offset, 1); if (r < 0) return -3; for (i = 0; i < len; i++) { r = rtlsdr_read_array(dev, IICB, EEPROM_ADDR, data + i, 1); if (r < 0) return -3; } return r; } int rtlsdr_set_center_freq(rtlsdr_dev_t *dev, uint32_t freq) { int r = -1; if (!dev || !dev->tuner) return -1; if (dev->direct_sampling) { rtlsdr_set_i2c_repeater(dev, 0); r = rtlsdr_set_if_freq(dev, freq); } else if (dev->tuner && dev->tuner->set_freq) { rtlsdr_set_i2c_repeater(dev, 1); r = dev->tuner->set_freq(dev, freq - dev->offs_freq); } if (!r) dev->freq = freq; else dev->freq = 0; return r; } uint32_t rtlsdr_get_center_freq(rtlsdr_dev_t *dev) { if (!dev) return 0; return dev->freq; } int rtlsdr_set_freq_correction(rtlsdr_dev_t *dev, int ppm) { int r = 0; rtlsdr_set_i2c_repeater(dev, 0); if (!dev) return -1; if (dev->corr == ppm) return -2; dev->corr = ppm; r |= rtlsdr_set_sample_freq_correction(dev, ppm); /* read corrected clock value into e4k and r82xx structure */ if (rtlsdr_get_xtal_freq(dev, NULL, &dev->e4k_s.vco.fosc) || rtlsdr_get_xtal_freq(dev, NULL, &dev->r82xx_c.xtal)) return -3; if (dev->freq) /* retune to apply new correction value */ r |= rtlsdr_set_center_freq(dev, dev->freq); return r; } int rtlsdr_get_freq_correction(rtlsdr_dev_t *dev) { if (!dev) return 0; return dev->corr; } enum rtlsdr_tuner rtlsdr_get_tuner_type(rtlsdr_dev_t *dev) { if (!dev) return RTLSDR_TUNER_UNKNOWN; return dev->tuner_type; } int rtlsdr_get_tuner_gains(rtlsdr_dev_t *dev, int *gains) { /* all gain values are expressed in tenths of a dB */ const int e4k_gains[] = { -10, 15, 40, 65, 90, 115, 140, 165, 190, 215, 240, 290, 340, 420 }; const int fc0012_gains[] = { -99, -40, 71, 179, 192 }; const int fc0013_gains[] = { -99, -73, -65, -63, -60, -58, -54, 58, 61, 63, 65, 67, 68, 70, 71, 179, 181, 182, 184, 186, 188, 191, 197 }; const int fc2580_gains[] = { 0 /* no gain values */ }; const int r82xx_gains[] = { 0, 9, 14, 27, 37, 77, 87, 125, 144, 157, 166, 197, 207, 229, 254, 280, 297, 328, 338, 364, 372, 386, 402, 421, 434, 439, 445, 480, 496 }; const int unknown_gains[] = { 0 /* no gain values */ }; const int *ptr = NULL; int len = 0; if (!dev) return -1; switch (dev->tuner_type) { case RTLSDR_TUNER_E4000: ptr = e4k_gains; len = sizeof(e4k_gains); break; case RTLSDR_TUNER_FC0012: ptr = fc0012_gains; len = sizeof(fc0012_gains); break; case RTLSDR_TUNER_FC0013: ptr = fc0013_gains; len = sizeof(fc0013_gains); break; case RTLSDR_TUNER_FC2580: ptr = fc2580_gains; len = sizeof(fc2580_gains); break; case RTLSDR_TUNER_R820T: case RTLSDR_TUNER_R828D: ptr = r82xx_gains; len = sizeof(r82xx_gains); break; default: ptr = unknown_gains; len = sizeof(unknown_gains); break; } if (!gains) { /* no buffer provided, just return the count */ return len / sizeof(int); } else { if (len) memcpy(gains, ptr, len); return len / sizeof(int); } } int rtlsdr_set_tuner_gain(rtlsdr_dev_t *dev, int gain) { int r = 0; if (!dev || !dev->tuner) return -1; if (dev->tuner->set_gain) { rtlsdr_set_i2c_repeater(dev, 1); r = dev->tuner->set_gain((void *)dev, gain); } if (!r) dev->gain = gain; else dev->gain = 0; return r; } int rtlsdr_get_tuner_gain(rtlsdr_dev_t *dev) { if (!dev) return 0; return dev->gain; } int rtlsdr_set_tuner_if_gain(rtlsdr_dev_t *dev, int stage, int gain) { int r = 0; if (!dev || !dev->tuner) return -1; if (dev->tuner->set_if_gain) { rtlsdr_set_i2c_repeater(dev, 1); r = dev->tuner->set_if_gain(dev, stage, gain); } return r; } int rtlsdr_set_tuner_gain_mode(rtlsdr_dev_t *dev, int mode) { int r = 0; if (!dev || !dev->tuner) return -1; if (dev->tuner->set_gain_mode) { rtlsdr_set_i2c_repeater(dev, 1); r = dev->tuner->set_gain_mode((void *)dev, mode); } return r; } int rtlsdr_set_sample_rate(rtlsdr_dev_t *dev, uint32_t samp_rate) { int r = 0; uint16_t tmp; uint32_t rsamp_ratio, real_rsamp_ratio; double real_rate; if (!dev) return -1; rtlsdr_set_i2c_repeater(dev, 0); /* check if the rate is supported by the resampler */ if ((samp_rate <= 225000) || (samp_rate > 3200000) || ((samp_rate > 300000) && (samp_rate <= 900000))) { fprintf(stderr, "Invalid sample rate: %u Hz\n", samp_rate); return -EINVAL; } rsamp_ratio = (uint32_t)((dev->rtl_xtal * TWO_POW(22)) / samp_rate); rsamp_ratio &= 0x0ffffffc; real_rsamp_ratio = rsamp_ratio | ((rsamp_ratio & 0x08000000) << 1); real_rate = (dev->rtl_xtal * TWO_POW(22)) / real_rsamp_ratio; if ( ((double)samp_rate) != real_rate ) fprintf(stderr, "Exact sample rate is: %f Hz\n", real_rate); if (dev->tuner && dev->tuner->set_bw) { rtlsdr_set_i2c_repeater(dev, 1); dev->tuner->set_bw(dev, (int)real_rate); rtlsdr_set_i2c_repeater(dev, 0); } dev->rate = (uint32_t)real_rate; tmp = (rsamp_ratio >> 16); r |= rtlsdr_demod_write_reg(dev, 1, 0x9f, tmp, 2); tmp = rsamp_ratio & 0xffff; r |= rtlsdr_demod_write_reg(dev, 1, 0xa1, tmp, 2); r |= rtlsdr_set_sample_freq_correction(dev, dev->corr); /* reset demod (bit 3, soft_rst) */ r |= rtlsdr_demod_write_reg(dev, 1, 0x01, 0x14, 1); r |= rtlsdr_demod_write_reg(dev, 1, 0x01, 0x10, 1); /* recalculate offset frequency if offset tuning is enabled */ if (dev->offs_freq) rtlsdr_set_offset_tuning(dev, 1); return r; } uint32_t rtlsdr_get_sample_rate(rtlsdr_dev_t *dev) { if (!dev) return 0; return dev->rate; } int rtlsdr_set_testmode(rtlsdr_dev_t *dev, int on) { if (!dev) return -1; rtlsdr_set_i2c_repeater(dev, 0); return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x03 : 0x05, 1); } int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on) { if (!dev) return -1; rtlsdr_set_i2c_repeater(dev, 0); return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x25 : 0x05, 1); } int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on) { int r = 0; if (!dev) return -1; /* set up normal direct sampling */ if (on == 1 || on == 2) { if (dev->tuner && dev->tuner->exit) { rtlsdr_set_i2c_repeater(dev, 1); r = dev->tuner->exit(dev); rtlsdr_set_i2c_repeater(dev, 0); dev->tuner_initialized = 0; } } /* set up no-mod direct sampling */ if (on == 3 && dev->tuner) { if (dev->tuner_type == RTLSDR_TUNER_E4000) { fprintf(stderr, "Tuning E4000 to 3708 MHz\n"); rtlsdr_set_i2c_repeater(dev, 1); dev->tuner->init(dev); dev->tuner_initialized = 1; dev->tuner->set_freq(dev, 3708000000u); e4000_set_bw(dev, 15000000); rtlsdr_set_i2c_repeater(dev, 0); } if (dev->tuner_type == RTLSDR_TUNER_R820T) { rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev; rtlsdr_set_i2c_repeater(dev, 1); dev->tuner->init(dev); dev->tuner_initialized = 1; r82xx_set_nomod(&devt->r82xx_p); rtlsdr_set_i2c_repeater(dev, 0); } } rtlsdr_set_i2c_repeater(dev, 0); /* common to all direct modes */ if (on) { /* disable Zero-IF mode */ r |= rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1a, 1); /* disable spectrum inversion */ r |= rtlsdr_demod_write_reg(dev, 1, 0x15, 0x00, 1); /* only enable In-phase ADC input */ r |= rtlsdr_demod_write_reg(dev, 0, 0x08, 0x4d, 1); /* swap I and Q ADC, this allows to select between two inputs */ r |= rtlsdr_demod_write_reg(dev, 0, 0x06, (on == 2) ? 0x90 : 0x80, 1); fprintf(stderr, "Enabled direct sampling mode, input %i\n", on); dev->direct_sampling = on; } /* disable direct sampling */ if (!on) { if (dev->tuner && dev->tuner->init) { rtlsdr_set_i2c_repeater(dev, 1); r |= dev->tuner->init(dev); rtlsdr_set_i2c_repeater(dev, 0); dev->tuner_initialized = 1; } if ((dev->tuner_type == RTLSDR_TUNER_R820T) || (dev->tuner_type == RTLSDR_TUNER_R828D)) { r |= rtlsdr_set_if_freq(dev, R82XX_DEFAULT_IF_FREQ); /* enable spectrum inversion */ r |= rtlsdr_demod_write_reg(dev, 1, 0x15, 0x01, 1); } else { r |= rtlsdr_set_if_freq(dev, 0); /* enable In-phase + Quadrature ADC input */ r |= rtlsdr_demod_write_reg(dev, 0, 0x08, 0xcd, 1); /* Enable Zero-IF mode */ r |= rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1b, 1); } /* opt_adc_iq = 0, default ADC_I/ADC_Q datapath */ r |= rtlsdr_demod_write_reg(dev, 0, 0x06, 0x80, 1); fprintf(stderr, "Disabled direct sampling mode\n"); dev->direct_sampling = 0; } r |= rtlsdr_set_center_freq(dev, dev->freq); return r; } int rtlsdr_get_direct_sampling(rtlsdr_dev_t *dev) { if (!dev) return -1; return dev->direct_sampling; } int rtlsdr_set_offset_tuning(rtlsdr_dev_t *dev, int on) { int r = 0; rtlsdr_set_i2c_repeater(dev, 0); if (!dev) return -1; if ((dev->tuner_type == RTLSDR_TUNER_R820T) || (dev->tuner_type == RTLSDR_TUNER_R828D)) return -2; if (dev->direct_sampling) return -3; /* based on keenerds 1/f noise measurements */ dev->offs_freq = on ? ((dev->rate / 2) * 170 / 100) : 0; r |= rtlsdr_set_if_freq(dev, dev->offs_freq); if (dev->tuner && dev->tuner->set_bw) { rtlsdr_set_i2c_repeater(dev, 1); dev->tuner->set_bw(dev, on ? (2 * dev->offs_freq) : dev->rate); rtlsdr_set_i2c_repeater(dev, 0); } if (dev->freq > dev->offs_freq) r |= rtlsdr_set_center_freq(dev, dev->freq); return r; } int rtlsdr_get_offset_tuning(rtlsdr_dev_t *dev) { if (!dev) return -1; return (dev->offs_freq) ? 1 : 0; } int rtlsdr_set_dithering(rtlsdr_dev_t *dev, int dither) { if (dev->tuner_type == RTLSDR_TUNER_R820T) { return r82xx_set_dither(&dev->r82xx_p, dither); } return 1; } static rtlsdr_dongle_t *find_known_device(uint16_t vid, uint16_t pid) { unsigned int i; rtlsdr_dongle_t *device = NULL; for (i = 0; i < sizeof(known_devices)/sizeof(rtlsdr_dongle_t); i++ ) { if (known_devices[i].vid == vid && known_devices[i].pid == pid) { device = &known_devices[i]; break; } } return device; } uint32_t rtlsdr_get_device_count(void) { int i; libusb_context *ctx; libusb_device **list; uint32_t device_count = 0; struct libusb_device_descriptor dd; ssize_t cnt; libusb_init(&ctx); cnt = libusb_get_device_list(ctx, &list); for (i = 0; i < cnt; i++) { libusb_get_device_descriptor(list[i], &dd); if (find_known_device(dd.idVendor, dd.idProduct)) device_count++; } libusb_free_device_list(list, 1); libusb_exit(ctx); return device_count; } const char *rtlsdr_get_device_name(uint32_t index) { int i; libusb_context *ctx; libusb_device **list; struct libusb_device_descriptor dd; rtlsdr_dongle_t *device = NULL; uint32_t device_count = 0; ssize_t cnt; libusb_init(&ctx); cnt = libusb_get_device_list(ctx, &list); for (i = 0; i < cnt; i++) { libusb_get_device_descriptor(list[i], &dd); device = find_known_device(dd.idVendor, dd.idProduct); if (device) { device_count++; if (index == device_count - 1) break; } } libusb_free_device_list(list, 1); libusb_exit(ctx); if (device) return device->name; else return ""; } int rtlsdr_get_device_usb_strings(uint32_t index, char *manufact, char *product, char *serial) { int r = -2; int i; libusb_context *ctx; libusb_device **list; struct libusb_device_descriptor dd; rtlsdr_dongle_t *device = NULL; rtlsdr_dev_t devt; uint32_t device_count = 0; ssize_t cnt; libusb_init(&ctx); cnt = libusb_get_device_list(ctx, &list); for (i = 0; i < cnt; i++) { libusb_get_device_descriptor(list[i], &dd); device = find_known_device(dd.idVendor, dd.idProduct); if (device) { device_count++; if (index == device_count - 1) { r = libusb_open(list[i], &devt.devh); if (!r) { r = rtlsdr_get_usb_strings(&devt, manufact, product, serial); libusb_close(devt.devh); } break; } } } libusb_free_device_list(list, 1); libusb_exit(ctx); return r; } int rtlsdr_get_index_by_serial(const char *serial) { int i, cnt, r; char str[256]; if (!serial) return -1; cnt = rtlsdr_get_device_count(); if (!cnt) return -2; for (i = 0; i < cnt; i++) { r = rtlsdr_get_device_usb_strings(i, NULL, NULL, str); if (!r && !strcmp(serial, str)) return i; } return -3; } int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index) { int r; int i; libusb_device **list; rtlsdr_dev_t *dev = NULL; libusb_device *device = NULL; uint32_t device_count = 0; struct libusb_device_descriptor dd; uint8_t reg; ssize_t cnt; dev = malloc(sizeof(rtlsdr_dev_t)); if (NULL == dev) return -ENOMEM; memset(dev, 0, sizeof(rtlsdr_dev_t)); memcpy(dev->fir, fir_default, sizeof(fir_default)); libusb_init(&dev->ctx); dev->dev_lost = 1; cnt = libusb_get_device_list(dev->ctx, &list); for (i = 0; i < cnt; i++) { device = list[i]; libusb_get_device_descriptor(list[i], &dd); if (find_known_device(dd.idVendor, dd.idProduct)) { device_count++; } if (index == device_count - 1) break; device = NULL; } if (!device) { r = -1; goto err; } r = libusb_open(device, &dev->devh); if (r < 0) { libusb_free_device_list(list, 1); fprintf(stderr, "usb_open error %d\n", r); if(r == LIBUSB_ERROR_ACCESS) fprintf(stderr, "Please fix the device permissions, e.g. " "by installing the udev rules file rtl-sdr.rules\n"); goto err; } libusb_free_device_list(list, 1); if (libusb_kernel_driver_active(dev->devh, 0) == 1) { dev->driver_active = 1; #ifdef DETACH_KERNEL_DRIVER if (!libusb_detach_kernel_driver(dev->devh, 0)) { fprintf(stderr, "Detached kernel driver\n"); } else { fprintf(stderr, "Detaching kernel driver failed!"); goto err; } #else fprintf(stderr, "\nKernel driver is active, or device is " "claimed by second instance of librtlsdr." "\nIn the first case, please either detach" " or blacklist the kernel module\n" "(dvb_usb_rtl28xxu), or enable automatic" " detaching at compile time.\n\n"); #endif } r = libusb_claim_interface(dev->devh, 0); if (r < 0) { fprintf(stderr, "usb_claim_interface error %d\n", r); goto err; } dev->rtl_xtal = DEF_RTL_XTAL_FREQ; /* perform a dummy write, if it fails, reset the device */ if (rtlsdr_write_reg(dev, USBB, USB_SYSCTL, 0x09, 1) < 0) { fprintf(stderr, "Resetting device...\n"); libusb_reset_device(dev->devh); } rtlsdr_init_baseband(dev); dev->dev_lost = 0; /* Probe tuners */ rtlsdr_set_i2c_repeater(dev, 1); reg = rtlsdr_i2c_read_reg(dev, E4K_I2C_ADDR, E4K_CHECK_ADDR); if (reg == E4K_CHECK_VAL) { fprintf(stderr, "Found Elonics E4000 tuner\n"); dev->tuner_type = RTLSDR_TUNER_E4000; goto found; } reg = rtlsdr_i2c_read_reg(dev, FC0013_I2C_ADDR, FC0013_CHECK_ADDR); if (reg == FC0013_CHECK_VAL) { fprintf(stderr, "Found Fitipower FC0013 tuner\n"); dev->tuner_type = RTLSDR_TUNER_FC0013; goto found; } reg = rtlsdr_i2c_read_reg(dev, R820T_I2C_ADDR, R82XX_CHECK_ADDR); if (reg == R82XX_CHECK_VAL) { fprintf(stderr, "Found Rafael Micro R820T tuner\n"); dev->tuner_type = RTLSDR_TUNER_R820T; goto found; } reg = rtlsdr_i2c_read_reg(dev, R828D_I2C_ADDR, R82XX_CHECK_ADDR); if (reg == R82XX_CHECK_VAL) { fprintf(stderr, "Found Rafael Micro R828D tuner\n"); dev->tuner_type = RTLSDR_TUNER_R828D; goto found; } /* initialise GPIOs */ rtlsdr_set_gpio_output(dev, 5); /* reset tuner before probing */ rtlsdr_set_gpio_bit(dev, 5, 1); rtlsdr_set_gpio_bit(dev, 5, 0); reg = rtlsdr_i2c_read_reg(dev, FC2580_I2C_ADDR, FC2580_CHECK_ADDR); if ((reg & 0x7f) == FC2580_CHECK_VAL) { fprintf(stderr, "Found FCI 2580 tuner\n"); dev->tuner_type = RTLSDR_TUNER_FC2580; goto found; } reg = rtlsdr_i2c_read_reg(dev, FC0012_I2C_ADDR, FC0012_CHECK_ADDR); if (reg == FC0012_CHECK_VAL) { fprintf(stderr, "Found Fitipower FC0012 tuner\n"); rtlsdr_set_gpio_output(dev, 6); dev->tuner_type = RTLSDR_TUNER_FC0012; goto found; } found: /* use the rtl clock value by default */ dev->tun_xtal = dev->rtl_xtal; dev->tuner = &tuners[dev->tuner_type]; switch (dev->tuner_type) { case RTLSDR_TUNER_R828D: dev->tun_xtal = R828D_XTAL_FREQ; case RTLSDR_TUNER_R820T: /* disable Zero-IF mode */ rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1a, 1); /* only enable In-phase ADC input */ rtlsdr_demod_write_reg(dev, 0, 0x08, 0x4d, 1); /* the R82XX use 3.57 MHz IF for the DVB-T 6 MHz mode, and * 4.57 MHz for the 8 MHz mode */ rtlsdr_set_if_freq(dev, R82XX_DEFAULT_IF_FREQ); /* enable spectrum inversion */ rtlsdr_demod_write_reg(dev, 1, 0x15, 0x01, 1); break; case RTLSDR_TUNER_UNKNOWN: fprintf(stderr, "No supported tuner found\n"); rtlsdr_set_direct_sampling(dev, 1); break; default: break; } if (dev->tuner->init) { rtlsdr_set_i2c_repeater(dev, 1); r = dev->tuner->init(dev); dev->tuner_initialized = 1; } rtlsdr_set_i2c_repeater(dev, 0); *out_dev = dev; return 0; err: if (dev) { if (dev->ctx) libusb_exit(dev->ctx); free(dev); } return r; } int rtlsdr_close(rtlsdr_dev_t *dev) { if (!dev) return -1; rtlsdr_set_i2c_repeater(dev, 0); if(!dev->dev_lost) { /* block until all async operations have been completed (if any) */ while (RTLSDR_INACTIVE != dev->async_status) { #ifdef _WIN32 Sleep(1); #else usleep(1000); #endif } rtlsdr_deinit_baseband(dev); } libusb_release_interface(dev->devh, 0); #ifdef DETACH_KERNEL_DRIVER if (dev->driver_active) { if (!libusb_attach_kernel_driver(dev->devh, 0)) fprintf(stderr, "Reattached kernel driver\n"); else fprintf(stderr, "Reattaching kernel driver failed!\n"); } #endif libusb_close(dev->devh); libusb_exit(dev->ctx); free(dev); return 0; } int rtlsdr_reset_buffer(rtlsdr_dev_t *dev) { if (!dev) return -1; rtlsdr_set_i2c_repeater(dev, 0); rtlsdr_write_reg(dev, USBB, USB_EPA_CTL, 0x1002, 2); rtlsdr_write_reg(dev, USBB, USB_EPA_CTL, 0x0000, 2); return 0; } int rtlsdr_read_sync(rtlsdr_dev_t *dev, void *buf, int len, int *n_read) { if (!dev) return -1; return libusb_bulk_transfer(dev->devh, 0x81, buf, len, n_read, BULK_TIMEOUT); } static void LIBUSB_CALL _libusb_callback(struct libusb_transfer *xfer) { rtlsdr_dev_t *dev = (rtlsdr_dev_t *)xfer->user_data; if (LIBUSB_TRANSFER_COMPLETED == xfer->status) { if (dev->cb) dev->cb(xfer->buffer, xfer->actual_length, dev->cb_ctx); libusb_submit_transfer(xfer); /* resubmit transfer */ dev->xfer_errors = 0; } else if (LIBUSB_TRANSFER_CANCELLED != xfer->status) { #ifndef _WIN32 if (LIBUSB_TRANSFER_ERROR == xfer->status) dev->xfer_errors++; if (dev->xfer_errors >= dev->xfer_buf_num || LIBUSB_TRANSFER_NO_DEVICE == xfer->status) { #endif dev->dev_lost = 1; rtlsdr_cancel_async(dev); fprintf(stderr, "cb transfer status: %d, " "canceling...\n", xfer->status); #ifndef _WIN32 } #endif } } int rtlsdr_wait_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx) { return rtlsdr_read_async(dev, cb, ctx, 0, 0); } static int _rtlsdr_alloc_async_buffers(rtlsdr_dev_t *dev) { unsigned int i; if (!dev) return -1; if (!dev->xfer) { dev->xfer = malloc(dev->xfer_buf_num * sizeof(struct libusb_transfer *)); for(i = 0; i < dev->xfer_buf_num; ++i) dev->xfer[i] = libusb_alloc_transfer(0); } if (!dev->xfer_buf) { dev->xfer_buf = malloc(dev->xfer_buf_num * sizeof(unsigned char *)); for(i = 0; i < dev->xfer_buf_num; ++i) dev->xfer_buf[i] = malloc(dev->xfer_buf_len); } return 0; } static int _rtlsdr_free_async_buffers(rtlsdr_dev_t *dev) { unsigned int i; if (!dev) return -1; if (dev->xfer) { for(i = 0; i < dev->xfer_buf_num; ++i) { if (dev->xfer[i]) { libusb_free_transfer(dev->xfer[i]); } } free(dev->xfer); dev->xfer = NULL; } if (dev->xfer_buf) { for(i = 0; i < dev->xfer_buf_num; ++i) { if (dev->xfer_buf[i]) free(dev->xfer_buf[i]); } free(dev->xfer_buf); dev->xfer_buf = NULL; } return 0; } int rtlsdr_read_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx, uint32_t buf_num, uint32_t buf_len) { unsigned int i; int r = 0; struct timeval tv = { 1, 0 }; struct timeval zerotv = { 0, 0 }; enum rtlsdr_async_status next_status = RTLSDR_INACTIVE; if (!dev) return -1; if (RTLSDR_INACTIVE != dev->async_status) return -2; dev->async_status = RTLSDR_RUNNING; dev->async_cancel = 0; dev->cb = cb; dev->cb_ctx = ctx; if (buf_num > 0) dev->xfer_buf_num = buf_num; else dev->xfer_buf_num = DEFAULT_BUF_NUMBER; if (buf_len > 0 && buf_len % 512 == 0) /* len must be multiple of 512 */ dev->xfer_buf_len = buf_len; else dev->xfer_buf_len = DEFAULT_BUF_LENGTH; _rtlsdr_alloc_async_buffers(dev); for(i = 0; i < dev->xfer_buf_num; ++i) { libusb_fill_bulk_transfer(dev->xfer[i], dev->devh, 0x81, dev->xfer_buf[i], dev->xfer_buf_len, _libusb_callback, (void *)dev, BULK_TIMEOUT); r = libusb_submit_transfer(dev->xfer[i]); if (r < 0) { fprintf(stderr, "Failed to submit transfer %u!\n", i); dev->async_status = RTLSDR_CANCELING; break; } } while (RTLSDR_INACTIVE != dev->async_status) { r = libusb_handle_events_timeout_completed(dev->ctx, &tv, &dev->async_cancel); if (r < 0) { /*fprintf(stderr, "handle_events returned: %d\n", r);*/ if (r == LIBUSB_ERROR_INTERRUPTED) /* stray signal */ continue; break; } if (RTLSDR_CANCELING == dev->async_status) { next_status = RTLSDR_INACTIVE; if (!dev->xfer) break; for(i = 0; i < dev->xfer_buf_num; ++i) { if (!dev->xfer[i]) continue; if (LIBUSB_TRANSFER_CANCELLED != dev->xfer[i]->status) { r = libusb_cancel_transfer(dev->xfer[i]); /* handle events after canceling * to allow transfer status to * propagate */ libusb_handle_events_timeout_completed(dev->ctx, &zerotv, NULL); if (r < 0) continue; next_status = RTLSDR_CANCELING; } } if (dev->dev_lost || RTLSDR_INACTIVE == next_status) { /* handle any events that still need to * be handled before exiting after we * just cancelled all transfers */ libusb_handle_events_timeout_completed(dev->ctx, &zerotv, NULL); break; } } } _rtlsdr_free_async_buffers(dev); dev->async_status = next_status; return r; } int rtlsdr_cancel_async(rtlsdr_dev_t *dev) { if (!dev) return -1; /* if streaming, try to cancel gracefully */ if (RTLSDR_RUNNING == dev->async_status) { dev->async_status = RTLSDR_CANCELING; dev->async_cancel = 1; return 0; } /* if called while in pending state, change the state forcefully */ #if 0 if (RTLSDR_INACTIVE != dev->async_status) { dev->async_status = RTLSDR_INACTIVE; return 0; } #endif return -2; } uint32_t rtlsdr_get_tuner_clock(void *dev) { uint32_t tuner_freq; if (!dev) return 0; /* read corrected clock value */ if (rtlsdr_get_xtal_freq((rtlsdr_dev_t *)dev, NULL, &tuner_freq)) return 0; return tuner_freq; } int rtlsdr_i2c_write_fn(void *dev, uint8_t addr, uint8_t *buf, int len) { int r; int retries = 2; if (!dev) return -1; do { r = rtlsdr_i2c_write(((rtlsdr_dev_t *)dev), addr, buf, len); if (r >= 0) return r; rtlsdr_set_i2c_repeater(dev, 2); retries--; } while (retries > 0); return -1; } int rtlsdr_i2c_read_fn(void *dev, uint8_t addr, uint8_t *buf, int len) { int r; int retries = 2; if (!dev) return -1; do { r = rtlsdr_i2c_read(((rtlsdr_dev_t *)dev), addr, buf, len); if (r >= 0) return r; rtlsdr_set_i2c_repeater(dev, 2); retries--; } while (retries > 0); return -1; }
4c3a18cc472cdabc3c1576fbc8abe69a2cf770a3
3225f903ab65e9e242f250a02b3b74fc7e34b098
/firmware/uip/rtimer-arch.h
fd4cf255fc9c55ff117fb9194d12aeb1914e28a7
[ "MIT", "BSD-2-Clause" ]
permissive
timvideos/litex-buildenv
6f7657a0d2836f66bbc8ad29f89f1f975eda7832
fafb0f1c645a0d36ff4947686b4d2d8e3433f686
refs/heads/master
2022-06-04T18:02:22.567089
2022-05-21T15:21:25
2022-05-21T15:21:25
115,785,208
217
88
BSD-2-Clause
2022-05-21T15:21:26
2017-12-30T08:50:22
Python
UTF-8
C
false
false
288
h
rtimer-arch.h
#ifndef RTIMER_ARCH_H_ #define RTIMER_ARCH_H_ #include "contiki-conf.h" #include <stdint.h> void rtimer_callback(void); void rtimer_arch_init(void); rtimer_clock_t rtimer_arch_now(void); void rtimer_arch_schedule(rtimer_clock_t t); #define RTIMER_ARCH_SECOND 312500 #endif /** @} */
328bd26af564158a9659f906961f453fcbc63c95
b49bb32eafeea931b86ddfc44ef43c01e81a9128
/CoreFoundation/Locale.subproj/CFICULogging.h
d521debf79320128d7816f004367d498b457da7e
[ "Apache-2.0", "Swift-exception" ]
permissive
apple/swift-corelibs-foundation
a70e9d95bc69de33ea26343efde3941c5d4d7c85
9f53cc551e065d73b327a80147895822bc8f89e0
refs/heads/main
2023-08-18T01:25:02.154068
2023-08-11T20:54:56
2023-08-11T20:54:56
45,863,890
5,583
1,542
Apache-2.0
2023-09-12T00:47:36
2015-11-09T20:12:23
Swift
UTF-8
C
false
false
4,718
h
CFICULogging.h
/* CFICULogging.h Copyright (c) 2008-2019, Apple Inc. and the Swift project authors Portions Copyright (c) 2014-2019, Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See http://swift.org/LICENSE.txt for license information See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors */ /* This file is for the use of the CoreFoundation project only. */ #if !defined(__COREFOUNDATION_CFICULOGGING__) #define __COREFOUNDATION_CFICULOGGING__ 1 #include <unicode/ucal.h> #include <unicode/udatpg.h> #include <unicode/udat.h> #include <unicode/unum.h> #include <unicode/ulistformatter.h> #include <unicode/ucurr.h> #include <unicode/ustring.h> #if __has_include(<unicode/ureldatefmt.h>) #include <unicode/ureldatefmt.h> #endif #if !DEPLOYMENT_RUNTIME_SWIFT && __has_include(<os/log.h>) #include <os/log.h> #endif // ucal // ucal #define __cficu_ucal_open ucal_open #define __cficu_ucal_close ucal_close #define __cficu_ucal_clone ucal_clone #define __cficu_ucal_setAttribute ucal_setAttribute #define __cficu_ucal_getAttribute ucal_getAttribute #define __cficu_ucal_setGregorianChange ucal_setGregorianChange #define __cficu_ucal_getGregorianChange ucal_getGregorianChange #define __cficu_ucal_getMillis ucal_getMillis #define __cficu_ucal_setMillis ucal_setMillis #define __cficu_ucal_set ucal_set #define __cficu_ucal_get ucal_get #define __cficu_ucal_getDayOfWeekType ucal_getDayOfWeekType #define __cficu_ucal_getWeekendTransition ucal_getWeekendTransition #define __cficu_ucal_isWeekend ucal_isWeekend #define __cficu_ucal_clear ucal_clear #define __cficu_ucal_getLimit ucal_getLimit #define __cficu_ucal_add ucal_add #define __cficu_ucal_roll ucal_roll #define __cficu_ucal_getFieldDifference ucal_getFieldDifference #define __cficu_ucal_getNow ucal_getNow #define __cficu_ucal_setTimeZone ucal_setTimeZone // udatpg #define __cficu_udatpg_open udatpg_open #define __cficu_udatpg_close udatpg_close #define __cficu_udatpg_getSkeleton udatpg_getSkeleton #define __cficu_udatpg_getBestPattern udatpg_getBestPattern // udat #define __cficu_udat_applyPattern udat_applyPattern #define __cficu_udat_applyPatternRelative udat_applyPatternRelative #define __cficu_udat_clone udat_clone #define __cficu_udat_close udat_close #define __cficu_udat_countSymbols udat_countSymbols #define __cficu_udat_format udat_format #define __cficu_udat_formatForFields udat_formatForFields #define __cficu_udat_get2DigitYearStart udat_get2DigitYearStart #define __cficu_udat_getCalendar udat_getCalendar #define __cficu_udat_getSymbols udat_getSymbols #define __cficu_udat_isLenient udat_isLenient #define __cficu_udat_open udat_open #define __cficu_udat_parseCalendar udat_parseCalendar #define __cficu_udat_set2DigitYearStart udat_set2DigitYearStart #define __cficu_udat_setCalendar udat_setCalendar #define __cficu_udat_setLenient udat_setLenient #define __cficu_udat_setSymbols udat_setSymbols #define __cficu_udat_toPattern udat_toPattern #define __cficu_udat_toPatternRelativeDate udat_toPatternRelativeDate #define __cficu_udat_toPatternRelativeTime udat_toPatternRelativeTime #define __cficu_unum_applyPattern unum_applyPattern #define __cficu_unum_close unum_close #define __cficu_unum_formatDecimal unum_formatDecimal #define __cficu_unum_formatDouble unum_formatDouble #define __cficu_unum_getAttribute unum_getAttribute #define __cficu_unum_getDoubleAttribute unum_getDoubleAttribute #define __cficu_unum_getSymbol unum_getSymbol #define __cficu_unum_getTextAttribute unum_getTextAttribute #define __cficu_unum_open unum_open #define __cficu_unum_parse unum_parse #define __cficu_unum_parseDecimal unum_parseDecimal #define __cficu_unum_setAttribute unum_setAttribute #define __cficu_unum_setDoubleAttribute unum_setDoubleAttribute #define __cficu_unum_setSymbol unum_setSymbol #define __cficu_unum_setTextAttribute unum_setTextAttribute #define __cficu_unum_toPattern unum_toPattern #define __cficu_udat_setContext udat_setContext #define __cficu_udat_getContext udat_getContext // ucurr #define __cficu_ucurr_getDefaultFractionDigits ucurr_getDefaultFractionDigits #define __cficu_ucurr_getRoundingIncrement ucurr_getRoundingIncrement // unum #define __cficu_unum_setContext unum_setContext #define __cficu_unum_getContext unum_getContext // ureldatefmt #define __cficu_ureldatefmt_open ureldatefmt_open #define __cficu_ureldatefmt_formatNumeric ureldatefmt_formatNumeric #define __cficu_ureldatefmt_format ureldatefmt_format #define __cficu_ureldatefmt_close ureldatefmt_close // ulistfmt #define __cficu_ulistfmt_open ulistfmt_open #define __cficu_ulistfmt_close ulistfmt_close #define __cficu_ulistfmt_format ulistfmt_format #endif
66ae7ac7fe6d534a7008d94bf53dfcfe3d4ee0d7
e73547787354afd9b717ea57fe8dd0695d161821
/src/world/area_nok/nok_02/nok_02_10_epilogue.c
08aca7ae3cdbc67f4671dd74274dd909dc0df3a2
[]
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
1,526
c
nok_02_10_epilogue.c
#include "nok_02.h" EvtScript N(EVS_Scene_Epilogue) = { EVT_CALL(DisablePlayerInput, TRUE) EVT_CALL(DisablePlayerPhysics, TRUE) EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2) EVT_CALL(SetPlayerPos, NPC_DISPOSE_LOCATION) EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar0, LVar1, LVar2) EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2) EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(90.0)) EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1) EVT_WAIT(50) EVT_CALL(SetNpcAnimation, NPC_Parakarry, ANIM_WorldParakarry_Talk) EVT_WAIT(15) EVT_CALL(SetNpcAnimation, NPC_Parakarry, ANIM_WorldParakarry_Idle) EVT_WAIT(15) EVT_CALL(SetNpcAnimation, NPC_Bombette, ANIM_WorldBombette_Talk) EVT_WAIT(15) EVT_CALL(SetNpcAnimation, NPC_Bombette, ANIM_WorldBombette_Idle) EVT_WAIT(15) EVT_CALL(SetNpcAnimation, NPC_KoloradoWife_Epilogue, ANIM_KoloradoWife_Walk) EVT_CALL(NpcMoveTo, NPC_KoloradoWife_Epilogue, -80, -50, 30) EVT_CALL(SetNpcAnimation, NPC_KoloradoWife_Epilogue, ANIM_KoloradoWife_Idle) EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(1.0)) EVT_CALL(SetPanTarget, CAM_DEFAULT, -53, LVar1, LVar2) EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0)) EVT_CALL(InterpNpcYaw, NPC_Parakarry, 270, 0) EVT_WAIT(15) EVT_CALL(SetNpcAnimation, NPC_KoloradoWife_Epilogue, ANIM_KoloradoWife_Talk) EVT_WAIT(45) EVT_CALL(FadeOutMusic, 0, 1000) EVT_CALL(GotoMap, EVT_PTR("obk_09"), obk_09_ENTRY_2) EVT_WAIT(100) EVT_RETURN EVT_END };
e321f861203aed3b60f051ed74d9088f941a9a97
50dd46b8ece33f3cdd174284b15d1d51f89669d4
/third_party/edk2/Vlv2TbltDevicePkg/PlatformInitPei/MemoryCallback.c
9d9c0e53b69fc89189608e4f68f67fed39344a12
[ "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
11,241
c
MemoryCallback.c
/** @file Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: MemoryCallback.c Abstract: EFI 2.0 PEIM to provide the platform support functionality on the Bridgeport. --*/ #include "PlatformEarlyInit.h" VOID UpdateDefaultSetupValue ( IN EFI_PLATFORM_INFO_HOB *PlatformInfo ) { return; } /** PEI termination callback. @param PeiServices General purpose services available to every PEIM. @param NotifyDescriptor Not uesed. @param Ppi Not uesed. @retval EFI_SUCCESS If the interface could be successfully installed. **/ EFI_STATUS EFIAPI EndOfPeiPpiNotifyCallback ( IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi ) { EFI_STATUS Status; UINT64 LowUncableBase; EFI_PLATFORM_INFO_HOB *PlatformInfo; UINT32 HecBaseHigh; EFI_BOOT_MODE BootMode; EFI_PEI_HOB_POINTERS Hob; Status = (*PeiServices)->GetBootMode( PeiServices, &BootMode ); ASSERT_EFI_ERROR (Status); // // Set the some PCI and chipset range as UC // And align to 1M at leaset // Hob.Raw = GetFirstGuidHob (&gEfiPlatformInfoGuid); ASSERT (Hob.Raw != NULL); PlatformInfo = GET_GUID_HOB_DATA(Hob.Raw); UpdateDefaultSetupValue (PlatformInfo); DEBUG ((EFI_D_ERROR, "Memory TOLM: %X\n", PlatformInfo->MemData.MemTolm)); DEBUG ((EFI_D_ERROR, "PCIE OSBASE: %lX\n", PlatformInfo->PciData.PciExpressBase)); DEBUG ( (EFI_D_ERROR, "PCIE BASE: %lX Size : %X\n", PlatformInfo->PciData.PciExpressBase, PlatformInfo->PciData.PciExpressSize) ); DEBUG ( (EFI_D_ERROR, "PCI32 BASE: %X Limit: %X\n", PlatformInfo->PciData.PciResourceMem32Base, PlatformInfo->PciData.PciResourceMem32Limit) ); DEBUG ( (EFI_D_ERROR, "PCI64 BASE: %lX Limit: %lX\n", PlatformInfo->PciData.PciResourceMem64Base, PlatformInfo->PciData.PciResourceMem64Limit) ); DEBUG ((EFI_D_ERROR, "UC START: %lX End : %lX\n", PlatformInfo->MemData.MemMir0, PlatformInfo->MemData.MemMir1)); LowUncableBase = PlatformInfo->MemData.MemMaxTolm; LowUncableBase &= (0x0FFF00000); if (BootMode != BOOT_ON_S3_RESUME) { // // In BIOS, HECBASE will be always below 4GB // HecBaseHigh = (UINT32) RShiftU64 (PlatformInfo->PciData.PciExpressBase, 28); ASSERT (HecBaseHigh < 16); } return Status; } /** Install Firmware Volume Hob's once there is main memory @param PeiServices General purpose services available to every PEIM. @param NotifyDescriptor Notify that this module published. @param Ppi PPI that was installed. @retval EFI_SUCCESS The function completed successfully. **/ EFI_STATUS EFIAPI MemoryDiscoveredPpiNotifyCallback ( IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi ) { EFI_STATUS Status; EFI_BOOT_MODE BootMode; EFI_CPUID_REGISTER FeatureInfo; UINT8 CpuAddressWidth; UINT16 Pm1Cnt; EFI_PEI_HOB_POINTERS Hob; EFI_PLATFORM_INFO_HOB *PlatformInfo; UINT32 RootComplexBar; UINT32 PmcBase; UINT32 IoBase; UINT32 IlbBase; UINT32 SpiBase; UINT32 MphyBase; // // Get Platform Info HOB // Hob.Raw = GetFirstGuidHob (&gEfiPlatformInfoGuid); ASSERT (Hob.Raw != NULL); PlatformInfo = GET_GUID_HOB_DATA(Hob.Raw); Status = (*PeiServices)->GetBootMode (PeiServices, &BootMode); // // Check if user wants to turn off in PEI phase // if ((BootMode != BOOT_ON_S3_RESUME) && (BootMode != BOOT_ON_FLASH_UPDATE)) { CheckPowerOffNow(); } else { Pm1Cnt = IoRead16 (ACPI_BASE_ADDRESS + R_PCH_ACPI_PM1_CNT); Pm1Cnt &= ~B_PCH_ACPI_PM1_CNT_SLP_TYP; IoWrite16 (ACPI_BASE_ADDRESS + R_PCH_ACPI_PM1_CNT, Pm1Cnt); } #ifndef MINNOW2_FSP_BUILD // // Set PEI cache mode here // SetPeiCacheMode (PeiServices); #endif // // Pulish memory tyoe info // PublishMemoryTypeInfo (); // // Work done if on a S3 resume // if (BootMode == BOOT_ON_S3_RESUME) { // //Program the side band packet register to send a sideband message to Punit //To indicate that DRAM has been initialized and PUNIT FW base address in memory. // return EFI_SUCCESS; } RootComplexBar = MmPci32( 0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_LPC, 0, R_PCH_LPC_RCBA ) & B_PCH_LPC_RCBA_BAR; BuildResourceDescriptorHob ( EFI_RESOURCE_MEMORY_MAPPED_IO, (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), RootComplexBar, 0x1000 ); DEBUG ((EFI_D_INFO, "RootComplexBar : 0x%x\n", RootComplexBar)); PmcBase = MmPci32( 0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_LPC, 0, R_PCH_LPC_PMC_BASE ) & B_PCH_LPC_PMC_BASE_BAR; BuildResourceDescriptorHob ( EFI_RESOURCE_MEMORY_MAPPED_IO, (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), PmcBase, 0x1000 ); DEBUG ((EFI_D_INFO, "PmcBase : 0x%x\n", PmcBase)); IoBase = MmPci32( 0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_LPC, 0, R_PCH_LPC_IO_BASE ) & B_PCH_LPC_IO_BASE_BAR; BuildResourceDescriptorHob ( EFI_RESOURCE_MEMORY_MAPPED_IO, (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), IoBase, 0x4000 ); DEBUG ((EFI_D_INFO, "IoBase : 0x%x\n", IoBase)); IlbBase = MmPci32( 0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_LPC, 0, R_PCH_LPC_ILB_BASE ) & B_PCH_LPC_ILB_BASE_BAR; BuildResourceDescriptorHob ( EFI_RESOURCE_MEMORY_MAPPED_IO, (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), IlbBase, 0x1000 ); DEBUG ((EFI_D_INFO, "IlbBase : 0x%x\n", IlbBase)); SpiBase = MmPci32( 0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_LPC, 0, R_PCH_LPC_SPI_BASE ) & B_PCH_LPC_SPI_BASE_BAR; BuildResourceDescriptorHob ( EFI_RESOURCE_MEMORY_MAPPED_IO, (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), SpiBase, 0x1000 ); DEBUG ((EFI_D_INFO, "SpiBase : 0x%x\n", SpiBase)); MphyBase = MmPci32( 0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_LPC, 0, R_PCH_LPC_MPHY_BASE ) & B_PCH_LPC_MPHY_BASE_BAR; BuildResourceDescriptorHob ( EFI_RESOURCE_MEMORY_MAPPED_IO, (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), MphyBase, 0x100000 ); DEBUG ((EFI_D_INFO, "MphyBase : 0x%x\n", MphyBase)); // // Local APIC // BuildResourceDescriptorHob ( EFI_RESOURCE_MEMORY_MAPPED_IO, (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), LOCAL_APIC_ADDRESS, 0x1000 ); DEBUG ((EFI_D_INFO, "LOCAL_APIC_ADDRESS : 0x%x\n", LOCAL_APIC_ADDRESS)); // // IO APIC // BuildResourceDescriptorHob ( EFI_RESOURCE_MEMORY_MAPPED_IO, (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), IO_APIC_ADDRESS, 0x1000 ); DEBUG ((EFI_D_INFO, "IO_APIC_ADDRESS : 0x%x\n", IO_APIC_ADDRESS)); // // Adding the PCIE Express area to the E820 memory table as type 2 memory. // BuildResourceDescriptorHob ( EFI_RESOURCE_MEMORY_MAPPED_IO, (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), PlatformInfo->PciData.PciExpressBase, PlatformInfo->PciData.PciExpressSize ); DEBUG ((EFI_D_INFO, "PciExpressBase : 0x%x\n", PlatformInfo->PciData.PciExpressBase)); // // Adding the Flashpart to the E820 memory table as type 2 memory. // BuildResourceDescriptorHob ( EFI_RESOURCE_FIRMWARE_DEVICE, (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE), FixedPcdGet32 (PcdFlashAreaBaseAddress), FixedPcdGet32 (PcdFlashAreaSize) ); DEBUG ((EFI_D_INFO, "FLASH_BASE_ADDRESS : 0x%x\n", FixedPcdGet32 (PcdFlashAreaBaseAddress))); // // Create a CPU hand-off information // CpuAddressWidth = 32; AsmCpuid (EFI_CPUID_EXTENDED_FUNCTION, &FeatureInfo.RegEax, &FeatureInfo.RegEbx, &FeatureInfo.RegEcx, &FeatureInfo.RegEdx); if (FeatureInfo.RegEax >= EFI_CPUID_VIRT_PHYS_ADDRESS_SIZE) { AsmCpuid (EFI_CPUID_VIRT_PHYS_ADDRESS_SIZE, &FeatureInfo.RegEax, &FeatureInfo.RegEbx, &FeatureInfo.RegEcx, &FeatureInfo.RegEdx); CpuAddressWidth = (UINT8) (FeatureInfo.RegEax & 0xFF); } BuildCpuHob(CpuAddressWidth, 16); ASSERT_EFI_ERROR (Status); return Status; } EFI_STATUS ValidateFvHeader ( IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader ) { UINT16 *Ptr; UINT16 HeaderLength; UINT16 Checksum; // // Verify the header revision, header signature, length // Length of FvBlock cannot be 2**64-1 // HeaderLength cannot be an odd number // if ((FwVolHeader->Revision != EFI_FVH_REVISION) || (FwVolHeader->Signature != EFI_FVH_SIGNATURE) || (FwVolHeader->FvLength == ((UINT64) -1)) || ((FwVolHeader->HeaderLength & 0x01) != 0) ) { return EFI_NOT_FOUND; } // // Verify the header checksum // HeaderLength = (UINT16) (FwVolHeader->HeaderLength / 2); Ptr = (UINT16 *) FwVolHeader; Checksum = 0; while (HeaderLength > 0) { Checksum = *Ptr++; HeaderLength--; } if (Checksum != 0) { return EFI_NOT_FOUND; } return EFI_SUCCESS; }
520bcef7b32bbc8e68c3bad093e5a3d7fbf87e35
f53891174b71e3b52497b3ab56b30ca7056ef1b7
/src/elle/reactor/modules/dokany/sys/notification.c
fd57c0ad797d67d637f5aadce6aa1e0945da013d
[ "MIT", "LGPL-2.0-or-later", "LGPL-3.0-only", "Apache-2.0" ]
permissive
infinit/elle
050e0a3825a585add8899cf8dd8e25b0531c67ce
1a8f3df18500a9854a514cbaf9824784293ca17a
refs/heads/master
2023-09-04T01:15:06.820585
2022-09-17T08:43:45
2022-09-17T08:43:45
51,672,792
533
51
Apache-2.0
2023-05-22T21:35:50
2016-02-14T00:38:23
C++
UTF-8
C
false
false
17,618
c
notification.c
/* Dokan : user-mode file system library for Windows Copyright (C) 2015 - 2016 Adrien J. <liryna.stark@gmail.com> and Maxime C. <maxime@islog.com> Copyright (C) 2007 - 2011 Hiroki Asakawa <info@dokan-dev.net> http://dokan-dev.github.io This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 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 Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* IOCTL_EVENT_START: DokanStartEventNotificationThread NotificationThread # PendingEvent has pending IPRs (IOCTL_EVENT_WAIT) # NotifyEvent has IO events (ex.IRP_MJ_READ) # notify NotifyEvent using PendingEvent in this loop NotificationLoop(&Dcb->PendingEvent, &Dcb->NotifyEvent); # PendingService has service events (ex. Unmount notification) # NotifyService has pending IRPs (IOCTL_SERVICE_WAIT) NotificationLoop(Dcb->Global->PendingService, &Dcb->Global->NotifyService); IOCTL_EVENT_RELEASE: DokanStopEventNotificationThread IRP_MJ_READ: DokanDispatchRead DokanRegisterPendingIrp # add IRP_MJ_READ to PendingIrp list DokanRegisterPendingIrpMain(PendingIrp) # put MJ_READ event into NotifyEvent DokanEventNotification(NotifyEvent, EventContext) IOCTL_EVENT_WAIT: DokanRegisterPendingIrpForEvent # add this irp to PendingEvent list DokanRegisterPendingIrpMain(PendingEvent) IOCTL_EVENT_INFO: DokanCompleteIrp DokanCompleteRead */ #include "dokan.h" VOID SetCommonEventContext(__in PDokanDCB Dcb, __in PEVENT_CONTEXT EventContext, __in PIRP Irp, __in_opt PDokanCCB Ccb) { PIO_STACK_LOCATION irpSp; irpSp = IoGetCurrentIrpStackLocation(Irp); EventContext->MountId = Dcb->MountId; EventContext->MajorFunction = irpSp->MajorFunction; EventContext->MinorFunction = irpSp->MinorFunction; EventContext->Flags = irpSp->Flags; if (Ccb) { EventContext->FileFlags = Ccb->Flags; } EventContext->ProcessId = IoGetRequestorProcessId(Irp); } PEVENT_CONTEXT AllocateEventContextRaw(__in ULONG EventContextLength) { ULONG driverContextLength; PDRIVER_EVENT_CONTEXT driverEventContext; PEVENT_CONTEXT eventContext; driverContextLength = EventContextLength - sizeof(EVENT_CONTEXT) + sizeof(DRIVER_EVENT_CONTEXT); driverEventContext = ExAllocatePool(driverContextLength); if (driverEventContext == NULL) { return NULL; } RtlZeroMemory(driverEventContext, driverContextLength); InitializeListHead(&driverEventContext->ListEntry); eventContext = &driverEventContext->EventContext; eventContext->Length = EventContextLength; return eventContext; } PEVENT_CONTEXT AllocateEventContext(__in PDokanDCB Dcb, __in PIRP Irp, __in ULONG EventContextLength, __in_opt PDokanCCB Ccb) { PEVENT_CONTEXT eventContext; eventContext = AllocateEventContextRaw(EventContextLength); if (eventContext == NULL) { return NULL; } SetCommonEventContext(Dcb, eventContext, Irp, Ccb); eventContext->SerialNumber = InterlockedIncrement((LONG *)&Dcb->SerialNumber); return eventContext; } VOID DokanFreeEventContext(__in PEVENT_CONTEXT EventContext) { PDRIVER_EVENT_CONTEXT driverEventContext = CONTAINING_RECORD(EventContext, DRIVER_EVENT_CONTEXT, EventContext); ExFreePool(driverEventContext); } VOID DokanEventNotification(__in PIRP_LIST NotifyEvent, __in PEVENT_CONTEXT EventContext) { PDRIVER_EVENT_CONTEXT driverEventContext = CONTAINING_RECORD(EventContext, DRIVER_EVENT_CONTEXT, EventContext); InitializeListHead(&driverEventContext->ListEntry); ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); // DDbgPrint("DokanEventNotification\n"); ExInterlockedInsertTailList(&NotifyEvent->ListHead, &driverEventContext->ListEntry, &NotifyEvent->ListLock); KeSetEvent(&NotifyEvent->NotEmpty, IO_NO_INCREMENT, FALSE); } VOID ReleasePendingIrp(__in PIRP_LIST PendingIrp) { PLIST_ENTRY listHead; LIST_ENTRY completeList; PIRP_ENTRY irpEntry; KIRQL oldIrql; PIRP irp; InitializeListHead(&completeList); ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); KeAcquireSpinLock(&PendingIrp->ListLock, &oldIrql); while (!IsListEmpty(&PendingIrp->ListHead)) { listHead = RemoveHeadList(&PendingIrp->ListHead); irpEntry = CONTAINING_RECORD(listHead, IRP_ENTRY, ListEntry); irp = irpEntry->Irp; if (irp == NULL) { // this IRP has already been canceled ASSERT(irpEntry->CancelRoutineFreeMemory == FALSE); DokanFreeIrpEntry(irpEntry); continue; } if (IoSetCancelRoutine(irp, NULL) == NULL) { // Cancel routine will run as soon as we release the lock InitializeListHead(&irpEntry->ListEntry); irpEntry->CancelRoutineFreeMemory = TRUE; continue; } InsertTailList(&completeList, &irpEntry->ListEntry); } KeClearEvent(&PendingIrp->NotEmpty); KeReleaseSpinLock(&PendingIrp->ListLock, oldIrql); while (!IsListEmpty(&completeList)) { listHead = RemoveHeadList(&completeList); irpEntry = CONTAINING_RECORD(listHead, IRP_ENTRY, ListEntry); irp = irpEntry->Irp; DokanFreeIrpEntry(irpEntry); DokanCompleteIrpRequest(irp, STATUS_CANCELLED, 0); } } VOID ReleaseNotifyEvent(__in PIRP_LIST NotifyEvent) { PDRIVER_EVENT_CONTEXT driverEventContext; PLIST_ENTRY listHead; KIRQL oldIrql; ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); KeAcquireSpinLock(&NotifyEvent->ListLock, &oldIrql); while (!IsListEmpty(&NotifyEvent->ListHead)) { listHead = RemoveHeadList(&NotifyEvent->ListHead); driverEventContext = CONTAINING_RECORD(listHead, DRIVER_EVENT_CONTEXT, ListEntry); ExFreePool(driverEventContext); } KeClearEvent(&NotifyEvent->NotEmpty); KeReleaseSpinLock(&NotifyEvent->ListLock, oldIrql); } VOID NotificationLoop(__in PIRP_LIST PendingIrp, __in PIRP_LIST NotifyEvent) { PDRIVER_EVENT_CONTEXT driverEventContext; PLIST_ENTRY listHead; PIRP_ENTRY irpEntry; LIST_ENTRY completeList; KIRQL irpIrql; KIRQL notifyIrql; PIRP irp; ULONG eventLen; ULONG bufferLen; PVOID buffer; DDbgPrint("=> NotificationLoop\n"); InitializeListHead(&completeList); ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); DDbgPrint("Try acquire SpinLock...\n"); KeAcquireSpinLock(&PendingIrp->ListLock, &irpIrql); DDbgPrint("SpinLock irp Acquired\n"); KeAcquireSpinLock(&NotifyEvent->ListLock, &notifyIrql); DDbgPrint("SpinLock notify Acquired\n"); while (!IsListEmpty(&PendingIrp->ListHead) && !IsListEmpty(&NotifyEvent->ListHead)) { listHead = RemoveHeadList(&NotifyEvent->ListHead); driverEventContext = CONTAINING_RECORD(listHead, DRIVER_EVENT_CONTEXT, ListEntry); listHead = RemoveHeadList(&PendingIrp->ListHead); irpEntry = CONTAINING_RECORD(listHead, IRP_ENTRY, ListEntry); eventLen = driverEventContext->EventContext.Length; // ensure this eventIrp is not cancelled irp = irpEntry->Irp; if (irp == NULL) { // this IRP has already been canceled DDbgPrint("Irp canceled\n"); ASSERT(irpEntry->CancelRoutineFreeMemory == FALSE); DokanFreeIrpEntry(irpEntry); // push back InsertTailList(&NotifyEvent->ListHead, &driverEventContext->ListEntry); continue; } if (IoSetCancelRoutine(irp, NULL) == NULL) { DDbgPrint("IoSetCancelRoutine return NULL\n"); // Cancel routine will run as soon as we release the lock InitializeListHead(&irpEntry->ListEntry); irpEntry->CancelRoutineFreeMemory = TRUE; // push back InsertTailList(&NotifyEvent->ListHead, &driverEventContext->ListEntry); continue; } // available size that is used for event notification bufferLen = irpEntry->IrpSp->Parameters.DeviceIoControl.OutputBufferLength; // buffer that is used to inform Event buffer = irp->AssociatedIrp.SystemBuffer; // buffer is not specified or short of length if (bufferLen == 0 || buffer == NULL || bufferLen < eventLen) { DDbgPrint("EventNotice : STATUS_INSUFFICIENT_RESOURCES\n"); DDbgPrint(" bufferLen: %d, eventLen: %d\n", bufferLen, eventLen); // push back InsertTailList(&NotifyEvent->ListHead, &driverEventContext->ListEntry); // marks as STATUS_INSUFFICIENT_RESOURCES irpEntry->SerialNumber = 0; } else { // let's copy EVENT_CONTEXT RtlCopyMemory(buffer, &driverEventContext->EventContext, eventLen); // save event length irpEntry->SerialNumber = eventLen; if (driverEventContext->Completed) { KeSetEvent(driverEventContext->Completed, IO_NO_INCREMENT, FALSE); } ExFreePool(driverEventContext); } InsertTailList(&completeList, &irpEntry->ListEntry); } DDbgPrint("Clear Events...\n"); KeClearEvent(&NotifyEvent->NotEmpty); DDbgPrint("Notify event cleared\n"); KeClearEvent(&PendingIrp->NotEmpty); DDbgPrint("Pending event cleared\n"); DDbgPrint("Release SpinLock...\n"); KeReleaseSpinLock(&NotifyEvent->ListLock, notifyIrql); DDbgPrint("SpinLock notify Released\n"); KeReleaseSpinLock(&PendingIrp->ListLock, irpIrql); DDbgPrint("SpinLock irp Released\n"); while (!IsListEmpty(&completeList)) { listHead = RemoveHeadList(&completeList); irpEntry = CONTAINING_RECORD(listHead, IRP_ENTRY, ListEntry); irp = irpEntry->Irp; if (irpEntry->SerialNumber == 0) { irp->IoStatus.Information = 0; irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES; } else { irp->IoStatus.Information = irpEntry->SerialNumber; irp->IoStatus.Status = STATUS_SUCCESS; } DokanFreeIrpEntry(irpEntry); DokanCompleteIrpRequest(irp, irp->IoStatus.Status, irp->IoStatus.Information); } DDbgPrint("<= NotificationLoop\n"); } KSTART_ROUTINE NotificationThread; VOID NotificationThread(__in PDokanDCB Dcb) { PKEVENT events[5]; PKWAIT_BLOCK waitBlock; NTSTATUS status; DDbgPrint("==> NotificationThread\n"); waitBlock = ExAllocatePool(sizeof(KWAIT_BLOCK) * 5); if (waitBlock == NULL) { DDbgPrint(" Can't allocate WAIT_BLOCK\n"); return; } events[0] = &Dcb->ReleaseEvent; events[1] = &Dcb->NotifyEvent.NotEmpty; events[2] = &Dcb->PendingEvent.NotEmpty; events[3] = &Dcb->Global->PendingService.NotEmpty; events[4] = &Dcb->Global->NotifyService.NotEmpty; do { status = KeWaitForMultipleObjects(5, events, WaitAny, Executive, KernelMode, FALSE, NULL, waitBlock); if (status != STATUS_WAIT_0) { if (status == STATUS_WAIT_1 || status == STATUS_WAIT_2) { NotificationLoop(&Dcb->PendingEvent, &Dcb->NotifyEvent); } else { NotificationLoop(&Dcb->Global->PendingService, &Dcb->Global->NotifyService); } } } while (status != STATUS_WAIT_0); ExFreePool(waitBlock); DDbgPrint("<== NotificationThread\n"); } NTSTATUS DokanStartEventNotificationThread(__in PDokanDCB Dcb) { NTSTATUS status; HANDLE thread; DDbgPrint("==> DokanStartEventNotificationThread\n"); KeResetEvent(&Dcb->ReleaseEvent); status = PsCreateSystemThread(&thread, THREAD_ALL_ACCESS, NULL, NULL, NULL, (PKSTART_ROUTINE)NotificationThread, Dcb); if (!NT_SUCCESS(status)) { return status; } ObReferenceObjectByHandle(thread, THREAD_ALL_ACCESS, NULL, KernelMode, (PVOID *)&Dcb->EventNotificationThread, NULL); ZwClose(thread); DDbgPrint("<== DokanStartEventNotificationThread\n"); return STATUS_SUCCESS; } VOID DokanStopEventNotificationThread(__in PDokanDCB Dcb) { DDbgPrint("==> DokanStopEventNotificationThread\n"); if (KeSetEvent(&Dcb->ReleaseEvent, 0, FALSE) > 0 && Dcb->EventNotificationThread) { DDbgPrint("Waiting for Notify thread to terminate.\n"); ASSERT(KeGetCurrentIrql() <= APC_LEVEL); if (Dcb->EventNotificationThread) { KeWaitForSingleObject(Dcb->EventNotificationThread, Executive, KernelMode, FALSE, NULL); DDbgPrint("Notify thread successfully terminated.\n"); ObDereferenceObject(Dcb->EventNotificationThread); Dcb->EventNotificationThread = NULL; } } DDbgPrint("<== DokanStopEventNotificationThread\n"); } NTSTATUS DokanEventRelease(__in PDEVICE_OBJECT DeviceObject, __in PIRP Irp) { PDokanDCB dcb; PDokanVCB vcb; PDokanFCB fcb; PDokanCCB ccb; PLIST_ENTRY fcbEntry, fcbNext, fcbHead; PLIST_ENTRY ccbEntry, ccbNext, ccbHead; NTSTATUS status = STATUS_SUCCESS; DDbgPrint("==> DokanEventRelease\n"); if (DeviceObject == NULL) { return STATUS_INVALID_PARAMETER; } vcb = DeviceObject->DeviceExtension; if (GetIdentifierType(vcb) != VCB) { return STATUS_INVALID_PARAMETER; } dcb = vcb->Dcb; if (IsDeletePending(dcb->DeviceObject)) { DDbgPrint(" DokanEventRelease already running for this device\n"); return STATUS_SUCCESS; } if (IsUnmountPendingVcb(vcb)) { DDbgPrint(" DokanEventRelease already running for this volume\n"); return STATUS_SUCCESS; } status = IoAcquireRemoveLock(&dcb->RemoveLock, Irp); if (!NT_SUCCESS(status)) { DDbgPrint("IoAcquireRemoveLock failed with %#x", status); return STATUS_DEVICE_REMOVED; } // as first delete the mountpoint // in case of MountManager some request because of delete // must be handled properly DokanDeleteMountPoint(dcb); // then mark the device for unmount pending SetLongFlag(vcb->Flags, VCB_DISMOUNT_PENDING); SetLongFlag(dcb->Flags, DCB_DELETE_PENDING); DDbgPrint(" Starting unmount for device %wZ\n", dcb->DiskDeviceName); ReleasePendingIrp(&dcb->PendingIrp); ReleasePendingIrp(&dcb->PendingEvent); DokanStopCheckThread(dcb); DokanStopEventNotificationThread(dcb); ClearLongFlag(vcb->Flags, VCB_MOUNTED); // search CCB list to complete not completed Directory Notification KeEnterCriticalRegion(); ExAcquireResourceExclusiveLite(&vcb->Resource, TRUE); fcbHead = &vcb->NextFCB; for (fcbEntry = fcbHead->Flink; fcbEntry != fcbHead; fcbEntry = fcbNext) { fcbNext = fcbEntry->Flink; fcb = CONTAINING_RECORD(fcbEntry, DokanFCB, NextFCB); DokanFCBLockRW(fcb); ccbHead = &fcb->NextCCB; for (ccbEntry = ccbHead->Flink; ccbEntry != ccbHead; ccbEntry = ccbNext) { ccbNext = ccbEntry->Flink; ccb = CONTAINING_RECORD(ccbEntry, DokanCCB, NextCCB); DDbgPrint(" NotifyCleanup ccb:%p, context:%X, filename:%wZ\n", ccb, (ULONG)ccb->UserContext, &fcb->FileName); FsRtlNotifyCleanup(vcb->NotifySync, &vcb->DirNotifyList, ccb); } DokanFCBUnlock(fcb); } ExReleaseResourceLite(&vcb->Resource); KeLeaveCriticalRegion(); IoReleaseRemoveLockAndWait(&dcb->RemoveLock, Irp); DokanDeleteDeviceObject(dcb); DDbgPrint("<== DokanEventRelease\n"); return status; } NTSTATUS DokanGlobalEventRelease(__in PDEVICE_OBJECT DeviceObject, __in PIRP Irp) { PDOKAN_GLOBAL dokanGlobal; PIO_STACK_LOCATION irpSp; PDOKAN_UNICODE_STRING_INTERMEDIATE szMountPoint; DOKAN_CONTROL dokanControl; PMOUNT_ENTRY mountEntry; dokanGlobal = DeviceObject->DeviceExtension; if (GetIdentifierType(dokanGlobal) != DGL) { return STATUS_INVALID_PARAMETER; } irpSp = IoGetCurrentIrpStackLocation(Irp); if (irpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(DOKAN_UNICODE_STRING_INTERMEDIATE)) { DDbgPrint( "Input buffer is too small (< DOKAN_UNICODE_STRING_INTERMEDIATE)\n"); return STATUS_BUFFER_TOO_SMALL; } szMountPoint = (PDOKAN_UNICODE_STRING_INTERMEDIATE)Irp->AssociatedIrp.SystemBuffer; if (irpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(DOKAN_UNICODE_STRING_INTERMEDIATE) + szMountPoint->MaximumLength) { DDbgPrint("Input buffer is too small\n"); return STATUS_BUFFER_TOO_SMALL; } RtlZeroMemory(&dokanControl, sizeof(dokanControl)); RtlStringCchCopyW(dokanControl.MountPoint, MAXIMUM_FILENAME_LENGTH, L"\\DosDevices\\"); if ((szMountPoint->Length / sizeof(WCHAR)) < 4) { dokanControl.MountPoint[12] = towupper(szMountPoint->Buffer[0]); dokanControl.MountPoint[13] = L':'; dokanControl.MountPoint[14] = L'\0'; } else { RtlCopyMemory(&dokanControl.MountPoint[12], szMountPoint->Buffer, szMountPoint->Length); } mountEntry = FindMountEntry(dokanGlobal, &dokanControl, TRUE); if (mountEntry == NULL) { DDbgPrint("Cannot found device associated to mount point %ws\n", dokanControl.MountPoint); return STATUS_BUFFER_TOO_SMALL; } if (IsDeletePending(mountEntry->MountControl.DeviceObject)) { DDbgPrint("Device is deleted\n") return STATUS_DEVICE_REMOVED; } if (!IsMounted(mountEntry->MountControl.DeviceObject)) { DDbgPrint("Device is still not mounted, so an unmount not possible at this " "point\n") return STATUS_DEVICE_BUSY; } return DokanEventRelease(mountEntry->MountControl.DeviceObject, Irp); }
674741f6d21daa9a96d717d0348c44a8b68aa290
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/fs/yaffs2/yaffs_tagscompat.c
9ac5896da37713d51875c8f9bd23b6d4e434fa88
[ "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
10,352
c
yaffs_tagscompat.c
/* * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. * * Copyright (C) 2002-2011 Aleph One Ltd. * for Toby Churchill Ltd and Brightstar Engineering * * Created by Charles Manning <charles@aleph1.co.uk> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include "yaffs_guts.h" #include "yaffs_tagscompat.h" #include "yaffs_ecc.h" #include "yaffs_getblockinfo.h" #include "yaffs_trace.h" static void yaffs_handle_rd_data_error(struct yaffs_dev *dev, int nand_chunk); /********** Tags ECC calculations *********/ void yaffs_calc_ecc(const u8 *data, struct yaffs_spare *spare) { yaffs_ecc_calc(data, spare->ecc1); yaffs_ecc_calc(&data[256], spare->ecc2); } void yaffs_calc_tags_ecc(struct yaffs_tags *tags) { /* Calculate an ecc */ unsigned char *b = ((union yaffs_tags_union *)tags)->as_bytes; unsigned i, j; unsigned ecc = 0; unsigned bit = 0; tags->ecc = 0; for (i = 0; i < 8; i++) { for (j = 1; j & 0xff; j <<= 1) { bit++; if (b[i] & j) ecc ^= bit; } } tags->ecc = ecc; } int yaffs_check_tags_ecc(struct yaffs_tags *tags) { unsigned ecc = tags->ecc; yaffs_calc_tags_ecc(tags); ecc ^= tags->ecc; if (ecc && ecc <= 64) { /* TODO: Handle the failure better. Retire? */ unsigned char *b = ((union yaffs_tags_union *)tags)->as_bytes; ecc--; b[ecc / 8] ^= (1 << (ecc & 7)); /* Now recvalc the ecc */ yaffs_calc_tags_ecc(tags); return 1; /* recovered error */ } else if (ecc) { /* Wierd ecc failure value */ /* TODO Need to do somethiong here */ return -1; /* unrecovered error */ } return 0; } /********** Tags **********/ static void yaffs_load_tags_to_spare(struct yaffs_spare *spare_ptr, struct yaffs_tags *tags_ptr) { union yaffs_tags_union *tu = (union yaffs_tags_union *)tags_ptr; yaffs_calc_tags_ecc(tags_ptr); spare_ptr->tb0 = tu->as_bytes[0]; spare_ptr->tb1 = tu->as_bytes[1]; spare_ptr->tb2 = tu->as_bytes[2]; spare_ptr->tb3 = tu->as_bytes[3]; spare_ptr->tb4 = tu->as_bytes[4]; spare_ptr->tb5 = tu->as_bytes[5]; spare_ptr->tb6 = tu->as_bytes[6]; spare_ptr->tb7 = tu->as_bytes[7]; } static void yaffs_get_tags_from_spare(struct yaffs_dev *dev, struct yaffs_spare *spare_ptr, struct yaffs_tags *tags_ptr) { union yaffs_tags_union *tu = (union yaffs_tags_union *)tags_ptr; int result; tu->as_bytes[0] = spare_ptr->tb0; tu->as_bytes[1] = spare_ptr->tb1; tu->as_bytes[2] = spare_ptr->tb2; tu->as_bytes[3] = spare_ptr->tb3; tu->as_bytes[4] = spare_ptr->tb4; tu->as_bytes[5] = spare_ptr->tb5; tu->as_bytes[6] = spare_ptr->tb6; tu->as_bytes[7] = spare_ptr->tb7; result = yaffs_check_tags_ecc(tags_ptr); if (result > 0) dev->n_tags_ecc_fixed++; else if (result < 0) dev->n_tags_ecc_unfixed++; } static void yaffs_spare_init(struct yaffs_spare *spare) { memset(spare, 0xff, sizeof(struct yaffs_spare)); } static int yaffs_wr_nand(struct yaffs_dev *dev, int nand_chunk, const u8 *data, struct yaffs_spare *spare) { if (nand_chunk < dev->param.start_block * dev->param.chunks_per_block) { yaffs_trace(YAFFS_TRACE_ERROR, "**>> yaffs chunk %d is not valid", nand_chunk); return YAFFS_FAIL; } return dev->param.write_chunk_fn(dev, nand_chunk, data, spare); } static int yaffs_rd_chunk_nand(struct yaffs_dev *dev, int nand_chunk, u8 *data, struct yaffs_spare *spare, enum yaffs_ecc_result *ecc_result, int correct_errors) { int ret_val; struct yaffs_spare local_spare; if (!spare) { /* If we don't have a real spare, then we use a local one. */ /* Need this for the calculation of the ecc */ spare = &local_spare; } if (!dev->param.use_nand_ecc) { ret_val = dev->param.read_chunk_fn(dev, nand_chunk, data, spare); if (data && correct_errors) { /* Do ECC correction */ /* Todo handle any errors */ int ecc_result1, ecc_result2; u8 calc_ecc[3]; yaffs_ecc_calc(data, calc_ecc); ecc_result1 = yaffs_ecc_correct(data, spare->ecc1, calc_ecc); yaffs_ecc_calc(&data[256], calc_ecc); ecc_result2 = yaffs_ecc_correct(&data[256], spare->ecc2, calc_ecc); if (ecc_result1 > 0) { yaffs_trace(YAFFS_TRACE_ERROR, "**>>yaffs ecc error fix performed on chunk %d:0", nand_chunk); dev->n_ecc_fixed++; } else if (ecc_result1 < 0) { yaffs_trace(YAFFS_TRACE_ERROR, "**>>yaffs ecc error unfixed on chunk %d:0", nand_chunk); dev->n_ecc_unfixed++; } if (ecc_result2 > 0) { yaffs_trace(YAFFS_TRACE_ERROR, "**>>yaffs ecc error fix performed on chunk %d:1", nand_chunk); dev->n_ecc_fixed++; } else if (ecc_result2 < 0) { yaffs_trace(YAFFS_TRACE_ERROR, "**>>yaffs ecc error unfixed on chunk %d:1", nand_chunk); dev->n_ecc_unfixed++; } if (ecc_result1 || ecc_result2) { /* We had a data problem on this page */ yaffs_handle_rd_data_error(dev, nand_chunk); } if (ecc_result1 < 0 || ecc_result2 < 0) *ecc_result = YAFFS_ECC_RESULT_UNFIXED; else if (ecc_result1 > 0 || ecc_result2 > 0) *ecc_result = YAFFS_ECC_RESULT_FIXED; else *ecc_result = YAFFS_ECC_RESULT_NO_ERROR; } } else { /* Must allocate enough memory for spare+2*sizeof(int) */ /* for ecc results from device. */ struct yaffs_nand_spare nspare; memset(&nspare, 0, sizeof(nspare)); ret_val = dev->param.read_chunk_fn(dev, nand_chunk, data, (struct yaffs_spare *) &nspare); memcpy(spare, &nspare, sizeof(struct yaffs_spare)); if (data && correct_errors) { if (nspare.eccres1 > 0) { yaffs_trace(YAFFS_TRACE_ERROR, "**>>mtd ecc error fix performed on chunk %d:0", nand_chunk); } else if (nspare.eccres1 < 0) { yaffs_trace(YAFFS_TRACE_ERROR, "**>>mtd ecc error unfixed on chunk %d:0", nand_chunk); } if (nspare.eccres2 > 0) { yaffs_trace(YAFFS_TRACE_ERROR, "**>>mtd ecc error fix performed on chunk %d:1", nand_chunk); } else if (nspare.eccres2 < 0) { yaffs_trace(YAFFS_TRACE_ERROR, "**>>mtd ecc error unfixed on chunk %d:1", nand_chunk); } if (nspare.eccres1 || nspare.eccres2) { /* We had a data problem on this page */ yaffs_handle_rd_data_error(dev, nand_chunk); } if (nspare.eccres1 < 0 || nspare.eccres2 < 0) *ecc_result = YAFFS_ECC_RESULT_UNFIXED; else if (nspare.eccres1 > 0 || nspare.eccres2 > 0) *ecc_result = YAFFS_ECC_RESULT_FIXED; else *ecc_result = YAFFS_ECC_RESULT_NO_ERROR; } } return ret_val; } /* * Functions for robustisizing */ static void yaffs_handle_rd_data_error(struct yaffs_dev *dev, int nand_chunk) { int flash_block = nand_chunk / dev->param.chunks_per_block; /* Mark the block for retirement */ yaffs_get_block_info(dev, flash_block + dev->block_offset)-> needs_retiring = 1; yaffs_trace(YAFFS_TRACE_ERROR | YAFFS_TRACE_BAD_BLOCKS, "**>>Block %d marked for retirement", flash_block); /* TODO: * Just do a garbage collection on the affected block * then retire the block * NB recursion */ } int yaffs_tags_compat_wr(struct yaffs_dev *dev, int nand_chunk, const u8 *data, const struct yaffs_ext_tags *ext_tags) { struct yaffs_spare spare; struct yaffs_tags tags; yaffs_spare_init(&spare); if (ext_tags->is_deleted) spare.page_status = 0; else { tags.obj_id = ext_tags->obj_id; tags.chunk_id = ext_tags->chunk_id; tags.n_bytes_lsb = ext_tags->n_bytes & (1024 - 1); if (dev->data_bytes_per_chunk >= 1024) tags.n_bytes_msb = (ext_tags->n_bytes >> 10) & 3; else tags.n_bytes_msb = 3; tags.serial_number = ext_tags->serial_number; if (!dev->param.use_nand_ecc && data) yaffs_calc_ecc(data, &spare); yaffs_load_tags_to_spare(&spare, &tags); } return yaffs_wr_nand(dev, nand_chunk, data, &spare); } int yaffs_tags_compat_rd(struct yaffs_dev *dev, int nand_chunk, u8 *data, struct yaffs_ext_tags *ext_tags) { struct yaffs_spare spare; struct yaffs_tags tags; enum yaffs_ecc_result ecc_result = YAFFS_ECC_RESULT_UNKNOWN; static struct yaffs_spare spare_ff; static int init; int deleted; if (!init) { memset(&spare_ff, 0xff, sizeof(spare_ff)); init = 1; } if (!yaffs_rd_chunk_nand(dev, nand_chunk, data, &spare, &ecc_result, 1)) return YAFFS_FAIL; /* ext_tags may be NULL */ if (!ext_tags) return YAFFS_OK; deleted = (hweight8(spare.page_status) < 7) ? 1 : 0; ext_tags->is_deleted = deleted; ext_tags->ecc_result = ecc_result; ext_tags->block_bad = 0; /* We're reading it */ /* therefore it is not a bad block */ ext_tags->chunk_used = memcmp(&spare_ff, &spare, sizeof(spare_ff)) ? 1 : 0; if (ext_tags->chunk_used) { yaffs_get_tags_from_spare(dev, &spare, &tags); ext_tags->obj_id = tags.obj_id; ext_tags->chunk_id = tags.chunk_id; ext_tags->n_bytes = tags.n_bytes_lsb; if (dev->data_bytes_per_chunk >= 1024) ext_tags->n_bytes |= (((unsigned)tags.n_bytes_msb) << 10); ext_tags->serial_number = tags.serial_number; } return YAFFS_OK; } int yaffs_tags_compat_mark_bad(struct yaffs_dev *dev, int flash_block) { struct yaffs_spare spare; memset(&spare, 0xff, sizeof(struct yaffs_spare)); spare.block_status = 'Y'; yaffs_wr_nand(dev, flash_block * dev->param.chunks_per_block, NULL, &spare); yaffs_wr_nand(dev, flash_block * dev->param.chunks_per_block + 1, NULL, &spare); return YAFFS_OK; } int yaffs_tags_compat_query_block(struct yaffs_dev *dev, int block_no, enum yaffs_block_state *state, u32 *seq_number) { struct yaffs_spare spare0, spare1; static struct yaffs_spare spare_ff; static int init; enum yaffs_ecc_result dummy; if (!init) { memset(&spare_ff, 0xff, sizeof(spare_ff)); init = 1; } *seq_number = 0; yaffs_rd_chunk_nand(dev, block_no * dev->param.chunks_per_block, NULL, &spare0, &dummy, 1); yaffs_rd_chunk_nand(dev, block_no * dev->param.chunks_per_block + 1, NULL, &spare1, &dummy, 1); if (hweight8(spare0.block_status & spare1.block_status) < 7) *state = YAFFS_BLOCK_STATE_DEAD; else if (memcmp(&spare_ff, &spare0, sizeof(spare_ff)) == 0) *state = YAFFS_BLOCK_STATE_EMPTY; else *state = YAFFS_BLOCK_STATE_NEEDS_SCAN; return YAFFS_OK; }
b9de104bff850075f55014d0d883703e44518e65
2f58e877a1e317cab8ccadd03e001bbe561ed191
/src/ngx_stream_lua_input_filters.h
e65d572faf6f871a995c82f727deee8f1ec7a48f
[ "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
909
h
ngx_stream_lua_input_filters.h
/* * !!! DO NOT EDIT DIRECTLY !!! * This file was automatically generated from the following template: * * src/subsys/ngx_subsys_lua_input_filters.h.tt2 */ /* * Copyright (C) by OpenResty Inc. */ #ifndef _NGX_STREAM_LUA_INPUT_FILTERS_H_INCLUDED_ #define _NGX_STREAM_LUA_INPUT_FILTERS_H_INCLUDED_ #include "ngx_stream_lua_common.h" ngx_int_t ngx_stream_lua_read_bytes(ngx_buf_t *src, ngx_chain_t *buf_in, size_t *rest, ssize_t bytes, ngx_log_t *log); ngx_int_t ngx_stream_lua_read_all(ngx_buf_t *src, ngx_chain_t *buf_in, ssize_t bytes, ngx_log_t *log); ngx_int_t ngx_stream_lua_read_any(ngx_buf_t *src, ngx_chain_t *buf_in, size_t *max, ssize_t bytes, ngx_log_t *log); ngx_int_t ngx_stream_lua_read_line(ngx_buf_t *src, ngx_chain_t *buf_in, ssize_t bytes, ngx_log_t *log); #endif /* _NGX_STREAM_LUA_INPUT_FILTERS_H_INCLUDED_ */ /* vi:set ft=c ts=4 sw=4 et fdm=marker: */
1c26ec7bd8dae4abefcb9ccc00723416b4930c45
2c052c996d4267623276a681308bf87ea7388f60
/src/kernel/schedule.c
4ad447f5c8f988b54d3db0f183fb35ba7a093ea8
[ "Apache-2.0" ]
permissive
nanovms/nanos
17d3ce113b63c4370e40d291b8fd8fb9d943c02d
9085e091e5250fc58bf036591c8959e05fd7957f
refs/heads/master
2023-08-25T16:49:14.521701
2023-08-25T14:00:54
2023-08-25T14:14:13
115,159,616
2,055
131
Apache-2.0
2023-09-14T17:16:19
2017-12-23T00:25:34
C
UTF-8
C
false
false
11,240
c
schedule.c
#include <kernel.h> //#define SCHED_DEBUG #ifdef SCHED_DEBUG #define sched_debug(x, ...) do {tprintf(sym(sched), 0, x, ##__VA_ARGS__);} while(0) #else #define sched_debug(x, ...) #endif static const char * const state_strings_backing[] = { "not present", "idle", "kernel", "interrupt", "user", }; const char * const * const state_strings = state_strings_backing; BSS_RO_AFTER_INIT static int wakeup_vector; BSS_RO_AFTER_INIT int shutdown_vector; boolean shutting_down; BSS_RO_AFTER_INIT queue bhqueue; /* kernel from interrupt */ BSS_RO_AFTER_INIT queue runqueue; BSS_RO_AFTER_INIT queue async_queue_1; /* queue of async 1 arg completions */ BSS_RO_AFTER_INIT bitmap idle_cpu_mask; BSS_RO_AFTER_INIT timerqueue kernel_timers; BSS_RO_AFTER_INIT thunk timer_interrupt_handler; NOTRACE void __attribute__((noreturn)) kernel_sleep(void) { // we're going to cover up this race by checking the state in the interrupt // handler...we shouldn't return here if we do get interrupted cpuinfo ci = current_cpu(); sched_debug("sleep\n"); ci->state = cpu_idle; bitmap_set_atomic(idle_cpu_mask, ci->id, 1); while (1) { wait_for_interrupt(); } } void wakeup_or_interrupt_cpu_all() { cpuinfo ci = current_cpu(); for (int i = 0; i < total_processors; i++) { if (i != ci->id) { bitmap_set_atomic(idle_cpu_mask, i, 0); send_ipi(i, wakeup_vector); } } } static void wakeup_cpu(u64 cpu) { if (bitmap_test_and_set_atomic(idle_cpu_mask, cpu, 0)) { sched_debug("waking up CPU %d\n", cpu); send_ipi(cpu, wakeup_vector); } } static sched_task migrate_to_self(sched_task t, u64 first_cpu, u64 ncpus) { u64 cpu; while ((ncpus > 0) && ((cpu = bitmap_range_get_first(idle_cpu_mask, first_cpu, ncpus)) != INVALID_PHYSICAL)) { cpuinfo cpui = cpuinfo_from_id(cpu); if (t == INVALID_ADDRESS) { t = sched_dequeue(&cpui->thread_queue); if (t != INVALID_ADDRESS) sched_debug("migrating thread from idle CPU %d to self\n", cpu); } if ((t != INVALID_ADDRESS) && !sched_queue_empty(&cpui->thread_queue)) wakeup_cpu(cpu); ncpus -= cpu - first_cpu + 1; first_cpu = cpu + 1; } return t; } static void migrate_from_self(cpuinfo ci, u64 first_cpu, u64 ncpus) { u64 cpu; while ((ncpus > 0) && ((cpu = bitmap_range_get_first(idle_cpu_mask, first_cpu, ncpus)) != INVALID_PHYSICAL)) { cpuinfo cpui = cpuinfo_from_id(cpu); sched_task task; if (!sched_queue_empty(&cpui->thread_queue)) { wakeup_cpu(cpu); } else if ((task = sched_dequeue(&ci->thread_queue)) != INVALID_ADDRESS) { sched_debug("migrating thread from self to idle CPU %d\n", cpu); sched_enqueue(&cpui->thread_queue, task); wakeup_cpu(cpu); } ncpus -= cpu - first_cpu + 1; first_cpu = cpu + 1; } } static inline boolean update_timer(timestamp here) { timestamp next = kernel_timers->next_expiry; if (!compare_and_swap_32(&kernel_timers->update, true, false)) return false; s64 delta = next - here; timestamp timeout = delta > (s64)kernel_timers->min ? MIN(delta, kernel_timers->max) : kernel_timers->min; sched_debug("set platform timer: delta %lx, timeout %lx\n", delta, timeout); current_cpu()->last_timer_update = next + timeout - delta; set_platform_timer(timeout); return true; } closure_function(0, 0, void, kernel_timers_service) { /* timer_service() should be reentrant, so we don't take a lock here */ kernel_timers->service_scheduled = false; timer_service(kernel_timers, now(CLOCK_ID_MONOTONIC_RAW)); } closure_function(0, 0, void, timer_interrupt_handler_fn) { schedule_timer_service(); } static inline void service_thunk_queue(queue q) { thunk t; context c; while ((t = dequeue(q)) != INVALID_ADDRESS) { c = context_from_closure(t); sched_debug(" run: %F state: %s context: %p\n", t, state_strings[current_cpu()->state], c); if (c) context_apply(c, t); else apply(t); } } static inline void service_async_1(queue q) { struct applied_async_1 aa; while (dequeue_n_irqsafe(q, (void **)&aa, sizeof(aa) / sizeof(u64))) { sched_debug(" run: %F arg0: 0x%lx\n", aa.a, aa.arg0); context c = context_from_closure(aa.a); if (c) context_apply_1(c, aa.a, aa.arg0); else apply(aa.a, aa.arg0); } } NOTRACE void __attribute__((noreturn)) runloop_internal(void) { cpuinfo ci = current_cpu(); disable_interrupts(); sched_debug("runloop from %s c: %d a1: %d b:%d r:%d t:%d\n", state_strings[ci->state], queue_length(ci->cpu_queue), queue_length(async_queue_1), queue_length(bhqueue), queue_length(runqueue), sched_queue_length(&ci->thread_queue)); ci->state = cpu_kernel; /* Make sure TLB entries are appropriately flushed before doing any work */ page_invalidate_flush(); retry: /* queue for cpu specific operations */ service_thunk_queue(ci->cpu_queue); /* bhqueue is for deferred operations, enqueued by interrupt handlers */ service_thunk_queue(bhqueue); /* serve deferred status_handlers, some of which may not return */ service_async_1(async_queue_1); service_thunk_queue(runqueue); /* should be a list of per-runloop checks - also low-pri background */ mm_service(); timestamp here = now(CLOCK_ID_MONOTONIC_RAW); boolean timer_updated = update_timer(here); if (!shutting_down) { sched_task t = sched_dequeue(&ci->thread_queue); if (t == INVALID_ADDRESS) { /* Try to steal a thread from an idle CPU (so that it doesn't * have to be woken up), and wake up CPUs that have a non-empty * thread queue). */ if (ci->id + 1 < total_processors) t = migrate_to_self(t, ci->id + 1, total_processors - ci->id - 1); if (ci->id > 0) t = migrate_to_self(t, 0, ci->id); if (t == INVALID_ADDRESS) { /* No threads found in idle CPUs: try to steal a thread from a * CPU that is currently running another thread. */ for (u64 cpu = ci->id + 1; ; cpu++) { if (cpu == total_processors) cpu = 0; if (cpu == ci->id) break; cpuinfo cpui = cpuinfo_from_id(cpu); if (cpui->state == cpu_user) { t = sched_dequeue(&cpui->thread_queue); if (t != INVALID_ADDRESS) { sched_debug("migrating thread from CPU %d to self\n", cpu); break; } } } } } else { /* Wake up idle CPUs that have a non-empty thread queue, and if our * thread queue is non-empty, migrate our threads to idle CPUs. */ if (ci->id + 1 < total_processors) migrate_from_self(ci, ci->id + 1, total_processors - ci->id - 1); if (ci->id > 0) migrate_from_self(ci, 0, ci->id); } if (t != INVALID_ADDRESS) { if (!timer_updated) { /* Before we schedule a thread on this CPU, we want to be sure that a timer will fire on this core within the interval kernel_timers->max into the future. Taking the place of a true time quantum per thread, this acts to prevent a thread from running for too long and starving out other threads. */ s64 timeout = ci->last_timer_update - here; if (kernel_timers->empty || (timeout > (s64)kernel_timers->max)) { sched_debug("setting CPU scheduler timer\n"); set_platform_timer(kernel_timers->max); ci->last_timer_update = here + kernel_timers->max; } } apply(t->t); } } /* We want to pick up items that were enqueued during this last pass, else runnable items may get stuck waiting for the next interrupt. Find cost of sleep / wakeup and consider spinning this check for that interval. */ if (queue_length(ci->cpu_queue) || queue_length(async_queue_1) || queue_length(bhqueue) || queue_length(runqueue) || (!shutting_down && !sched_queue_empty(&ci->thread_queue))) goto retry; kernel_sleep(); } /* non-inlined trampoline target */ NOTRACE void __attribute__((noreturn)) runloop_target(void) { runloop(); } closure_function(0, 0, void, global_shutdown) { machine_halt(); } void init_scheduler(heap h) { /* timer init */ kernel_timers = allocate_timerqueue(h, 0, "runloop"); assert(kernel_timers != INVALID_ADDRESS); kernel_timers->min = microseconds(RUNLOOP_TIMER_MIN_PERIOD_US); kernel_timers->max = microseconds(RUNLOOP_TIMER_MAX_PERIOD_US); kernel_timers->service = closure(h, kernel_timers_service); timer_interrupt_handler = closure(h, timer_interrupt_handler_fn); /* IPI init */ wakeup_vector = allocate_ipi_interrupt(); register_interrupt(wakeup_vector, ignore, "wakeup ipi"); shutdown_vector = allocate_ipi_interrupt(); register_interrupt(shutdown_vector, closure(h, global_shutdown), "shutdown ipi"); assert(wakeup_vector != INVALID_PHYSICAL); /* scheduling queues init */ bhqueue = allocate_queue(h, BHQUEUE_SIZE); runqueue = allocate_queue(h, RUNQUEUE_SIZE); async_queue_1 = allocate_queue(h, ASYNC_QUEUE_1_SIZE); shutting_down = false; } void init_scheduler_cpus(heap h) { idle_cpu_mask = allocate_bitmap(h, h, present_processors); assert(idle_cpu_mask != INVALID_ADDRESS); bitmap_alloc(idle_cpu_mask, present_processors); } static boolean sched_sort(void *a, void *b) { sched_task ta = a, tb = b; return (ta->runtime > tb->runtime); } boolean sched_queue_init(sched_queue sq, heap h) { sq->q = allocate_pqueue(h, sched_sort); if (sq->q == INVALID_ADDRESS) return false; sq->min_runtime = 0; spin_lock_init(&sq->lock); return true; } void sched_enqueue(sched_queue sq, sched_task task) { spin_lock(&sq->lock); sched_debug("sq %p, enqueuing task %p, runtime %T\n", sq, task, task->runtime); task->runtime += sq->min_runtime; pqueue_insert(sq->q, task); spin_unlock(&sq->lock); } sched_task sched_dequeue(sched_queue sq) { spin_lock(&sq->lock); sched_task task = pqueue_pop(sq->q); if (task != INVALID_ADDRESS) { sched_debug("sq %p, dequeued task %p, runtime %T\n", sq, task, task->runtime - sq->min_runtime); sq->min_runtime = task->runtime; task->runtime = 0; } spin_unlock(&sq->lock); return task; } u64 sched_queue_length(sched_queue sq) { return pqueue_length(sq->q); }
5f43374cf5426b6da53fd693dd49b66a1ef50169
88ae8695987ada722184307301e221e1ba3cc2fa
/native_client/tests/glibc_syscall_wrappers/test_fstat.c
05c7c746f9bbf7bc356c12ef628ce98f7ccab728
[ "BSD-3-Clause", "Zlib", "Classpath-exception-2.0", "BSD-Source-Code", "LZMA-exception", "LicenseRef-scancode-unicode", "LGPL-3.0-only", "LGPL-2.0-or-later", "LicenseRef-scancode-philippe-de-muyter", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-intel-osl-1993", "HPND-sell-variant", "ICU", "LicenseRef-scancode-protobuf", "bzip2-1.0.6", "Spencer-94", "NCSA", "LicenseRef-scancode-nilsson-historical", "CC0-1.0", "LicenseRef-scancode-proprietary-license", "LGPL-2.1-only", "LicenseRef-scancode-other-copyleft", "GPL-2.0-or-later", "NTP", "GPL-2.0-only", "LicenseRef-scancode-other-permissive", "GPL-3.0-only", "GFDL-1.1-only", "W3C", "LicenseRef-scancode-python-cwi", "GCC-exception-3.1", "BSL-1.0", "Python-2.0", "GPL-1.0-or-later", "LGPL-2.1-or-later", "LicenseRef-scancode-unknown-license-reference", "CPL-1.0", "GFDL-1.1-or-later", "W3C-19980720", "LGPL-2.0-only", "LicenseRef-scancode-amd-historical", "LicenseRef-scancode-ietf", "SAX-PD", "LicenseRef-scancode-x11-hanson", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "dtoa", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "PSF-2.0", "LicenseRef-scancode-newlib-historical", "LicenseRef-scancode-generic-exception", "SMLNJ", "HP-1986", "LicenseRef-scancode-free-unknown", "SunPro", "MPL-1.1" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C
false
false
795
c
test_fstat.c
/* * Copyright 2010 The Native Client Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include <assert.h> #include <errno.h> #include <stddef.h> #include <stdio.h> #include <sys/stat.h> int main(int argc, char** argv) { struct stat st; FILE *file; int fd; if (2 != argc) { printf("Usage: sel_ldr test_fstat.nexe test_stat_data\n"); return 1; } file = fopen(argv[1], "r"); if (file == NULL) return 2; fd = fileno(file); errno = 0; if (fstat(fd, &st)) return 3; printf("%d\n", (int)st.st_size); if (errno != 0) return 4; if (fclose(file)) return 5; errno = 0; if (fstat(-1, &st) != -1) return 6; if (errno != EBADF) return 7; return 0; }
46ffef02b3ba8dfe59004e665ba893b84248cb6f
ca4c4631f3d47a90b8415bbe70dbc7cae18c071e
/unit_tests/matrix_free/UnitTestConductionUpdate.C
fa0057f5ed2be43193253193acf136556b2730eb
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
Exawind/nalu-wind
5765078c445d379ea952d2b25a01f5ff490837a6
722cd7757a412c9306645963808047824c312a17
refs/heads/master
2023-08-16T17:44:54.744168
2023-08-15T18:05:23
2023-08-15T18:05:23
132,016,365
111
87
NOASSERTION
2023-09-14T04:02:07
2018-05-03T15:39:32
C
UTF-8
C
false
false
11,304
c
UnitTestConductionUpdate.C
// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC // (NTESS), National Renewable Energy Laboratory, University of Texas Austin, // Northwest Research Associates. Under the terms of Contract DE-NA0003525 // with NTESS, the U.S. Government retains certain rights in this software. // // This software is released under the BSD 3-clause license. See LICENSE file // for more details. // #include "StkConductionFixture.h" #include "matrix_free/ConductionFields.h" #include "matrix_free/ConductionInfo.h" #include "matrix_free/ConductionUpdate.h" #include "matrix_free/EquationUpdate.h" #include "gtest/gtest.h" #include "Kokkos_Core.hpp" #include "Teuchos_ParameterList.hpp" #include "Teuchos_RCP.hpp" #include "stk_mesh/base/BulkData.hpp" #include "stk_mesh/base/Bucket.hpp" #include "stk_mesh/base/BulkData.hpp" #include "stk_mesh/base/Field.hpp" #include "stk_mesh/base/FieldBase.hpp" #include "stk_mesh/base/FieldState.hpp" #include "stk_mesh/base/FieldTraits.hpp" #include "stk_mesh/base/MetaData.hpp" #include "stk_mesh/base/Ngp.hpp" #include "stk_mesh/base/NgpField.hpp" #include "stk_mesh/base/NgpForEachEntity.hpp" #include "stk_mesh/base/Selector.hpp" #include "stk_mesh/base/Types.hpp" #include "stk_topology/topology.hpp" #include <math.h> #include <algorithm> #include <limits> #include <memory> namespace sierra { namespace nalu { namespace matrix_free { namespace test_simulation { constexpr int nx = 40; constexpr double scale = M_PI; constexpr double rhocp = 1000; constexpr double kappa = 4.5e-2; constexpr double smallish = 1.0e-4; constexpr int kx = 2; constexpr int ky = 3; constexpr int kz = 4; void field_add( const stk::mesh::NgpMesh& mesh, const stk::mesh::Selector& active, const stk::mesh::NgpField<double>& x, stk::mesh::NgpField<double>& y) { stk::mesh::for_each_entity_run( mesh, stk::topology::NODE_RANK, active, KOKKOS_LAMBDA(const stk::mesh::FastMeshIndex& mi) { y.get(mi, 0) += x.get(mi, 0); }); y.modify_on_device(); } stk::mesh::NgpField<double>& get_ngp_field( const stk::mesh::MetaData& meta, std::string name, stk::mesh::FieldState state = stk::mesh::StateNP1) { ThrowAssert(meta.get_field(stk::topology::NODE_RANK, name)); ThrowAssert( meta.get_field(stk::topology::NODE_RANK, name)->field_state(state)); return stk::mesh::get_updated_ngp_field<double>( *meta.get_field(stk::topology::NODE_RANK, name)->field_state(state)); } double initial_condition(double x, double y, double z) { constexpr double xshift = (kx % 2 == 1) ? M_PI_2 : 0; constexpr double yshift = (ky % 2 == 1) ? M_PI_2 : 0; constexpr double zshift = (kz % 2 == 1) ? M_PI_2 : 0; return std::cos(kx * x + xshift) * std::cos(ky * y + yshift) * std::cos(kz * z + zshift); } double solution(double t, double x, double y, double z) { return std::exp(-(kx * kx + ky * ky + kz * kz) * kappa / rhocp * t) * initial_condition(x, y, z); } class ConductionSimulationFixture : public ::ConductionFixture { protected: ConductionSimulationFixture() : ConductionFixture(nx, scale), update(make_updater<ConductionUpdate>( order, bulk, Teuchos::ParameterList{}, meta.universal_part(), stk::mesh::Selector{}, stk::mesh::Selector{})) { auto& coordField = coordinate_field(); for (auto ib : bulk.get_buckets(stk::topology::NODE_RANK, meta.universal_part())) { for (auto node : *ib) { const double x = stk::mesh::field_data(coordField, node)[0]; const double y = stk::mesh::field_data(coordField, node)[1]; const double z = stk::mesh::field_data(coordField, node)[2]; *stk::mesh::field_data( q_field.field_of_state(stk::mesh::StateNP1), node) = initial_condition(x, y, z); *stk::mesh::field_data( q_field.field_of_state(stk::mesh::StateN), node) = initial_condition(x, y, z); *stk::mesh::field_data( q_field.field_of_state(stk::mesh::StateNM1), node) = initial_condition(x, y, z); *stk::mesh::field_data(qtmp_field, node) = 0; *stk::mesh::field_data(alpha_field, node) = rhocp; *stk::mesh::field_data(lambda_field, node) = kappa; } } } double run_simulation(double dt, double final_time) { double time = 0; Kokkos::Array<double, 3> gammas = {{+1 / dt, -1 / dt, 0}}; update->initialize(); update->compute_preconditioner(gammas[0]); update->compute_update( gammas, get_ngp_field(meta, conduction_info::q_name)); update->update_solution_fields(); time += dt; gammas = {{1.5 / dt, -2 / dt, 0.5 / dt}}; update->compute_preconditioner(gammas[0]); while (time < final_time - dt / 2) { bulk.update_field_data_states(); get_ngp_field(meta, conduction_info::q_name, stk::mesh::StateNM1) .swap(get_ngp_field(meta, conduction_info::q_name, stk::mesh::StateN)); get_ngp_field(meta, conduction_info::q_name, stk::mesh::StateN) .swap( get_ngp_field(meta, conduction_info::q_name, stk::mesh::StateNP1)); update->swap_states(); update->predict_state(); update->compute_update( gammas, get_ngp_field(meta, conduction_info::q_name)); update->update_solution_fields(); time += dt; } get_ngp_field(meta, conduction_info::q_name, stk::mesh::StateNP1) .sync_to_host(); return time; } double max_value() { auto& qp1 = q_field.field_of_state(stk::mesh::StateNP1); double max_val = std::numeric_limits<double>::lowest(); for (auto ib : bulk.get_buckets(stk::topology::NODE_RANK, meta.universal_part())) { for (auto node : *ib) { max_val = std::max(std::abs(*stk::mesh::field_data(qp1, node)), max_val); } } return max_val; } double error(double time) { auto& coords = coordinate_field(); auto& qp1 = q_field.field_of_state(stk::mesh::StateNP1); double max_error = std::numeric_limits<double>::lowest(); for (auto ib : bulk.get_buckets(stk::topology::NODE_RANK, meta.universal_part())) { for (auto node : *ib) { const double x = stk::mesh::field_data(coords, node)[0]; const double y = stk::mesh::field_data(coords, node)[1]; const double z = stk::mesh::field_data(coords, node)[2]; const double val = *stk::mesh::field_data(qp1, node); max_error = std::max(max_error, val - solution(time, x, y, z)); } } return max_error; } std::unique_ptr<EquationUpdate> update; }; TEST_F(ConductionSimulationFixture, heat_conduction_reduces_peak_value) { auto max_val_pre = max_value(); run_simulation(5e-3, 1.5e-2); auto max_val_post = max_value(); ASSERT_GT(max_val_pre, max_val_post); } TEST_F(ConductionSimulationFixture, difference_from_exact_solution_is_smallish) { const double dt = 5.0e-5 * rhocp / kappa; const double final_time = run_simulation(dt, 3 * dt); ASSERT_LT(error(final_time), smallish); } class QuadraticElementConductionSimulationFixture : public ::ConductionFixtureP2 { protected: QuadraticElementConductionSimulationFixture() : ConductionFixtureP2(nx / order, scale), update(make_updater<ConductionUpdate>( order, bulk, Teuchos::ParameterList{}, meta.universal_part(), stk::mesh::Selector{}, stk::mesh::Selector{})) { auto& coordField = coordinate_field(); for (auto ib : bulk.get_buckets(stk::topology::NODE_RANK, meta.universal_part())) { for (auto node : *ib) { const double x = stk::mesh::field_data(coordField, node)[0]; const double y = stk::mesh::field_data(coordField, node)[1]; const double z = stk::mesh::field_data(coordField, node)[2]; *stk::mesh::field_data( q_field.field_of_state(stk::mesh::StateNP1), node) = initial_condition(x, y, z); *stk::mesh::field_data( q_field.field_of_state(stk::mesh::StateN), node) = initial_condition(x, y, z); *stk::mesh::field_data( q_field.field_of_state(stk::mesh::StateNM1), node) = initial_condition(x, y, z); *stk::mesh::field_data(qtmp_field, node) = 0; *stk::mesh::field_data(alpha_field, node) = rhocp; *stk::mesh::field_data(lambda_field, node) = kappa; } } } double max_value() { auto& qp1 = q_field.field_of_state(stk::mesh::StateNP1); double max_val = std::numeric_limits<double>::lowest(); for (auto ib : bulk.get_buckets(stk::topology::NODE_RANK, meta.universal_part())) { for (auto node : *ib) { max_val = std::max(std::abs(*stk::mesh::field_data(qp1, node)), max_val); } } return max_val; } double error(double time) { auto& coords = coordinate_field(); auto& qp1 = q_field.field_of_state(stk::mesh::StateNP1); double max_error = std::numeric_limits<double>::lowest(); for (auto ib : bulk.get_buckets(stk::topology::NODE_RANK, meta.universal_part())) { for (auto node : *ib) { const double x = stk::mesh::field_data(coords, node)[0]; const double y = stk::mesh::field_data(coords, node)[1]; const double z = stk::mesh::field_data(coords, node)[2]; const double val = *stk::mesh::field_data(qp1, node); max_error = std::max(max_error, val - solution(time, x, y, z)); } } return max_error; } double run_simulation(double dt, double final_time) { double time = 0; Kokkos::Array<double, 3> gammas = {{+1 / dt, -1 / dt, 0}}; update->initialize(); update->compute_preconditioner(gammas[0]); update->compute_update( gammas, get_ngp_field(meta, conduction_info::q_name)); update->update_solution_fields(); time += dt; gammas = {{1.5 / dt, -2 / dt, 0.5 / dt}}; update->compute_preconditioner(gammas[0]); while (time < final_time - dt / 2) { bulk.update_field_data_states(); get_ngp_field(meta, conduction_info::q_name, stk::mesh::StateNM1) .swap(get_ngp_field(meta, conduction_info::q_name, stk::mesh::StateN)); get_ngp_field(meta, conduction_info::q_name, stk::mesh::StateN) .swap( get_ngp_field(meta, conduction_info::q_name, stk::mesh::StateNP1)); update->swap_states(); update->predict_state(); update->compute_update( gammas, get_ngp_field(meta, conduction_info::q_name)); update->update_solution_fields(); time += dt; } get_ngp_field(meta, conduction_info::q_name, stk::mesh::StateNP1) .sync_to_host(); return time; } std::unique_ptr<EquationUpdate> update; }; TEST_F( QuadraticElementConductionSimulationFixture, heat_conduction_reduces_peak_value) { auto max_val_pre = max_value(); run_simulation(5e-3, 1.5e-2); auto max_val_post = max_value(); ASSERT_GT(max_val_pre, max_val_post); } TEST_F( QuadraticElementConductionSimulationFixture, difference_from_exact_solution_is_smallish) { const double dt = 5.0e-5 * rhocp / kappa; const double final_time = run_simulation(dt, 6 * dt); ASSERT_LT(error(final_time), smallish); } } // namespace test_simulation } // namespace matrix_free } // namespace nalu } // namespace sierra
244bef756123c8cc4ed7571045732b70ebc0b046
7664f318ed04bd0680f3d82321c18896e3ef6ad5
/src/overlays/actors/ovl_Bg_Gnd_Nisekabe/z_bg_gnd_nisekabe.h
32da8fa08554ef6bd35496b7169a50548dbe8578
[]
no_license
zeldaret/oot
9c80ce17f2d8fd61514b375f92ee4739b5ce9d4e
2875ab4fcf5c5f81d76353d1ee0024c9ea8d0b23
refs/heads/master
2023-08-29T05:29:31.356427
2023-08-28T22:48:52
2023-08-28T22:48:52
247,875,738
4,401
802
null
2023-09-14T13:34:38
2020-03-17T04:02:19
C
UTF-8
C
false
false
225
h
z_bg_gnd_nisekabe.h
#ifndef Z_BG_GND_NISEKABE_H #define Z_BG_GND_NISEKABE_H #include "ultra64.h" #include "global.h" struct BgGndNisekabe; typedef struct BgGndNisekabe { /* 0x0000 */ Actor actor; } BgGndNisekabe; // size = 0x014C #endif
a5f370ba073fb1c5bd845fb92e5f98f6f9e46c00
5ab69c8644a936a3d9dec1669a86c7369c911bf8
/arch/platform/gecko/brd4166a/config/sl_uartdrv_usart_vcom_config.h
4dfd5e6180f61c96bd2c7ebf29201a648964e4bc
[ "BSD-3-Clause" ]
permissive
contiki-ng/contiki-ng
393d36f68b98f5ee3544ea32502cf662ffb2fe9f
31fcaadf7a0dc8ceea07f438cd69db73174879e6
refs/heads/develop
2023-09-01T20:10:30.000765
2023-09-01T14:37:12
2023-09-01T14:37:12
91,191,972
1,242
788
BSD-3-Clause
2023-09-14T19:08:35
2017-05-13T17:37:59
C
UTF-8
C
false
false
3,929
h
sl_uartdrv_usart_vcom_config.h
/***************************************************************************//** * @file * @brief UARTDRV_USART Config ******************************************************************************* * # License * <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b> ******************************************************************************* * * The licensor of this software is Silicon Laboratories Inc. Your use of this * software is governed by the terms of Silicon Labs Master Software License * Agreement (MSLA) available at * www.silabs.com/about-us/legal/master-software-license-agreement. This * software is distributed to you in Source Code format and is governed by the * sections of the MSLA applicable to Source Code. * ******************************************************************************/ #ifndef SL_UARTDRV_USART_VCOM_CONFIG_H #define SL_UARTDRV_USART_VCOM_CONFIG_H #include "em_usart.h" // <<< Use Configuration Wizard in Context Menu >>> // <h> UART settings // <o SL_UARTDRV_USART_VCOM_BAUDRATE> Baud rate // <i> Default: 115200 #define SL_UARTDRV_USART_VCOM_BAUDRATE 115200 // <o SL_UARTDRV_USART_VCOM_PARITY> Parity mode to use // <usartNoParity=> No Parity // <usartEvenParity=> Even parity // <usartOddParity=> Odd parity // <i> Default: usartNoParity #define SL_UARTDRV_USART_VCOM_PARITY usartNoParity // <o SL_UARTDRV_USART_VCOM_STOP_BITS> Number of stop bits to use. // <usartStopbits0p5=> 0.5 stop bits // <usartStopbits1=> 1 stop bits // <usartStopbits1p5=> 1.5 stop bits // <usartStopbits2=> 2 stop bits // <i> Default: usartStopbits1 #define SL_UARTDRV_USART_VCOM_STOP_BITS usartStopbits1 // <o SL_UARTDRV_USART_VCOM_FLOW_CONTROL_TYPE> Flow control method // <uartdrvFlowControlNone=> None // <uartdrvFlowControlSw=> Software XON/XOFF // <uartdrvFlowControlHw=> nRTS/nCTS hardware handshake // <uartdrvFlowControlHwUart=> UART peripheral controls nRTS/nCTS // <i> Default: uartdrvFlowControlHw #define SL_UARTDRV_USART_VCOM_FLOW_CONTROL_TYPE uartdrvFlowControlSw // <o SL_UARTDRV_USART_VCOM_OVERSAMPLING> Oversampling selection // <usartOVS16=> 16x oversampling // <usartOVS8=> 8x oversampling // <usartOVS6=> 6x oversampling // <usartOVS4=> 4x oversampling // <i> Default: usartOVS16 #define SL_UARTDRV_USART_VCOM_OVERSAMPLING usartOVS4 // <o SL_UARTDRV_USART_VCOM_MVDIS> Majority vote disable for 16x, 8x and 6x oversampling modes // <true=> True // <false=> False #define SL_UARTDRV_USART_VCOM_MVDIS false // <o SL_UARTDRV_USART_VCOM_RX_BUFFER_SIZE> Size of the receive operation queue // <i> Default: 6 #define SL_UARTDRV_USART_VCOM_RX_BUFFER_SIZE 6 // <o SL_UARTDRV_USART_VCOM_TX_BUFFER_SIZE> Size of the transmit operation queue // <i> Default: 6 #define SL_UARTDRV_USART_VCOM_TX_BUFFER_SIZE 6 // </h> // <<< end of configuration section >>> // <<< sl:start pin_tool >>> // <usart signal=TX,RX,(CTS),(RTS)> SL_UARTDRV_USART_VCOM // $[USART_SL_UARTDRV_USART_VCOM] #define SL_UARTDRV_USART_VCOM_PERIPHERAL USART0 #define SL_UARTDRV_USART_VCOM_PERIPHERAL_NO 0 // USART0 TX on PA0 #define SL_UARTDRV_USART_VCOM_TX_PORT gpioPortA #define SL_UARTDRV_USART_VCOM_TX_PIN 0 #define SL_UARTDRV_USART_VCOM_TX_LOC 0 // USART0 RX on PA1 #define SL_UARTDRV_USART_VCOM_RX_PORT gpioPortA #define SL_UARTDRV_USART_VCOM_RX_PIN 1 #define SL_UARTDRV_USART_VCOM_RX_LOC 0 // USART0 CTS on PA2 #define SL_UARTDRV_USART_VCOM_CTS_PORT gpioPortA #define SL_UARTDRV_USART_VCOM_CTS_PIN 2 #define SL_UARTDRV_USART_VCOM_CTS_LOC 30 // USART0 RTS on PA3 #define SL_UARTDRV_USART_VCOM_RTS_PORT gpioPortA #define SL_UARTDRV_USART_VCOM_RTS_PIN 3 #define SL_UARTDRV_USART_VCOM_RTS_LOC 30 // [USART_SL_UARTDRV_USART_VCOM]$ // <<< sl:end pin_tool >>> #endif // SL_UARTDRV_USART_VCOM_CONFIG_H
e270f7931816087ce3178b9b6f46a9c62ebe30e4
0744dcc5394cebf57ebcba343747af6871b67017
/os/kernel/task/task_setup.c
3a24858f0c99c5c763b4ebdb199b75f1964e546c
[ "GPL-1.0-or-later", "BSD-3-Clause", "ISC", "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive", "Apache-2.0" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C
false
false
23,402
c
task_setup.c
/**************************************************************************** * * Copyright 2016 Samsung Electronics All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * 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. * ****************************************************************************/ /**************************************************************************** * kernel/task/task_setup.c * * Copyright (C) 2007-2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <tinyara/config.h> #include <sys/types.h> #include <stdint.h> #include <sched.h> #include <string.h> #include <errno.h> #include <debug.h> #include <tinyara/arch.h> #include <tinyara/ttrace.h> #include <tinyara/irq.h> #ifdef CONFIG_SCHED_CPULOAD #include <tinyara/clock.h> #endif #include "sched/sched.h" #include "pthread/pthread.h" #include "group/group.h" #include "task/task.h" #include "clock/clock.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /* This is an artificial limit to detect error conditions where an argv[] * list is not properly terminated. */ #define MAX_STACK_ARGS 256 /**************************************************************************** * Private Type Declarations ****************************************************************************/ /**************************************************************************** * Global Variables ****************************************************************************/ /**************************************************************************** * Private Variables ****************************************************************************/ /* This is the name for un-named tasks */ static const char g_noname[] = "<noname>"; /**************************************************************************** * Private Function Prototypes ****************************************************************************/ static int task_assignpid(FAR struct tcb_s *tcb); /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** * Name: task_assignpid * * Description: * This function assigns the next unique task ID to a task. * * Inputs: * tcb - TCB of task * * Return: * OK on success; ERROR on failure. * errno is set as EBUSY, if already CONFIG_MAX_TASKS are running in system * ****************************************************************************/ static int task_assignpid(FAR struct tcb_s *tcb) { pid_t next_pid; int hash_ndx; int tries; trace_begin(TTRACE_TAG_TASK, "task_assignpid"); /* Disable pre-emption. This should provide sufficient protection * for the following operation. */ (void)sched_lock(); /* We'll try every allowable pid */ for (tries = 0; tries < CONFIG_MAX_TASKS; tries++) { /* Get the next process ID candidate */ next_pid = ++g_lastpid; /* Verify that the next_pid is in the valid range */ #ifdef CONFIG_DEBUG_MM_HEAPINFO /* Last two values(INT16_MAX and INT16_MAX - 1) are used for heapinfo. So pid can be smaller than (INT16_MAX - 1). */ if (next_pid == (INT16_MAX - 1)) { g_lastpid = 1; next_pid = 1; } #else if (next_pid <= 0) { g_lastpid = 1; next_pid = 1; } #endif /* Get the hash_ndx associated with the next_pid */ hash_ndx = PIDHASH(next_pid); /* Check if there is a (potential) duplicate of this pid */ if (!g_pidhash[hash_ndx].tcb) { /* Assign this PID to the task */ g_pidhash[hash_ndx].tcb = tcb; g_pidhash[hash_ndx].pid = next_pid; #ifdef CONFIG_SCHED_CPULOAD int cpuload_idx; for (cpuload_idx = 0; cpuload_idx < SCHED_NCPULOAD; cpuload_idx++) { g_pidhash[hash_ndx].ticks[cpuload_idx] = 0; } #endif tcb->pid = next_pid; /* Increment the task count */ g_alive_taskcount++; (void)sched_unlock(); trace_end(TTRACE_TAG_TASK); return OK; } } /* If we get here, then the g_pidhash[] table is completely full. * We cannot allow another task to be started. */ (void)sched_unlock(); set_errno(EBUSY); trace_end(TTRACE_TAG_TASK); return ERROR; } /**************************************************************************** * Name: task_saveparent * * Description: * Save the task ID of the parent task in the child task's TCB and allocate * a child status structure to catch the child task's exit status. * * Parameters: * tcb - The TCB of the new, child task. * ttype - Type of the new thread: task, pthread, or kernel thread * * Returned Value: * None * * Assumptions: * The parent of the new task is the task at the head of the ready-to-run * list. * ****************************************************************************/ #ifdef CONFIG_SCHED_HAVE_PARENT static inline void task_saveparent(FAR struct tcb_s *tcb, uint8_t ttype) { FAR struct tcb_s *rtcb = this_task(); #if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_SCHED_CHILD_STATUS) DEBUGASSERT(tcb != NULL && tcb->group != NULL && rtcb->group != NULL); #else #endif #ifdef HAVE_GROUP_MEMBERS /* Save the ID of the parent tasks' task group in the child's task group. * Do nothing for pthreads. The parent and the child are both members of * the same task group. */ #ifndef CONFIG_DISABLE_PTHREAD if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_PTHREAD) #endif { /* This is a new task in a new task group, we have to copy the ID from * the parent's task group structure to child's task group. */ tcb->group->tg_pgid = rtcb->group->tg_gid; } #else DEBUGASSERT(tcb); #ifndef CONFIG_DISABLE_PTHREAD if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_PTHREAD) #endif { /* Save the parent task's ID in the child task's group. */ tcb->group->tg_ppid = rtcb->pid; } #endif #ifndef CONFIG_DISABLE_PTHREAD if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_PTHREAD) #endif { #ifdef CONFIG_SCHED_CHILD_STATUS /* Tasks can also suppress retention of their child status by applying * the SA_NOCLDWAIT flag with sigaction(). */ if ((rtcb->group->tg_flags && GROUP_FLAG_NOCLDWAIT) == 0) { FAR struct child_status_s *child; /* Make sure that there is not already a structure for this PID in the * parent TCB. There should not be. */ child = group_findchild(rtcb->group, tcb->pid); DEBUGASSERT(!child); if (!child) { /* Allocate a new status structure */ child = group_allocchild(); } /* Did we successfully find/allocate the child status structure? */ DEBUGASSERT(child); if (child) { /* Yes.. Initialize the structure */ child->ch_flags = ttype; child->ch_pid = tcb->pid; child->ch_status = 0; /* Add the entry into the TCB list of children */ group_addchild(rtcb->group, child); } } #else DEBUGASSERT(rtcb->group != NULL && rtcb->group->tg_nchildren < UINT16_MAX); rtcb->group->tg_nchildren++; #endif } } #else #define task_saveparent(tcb, ttype) #endif /**************************************************************************** * Name: task_dupdspace * * Description: * When a new task or thread is created from a PIC module, then that * module (probably) intends the task or thread to execute in the same * D-Space. This function will duplicate the D-Space for that purpose. * * Parameters: * tcb - The TCB of the new task. * * Returned Value: * None * * Assumptions: * The parent of the new task is the task at the head of the ready-to-run * list. * ****************************************************************************/ #ifdef CONFIG_PIC static inline void task_dupdspace(FAR struct tcb_s *tcb) { FAR struct tcb_s *rtcb = this_task(); if (rtcb->dspace != NULL) { /* Copy the D-Space structure reference and increment the reference * count on the memory. The D-Space memory will persist until the * last thread exits (see sched_releasetcb()). */ tcb->dspace = rtcb->dspace; tcb->dspace->crefs++; } } #else #define task_dupdspace(tcb) #endif /**************************************************************************** * Name: thread_schedsetup * * Description: * This functions initializes the common portions of the Task Control Block * (TCB) in preparation for starting a new thread. * * thread_schedsetup() is called from task_schedsetup() and * pthread_schedsetup(). * * Input Parameters: * tcb - Address of the new task's TCB * priority - Priority of the new task * start - Thread startup routine * entry - Thread user entry point * ttype - Type of the new thread: task, pthread, or kernel thread * * Return Value: * OK on success; ERROR on failure. * * This function can fail for two reasons. * 1) If requested priority is beyond the allowed range, errno = EINVAL * 2) If it is unable to assign a new, unique task ID to the TCB. errno = EBUSY * errno is set accodingly. * ****************************************************************************/ static int thread_schedsetup(FAR struct tcb_s *tcb, int priority, start_t start, CODE void *entry, uint8_t ttype) { int ret; #ifdef CONFIG_APP_BINARY_SEPARATION struct tcb_s *rtcb; #endif if (priority < SCHED_PRIORITY_MIN || priority > SCHED_PRIORITY_MAX) { set_errno(EINVAL); return ERROR; } trace_begin(TTRACE_TAG_TASK, "thread_schedsetup"); /* Assign a unique task ID to the task. */ ret = task_assignpid(tcb); if (ret == OK) { /* Save task priority and entry point in the TCB */ tcb->sched_priority = (uint8_t)priority; #ifdef CONFIG_PRIORITY_INHERITANCE tcb->base_priority = (uint8_t)priority; #endif tcb->start = start; tcb->entry.main = (main_t)entry; /* Save the thread type. This setting will be needed in * up_initial_state() is called. */ ttype &= TCB_FLAG_TTYPE_MASK; tcb->flags &= ~TCB_FLAG_TTYPE_MASK; tcb->flags |= ttype; #ifdef CONFIG_CANCELLATION_POINTS /* Set the deferred cancellation type */ tcb->flags |= TCB_FLAG_CANCEL_DEFERRED; #endif /* Save initial thread scheduling policy int the TCB */ #if CONFIG_RR_INTERVAL > 0 tcb->flags |= TCB_FLAG_ROUND_ROBIN; tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL); #else tcb->flags &= ~TCB_FLAG_ROUND_ROBIN; #endif /* Save the task ID of the parent task in the TCB and allocate * a child status structure. */ task_saveparent(tcb, ttype); /* exec(), pthread_create(), task_create(), and vfork() all * inherit the signal mask of the parent thread. */ #ifndef CONFIG_DISABLE_SIGNALS (void)sigprocmask(SIG_SETMASK, NULL, &tcb->sigprocmask); #endif /* Initialize the task state. It does not get a valid state * until it is activated. */ tcb->task_state = TSTATE_TASK_INVALID; /* Clone the parent tasks D-Space (if it was running PIC). This * must be done before calling up_initial_state() so that the * state setup will take the PIC address base into account. */ task_dupdspace(tcb); /* Initialize the processor-specific portion of the TCB */ up_initial_state(tcb); #ifdef CONFIG_APP_BINARY_SEPARATION /* Copy the parent task ram details to this task */ rtcb = this_task(); tcb->uspace = rtcb->uspace; tcb->uheap = rtcb->uheap; #ifdef CONFIG_SUPPORT_COMMON_BINARY tcb->app_id = rtcb->app_id; #endif /* Copy the MPU register values from parent to child task */ #ifdef CONFIG_ARM_MPU int i = 0; #ifdef CONFIG_OPTIMIZE_APP_RELOAD_TIME for (; i < MPU_REG_NUMBER * MPU_NUM_REGIONS; i += MPU_REG_NUMBER) #endif { tcb->mpu_regs[i + MPU_REG_RNR] = rtcb->mpu_regs[i + MPU_REG_RNR]; tcb->mpu_regs[i + MPU_REG_RBAR] = rtcb->mpu_regs[i + MPU_REG_RBAR]; tcb->mpu_regs[i + MPU_REG_RASR] = rtcb->mpu_regs[i + MPU_REG_RASR]; } #endif #endif tcb->fin_data = NO_FIN_DATA; /* Add the task to the inactive task list */ sched_lock(); dq_addfirst((FAR dq_entry_t *)tcb, (dq_queue_t *)&g_inactivetasks); tcb->task_state = TSTATE_TASK_INACTIVE; sched_unlock(); } trace_end(TTRACE_TAG_TASK); return ret; } /**************************************************************************** * Name: task_namesetup * * Description: * Assign the task name. * * Input Parameters: * tcb - Address of the new task's TCB * name - Name of the new task * * Return Value: * None * ****************************************************************************/ #if CONFIG_TASK_NAME_SIZE > 0 static void task_namesetup(FAR struct task_tcb_s *tcb, FAR const char *name) { /* Give a name to the unnamed tasks */ if (!name) { name = (FAR char *)g_noname; } /* Copy the name into the TCB */ strncpy(tcb->cmn.name, name, CONFIG_TASK_NAME_SIZE); tcb->cmn.name[CONFIG_TASK_NAME_SIZE] = '\0'; } #else #define task_namesetup(t, n) #endif /* CONFIG_TASK_NAME_SIZE */ /**************************************************************************** * Name: task_stackargsetup * * Description: * This functions is called only from task_argsetup() It will allocate * space on the new task's stack and will copy the argv[] array and all * strings to the task's stack where it is readily accessible to the * task. Data on the stack, on the other hand, is guaranteed to be * accessible no matter what privilege mode the task runs in. * * Input Parameters: * tcb - Address of the new task's TCB * argv - A pointer to an array of input parameters. The array should be * terminated with a NULL argv[] value. If no parameters are * required, argv may be NULL. * * Return Value: * Zero (OK) on success; a negated errno on failure. * ****************************************************************************/ static inline int task_stackargsetup(FAR struct task_tcb_s *tcb, FAR char *const argv[]) { FAR char **stackargv; FAR const char *name; FAR char *str; size_t strtablen; size_t argvlen; int nbytes; int argc; int i; /* Get the name string that we will use as the first argument */ #if CONFIG_TASK_NAME_SIZE > 0 name = tcb->cmn.name; #else name = (FAR const char *)g_noname; #endif /* CONFIG_TASK_NAME_SIZE */ /* Get the size of the task name (including the NUL terminator) */ strtablen = (strlen(name) + 1); /* Count the number of arguments and get the accumulated size of the * argument strings (including the null terminators). The argument count * does not include the task name in that will be in argv[0]. */ argc = 0; if (argv) { /* A NULL argument terminates the list */ while (argv[argc]) { /* Add the size of this argument (with NUL terminator). * Check each time if the accumulated size exceeds the * size of the allocated stack. */ strtablen += (strlen(argv[argc]) + 1); if (strtablen >= tcb->cmn.adj_stack_size) { return -ENAMETOOLONG; } /* Increment the number of args. Here is a sanity check to * prevent running away with an unterminated argv[] list. * MAX_STACK_ARGS should be sufficiently large that this never * happens in normal usage. */ if (++argc > MAX_STACK_ARGS) { return -E2BIG; } } } /* Allocate a stack frame to hold argv[] array and the strings. NOTE * that argc + 2 entries are needed: The number of arguments plus the * task name plus a NULL argv[] entry to terminate the list. */ argvlen = (argc + 2) * sizeof(FAR char *); stackargv = (FAR char **)up_stack_frame(&tcb->cmn, argvlen + strtablen); DEBUGASSERT(stackargv != NULL); if (stackargv == NULL) { return -ENOMEM; } /* Get the address of the string table that will lie immediately after * the argv[] array and mark it as a null string. */ str = (FAR char *)stackargv + argvlen; /* Copy the task name. Increment str to skip over the task name and its * NUL terminator in the string buffer. */ stackargv[0] = str; nbytes = strlen(name) + 1; strncpy(str, name, nbytes); str += nbytes; /* Copy each argument */ for (i = 0; i < argc; i++) { /* Save the pointer to the location in the string buffer and copy * the argument into the buffer. Increment str to skip over the * argument and its NUL terminator in the string buffer. */ stackargv[i + 1] = str; nbytes = strlen(argv[i]) + 1; strncpy(str, argv[i], nbytes); str += nbytes; } /* Put a terminator entry at the end of the argv[] array. Then save the * argv[] arry pointer in the TCB where it will be recovered later by * task_start(). */ stackargv[argc + 1] = NULL; tcb->argv = stackargv; return OK; } /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: task_schedsetup * * Description: * This functions initializes a Task Control Block (TCB) in preparation * for starting a new task. * * task_schedsetup() is called from task_init() and task_start(). * * Input Parameters: * tcb - Address of the new task's TCB * priority - Priority of the new task * start - Start-up function (probably task_start()) * main - Application start point of the new task * ttype - Type of the new thread: task or kernel thread * * Return Value: * OK on success; ERROR on failure. * * This function can fail for two reasons. * 1) If requested priority is beyond the allowed range, errno = EINVAL * 2) If it is unable to assign a new, unique task ID to the TCB. errno = EBUSY * errno is set accodingly. * ****************************************************************************/ int task_schedsetup(FAR struct task_tcb_s *tcb, int priority, start_t start, main_t main, uint8_t ttype) { int ret; /* Perform common thread setup */ ret = thread_schedsetup((FAR struct tcb_s *)tcb, priority, start, (CODE void *)main, ttype); if (ret == OK) { /* Save task restart priority */ tcb->init_priority = (uint8_t)priority; } return ret; } /**************************************************************************** * Name: pthread_schedsetup * * Description: * This functions initializes a Task Control Block (TCB) in preparation * for starting a new pthread. * * pthread_schedsetup() is called from pthread_create(), * * Input Parameters: * tcb - Address of the new task's TCB * priority - Priority of the new task * start - Start-up function (probably pthread_start()) * entry - Entry point of the new pthread * ttype - Type of the new thread: task, pthread, or kernel thread * * Return Value: * OK on success; ERROR on failure. * * This function can fail for two reasons. * 1) If requested priority is beyond the allowed range, errno = EINVAL * 2) If it is unable to assign a new, unique task ID to the TCB. errno = EBUSY * errno is set accodingly. * ****************************************************************************/ #ifndef CONFIG_DISABLE_PTHREAD int pthread_schedsetup(FAR struct pthread_tcb_s *tcb, int priority, start_t start, pthread_startroutine_t entry) { /* Perform common thread setup */ return thread_schedsetup((FAR struct tcb_s *)tcb, priority, start, (CODE void *)entry, TCB_FLAG_TTYPE_PTHREAD); } #endif /**************************************************************************** * Name: task_argsetup * * Description: * This functions sets up parameters in the Task Control Block (TCB) in * preparation for starting a new thread. * * task_argsetup() is called only from task_init() and task_start() to * create a new task. In the "normal" case, the argv[] array is a * structure in the TCB, the arguments are cloned via strdup. * * In the kernel build case, the argv[] array and all strings are copied * to the task's stack. This is done because the TCB (and kernel allocated * strings) are only accessible in kernel-mode. Data on the stack, on the * other hand, is guaranteed to be accessible no matter what mode the * task runs in. * * Input Parameters: * tcb - Address of the new task's TCB * name - Name of the new task (not used) * argv - A pointer to an array of input parameters. * The array should be terminated with a NULL argv[] value. * If no parameters are required, argv may be NULL. * * Return Value: * OK * ****************************************************************************/ int task_argsetup(FAR struct task_tcb_s *tcb, FAR const char *name, FAR char *const argv[]) { /* Setup the task name */ task_namesetup(tcb, name); /* Copy the argv[] array and all strings are to the task's stack. Data on * the stack is guaranteed to be accessible by the ask no matter what * privilege mode the task runs in. */ return task_stackargsetup(tcb, argv); }
c6fb0b205ffaec9bfb985287146386807e5acf2a
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/devel/xxgdb/files/patch-signals.c
be9783cfec226369b222f2b970e7f59030eec40b
[ "BSD-2-Clause" ]
permissive
freebsd/freebsd-ports
86f2e89d43913412c4f6b2be3e255bc0945eac12
605a2983f245ac63f5420e023e7dce56898ad801
refs/heads/main
2023-08-30T21:46:28.720924
2023-08-30T19:33:44
2023-08-30T19:33:44
1,803,961
916
918
NOASSERTION
2023-09-08T04:06:26
2011-05-26T11:15:35
null
UTF-8
C
false
false
579
c
patch-signals.c
--- signals.c.orig 1995-04-06 16:25:04 UTC +++ signals.c @@ -93,7 +93,7 @@ kill_handler(sig) static void quit_handler(int sig) { int pid; -#ifdef SYSV +#if defined(SYSV) || defined(__FreeBSD__) int status; #else union wait status; @@ -102,7 +102,7 @@ static void quit_handler(int sig) /* wait for the child to report its status; if the child has died, * exit gracefully. */ -#ifdef SYSV +#if defined(SYSV) || defined(__FreeBSD__) #if 1 /* instead of ifdef SVR4 */ pid = waitpid((pid_t)0, &status, WNOHANG|WUNTRACED); /* (MJH) */ #else
8c67173b70cf9e91955a27d6a93e0775719be7b4
b71097386a6da0e3ca65f19a1906f0ebe11eac18
/lib/ltrcc.c
fda91c0c5d6280c81d83bccd5999d17c9a1e863b
[ "BSD-3-Clause" ]
permissive
hroptatyr/dateutils
0584063e4a35c511ad3600c27efb2f4214af24c6
c57828809a018061147bc806a058aa4c4b9c449a
refs/heads/master
2023-09-05T20:26:30.356886
2023-07-05T12:19:20
2023-07-05T12:19:20
2,341,061
517
44
NOASSERTION
2023-06-26T12:04:46
2011-09-07T11:19:46
C
UTF-8
C
false
false
9,437
c
ltrcc.c
/*** ltrcc.c -- leapseconds materialiser * * Copyright (C) 2012-2022 Sebastian Freundt * * Author: Sebastian Freundt <freundt@ga-group.nl> * * This file is part of dateutils. * * 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 author nor the names of any contributors * may 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 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. * ***/ #if defined HAVE_CONFIG_H # include "config.h" #endif /* HAVE_CONFIG_H */ #include <unistd.h> #include <stdlib.h> #include <stdint.h> #if defined HAVE_SYS_STDINT_H # include <sys/stdint.h> #endif /* HAVE_SYS_STDINT_H */ #include <stdio.h> #include <stdarg.h> #include <string.h> #include "leaps.h" #include "date-core.h" #include "time-core.h" #include "nifty.h" #include "version.c" static __attribute__((const)) unsigned long int ntp_to_unix_epoch(unsigned long int x) { return x - 25567U * 86400U; } #define PROLOGUE (-1UL) #define EPILOGUE (0UL) static int pr_line_corr(const char *line, size_t llen, va_list UNUSED(vap)) { static unsigned long int cor; char *sp, *ep; if (llen == PROLOGUE) { /* prologue */ fprintf(stdout, "\ const int32_t %s[] = {\n\ 10,\n", line); return 0; } else if (llen == EPILOGUE) { fprintf(stdout, "\ %ld\n\ };\n", cor); cor = 0; return 0; } else if (line == NULL) { /* grrrr */ return -1; } else if (line[0] == '#') { /* comment line */ return 0; } else if (line[0] == '\n') { /* empty line */ return 0; } /* otherwise process */ if ((sp = memchr(line, '\t', llen)) == NULL) { return -1; } else if ((ep = NULL, cor = strtoul(++sp, &ep, 10), ep == NULL || cor == ULONG_MAX)) { return -1; } /* output the correction then */ fprintf(stdout, "\t%ld,\n", cor); return 0; } static int pr_line_d(const char *line, size_t llen, va_list vap) { static unsigned long int cor; struct dt_d_s d; dt_dtyp_t typ; unsigned long int val; int colp; char *ep; /* extract type from inner list */ typ = va_arg(vap, dt_dtyp_t); colp = va_arg(vap, int); if (llen == PROLOGUE) { /* prologue */ if (!colp) { fprintf(stdout, "\ const struct zleap_s %s[] = {\n\ {0x00U/* 0 */, 0},\n", line); } else { fprintf(stdout, "\ const uint32_t %s[] = {\n\ 0x00U/* 0 */,\n", line); } return 0; } else if (llen == EPILOGUE) { /* epilogue */ if (!colp) { fprintf(stdout, "\ {UINT32_MAX, %li}\n\ };\n", cor); } else { fputs("\ UINT32_MAX\n\ };\n", stdout); } cor = 0; return 0; } else if (line == NULL) { /* something's fucked */ return -1; } else if (line[0] == '#') { /* comment line */ return 0; } else if (line[0] == '\n') { /* empty line */ return 0; } /* otherwise process */ if ((ep = NULL, val = strtoul(line, &ep, 10), ep == NULL || val == ULONG_MAX)) { return -1; } /* fix up and convert to target type */ d = (struct dt_d_s){DT_DAISY, .daisy = val / 86400 + 109207}; d = dt_dconv(typ, d); if (!colp) { if ((cor = strtoul(ep, &ep, 10), ep == NULL || val == ULONG_MAX)) { return -1; } /* just output the line then */ fprintf(stdout, "\t{0x%xU/* %i */, %li},\n", d.u, (int32_t)d.u, cor); } else { fprintf(stdout, "\t0x%xU/* %i */,\n", d.u, (int32_t)d.u); } return 0; } static int pr_line_dt(const char *line, size_t llen, va_list vap) { static unsigned long int cor; dt_dtyp_t __attribute__((unused)) typ; unsigned long int val; int colp; char *ep; /* extract type from inner list */ typ = va_arg(vap, dt_dtyp_t); colp = va_arg(vap, int); if (llen == PROLOGUE) { /* prologue */ if (!colp) { fprintf(stdout, "\ const struct zleap_s %s[] = {\n\ {INT32_MIN, 10},\n", line); } else { fprintf(stdout, "\ const int32_t %s[] = {\n\ INT32_MIN,\n", line); } return 0; } else if (llen == EPILOGUE) { /* epilogue */ if (!colp) { fprintf(stdout, "\ {INT32_MAX, %li}\n\ };\n", cor); } else { fputs("\ INT32_MAX\n\ };\n", stdout); } cor = 0; return 0; } else if (line == NULL) { /* buggre */ return -1; } else if (line[0] == '#') { /* comment line */ return 0; } else if (line[0] == '\n') { /* empty line */ return 0; } /* otherwise process */ if ((ep = NULL, val = strtoul(line, &ep, 10), ep == NULL || val == ULONG_MAX)) { return -1; } /* fix up and convert to target type */ val--; val = ntp_to_unix_epoch(val); if (!colp) { if ((cor = strtoul(ep, &ep, 10), ep == NULL || cor == ULONG_MAX)) { return -1; } /* just output the line then */ fprintf(stdout, "\t{0x%lxU/* %li */, %li},\n", val, val, cor); } else { /* column-oriented mode */ fprintf(stdout, "\t0x%lxU/* %li */,\n", val, val); } return 0; } static int pr_line_t(const char *line, size_t llen, va_list vap) { static unsigned long int cor; struct dt_t_s t = {DT_TUNK}; dt_dtyp_t typ; int colp; char *ep; unsigned long int val; /* extract type from inner list */ typ = va_arg(vap, dt_dtyp_t); colp = va_arg(vap, int); /* column-oriented mode only */ if (!colp) { return 0; } if (llen == PROLOGUE) { /* prologue */ fprintf(stdout, "\ const uint32_t %s[] = {\n\ UINT32_MAX,\n", line); return 0; } else if (llen == EPILOGUE) { /* epilogue */ fputs("\ UINT32_MAX\n\ };\n", stdout); cor = 0; return 0; } else if (typ != (dt_dtyp_t)DT_HMS || !colp) { return 0; } else if (line == NULL) { /* do fuckall */ return -1; } else if (line[0] == '#') { /* comment line */ return 0; } else if (line[0] == '\n') { /* empty line */ return 0; } /* otherwise process */ if ((ep = NULL, val = strtoul(line, &ep, 10), ep == NULL || val == ULONG_MAX)) { return -1; } val--; t.hms.s = val % 60L; val /= 60L; t.hms.m = val % 60L; val /= 60L; t.hms.h = val % 24L; /* read correction */ if ((val = strtoul(ep, &ep, 10), ep == NULL || val == ULONG_MAX)) { return -1; } /* fix up and convert to target type */ with (uint32_t ual = t.hms.u24) { ual += val >= cor; fprintf(stdout, "\t0x%xU/* %u */,\n", ual, ual); cor = val; } return 0; } static int pr_file(FILE *fp, const char *var, int(*cb)(const char*, size_t, va_list), ...) { va_list vap; char *line = NULL; size_t len = 0; ssize_t nrd; /* prologue */ va_start(vap, cb); cb(var, PROLOGUE, vap); va_end(vap); /* main loop */ while ((nrd = getline(&line, &len, fp)) >= 0) { va_start(vap, cb); if (cb(line, nrd, vap) < 0) { fprintf(stderr, "line buggered: %s", line); } va_end(vap); } /* epilogue */ va_start(vap, cb); cb(var, EPILOGUE, vap); va_end(vap); /* standard epilogue */ fprintf(stdout, "\ const size_t n%s = countof(%s);\n\n", var, var); if (line != NULL) { free(line); } return 0; } static int col = 0; static int parse_file(const char *file) { FILE *fp; if ((fp = fopen(file, "r")) == NULL) { return -1; } fprintf(stdout, "\ /*** autogenerated by: ltrcc %s */\n\ \n\ #include <stdint.h>\n\ #include <limits.h>\n\ #include \"leaps.h\"\n\ #include \"leap-seconds.h\"\n\ \n\ #if !defined INCLUDED_ltrcc_generated_def_\n\ #define INCLUDED_ltrcc_generated_def_\n\ \n\ #if !defined countof\n\ # define countof(x) (sizeof(x) / sizeof(*x))\n\ #endif /* !countof */\n\ \n", file); if (col) { pr_file(fp, "leaps_corr", pr_line_corr); rewind(fp); } pr_file(fp, "leaps_ymd", pr_line_d, DT_YMD, col); rewind(fp); pr_file(fp, "leaps_ymcw", pr_line_d, DT_YMCW, col); rewind(fp); pr_file(fp, "leaps_d", pr_line_d, DT_DAISY, col); rewind(fp); pr_file(fp, "leaps_s", pr_line_dt, DT_YMD, col); rewind(fp); pr_file(fp, "leaps_hms", pr_line_t, DT_HMS, col); fputs("\ /* exported number of leap transitions */\n\ const size_t nleaps = countof(leaps_corr);\n\ \n\ #endif /* INCLUDED_ltrcc_generated_def_ */\n", stdout); return 0; } #include "ltrcc.yucc" int main(int argc, char *argv[]) { yuck_t argi[1U]; int rc = 0; if (yuck_parse(argi, argc, argv) < 0) { rc = 1; goto out; } else if (!argi->nargs) { fputs("LEAP-SECONDSS.LIST argument is mandatory\n", stderr); rc = 1; goto out; } /* assign params */ col = argi->column_oriented_flag; if (parse_file(argi->args[0U]) < 0) { perror("Cannot parse file"); rc = 1; } out: yuck_free(argi); return rc; } /* ltrcc.c ends here */
323ee5b5a644916c485e611aaf97c9447217a3fb
07327b5e8b2831b12352bf7c6426bfda60129da7
/Include/10.0.10240.0/km/wwan.h
e816a4094c7c80dc5011af3cc215dd242b262b9a
[]
no_license
tpn/winsdk-10
ca279df0fce03f92036e90fb04196d6282a264b7
9b69fd26ac0c7d0b83d378dba01080e93349c2ed
refs/heads/master
2021-01-10T01:56:18.586459
2018-02-19T21:26:31
2018-02-19T21:29:50
44,352,845
218
432
null
null
null
null
UTF-8
C
false
false
50,914
h
wwan.h
/*++ Copyright (c) 2007 Microsoft Corporation Module Name: wwan.h Abstract: Header file for WWAN structures Revision History: DATE DESCRIPTION ------------ ----------- 23-FEB-2007 V0.40 Driver Model Compliant 23-MAY-2007 V0.50 Driver Model Compliant 01-AUG-2007 V0.60 Driver Model Compliant 02-APR-2008 V1.00 Driver Model Compliant 15-FEB-2011 Incorporated device services 21-NOV-2011 V2.00 Driver Model Compliant 30-NOV-2012 V2.1 Driver Model Compliant --*/ #ifndef __WWAN_DECL__ #define __WWAN_DECL__ #if _MSC_VER >= 1200 #pragma warning(push) #endif #pragma warning(disable:4201) // nameless struct/union #define WWAN_ERROR_UNSUPPORTED_FIRMWARE 0xf0f0f000 #define WWAN_ERROR_COM_PORT_CONFLICT 0xf0f0f001 #define WWAN_ERROR_RESOURCE_CONFLICT_OTHER 0xf0f0ffff typedef ULONG WWAN_STATUS; #define WWAN_STATUS_SUCCESS STATUS_SUCCESS #define WWAN_STATUS_BUSY 0xC0040002 #define WWAN_STATUS_FAILURE 0xC0040003 #define WWAN_STATUS_SIM_NOT_INSERTED 0xC0040004 #define WWAN_STATUS_BAD_SIM 0xC0040005 #define WWAN_STATUS_PIN_REQUIRED 0xC0040006 #define WWAN_STATUS_PIN_DISABLED 0x40040007 #define WWAN_STATUS_NOT_REGISTERED 0x40040008 #define WWAN_STATUS_PROVIDERS_NOT_FOUND 0x40040009 #define WWAN_STATUS_NO_DEVICE_SUPPORT 0xC004000a #define WWAN_STATUS_PROVIDER_NOT_VISIBLE 0x4004000b #define WWAN_STATUS_DATA_CLASS_NOT_AVAILABLE 0x4004000c #define WWAN_STATUS_PACKET_SVC_DETACHED 0xC004000d #define WWAN_STATUS_MAX_ACTIVATED_CONTEXTS 0xC004000e #define WWAN_STATUS_NOT_INITIALIZED 0xC004000f #define WWAN_STATUS_VOICE_CALL_IN_PROGRESS 0x40040010 #define WWAN_STATUS_CONTEXT_NOT_ACTIVATED 0xC0040011 #define WWAN_STATUS_SERVICE_NOT_ACTIVATED 0xC0040012 #define WWAN_STATUS_INVALID_ACCESS_STRING 0xC0040013 #define WWAN_STATUS_INVALID_USER_NAME_PWD 0xC0040014 #define WWAN_STATUS_RADIO_POWER_OFF 0xC0040015 #define WWAN_STATUS_INVALID_PARAMETERS 0xC0040016 #define WWAN_STATUS_READ_FAILURE 0xC0040017 #define WWAN_STATUS_WRITE_FAILURE 0xC0040018 #define WWAN_STATUS_DENIED_POLICY 0xC0040019 #define WWAN_STATUS_INVALID_DEVICE_SERVICE_OPERATION 0xC004001a #define WWAN_STATUS_MORE_DATA 0xC004001b #define WWAN_STATUS_INTER_RESOURCE_CONFLICT 0xC004001c //SMS specific error codes #define WWAN_STATUS_SMS_OPERATION_NOT_ALLOWED 0xC0040100 #define WWAN_STATUS_SMS_MEMORY_FAILURE 0xC0040101 #define WWAN_STATUS_SMS_INVALID_MEMORY_INDEX 0xC0040102 #define WWAN_STATUS_SMS_UNKNOWN_SMSC_ADDRESS 0xC0040103 #define WWAN_STATUS_SMS_NETWORK_TIMEOUT 0xC0040104 #define WWAN_STATUS_SMS_MEMORY_FULL 0xC0040105 #define WWAN_STATUS_SMS_UNKNOWN_ERROR 0xC0040106 #define WWAN_STATUS_SMS_FILTER_NOT_SUPPORTED 0xC0040107 #define WWAN_STATUS_SMS_MORE_DATA 0x40040108 #define WWAN_STATUS_SMS_LANG_NOT_SUPPORTED 0xC0040109 #define WWAN_STATUS_SMS_ENCODING_NOT_SUPPORTED 0xC004010A #define WWAN_STATUS_SMS_FORMAT_NOT_SUPPORTED 0xC004010B //Authentication Algorithm specific error codes #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630 ) #define WWAN_STATUS_AUTH_INCORRECT_AUTN 0xC0040200 #define WWAN_STATUS_AUTH_SYNC_FAILURE 0xC0040201 #define WWAN_STATUS_AUTH_AMF_NOT_SET 0xC0040202 #endif typedef enum _WWAN_STRUCT_TYPE { WwanStructTN = 0, WwanStructContext, WwanStructProvider, WwanStructSmsPdu, WwanStructReserved0, WwanStructReserved1, WwanStructReserved2, WwanStructSmsCdma, WwanStructReserved3, WwanStructDeviceServiceEntry, WwanStructProvider2, WwanStructDeviceServiceGuid, WwanStructDeviceServiceCommandId, WwanStructCellularClass, WwanStructDeviceSlotMap, WwanStructUiccApplication, WwanStructRegisterAcquisitionOrder, WwanStructRegistrationState, WwanStructSignalState, WwanStructMax } WWAN_STRUCT_TYPE, *PWWAN_STRUCT_TYPE; typedef struct _WWAN_LIST_HEADER { WWAN_STRUCT_TYPE ElementType; ULONG ElementCount; } WWAN_LIST_HEADER, *PWWAN_LIST_HEADER; #define WWAN_MANUFACTURER_LEN 32 #define WWAN_MODEL_LEN 32 #define WWAN_FIRMWARE_LEN 32 #define WWAN_DEVICEID_LEN 18 #define WWAN_CUSTOM_DATA_CLASS_LEN 12 #define WWAN_CUSTOM_BAND_CLASS_LEN 20 #define WWAN_PROVIDERID_LEN 7 #define WWAN_PROVIDERNAME_LEN 21 #define WWAN_ROAMTEXT_LEN 64 #define WWAN_ACCESSSTRING_LEN 101 #define WWAN_USERNAME_LEN 256 #define WWAN_PASSWORD_LEN 256 #define WWAN_SUBSCRIBERID_LEN 16 #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630) // // Starting Win 8, we are changing the PIN length to 16 // #define WWAN_PIN_LEN 17 #else // // Win 7 // #define WWAN_PIN_LEN 12 #endif #define WWAN_SUBSCRIBERID_LEN_EX 19 #define DEFAULT_MIN_PIN_LENGTH 4 #define WWAN_SIMICCID_LEN 21 // // Starting with Blue, and MBIM Errata, the MSISDN (telephone number) length grows to 22 (23 with null termination) // #if ( _WIN32_WINNT >= _WIN32_WINNT_WINBLUE || NTDDI_VERSION >= NTDDI_WINBLUE || NDIS_SUPPORT_NDIS640 ) #define WWAN_TN_LEN 23 #else // // Win 8 and below // #define WWAN_TN_LEN 16 #endif #define WWAN_SCA_MAX_LEN 14 #define WWAN_SMS_ADDRESS_MAX_LEN 16 #define WWAN_SC_TIME_STAMP_MAX_LEN 20 #define WWAN_SMS_CDMA_ADDR_MAX_LEN 50 #define WWAN_SMS_CDMA_TIMESTAMP_MAX_LEN 20 #define WWAN_SMS_MSG_PDU_LEN 183 #define WWAN_SMS_RAW_PDU_LEN (WWAN_SMS_MSG_PDU_LEN - 12) #define WWAN_SMS_PDU_HEX_BUF_LEN (WWAN_SMS_MSG_PDU_LEN * 2) #define WWAN_CDMA_SHORT_MSG_SIZE_UNKNOWN 0 #define WWAN_CDMA_SHORT_MSG_SIZE_MAX 160 #define WWAN_SMS_CDMA_MAX_BUF_LEN 160 #define WWAN_SMS_CDMA_MAX_MSG_LEN WWAN_CDMA_SHORT_MSG_SIZE_MAX #define WWAN_USSD_STRING_LEN_MAX 160 #define WWAN_CDMA_DEFAULT_PROVIDER_ID (0) #define WWAN_AUTH_RAND_LEN 16 #define WWAN_AUTH_AUTN_LEN 16 #define WWAN_AUTH_SRES_LEN 4 #define WWAN_AUTH_KC_LEN 8 #define WWAN_AUTH_RES_MAX_LEN 16 #define WWAN_AUTH_IK_LEN 16 #define WWAN_AUTH_CK_LEN 16 #define WWAN_AUTH_AUTS_LEN 14 #define WWAN_AUTH_NETWORK_NAME_MAX_LEN 256 #define WWAN_UICC_APP_ID_MAX_LEN 16 #define WWAN_UICC_FILE_PATH_MAX_LEN 8 #define WWAN_EF_ACCESS_TYPES_LEN 4 #define WWAN_UICC_RECORD_DATA_MAX_LEN 256 typedef enum _WWAN_ASYNC_GETSET_TYPE { WwanAsyncGetDeviceCaps = 0, WwanAsyncGetReadyInfo, WwanAsyncGetRadioState, WwanAsyncSetRadioState, WwanAsyncGetPin, WwanAsyncSetPin, WwanAsyncGetPinList, WwanAsyncGetHomeProvider, WwanAsyncSetHomeProvider, WwanAsyncGetPreferredProviders, WwanAsyncSetPreferredProviders, WwanAsyncGetVisibleProviders, WwanAsyncGetRegisterState, WwanAsyncSetRegisterState, WwanAsyncGetPacketService, WwanAsyncSetPacketService, WwanAsyncGetSignalState, WwanAsyncSetSignalState, WwanAsyncGetConnect, WwanAsyncSetConnect, WwanAsyncGetProvisionedContexts, WwanAsyncSetProvisionedContext, WwanAsyncSetServiceActivation, WwanAsyncGetSmsConfiguration, WwanAsyncSetSmsConfiguration, WwanAsyncSmsRead, WwanAsyncSmsSend, WwanAsyncSmsDelete, WwanAsyncSmsStatus, WwanAsyncSetVendorSpecific, WwanAsyncSetProfileIndex, WwanAsyncGetDeviceServices, WwanAsyncSubscribeDeviceServiceEvents, WwanAsyncAuthChallenge, WwanAsyncUssdRequest, WwanAsyncSetPinEx, WwanAsyncGetPinEx, WwanAsyncGetDeviceServiceCommand, WwanAsyncSetDeviceServiceCommand, WwanAsyncQueryDeviceServiceSupportedCommands, WwanAsyncGetPreferredMultiCarrierProviders, WwanAsyncSetPreferredMultiCarrierProviders, WwanAsyncSetDeviceServiceSession, WwanAsyncWriteDeviceServiceSession, WwanAsyncSetNetworkIdleHint, WWAN_ASYNC_GETSET_TYPE_MAX } WWAN_ASYNC_GETSET_TYPE, *PWWAN_ASYNC_GETSET_TYPE; #ifndef WWAN_MAJOR_VERSION #define WWAN_MAJOR_VERSION_1 1 #define WWAN_MAJOR_VERSION_2 2 #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630 ) #define WWAN_MAJOR_VERSION WWAN_MAJOR_VERSION_2 #else #define WWAN_MAJOR_VERSION WWAN_MAJOR_VERSION_1 #endif #endif typedef ULONG WWAN_VERSION; /* A value specifies the version. */ /* bit[16:31]: major version */ /* bit[0:15]: minor version */ #define WWAN_FORM_VERSION( _MAJOR_, _MINOR_ ) \ ((WWAN_VERSION)(((_MAJOR_) << 16) | (_MINOR_))) #ifndef WWAN_MINOR_VERSION #define WWAN_MINOR_VERSION_0 0 #define WWAN_MINOR_VERSION_1 1 #if ( _WIN32_WINNT >= _WIN32_WINNT_WINBLUE || NTDDI_VERSION >= NTDDI_WINBLUE || NDIS_SUPPORT_NDIS640 ) #define WWAN_MINOR_VERSION WWAN_MINOR_VERSION_1 #else #define WWAN_MINOR_VERSION WWAN_MINOR_VERSION_0 #endif // Major = 1, Minor = 0 #define WWAN_VERSION_1_0 \ WWAN_FORM_VERSION( WWAN_MAJOR_VERSION_1, WWAN_MINOR_VERSION_0 ) // Major = 2, Minor = 0 #define WWAN_VERSION_2_0 \ WWAN_FORM_VERSION( WWAN_MAJOR_VERSION_2, WWAN_MINOR_VERSION_0 ) // Major = 2, Minor = 1 #define WWAN_VERSION_2_1 \ WWAN_FORM_VERSION( WWAN_MAJOR_VERSION_2, WWAN_MINOR_VERSION_1 ) #endif #ifndef WWAN_CURRENT_VERSION #define WWAN_CURRENT_VERSION \ WWAN_FORM_VERSION( WWAN_MAJOR_VERSION, WWAN_MINOR_VERSION ) #endif #define WWAN_VERSION_IS_WIN7( _MAJOR_, _MINOR_ ) \ (((_MAJOR_) == WWAN_MAJOR_VERSION_1) && ((_MINOR_) == WWAN_MINOR_VERSION_0)) #define WWAN_VERSION_IS_WIN8( _MAJOR_, _MINOR_ ) \ (((_MAJOR_) == WWAN_MAJOR_VERSION_2) && ((_MINOR_) == WWAN_MINOR_VERSION_0)) #define WWAN_VERSION_IS_WIN8_OR_HIGHER( _MAJOR_, _MINOR_ ) \ ((_MAJOR_) >= WWAN_MAJOR_VERSION_2) #define WWAN_VERSION_IS_BLUE( _MAJOR_, _MINOR_ ) \ (((_MAJOR_) == WWAN_MAJOR_VERSION_2) && ((_MINOR_) == WWAN_MINOR_VERSION_1)) #define WWAN_VERSION_IS_BLUE_OR_HIGHER( _MAJOR_, _MINOR_ ) \ ((((_MAJOR_) == WWAN_MAJOR_VERSION_2) && ((_MINOR_) >= WWAN_MINOR_VERSION_1)) || \ ((_MAJOR_) > WWAN_MAJOR_VERSION_2)) #define WWAN_DRIVER_CAPS_NONE 0x00000000 typedef struct _WWAN_DRIVER_CAPS { ULONG ulMajorVersion; ULONG ulMinorVersion; ULONG ulDriverCaps; } WWAN_DRIVER_CAPS, *PWWAN_DRIVER_CAPS; typedef enum _WWAN_DEVICE_TYPE { WwanDeviceTypeUnknown = 0, WwanDeviceTypeEmbedded, WwanDeviceTypeRemovable, WwanDeviceTypeRemote, WwanDeviceTypeMax } WWAN_DEVICE_TYPE, *PWWAN_DEVICE_TYPE; typedef enum _WWAN_CELLULAR_CLASS { WwanCellularClassUnknown = 0, WwanCellularClassGsm, WwanCellularClassCdma, WwanCellularClassMax } WWAN_CELLULAR_CLASS, *PWWAN_CELLULAR_CLASS; typedef enum _WWAN_VOICE_CLASS { WwanVoiceClassUnknown = 0, WwanVoiceClassNoVoice, WwanVoiceClassSeparateVoiceData, WwanVoiceClassSimultaneousVoiceData, WwanVoiceClassMax } WWAN_VOICE_CLASS, *PWWAN_VOICE_CLASS; typedef enum _WWAN_SIM_CLASS { WwanSimClassUnknown = 0, WwanSimClassSimLogical, WwanSimClassSimRemovable, WwanSimClassSimRemote, WwanSimClassMax } WWAN_SIM_CLASS, *PWWAN_SIM_CLASS; #define WWAN_DATA_CLASS_NONE 0x00000000 #define WWAN_DATA_CLASS_GPRS 0x00000001 #define WWAN_DATA_CLASS_EDGE 0x00000002 /* EGPRS */ #define WWAN_DATA_CLASS_UMTS 0x00000004 #define WWAN_DATA_CLASS_HSDPA 0x00000008 #define WWAN_DATA_CLASS_HSUPA 0x00000010 #define WWAN_DATA_CLASS_LTE 0x00000020 #define WWAN_DATA_CLASS_TDSCDMA 0x00001000 #define WWAN_DATA_CLASS_1XRTT 0x00010000 #define WWAN_DATA_CLASS_1XEVDO 0x00020000 #define WWAN_DATA_CLASS_1XEVDO_REVA 0x00040000 #define WWAN_DATA_CLASS_1XEVDV 0x00080000 #define WWAN_DATA_CLASS_3XRTT 0x00100000 #define WWAN_DATA_CLASS_1XEVDO_REVB 0x00200000 /* for future use */ #define WWAN_DATA_CLASS_UMB 0x00400000 #define WWAN_DATA_CLASS_CUSTOM 0x80000000 #define WWAN_BAND_CLASS_UNKNOWN 0x00000000 #define WWAN_BAND_CLASS_0 0x00000001 #define WWAN_BAND_CLASS_I 0x00000002 #define WWAN_BAND_CLASS_II 0x00000004 #define WWAN_BAND_CLASS_III 0x00000008 #define WWAN_BAND_CLASS_IV 0x00000010 #define WWAN_BAND_CLASS_V 0x00000020 #define WWAN_BAND_CLASS_VI 0x00000040 #define WWAN_BAND_CLASS_VII 0x00000080 #define WWAN_BAND_CLASS_VIII 0x00000100 #define WWAN_BAND_CLASS_IX 0x00000200 #define WWAN_BAND_CLASS_X 0x00000400 #define WWAN_BAND_CLASS_XI 0x00000800 #define WWAN_BAND_CLASS_XII 0x00001000 #define WWAN_BAND_CLASS_XIII 0x00002000 #define WWAN_BAND_CLASS_XIV 0x00004000 #define WWAN_BAND_CLASS_XV 0x00008000 #define WWAN_BAND_CLASS_XVI 0x00010000 #define WWAN_BAND_CLASS_XVII 0x00020000 #define WWAN_BAND_CLASS_CUSTOM 0x80000000 #define WWAN_CTRL_CAPS_NONE 0x00000000 #define WWAN_CTRL_CAPS_REG_MANUAL 0x00000001 #define WWAN_CTRL_CAPS_HW_RADIO_SWITCH 0x00000002 #define WWAN_CTRL_CAPS_CDMA_MOBILE_IP 0x00000004 #define WWAN_CTRL_CAPS_CDMA_SIMPLE_IP 0x00000008 #define WWAN_CTRL_CAPS_PROTECT_UNIQUEID 0x00000010 #define WWAN_CTRL_CAPS_MODEL_MULTI_CARRIER 0x00000020 #define WWAN_CTRL_CAPS_USSD 0x00000040 #define WWAN_CTRL_CAPS_MULTI_MODE 0x00000080 #define WWAN_SMS_CAPS_NONE 0x00000000 #define WWAN_SMS_CAPS_PDU_RECEIVE 0x00000001 #define WWAN_SMS_CAPS_PDU_SEND 0x00000002 #define WWAN_SMS_CAPS_TEXT_RECEIVE 0x00000004 #define WWAN_SMS_CAPS_TEXT_SEND 0x00000008 #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630 ) #define WWAN_AUTH_ALGO_CAPS_NONE 0x00000000 #define WWAN_AUTH_ALGO_CAPS_SIM 0x00000001 #define WWAN_AUTH_ALGO_CAPS_AKA 0x00000002 #define WWAN_AUTH_ALGO_CAPS_AKAPRIME 0x00000004 #endif typedef struct _WWAN_DEVICE_CAPS { WWAN_DEVICE_TYPE WwanDeviceType; WWAN_CELLULAR_CLASS WwanCellularClass; WWAN_VOICE_CLASS WwanVoiceClass; WWAN_SIM_CLASS WwanSimClass; ULONG WwanDataClass; WCHAR CustomDataClass[WWAN_CUSTOM_DATA_CLASS_LEN]; ULONG WwanGsmBandClass; ULONG WwanCdmaBandClass; WCHAR CustomBandClass[WWAN_CUSTOM_BAND_CLASS_LEN]; ULONG WwanSmsCaps; ULONG WwanControlCaps; WCHAR DeviceId [WWAN_DEVICEID_LEN]; WCHAR Manufacturer [WWAN_MANUFACTURER_LEN]; WCHAR Model [WWAN_MODEL_LEN]; WCHAR FirmwareInfo [WWAN_FIRMWARE_LEN]; ULONG MaxActivatedContexts; #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630 ) ULONG WwanAuthAlgoCaps; WWAN_LIST_HEADER CellularClassListHeader; #endif } WWAN_DEVICE_CAPS, *PWWAN_DEVICE_CAPS; #if ( _WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD || NTDDI_VERSION >= NTDDI_WINTHRESHOLD || NDIS_SUPPORT_NDIS650 ) typedef struct _WWAN_DEVICE_CAPS_EX2 { WWAN_DEVICE_TYPE WwanDeviceType; WWAN_CELLULAR_CLASS WwanCellularClass; WWAN_VOICE_CLASS WwanVoiceClass; WWAN_SIM_CLASS WwanSimClass; ULONG WwanDataClass; WCHAR CustomDataClass[WWAN_CUSTOM_DATA_CLASS_LEN]; ULONG WwanGsmBandClass; ULONG WwanCdmaBandClass; WCHAR CustomBandClass[WWAN_CUSTOM_BAND_CLASS_LEN]; ULONG WwanSmsCaps; ULONG WwanControlCaps; WCHAR DeviceId[WWAN_DEVICEID_LEN]; WCHAR Manufacturer[WWAN_MANUFACTURER_LEN]; WCHAR Model[WWAN_MODEL_LEN]; WCHAR FirmwareInfo[WWAN_FIRMWARE_LEN]; ULONG MaxActivatedContexts; ULONG DeviceIndex; ULONG WwanAuthAlgoCaps; WWAN_LIST_HEADER CellularClassListHeader; } WWAN_DEVICE_CAPS_EX2, *PWWAN_DEVICE_CAPS_EX2; #endif typedef enum _WWAN_READY_STATE { WwanReadyStateOff = 0, /* stack is off */ WwanReadyStateInitialized, /* ready to power up and register */ WwanReadyStateSimNotInserted, /* SIM not inserted */ WwanReadyStateBadSim, /* SIM is invalid */ WwanReadyStateFailure, /* Device failure */ WwanReadyStateNotActivated, /* Device not activated (CDMA) */ WwanReadyStateDeviceLocked /* Device is locked */ } WWAN_READY_STATE, *PWWAN_READY_STATE; typedef enum _WWAN_EMERGENCY_MODE { WwanEmergencyModeOff = 0, WwanEmergencyModeOn, WwanEmergencyModeMax }WWAN_EMERGENCY_MODE, *PWWAN_EMERGENCY_MODE; typedef struct _WWAN_READY_INFO { WWAN_READY_STATE ReadyState; WWAN_EMERGENCY_MODE EmergencyMode; WCHAR SubscriberId [WWAN_SUBSCRIBERID_LEN]; WCHAR SimIccId [WWAN_SIMICCID_LEN]; BYTE CdmaShortMsgSize; WWAN_LIST_HEADER TNListHeader; } WWAN_READY_INFO, *PWWAN_READY_INFO; typedef struct _WWAN_SERVICE_ACTIVATION { ULONG uVendorSpecificBufferSize; } WWAN_SERVICE_ACTIVATION, *PWWAN_SERVICE_ACTIVATION; typedef enum _WWAN_RADIO { WwanRadioOff = 0, WwanRadioOn } WWAN_RADIO, *PWWAN_RADIO; typedef enum _WWAN_ACE_STATE { WwanAutoOff = 0, WwanAutoOn, WwanManualOff, WwanManualOn } WWAN_ACE_STATE, *PWWAN_ACE_STATE; typedef struct _WWAN_RADIO_STATE { WWAN_RADIO HwRadioState; WWAN_RADIO SwRadioState; } WWAN_RADIO_STATE, *PWWAN_RADIO_STATE; typedef enum _WWAN_PIN_TYPE { WwanPinTypeNone = 0, WwanPinTypeCustom, WwanPinTypePin1, WwanPinTypePin2, WwanPinTypeDeviceSimPin, WwanPinTypeDeviceFirstSimPin, WwanPinTypeNetworkPin, WwanPinTypeNetworkSubsetPin, WwanPinTypeSvcProviderPin, WwanPinTypeCorporatePin, WwanPinTypeSubsidyLock, WwanPinTypePuk1, WwanPinTypePuk2, WwanPinTypeDeviceFirstSimPuk, WwanPinTypeNetworkPuk, WwanPinTypeNetworkSubsetPuk, WwanPinTypeSvcProviderPuk, WwanPinTypeCorporatePuk, WwanPinTypeNev, WwanPinTypeAdm, WwanPinTypeMax } WWAN_PIN_TYPE, *PWWAN_PIN_TYPE; typedef enum _WWAN_PIN_STATE { WwanPinStateNone = 0, WwanPinStateEnter, WwanPinStateMax } WWAN_PIN_STATE, *PWWAN_PIN_STATE; #define WWAN_ATTEMPTS_REMAINING_UNKNOWN ~0 typedef struct _WWAN_PIN_INFO { WWAN_PIN_TYPE PinType; WWAN_PIN_STATE PinState; ULONG AttemptsRemaining; } WWAN_PIN_INFO, *PWWAN_PIN_INFO; typedef enum _WWAN_PIN_OPERATION { WwanPinOperationEnter = 0, WwanPinOperationEnable, WwanPinOperationDisable, WwanPinOperationChange, WwanPinOperationMax } WWAN_PIN_OPERATION, *PWWAN_PIN_OPERATION; typedef struct _WWAN_PIN_ACTION { WWAN_PIN_TYPE PinType; WWAN_PIN_OPERATION PinOperation; WCHAR Pin [WWAN_PIN_LEN]; WCHAR NewPin [WWAN_PIN_LEN]; } WWAN_PIN_ACTION, *PWWAN_PIN_ACTION; #if ( _WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD || NTDDI_VERSION >= NTDDI_WINTHRESHOLD || NDIS_SUPPORT_NDIS650 ) typedef struct _WWAN_PIN_ACTION_EX2 { WWAN_PIN_TYPE PinType; WWAN_PIN_OPERATION PinOperation; WCHAR Pin[WWAN_PIN_LEN]; WCHAR NewPin[WWAN_PIN_LEN]; BYTE AppIdLength; BYTE AppId[WWAN_UICC_APP_ID_MAX_LEN]; } WWAN_PIN_ACTION_EX2, *PWWAN_PIN_ACTION_EX2; #endif typedef enum _WWAN_PIN_FORMAT { WwanPinFormatUnknown = 0, WwanPinFormatNumeric, WwanPinFormatAlphaNumeric, WwanPinFormatMax } WWAN_PIN_FORMAT, *PWWAN_PIN_FORMAT; typedef enum _WWAN_PIN_MODE { WwanPinModeNotSupported = 0, WwanPinModeEnabled, WwanPinModeDisabled, WwanPinModeMax } WWAN_PIN_MODE, *PWWAN_PIN_MODE; #define WWAN_PIN_LENGTH_UNKNOWN ~0 typedef struct _WWAN_PIN_DESC { WWAN_PIN_MODE PinMode; WWAN_PIN_FORMAT PinFormat; ULONG PinLengthMin; ULONG PinLengthMax; } WWAN_PIN_DESC, *PWWAN_PIN_DESC; typedef struct _WWAN_PIN_LIST { WWAN_PIN_DESC WwanPinDescPin1; WWAN_PIN_DESC WwanPinDescPin2; WWAN_PIN_DESC WwanPinDescDeviceSimPin; WWAN_PIN_DESC WwanPinDescDeviceFirstSimPin; WWAN_PIN_DESC WwanPinDescNetworkPin; WWAN_PIN_DESC WwanPinDescNetworkSubsetPin; WWAN_PIN_DESC WwanPinDescSvcProviderPin; WWAN_PIN_DESC WwanPinDescCorporatePin; WWAN_PIN_DESC WwanPinDescSubsidyLock; WWAN_PIN_DESC WwanPinDescCustom; } WWAN_PIN_LIST, *PWWAN_PIN_LIST; #define WWAN_PROVIDER_STATE_UNKNOWN 0x00000000 #define WWAN_PROVIDER_STATE_HOME 0x00000001 #define WWAN_PROVIDER_STATE_FORBIDDEN 0x00000002 #define WWAN_PROVIDER_STATE_PREFERRED 0x00000004 #define WWAN_PROVIDER_STATE_VISIBLE 0x00000008 #define WWAN_PROVIDER_STATE_REGISTERED 0x00000010 #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630 ) #define WWAN_PROVIDER_STATE_PREFERRED_MULTICARRIER 0x00000020 #endif typedef struct _WWAN_PROVIDER { WCHAR ProviderId [WWAN_PROVIDERID_LEN]; ULONG ProviderState; WCHAR ProviderName [WWAN_PROVIDERNAME_LEN]; ULONG WwanDataClass; } WWAN_PROVIDER, *PWWAN_PROVIDER; typedef enum _WWAN_REGISTER_ACTION { WwanRegisterActionAutomatic = 0, WwanRegisterActionManual, WwanRegisterActionMax } WWAN_REGISTER_ACTION, *PWWAN_REGISTER_ACTION; #if ( _WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD || NTDDI_VERSION >= NTDDI_WINTHRESHOLD || NDIS_SUPPORT_NDIS650 ) typedef enum _WWAN_REGISTRATION_VOICE_CLASS { WwanRegistrationVoiceClassVoiceCentric = 0, WwanRegistrationVoiceClassDataCentric } WWAN_REGISTRATION_VOICE_CLASS, *PWWAN_REGISTRATION_VOICE_CLASS; typedef enum _WWAN_REGISTRATION_VOICE_DOMAIN_PREFERENCE { WwanRegistrationVoiceDomainPreferenceCsOnly = 0, WwanRegistrationVoiceDomainPreferenceCsPreferred, WwanRegistrationVoiceDomainPreferenceImsPreferred, WwanRegistrationVoiceDomainPreferenceImsOnly } WWAN_REGISTRATION_VOICE_DOMAIN_PREFERENCE, *PWWAN_REGISTRATION_VOICE_DOMAIN_PREFERENCE; #define WWAN_REGISTRATION_VOICE_SUPPORT_NONE 0x00000000 #define WWAN_REGISTRATION_VOICE_SUPPORT_IMS 0x00000001 #define WWAN_REGISTRATION_VOICE_SUPPORT_EMERGENCY_ATTACH 0x00000002 #define WWAN_REGISTRATION_VOICE_SUPPORT_CS 0x00000004 #define WWAN_REGISTRATION_VOICE_SUPPORT_CSFB 0x00000008 #define WWAN_REGISTRATION_VOICE_SUPPORT_1XCSFB 0x00000010 #define WWAN_REGISTRATION_VOICE_SUPPORT_EMERGENCY 0x00000020 typedef enum _WWAN_REGISTRATION_CDMA_ROAM_MODE { WwanRegistrationCdmaRoamModeAutomatic = 0, WwanRegistrationCdmaRoamModeHomeOnly } WWAN_REGISTRATION_CDMA_ROAM_MODE, *PWWAN_REGISTRATION_CDMA_ROAM_MODE; #endif typedef struct _WWAN_SET_REGISTER_STATE { WCHAR ProviderId [WWAN_PROVIDERID_LEN]; WWAN_REGISTER_ACTION RegisterAction; ULONG WwanDataClass; } WWAN_SET_REGISTER_STATE, *PWWAN_SET_REGISTER_STATE; #if ( _WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD || NTDDI_VERSION >= NTDDI_WINTHRESHOLD || NDIS_SUPPORT_NDIS650 ) typedef struct _WWAN_SET_REGISTER_STATE_EX { WCHAR ProviderId[WWAN_PROVIDERID_LEN]; WWAN_REGISTER_ACTION RegisterAction; ULONG WwanDataClass; WWAN_REGISTRATION_VOICE_CLASS WwanVoiceClass; WWAN_REGISTRATION_VOICE_DOMAIN_PREFERENCE WwanVoiceDomain; WWAN_REGISTRATION_CDMA_ROAM_MODE WwanCdmaRoamMode; WWAN_LIST_HEADER AcquisitionOrderListHeader; } WWAN_SET_REGISTER_STATE_EX, *PWWAN_SET_REGISTER_STATE_EX; #endif typedef enum _WWAN_REGISTER_STATE { WwanRegisterStateUnknown = 0, WwanRegisterStateDeregistered, WwanRegisterStateSearching, WwanRegisterStateHome, WwanRegisterStateRoaming, WwanRegisterStatePartner, WwanRegisterStateDenied, WwanRegisterStateMax } WWAN_REGISTER_STATE, *PWWAN_REGISTER_STATE; typedef enum _WWAN_REGISTER_MODE { WwanRegisterModeUnknown = 0, WwanRegisterModeAutomatic, WwanRegisterModeManual, WwanRegisterModeMax } WWAN_REGISTER_MODE, *PWWAN_REGISTER_MODE; #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630 ) #define WWAN_REG_FLAGS_NONE 0x00000000 #define WWAN_REG_FLAGS_NO_MANUAL_REG 0x00000001 #define WWAN_REG_FLAGS_PS_AUTO_ATTACH 0x00000002 #endif typedef struct _WWAN_REGISTRATION_STATE { ULONG uNwError; WWAN_REGISTER_STATE RegisterState; WWAN_REGISTER_MODE RegisterMode; WCHAR ProviderId [WWAN_PROVIDERID_LEN]; WCHAR ProviderName [WWAN_PROVIDERNAME_LEN]; WCHAR RoamingText [WWAN_ROAMTEXT_LEN]; #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630 ) DWORD WwanRegFlags; WWAN_CELLULAR_CLASS CurrentCellularClass; #endif } WWAN_REGISTRATION_STATE, *PWWAN_REGISTRATION_STATE; #if ( _WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD || NTDDI_VERSION >= NTDDI_WINTHRESHOLD || NDIS_SUPPORT_NDIS650 ) typedef struct _WWAN_REGISTRATION_STATE_EX { ULONG uNwError; WWAN_REGISTER_STATE RegisterState; WWAN_REGISTER_MODE RegisterMode; WCHAR ProviderId[WWAN_PROVIDERID_LEN]; WCHAR ProviderName[WWAN_PROVIDERNAME_LEN]; WCHAR RoamingText[WWAN_ROAMTEXT_LEN]; DWORD WwanRegFlags; WWAN_CELLULAR_CLASS CurrentCellularClass; ULONG AvailableDataClasses; ULONG VoiceSupport; ULONG CurrentRATClass; } WWAN_REGISTRATION_STATE_EX, *PWWAN_REGISTRATION_STATE_EX; typedef struct _WWAN_REGISTRATION_STATE_INFOS { WWAN_LIST_HEADER RegistrationStateListHeader; } WWAN_REGISTRATION_STATE_INFOS, *PWWAN_REGISTRATION_STATE_INFOS; #endif typedef enum _WWAN_PACKET_SERVICE_ACTION { WwanPacketServiceActionAttach = 0, WwanPacketServiceActionDetach } WWAN_PACKET_SERVICE_ACTION, *PWWAN_PACKET_SERVICE_ACTION; typedef enum _WWAN_PACKET_SERVICE_STATE { WwanPacketServiceStateUnknown = 0, WwanPacketServiceStateAttaching, WwanPacketServiceStateAttached, WwanPacketServiceStateDetaching, WwanPacketServiceStateDetached } WWAN_PACKET_SERVICE_STATE, *PWWAN_PACKET_SERVICE_STATE; typedef struct _WWAN_PACKET_SERVICE { ULONG uNwError; WWAN_PACKET_SERVICE_STATE PacketServiceState; ULONG AvailableDataClass; ULONG CurrentDataClass; } WWAN_PACKET_SERVICE, *PWWAN_PACKET_SERVICE; #define WWAN_RSSI_UNKNOWN 99 #define WWAN_ERROR_RATE_UNKNOWN 99 typedef struct _WWAN_SIGNAL_STATE { ULONG Rssi; ULONG ErrorRate; ULONG RssiInterval; ULONG RssiThreshold; } WWAN_SIGNAL_STATE, *PWWAN_SIGNAL_STATE; #if ( _WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD || NTDDI_VERSION >= NTDDI_WINTHRESHOLD || NDIS_SUPPORT_NDIS650 ) typedef struct _WWAN_SIGNAL_STATE_EX { ULONG Rssi; ULONG ErrorRate; ULONG RssiInterval; ULONG RssiThreshold; ULONG ErrorRateThreshold; ULONG Snr; ULONG SnrThreshold; ULONG DataClass; } WWAN_SIGNAL_STATE_EX, *PWWAN_SIGNAL_STATE_EX; typedef struct _WWAN_SIGNAL_STATE_INFOS { WWAN_LIST_HEADER SignalStateListHeader; } WWAN_SIGNAL_STATE_INFOS, *PWWAN_SIGNAL_STATE_INFOS; #endif #define WWAN_RSSI_DEFAULT 0xffffffff #define WWAN_RSSI_DISABLE 0 #define WWAN_RSSI_INTERVAL_SECS_WIN8 30 #define WWAN_RSSI_THRESHOLD_CODED_UNIT_WIN8 WWAN_RSSI_DEFAULT #define WWAN_RSSI_INTERVAL_SECS_BLUE 60 #define WWAN_RSSI_THRESHOLD_CODED_UNIT_BLUE 1 typedef struct _WWAN_SET_SIGNAL_INDICATION { ULONG RssiInterval; ULONG RssiThreshold; } WWAN_SET_SIGNAL_INDICATION, *PWWAN_SET_SIGNAL_INDICATION; #if ( _WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD || NTDDI_VERSION >= NTDDI_WINTHRESHOLD || NDIS_SUPPORT_NDIS650 ) typedef struct _WWAN_SET_SIGNAL_INDICATION_EX { ULONG RssiInterval; ULONG RssiThreshold; ULONG ErrorRateThreshold; ULONG SnrThreshold; } WWAN_SET_SIGNAL_INDICATION_EX, *PWWAN_SET_SIGNAL_INDICATION_EX; #endif typedef enum _WWAN_ACTIVATION_COMMAND { WwanActivationCommandDeactivate = 0, WwanActivationCommandActivate, WwanActivationCommandMax } WWAN_ACTIVATION_COMMAND, *PWWAN_ACTIVATION_COMMAND; typedef enum _WWAN_COMPRESSION { WwanCompressionNone = 0, WwanCompressionEnable, WwanCompressionMax } WWAN_COMPRESSION, *PWWAN_COMPRESSION; typedef enum _WWAN_AUTH_PROTOCOL { WwanAuthProtocolNone = 0, WwanAuthProtocolPap, WwanAuthProtocolChap, WwanAuthProtocolMsChapV2, #if ( _WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD || NTDDI_VERSION >= NTDDI_WINTHRESHOLD || NDIS_SUPPORT_NDIS650 ) WwanAuthProtocolAuto, #endif WwanAuthProtocolMax } WWAN_AUTH_PROTOCOL, *PWWAN_AUTH_PROTOCOL; typedef enum _WWAN_IP_TYPE { WwanIPTypeDefault = 0, WwanIPTypeIPv4, WwanIPTypeIPv6, WwanIPTypeIpv4v6, #if ( _WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD || NTDDI_VERSION >= NTDDI_WINTHRESHOLD || NDIS_SUPPORT_NDIS650 ) WwanIPTypeXlat #endif } WWAN_IP_TYPE, *PWWAN_IP_TYPE; typedef struct _WWAN_SET_CONTEXT_STATE { ULONG ConnectionId; WWAN_ACTIVATION_COMMAND ActivationCommand; WCHAR AccessString [WWAN_ACCESSSTRING_LEN]; WCHAR UserName [WWAN_USERNAME_LEN]; WCHAR Password [WWAN_PASSWORD_LEN]; WWAN_COMPRESSION Compression; WWAN_AUTH_PROTOCOL AuthType; #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630 ) WWAN_IP_TYPE IPType; #endif } WWAN_SET_CONTEXT_STATE, *PWWAN_SET_CONTEXT_STATE; typedef enum _WWAN_ACTIVATION_STATE { WwanActivationStateUnknown = 0, WwanActivationStateActivated, WwanActivationStateActivating, WwanActivationStateDeactivated, WwanActivationStateDeactivating, WwanActivationStateMax } WWAN_ACTIVATION_STATE, *PWWAN_ACTIVATION_STATE; typedef enum _WWAN_VOICE_CALL_STATE { WwanVoiceCallStateNone = 0, WwanVoiceCallStateInProgress, WwanVoiceCallStateHangUp, WwanVoiceCallStateMaximum } WWAN_VOICE_CALL_STATE, *PWWAN_VOICE_CALL_STATE; typedef struct _WWAN_CONTEXT_STATE { ULONG uNwError; ULONG ConnectionId; WWAN_ACTIVATION_STATE ActivationState; WWAN_VOICE_CALL_STATE VoiceCallState; #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630 ) WWAN_IP_TYPE IPType; #endif } WWAN_CONTEXT_STATE, *PWWAN_CONTEXT_STATE; typedef enum _WWAN_CONTEXT_TYPE { WwanContextTypeNone = 0, WwanContextTypeInternet, WwanContextTypeVpn, WwanContextTypeVoice, WwanContextTypeVideoShare, WwanContextTypeCustom, WwanContextTypePurchase, WwanContextTypeMax } WWAN_CONTEXT_TYPE, *PWWAN_CONTEXT_TYPE; #define WWAN_CONTEXT_ID_APPEND 0xffffffff typedef struct _WWAN_CONTEXT { ULONG ContextId; WWAN_CONTEXT_TYPE ContextType; WCHAR AccessString [WWAN_ACCESSSTRING_LEN]; WCHAR UserName [WWAN_USERNAME_LEN]; WCHAR Password [WWAN_PASSWORD_LEN]; WWAN_COMPRESSION Compression; WWAN_AUTH_PROTOCOL AuthType; } WWAN_CONTEXT, *PWWAN_CONTEXT; typedef struct _WWAN_SET_CONTEXT { ULONG ContextId; WWAN_CONTEXT_TYPE ContextType; WCHAR AccessString[WWAN_ACCESSSTRING_LEN]; WCHAR UserName[WWAN_USERNAME_LEN]; WCHAR Password[WWAN_PASSWORD_LEN]; WWAN_COMPRESSION Compression; WWAN_AUTH_PROTOCOL AuthType; WCHAR ProviderId[WWAN_PROVIDERID_LEN]; } WWAN_SET_CONTEXT, *PWWAN_SET_CONTEXT; typedef enum _WWAN_SMS_FORMAT { WwanSmsFormatPdu = 0, WwanSmsFormatReserved0, WwanSmsFormatReserved1, WwanSmsFormatReserved2, WwanSmsFormatCdma, WwanSmsFormatMax } WWAN_SMS_FORMAT, *PWWAN_SMS_FORMAT; typedef struct _WWAN_SET_SMS_CONFIGURATION { CHAR ScAddress [WWAN_SMS_ADDRESS_MAX_LEN]; WWAN_SMS_FORMAT SmsFormat; } WWAN_SET_SMS_CONFIGURATION, *PWWAN_SET_SMS_CONFIGURATION; typedef struct _WWAN_SMS_CONFIGURATION { CHAR ScAddress [WWAN_SMS_ADDRESS_MAX_LEN]; WWAN_SMS_FORMAT SmsFormat; ULONG ulMaxMessageIndex; } WWAN_SMS_CONFIGURATION, *PWWAN_SMS_CONFIGURATION; typedef enum _WWAN_SMS_FLAG { WwanSmsFlagAll = 0, WwanSmsFlagIndex, WwanSmsFlagNew, WwanSmsFlagOld, WwanSmsFlagSent, WwanSmsFlagDraft, WwanSmsFlagMax } WWAN_SMS_FLAG, *PWWAN_SMS_FLAG; #define WWAN_MESSAGE_INDEX_NONE 0 typedef struct _WWAN_SMS_FILTER { WWAN_SMS_FLAG Flag; ULONG MessageIndex; } WWAN_SMS_FILTER, *PWWAN_SMS_FILTER; typedef struct _WWAN_SMS_READ { WWAN_SMS_FORMAT SmsFormat; WWAN_SMS_FILTER ReadFilter; } WWAN_SMS_READ, *PWWAN_SMS_READ; typedef enum _WWAN_MSG_STATUS { WwanMsgStatusNew = 0, WwanMsgStatusOld, WwanMsgStatusDraft, WwanMsgStatusSent, WwanMsgStatusMax } WWAN_MSG_STATUS, *PWWAN_MSG_STATUS; typedef enum _WWAN_SMS_CDMA_LANG { WwanSmsCdmaLangUnknown = 0, WwanSmsCdmaLangEnglish, WwanSmsCdmaLangFrench, WwanSmsCdmaLangSpanish, WwanSmsCdmaLangJapanese, WwanSmsCdmaLangKorean, WwanSmsCdmaLangChinese, WwanSmsCdmaLangHebrew, WwanSmsCdmaLangMax } WWAN_SMS_CDMA_LANG, *PWWAN_SMS_CDMA_LANG; typedef enum _WWAN_SMS_CDMA_ENCODING { WwanSmsCdmaEncodingOctet = 0, WwanSmsCdmaEncodingEpm, WwanSmsCdmaEncoding7BitAscii, WwanSmsCdmaEncodingIa5, WwanSmsCdmaEncodingUnicode, WwanSmsCdmaEncodingShiftJis, WwanSmsCdmaEncodingKorean, WwanSmsCdmaEncodingLatinHebrew, WwanSmsCdmaEncodingLatin, WwanSmsCdmaEncodingGsm7Bit, WwanSmsCdmaEncodingMax } WWAN_SMS_CDMA_ENCODING, *PWWAN_SMS_CDMA_ENCODING; typedef struct _WWAN_SMS_CDMA_RECORD { ULONG MessageIndex; WWAN_MSG_STATUS MsgStatus; CHAR Address[WWAN_SMS_CDMA_ADDR_MAX_LEN]; CHAR ScTimeStamp[WWAN_SMS_CDMA_TIMESTAMP_MAX_LEN]; WWAN_SMS_CDMA_ENCODING EncodingId; WWAN_SMS_CDMA_LANG LanguageId; USHORT SizeInBytes; BYTE SizeInCharacters; BYTE EncodedMsg [WWAN_SMS_CDMA_MAX_BUF_LEN]; } WWAN_SMS_CDMA_RECORD, *PWWAN_SMS_CDMA_RECORD; typedef struct _WWAN_SMS_PDU_RECORD { ULONG MessageIndex; WWAN_MSG_STATUS MsgStatus; BYTE Size; CHAR PduData [WWAN_SMS_PDU_HEX_BUF_LEN]; } WWAN_SMS_PDU_RECORD, *PWWAN_SMS_PDU_RECORD; typedef struct _WWAN_SMS_SEND_CDMA { WWAN_SMS_CDMA_ENCODING EncodingId; WWAN_SMS_CDMA_LANG LanguageId; CHAR Address [WWAN_SMS_CDMA_ADDR_MAX_LEN]; USHORT SizeInBytes; BYTE SizeInCharacters; BYTE EncodedMsg [WWAN_SMS_CDMA_MAX_BUF_LEN]; } WWAN_SMS_SEND_CDMA, *PWWAN_SMS_SEND_CDMA; typedef struct _WWAN_SMS_SEND_PDU { BYTE Size; CHAR PduData [WWAN_SMS_PDU_HEX_BUF_LEN]; } WWAN_SMS_SEND_PDU, *PWWAN_SMS_SEND_PDU; typedef struct _WWAN_SMS_SEND { WWAN_SMS_FORMAT SmsFormat; union { WWAN_SMS_SEND_PDU Pdu; WWAN_SMS_SEND_CDMA Cdma; } u; } WWAN_SMS_SEND, *PWWAN_SMS_SEND; #define WWAN_SMS_FLAG_NONE 0x00000000 #define WWAN_SMS_FLAG_MESSAGE_STORE_FULL 0x00000001 #define WWAN_SMS_FLAG_NEW_MESSAGE 0x00000002 typedef struct _WWAN_SMS_STATUS { ULONG uFlag; ULONG MessageIndex; } WWAN_SMS_STATUS, *PWWAN_SMS_STATUS; typedef struct _WWAN_SERVICE_ACTIVATION_STATUS { ULONG uNwError; ULONG uVendorSpecificBufferSize; } WWAN_SERVICE_ACTIVATION_STATUS,*PWWAN_SERVICE_ACTIVATION_STATUS; typedef struct _WWAN_VENDOR_SPECIFIC { ULONG uVendorSpecificBufferSize; } WWAN_VENDOR_SPECIFIC, *PWWAN_VENDOR_SPECIFIC; #if ( _WIN32_WINNT >= _WIN32_WINNT_WIN8 || NTDDI_VERSION >= NTDDI_WIN8 || NDIS_SUPPORT_NDIS630 ) typedef enum _WWAN_DEVICE_SERVICE_SESSION_CAPABILITY { WwanDeviceServiceSessionNotSupported = 0x00, WwanDeviceServiceSessionWriteSupported = 0x01, WwanDeviceServiceSessionReadSupported = 0x02 } WWAN_DEVICE_SERVICE_SESSION_CAPABILITY, *PWWAN_DEVICE_SERVICE_SESSION_CAPABILITY; typedef enum _WWAN_DEVICE_SERVICE_SESSION_STATE { WwanDeviceServiceSessionOpen = 0x01, WwanDeviceServiceSessionClosed = 0x02 } WWAN_DEVICE_SERVICE_SESSION_STATE, *PWWAN_DEVICE_SERVICE_SESSION_STATE; typedef struct _WWAN_DEVICE_SERVICE_ENTRY { GUID DeviceServiceGuid; WWAN_DEVICE_SERVICE_SESSION_CAPABILITY SessionCapability; ULONG uMaxSessionInstances; } WWAN_DEVICE_SERVICE_ENTRY, *PWWAN_DEVICE_SERVICE_ENTRY; typedef struct _WWAN_SUPPORTED_DEVICE_SERVICES { ULONG uMaxCommandDataSize; ULONG uMaxSessionDataSize; ULONG uMaxSessionCount; WWAN_LIST_HEADER ListHeader; } WWAN_SUPPORTED_DEVICE_SERVICES, *PWWAN_SUPPORTED_DEVICE_SERVICES; typedef struct _WWAN_DEVICE_SERVICE_COMMAND { GUID DeviceServiceGuid; ULONG CommandID; ULONG uDataSize; } WWAN_DEVICE_SERVICE_COMMAND, *PWWAN_DEVICE_SERVICE_COMMAND; typedef struct _WWAN_DEVICE_SERVICE_RESPONSE { GUID DeviceServiceGuid; ULONG ResponseID; ULONG uDataSize; } WWAN_DEVICE_SERVICE_RESPONSE, *PWWAN_DEVICE_SERVICE_RESPONSE; typedef struct _WWAN_DEVICE_SERVICE_EVENT { GUID DeviceServiceGuid; ULONG EventID; ULONG uDataSize; } WWAN_DEVICE_SERVICE_EVENT, *PWWAN_DEVICE_SERVICE_EVENT; typedef struct _WWAN_DEVICE_SERVICE_SUPPORTED_COMMANDS { GUID DeviceServiceGuid; WWAN_LIST_HEADER ListHeader; } WWAN_DEVICE_SERVICE_SUPPORTED_COMMANDS, *PWWAN_DEVICE_SERVICE_SUPPORTED_COMMANDS; typedef struct _WWAN_DEVICE_SERVICE_SESSION { GUID DeviceServiceGuid; WWAN_DEVICE_SERVICE_SESSION_STATE State; ULONG uSessionID; } WWAN_DEVICE_SERVICE_SESSION, *PWWAN_DEVICE_SERVICE_SESSION; typedef struct _WWAN_DEVICE_SERVICE_SESSION_READ { ULONG uSessionID; ULONG uDataSize; } WWAN_DEVICE_SERVICE_SESSION_READ, *PWWAN_DEVICE_SERVICE_SESSION_READ; typedef struct _WWAN_DEVICE_SERVICE_SESSION_WRITE { ULONG uSessionID; ULONG uDataSize; } WWAN_DEVICE_SERVICE_SESSION_WRITE, *PWWAN_DEVICE_SERVICE_SESSION_WRITE; typedef struct _WWAN_PROVIDER2 { WWAN_PROVIDER Provider; WWAN_CELLULAR_CLASS WwanCellularClass; ULONG Rssi; ULONG ErrorRate; } WWAN_PROVIDER2, *PWWAN_PROVIDER2; typedef enum _WWAN_USSD_REQUEST_TYPE { WwanUssdRequestInitiate = 0, WwanUssdRequestContinue = 1, WwanUssdRequestCancel = 2 } WWAN_USSD_REQUEST_TYPE, *PWWAN_USSD_REQUEST_TYPE; typedef enum _WWAN_USSD_EVENT_TYPE { WwanUssdEventNoActionRequired = 0, WwanUssdEventActionRequired = 1, WwanUssdEventTerminated = 2, WwanUssdEventOtherLocalClient = 3, WwanUssdEventOperationNotSupported = 4, WwanUssdEventNetworkTimeOut = 5 } WWAN_USSD_EVENT_TYPE, *PWWAN_USSD_EVENT_TYPE; typedef enum _WWAN_USSD_SESSION_STATE { WwanUssdSessionStateNew = 0, WwanUssdSessionStateExisting = 1 } WWAN_USSD_SESSION_STATE, *PWWAN_USSD_SESSION_STATE; typedef struct _WWAN_USSD_STRING { BYTE DataCodingScheme; BYTE StringLength; // 1-160 bytes; 0 indicates absent string BYTE String[WWAN_USSD_STRING_LEN_MAX]; } WWAN_USSD_STRING, *PWWAN_USSD_STRING; typedef struct _WWAN_USSD_REQUEST { WWAN_USSD_REQUEST_TYPE RequestType; WWAN_USSD_STRING UssdString; } WWAN_USSD_REQUEST, *PWWAN_USSD_REQUEST; typedef struct _WWAN_USSD_EVENT { WWAN_USSD_EVENT_TYPE EventType; WWAN_USSD_SESSION_STATE SessionState; WWAN_USSD_STRING UssdString; } WWAN_USSD_EVENT, *PWWAN_USSD_EVENT; #define WWAN_GET_VISIBLE_PROVIDERS_ALL 0x00000000 #define WWAN_GET_VISIBLE_PROVIDERS_MULTICARRIER 0x00000001 typedef struct _WWAN_GET_VISIBLE_PROVIDERS { ULONG Action; }WWAN_GET_VISIBLE_PROVIDERS, *PWWAN_GET_VISIBLE_PROVIDERS; #endif typedef enum _WWAN_AUTH_METHOD{ WwanAuthSim = 0, WwanAuthAka, WwanAuthAkaPrime, WwanAuthMethodMax } WWAN_AUTH_METHOD, *PWWAN_AUTH_METHOD; typedef struct _WWAN_AUTH_SIM_CHALLENGE { BYTE Rand1[WWAN_AUTH_RAND_LEN]; BYTE Rand2[WWAN_AUTH_RAND_LEN]; BYTE Rand3[WWAN_AUTH_RAND_LEN]; ULONG n; } WWAN_AUTH_SIM_CHALLENGE, *PWWAN_AUTH_SIM_CHALLENGE; typedef struct _WWAN_AUTH_AKA_CHALLENGE { BYTE Rand[WWAN_AUTH_RAND_LEN]; BYTE Autn[WWAN_AUTH_AUTN_LEN]; } WWAN_AUTH_AKA_CHALLENGE, *PWWAN_AUTH_AKA_CHALLENGE; typedef struct _WWAN_AUTH_AKAP_CHALLENGE { BYTE Rand[WWAN_AUTH_RAND_LEN]; BYTE Autn[WWAN_AUTH_AUTN_LEN]; BYTE NetworkName[WWAN_AUTH_NETWORK_NAME_MAX_LEN]; ULONG NetworkNameLength; } WWAN_AUTH_AKAP_CHALLENGE, *PWWAN_AUTH_AKAP_CHALLENGE; typedef struct _WWAN_AUTH_CHALLENGE { WWAN_AUTH_METHOD AuthMethod; union { WWAN_AUTH_SIM_CHALLENGE AuthSim; WWAN_AUTH_AKA_CHALLENGE AuthAka; WWAN_AUTH_AKAP_CHALLENGE AuthAkap; } u; } WWAN_AUTH_CHALLENGE, *PWWAN_AUTH_CHALLENGE; typedef struct _WWAN_AUTH_SIM_RESPONSE { BYTE Sres1[WWAN_AUTH_SRES_LEN]; BYTE Kc1[WWAN_AUTH_KC_LEN]; BYTE Sres2[WWAN_AUTH_SRES_LEN]; BYTE Kc2[WWAN_AUTH_KC_LEN]; BYTE Sres3[WWAN_AUTH_SRES_LEN]; BYTE Kc3[WWAN_AUTH_KC_LEN]; ULONG n; } WWAN_AUTH_SIM_RESPONSE, *PWWAN_AUTH_SIM_RESPONSE; typedef struct _WWAN_AUTH_AKA_RESPONSE { BYTE Res[WWAN_AUTH_RES_MAX_LEN]; ULONG ResLength; BYTE IK[WWAN_AUTH_IK_LEN]; BYTE CK[WWAN_AUTH_CK_LEN]; BYTE Auts[WWAN_AUTH_AUTS_LEN]; } WWAN_AUTH_AKA_RESPONSE, *PWWAN_AUTH_AKA_RESPONSE; typedef struct _WWAN_AUTH_AKAP_RESPONSE { BYTE Res[WWAN_AUTH_RES_MAX_LEN]; ULONG ResLength; BYTE IKP[WWAN_AUTH_IK_LEN]; BYTE CKP[WWAN_AUTH_CK_LEN]; BYTE Auts[WWAN_AUTH_AUTS_LEN]; } WWAN_AUTH_AKAP_RESPONSE, *PWWAN_AUTH_AKAP_RESPONSE; typedef struct _WWAN_AUTH_RESPONSE { WWAN_AUTH_METHOD AuthMethod; union { WWAN_AUTH_SIM_RESPONSE AuthSim; WWAN_AUTH_AKA_RESPONSE AuthAka; WWAN_AUTH_AKAP_RESPONSE AuthAkap; } u; } WWAN_AUTH_RESPONSE, *PWWAN_AUTH_RESPONSE; typedef union { ULONG Value; struct { ULONG AddressAvailable:1; ULONG GatewayAvailable:1; ULONG DnsServerAvailable:1; ULONG MTUAvailable:1; }; } WWAN_IP_CONFIGURATION_FLAGS; typedef struct _WWAN_IPV4_ADDRESS { ULONG OnLinkPrefixLength; UCHAR IPV4Address[4]; } WWAN_IPV4_ADDRESS, *PWWAN_IPV4_ADDRESS; typedef struct _WWAN_IPV6_ADDRESS { ULONG OnLinkPrefixLength; UCHAR IPV6Address[16]; } WWAN_IPV6_ADDRESS, *PWWAN_IPV6_ADDRESS; typedef struct _WWAN_IPADDRESS_ENTRY { ULONG IsIpv6:1; ULONG IsReported:1; union { WWAN_IPV4_ADDRESS Ipv4; WWAN_IPV6_ADDRESS Ipv6; }; } WWAN_IPADDRESS_ENTRY, *PWWAN_IPADDRESS_ENTRY; typedef struct _WWAN_IP_ADDRESS_STATE { WWAN_IP_CONFIGURATION_FLAGS IPv4Flags; WWAN_IP_CONFIGURATION_FLAGS IPv6Flags; ULONG IPv4MTU; ULONG IPv6MTU; PWWAN_IPADDRESS_ENTRY IpTable; ULONG IpCount; PWWAN_IPADDRESS_ENTRY GatewayTable; ULONG GatewayCount; PWWAN_IPADDRESS_ENTRY DnsTable; ULONG DnsCount; } WWAN_IP_ADDRESS_STATE, *PWWAN_IP_ADDRESS_STATE; #if ( _WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD || NTDDI_VERSION >= NTDDI_WINTHRESHOLD || NDIS_SUPPORT_NDIS650 ) typedef enum _WWAN_UICC_FILE_ACCESSIBILITY { WwanUiccFileAccessibilityNotShareable = 0, WwanUiccFileAccessibilityShareable = 1, WwanUiccFileAccessibilityMaximum } WWAN_UICC_FILE_ACCESSIBILITY, *PWWAN_UICC_FILE_ACCESSIBILITY; typedef enum _WWAN_UICC_FILE_TYPE { WwanUiccFileTypeWorkingEf = 0, WwanUiccFileTypeInternalEf = 1, WwanUiccFileTypeDfOrEf = 2, WwanUiccFileTypeMax } WWAN_UICC_FILE_TYPE, *PWWAN_UICC_FILE_TYPE; typedef enum _WWAN_UICC_FILE_STRUCTURE { WwanUiccFileStructureUnknown = 0, WwanUiccFileStructureTransparent = 1, WwanUiccFileStructureCyclic = 2, WwanUiccFileStructureLinear = 3, WwanUiccFileStructureBertlv = 4, WwanUiccFileStructureMax } WWAN_UICC_FILE_STRUCTURE, *PWWAN_UICC_FILE_STRUCTURE; typedef struct _WWAN_UICC_FILE_PATH { BYTE AppIdLength; BYTE AppId[WWAN_UICC_APP_ID_MAX_LEN]; BYTE FilePathLength; USHORT FilePath[WWAN_UICC_FILE_PATH_MAX_LEN]; } WWAN_UICC_FILE_PATH, *PWWAN_UICC_FILE_PATH; typedef struct _WWAN_UICC_FILE_STATUS { ULONG StatusWord1; ULONG StatusWord2; WWAN_UICC_FILE_ACCESSIBILITY FileAccessibility; WWAN_UICC_FILE_TYPE FileType; WWAN_UICC_FILE_STRUCTURE FileStructure; ULONG ItemCount; ULONG Size; WWAN_PIN_TYPE FileLockStatus[WWAN_EF_ACCESS_TYPES_LEN]; } WWAN_UICC_FILE_STATUS, *PWWAN_UICC_FILE_STATUS; typedef struct _WWAN_UICC_ACCESS_BINARY { WWAN_UICC_FILE_PATH UiccFilePath; ULONG Offset; ULONG NumberOfBytes; BYTE LocalPinLength; BYTE LocalPin[WWAN_PIN_LEN]; USHORT CommandDataLength; BYTE CommandData[ANYSIZE_ARRAY]; } WWAN_UICC_ACCESS_BINARY, *PWWAN_UICC_ACCESS_BINARY; typedef struct _WWAN_UICC_ACCESS_RECORD { WWAN_UICC_FILE_PATH UiccFilePath; ULONG RecordNumber; ULONG NumberOfBytes; BYTE LocalPinLength; BYTE LocalPin[WWAN_PIN_LEN]; BYTE CommandDataLength; BYTE CommandData[WWAN_UICC_RECORD_DATA_MAX_LEN]; } WWAN_UICC_ACCESS_RECORD, *PWWAN_UICC_ACCESS_RECORD; typedef struct _WWAN_UICC_RESPONSE { ULONG StatusWord1; ULONG StatusWord2; USHORT ResponseDataLength; BYTE ResponseData[ANYSIZE_ARRAY]; } WWAN_UICC_RESPONSE, *PWWAN_UICC_RESPONSE; typedef struct _WWAN_SYS_CAPS_INFO { ULONG NumberOfExecutors; ULONG NumberOfSlots; ULONG Concurrency; } WWAN_SYS_CAPS_INFO, *PWWAN_SYS_CAPS_INFO; typedef struct _WWAN_MBIM_VERSION { USHORT MbimVersion; } WWAN_MBIM_VERSION, *PWWAN_MBIM_VERSION; typedef struct _WWAN_DEVICE_SLOT_MAPPING_INFO { WWAN_LIST_HEADER SlotMapListHeader; } WWAN_DEVICE_SLOT_MAPPING_INFO, *PWWAN_DEVICE_SLOT_MAPPING_INFO; typedef enum _WWAN_UICCSLOT_STATE { WwanUiccSlotStateOffEmpty = 0, WwanUiccSlotStateOff, WwanUiccSlotStateEmpty, WwanUiccSlotStateNotReady, WwanUiccSlotStateActive, WwanUiccSlotStateError, WwanUiccSlotStateMax } WWAN_UICCSLOT_STATE, *PWWAN_UICCSLOT_STATE; typedef struct _WWAN_GET_SLOT_INFO { ULONG SlotIndex; } WWAN_GET_SLOT_INFO, *PWWAN_GET_SLOT_INFO; typedef struct _WWAN_SLOT_INFO { ULONG SlotIndex; WWAN_UICCSLOT_STATE State; } WWAN_SLOT_INFO, *PWWAN_SLOT_INFO; #define MAX_CNT_UICC_APPS_BOUND_TO_DEVICE 2 typedef struct _WWAN_DEVICE_BINDINGS_INFO { WWAN_LIST_HEADER ApplicationListHeader; } WWAN_DEVICE_BINDINGS_INFO, *PWWAN_DEVICE_BINDINGS_INFO; typedef enum _WWAN_IMS_VOICE_STATUS { WwanImsVoiceStatusUnknown = 0, WwanImsVoiceStatusUnregistered, WwanImsVoiceStatusRegistered, WwanImsVoiceStatusMax } WWAN_IMS_VOICE_STATUS, *PWWAN_IMS_VOICE_STATUS; typedef struct _WWAN_SET_IMS_VOICE_STATE { WWAN_IMS_VOICE_STATUS ImsVoiceStatus; } WWAN_SET_IMS_VOICE_STATE, *PWWAN_SET_IMS_VOICE_STATE; typedef struct _WWAN_IMS_VOICE_STATE { WWAN_IMS_VOICE_STATUS ImsVoiceStatus; } WWAN_IMS_VOICE_STATE, *PWWAN_IMS_VOICE_STATE; typedef enum _WWAN_LOCATION_TRIGGER_MODE { WwanLocationTriggerNone = 0, WwanLocationTriggerAreaCode, WwanLocationTriggerAreaCellId, WwanLocationTriggerMax } WWAN_LOCATION_TRIGGER_MODE, *PWWAN_LOCATION_TRIGGER_MODE; typedef struct _WWAN_SET_LOCATION_STATE { WWAN_LOCATION_TRIGGER_MODE Trigger; } WWAN_SET_LOCATION_STATE, *PWWAN_SET_LOCATION_STATE; typedef struct _WWAN_LOCATION_STATE_INFO { WWAN_LOCATION_TRIGGER_MODE Trigger; ULONG DataClass; ULONG AreaCode; ULONG CellId; } WWAN_LOCATION_STATE_INFO, *PWWAN_LOCATION_STATE_INFO; typedef struct _WWAN_NITZ_INFO { ULONG Year; ULONG Month; ULONG Day; ULONG Hour; ULONG Minute; ULONG Second; ULONG TimeZoneOffsetMinutes; ULONG DaylightSavingTimeOffsetMinutes; ULONG DataClasses; } WWAN_NITZ_INFO, *PWWAN_NITZ_INFO; typedef struct _WWAN_NETWORK_IDLE_HINT { BOOLEAN IsEnabled; } WWAN_NETWORK_IDLE_HINT, *PWWAN_NETWORK_IDLE_HINT; #endif #if _MSC_VER >= 1200 #pragma warning(pop) #else #pragma warning(default:4201) #endif #endif
5bca9f921afd8d22b3dc86d2fc691c830700218a
fa1ad2e2ac7e376fc7cb3b3a6e1bb88eed3e80be
/govern/data-security/krb-1.2.1/src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c
bcb622e8fffe037c409d72f67b97afaee73b9216
[ "BSD-4-Clause", "LicenseRef-scancode-generic-export-compliance", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-mit-old-style", "BSD-4-Clause-UC", "LicenseRef-scancode-rsa-1990", "BSD-3-Clause", "MIT-CMU", "LicenseRef-scancode-mit-no-advert-export-control", "CC-BY-SA-3.0", "LicenseRef-scancode-mit-modification-obligations", "LicenseRef-scancode-proprietary-license", "GPL-2.0-or-later", "LicenseRef-scancode-michigan-disclaimer", "ISC", "LicenseRef-scancode-nrl-permission", "FreeBSD-DOC", "LicenseRef-scancode-rsa-md4", "RSA-MD", "OLDAP-2.8", "FSFULLRWD", "BSD-2-Clause", "LicenseRef-scancode-brian-gladman", "MIT", "Apache-2.0" ]
permissive
alldatacenter/alldata
7bc7713c9f1d56ad6b8e59ea03206d1073b7e047
8d5f9a2d49ab8f9e85ccf058cb02c2fda287afc6
refs/heads/master
2023-08-05T07:32:25.442740
2023-08-03T13:17:24
2023-08-03T13:17:24
213,321,771
774
250
Apache-2.0
2023-09-06T17:35:32
2019-10-07T07:36:18
null
UTF-8
C
false
false
4,047
c
ldap_service_stash.c
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c */ /* * Copyright (c) 2004-2005, Novell, Inc. * 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. * * The copyright holder's name is not used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include "ldap_main.h" #include "kdb_ldap.h" #include "ldap_service_stash.h" #include <k5-hex.h> #include <ctype.h> /* Decode a password of the form {HEX}<hexstring>. */ static krb5_error_code dec_password(krb5_context context, const char *str, char **password_out) { krb5_error_code ret; uint8_t *bytes; size_t len; *password_out = NULL; if (strncmp(str, "{HEX}", 5) != 0) { k5_setmsg(context, EINVAL, _("Not a hexadecimal password")); return EINVAL; } ret = k5_hex_decode(str + 5, &bytes, &len); if (ret) { if (ret == EINVAL) k5_setmsg(context, ret, _("Password corrupt")); return ret; } *password_out = (char *)bytes; return 0; } krb5_error_code krb5_ldap_readpassword(krb5_context context, const char *filename, const char *name, char **password_out) { krb5_error_code ret; char line[RECORDLEN], *end; const char *start, *sep, *val = NULL; int namelen = strlen(name); FILE *fp; *password_out = NULL; fp = fopen(filename, "r"); if (fp == NULL) { ret = errno; k5_setmsg(context, ret, _("Cannot open LDAP password file '%s': %s"), filename, error_message(ret)); return ret; } set_cloexec_file(fp); while (fgets(line, RECORDLEN, fp) != NULL) { /* Remove trailing newline. */ end = line + strlen(line); if (end > line && end[-1] == '\n') end[-1] = '\0'; /* Skip past leading whitespace. */ for (start = line; isspace(*start); ++start); /* Ignore comment lines */ if (*start == '!' || *start == '#') continue; sep = strchr(start, '#'); if (sep != NULL && sep - start == namelen && strncasecmp(start, name, namelen) == 0) { val = sep + 1; break; } } fclose(fp); if (val == NULL) { k5_setmsg(context, KRB5_KDB_SERVER_INTERNAL_ERR, _("Bind DN entry '%s' missing in LDAP password file '%s'"), name, filename); return KRB5_KDB_SERVER_INTERNAL_ERR; } /* Extract the plain password information. */ return dec_password(context, val, password_out); }
65c7ecd3270c3cb03a463c0a643177b291646a4a
2c73a693c2b3c162eae2ab94f649d8c4494878ba
/components/u8g2/u8x8_d_uc1701_dogs102.c
7d0fc3e491be7502ab552a44ca8bca1eb8050dc0
[ "MIT" ]
permissive
openLuat/LuatOS
185e1e140aed908434168133571ddcafe98f4e12
4b29d5121ab4f7133630331e8502c526c7856897
refs/heads/master
2023-08-23T04:57:23.263539
2023-08-23T04:46:46
2023-08-23T04:46:46
230,403,844
378
93
MIT
2021-12-17T02:19:30
2019-12-27T08:29:19
C
UTF-8
C
false
false
7,530
c
u8x8_d_uc1701_dogs102.c
/* u8x8_d_uc1701_dogs102.c Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com 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. 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. */ #include "u8x8.h" static const uint8_t u8x8_d_uc1701_dogs102_init_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ U8X8_C(0x0e2), /* soft reset */ U8X8_C(0x0ae), /* display off */ U8X8_C(0x040), /* set display start line to 0 */ U8X8_C(0x0a1), /* ADC set to reverse */ U8X8_C(0x0c0), /* common output mode */ // Flipmode //U8X8_C(0x0a0), /* ADC set to reverse */ //U8X8_C(0x0c8), /* common output mode */ U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ U8X8_C(0x0a2), /* LCD bias 1/9 */ U8X8_C(0x02f), /* all power control circuits on */ U8X8_C(0x027), /* regulator, booster and follower */ U8X8_CA(0x081, 0x00e), /* set contrast, contrast value, EA default: 0x010, previous value for S102: 0x0e */ U8X8_C(0x0fa), /* Set Temp compensation */ U8X8_C(0x090), /* 0.11 deg/c WP Off WC Off*/ U8X8_C(0x0ae), /* display off */ U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ U8X8_END_TRANSFER(), /* disable chip */ U8X8_END() /* end of sequence */ }; static const uint8_t u8x8_d_uc1701_dogs102_powersave0_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ U8X8_C(0x0a4), /* all pixel off, issue 142 */ U8X8_C(0x0af), /* display on */ U8X8_END_TRANSFER(), /* disable chip */ U8X8_END() /* end of sequence */ }; static const uint8_t u8x8_d_uc1701_dogs102_powersave1_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ U8X8_C(0x0ae), /* display off */ U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ U8X8_END_TRANSFER(), /* disable chip */ U8X8_END() /* end of sequence */ }; static const uint8_t u8x8_d_uc1701_dogs102_flip0_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ U8X8_C(0x0a1), /* segment remap a0/a1*/ U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ U8X8_END_TRANSFER(), /* disable chip */ U8X8_END() /* end of sequence */ }; static const uint8_t u8x8_d_uc1701_dogs102_flip1_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ U8X8_C(0x0a0), /* segment remap a0/a1*/ U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ U8X8_END_TRANSFER(), /* disable chip */ U8X8_END() /* end of sequence */ }; static const u8x8_display_info_t u8x8_uc1701_display_info = { /* chip_enable_level = */ 0, /* chip_disable_level = */ 1, /* post_chip_enable_wait_ns = */ 5, /* pre_chip_disable_wait_ns = */ 5, /* reset_pulse_width_ms = */ 1, /* post_reset_wait_ms = */ 6, /* sda_setup_time_ns = */ 12, /* sck_pulse_width_ns = */ 75, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ /* spi_mode = */ 0, /* active high, rising edge */ /* i2c_bus_clock_100kHz = */ 4, /* data_setup_time_ns = */ 30, /* write_pulse_width_ns = */ 40, /* tile_width = */ 13, /* width of 13*8=104 pixel */ /* tile_hight = */ 8, /* default_x_offset = */ 0, /* flipmode_x_offset = */ 30, /* pixel_width = */ 102, /* pixel_height = */ 64 }; uint8_t u8x8_d_uc1701_ea_dogs102(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) { uint8_t x, c; uint8_t *ptr; switch(msg) { case U8X8_MSG_DISPLAY_SETUP_MEMORY: u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1701_display_info); break; case U8X8_MSG_DISPLAY_INIT: u8x8_d_helper_display_init(u8x8); u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq); break; case U8X8_MSG_DISPLAY_SET_POWER_SAVE: if ( arg_int == 0 ) u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_powersave0_seq); else u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_powersave1_seq); break; case U8X8_MSG_DISPLAY_SET_FLIP_MODE: if ( arg_int == 0 ) { u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_flip0_seq); u8x8->x_offset = u8x8->display_info->default_x_offset; } else { u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_flip1_seq); u8x8->x_offset = u8x8->display_info->flipmode_x_offset; } break; #ifdef U8X8_WITH_SET_CONTRAST case U8X8_MSG_DISPLAY_SET_CONTRAST: u8x8_cad_StartTransfer(u8x8); u8x8_cad_SendCmd(u8x8, 0x081 ); u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* uc1701 has range from 0 to 63 */ u8x8_cad_EndTransfer(u8x8); break; #endif case U8X8_MSG_DISPLAY_DRAW_TILE: u8x8_cad_StartTransfer(u8x8); x = ((u8x8_tile_t *)arg_ptr)->x_pos; x *= 8; x += u8x8->x_offset; u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) ); u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15))); u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); c = ((u8x8_tile_t *)arg_ptr)->cnt; c *= 8; ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* The following if condition checks the hardware limits of the uc1701 controller: It is not allowed to write beyond the display limits. This is in fact an issue within flip mode. */ if ( c + x > 132u ) { c = 132u; c -= x; } do { u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */ arg_int--; } while( arg_int > 0 ); u8x8_cad_EndTransfer(u8x8); break; default: return 0; } return 1; }
187fddbe7a322fce7e904a018ccf14d942d8334f
4c76a7af8c8f9996421b5de1c838254fa3ca7443
/c-api/tests/src/test_document_end_api.c
bbb744519317c75798c335414072367e7b210a0e
[ "BSD-3-Clause", "CC-BY-SA-4.0" ]
permissive
cloudflare/lol-html
0087e363d4fdc6098b7d2fdad10264dd03b33fe4
8d4c273ded322193d017042d1f48df2766b0f88b
refs/heads/master
2023-09-04T05:24:37.847130
2023-08-06T12:17:18
2023-08-06T13:07:07
207,206,333
1,284
68
BSD-3-Clause
2023-09-13T18:39:59
2019-09-09T02:20:32
Rust
UTF-8
C
false
false
2,737
c
test_document_end_api.c
#include "../../include/lol_html.h" #include "deps/picotest/picotest.h" #include "tests.h" #include "test_util.h" static int EXPECTED_USER_DATA = 43; //------------------------------------------------------------------------- EXPECT_OUTPUT( append_to_empty_doc_output_sink, "<!--appended text-->hello &amp; world", &EXPECTED_USER_DATA, sizeof(EXPECTED_USER_DATA) ); static lol_html_rewriter_directive_t append_to_empty_doc( lol_html_doc_end_t *doc_end, void *user_data ) { note("Append at at the end of an empty document"); ok(*(int*)user_data == EXPECTED_USER_DATA); const char *append_html = "<!--appended text-->"; ok(!lol_html_doc_end_append(doc_end, append_html, strlen(append_html), true)); const char *append_text = "hello & world"; ok(!lol_html_doc_end_append(doc_end, append_text, strlen(append_text), false)); return LOL_HTML_CONTINUE; } static void test_append_to_empty_doc(void *user_data) { lol_html_rewriter_builder_t *builder = lol_html_rewriter_builder_new(); lol_html_rewriter_builder_add_document_content_handlers( builder, NULL, NULL, NULL, NULL, NULL, NULL, append_to_empty_doc, user_data ); run_rewriter( builder, "", append_to_empty_doc_output_sink, user_data ); } //------------------------------------------------------------------------- EXPECT_OUTPUT( append_at_end_output_sink, "<html><div>Hello</div></html><!--appended text-->hello &amp; world", &EXPECTED_USER_DATA, sizeof(EXPECTED_USER_DATA) ); static lol_html_rewriter_directive_t append_at_end( lol_html_doc_end_t *doc_end, void *user_data ) { note("Append at at the end"); ok(*(int*)user_data == EXPECTED_USER_DATA); const char *append_html = "<!--appended text-->"; ok(!lol_html_doc_end_append(doc_end, append_html, strlen(append_html), true)); const char *append_text = "hello & world"; ok(!lol_html_doc_end_append(doc_end, append_text, strlen(append_text), false)); return LOL_HTML_CONTINUE; } static void test_append_at_end(void *user_data) { lol_html_rewriter_builder_t *builder = lol_html_rewriter_builder_new(); lol_html_rewriter_builder_add_document_content_handlers( builder, NULL, NULL, NULL, NULL, NULL, NULL, append_at_end, user_data ); run_rewriter( builder, "<html><div>Hello</div></html>", append_at_end_output_sink, user_data ); } void document_end_api_test() { int user_data = 43; test_append_to_empty_doc(&user_data); test_append_at_end(&user_data); }
49a55c87f440a0dda5befefa160ac6eb9df69810
0744dcc5394cebf57ebcba343747af6871b67017
/apps/examples/wifi_manager/wm_test/wm_test_stress_test2.c
c1a1546314eca559065d86dd4c77539ce0b1c5ed
[ "Apache-2.0", "BSD-3-Clause", "MIT" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C
false
false
12,970
c
wm_test_stress_test2.c
/**************************************************************************** * * Copyright 2018 Samsung Electronics All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License\n"); * 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 <tinyara/config.h> #include <sys/types.h> #include <stdio.h> #include <queue.h> #include <semaphore.h> #include <assert.h> #include <string.h> #include <wifi_manager/wifi_manager.h> #include <stress_tool/st_perf.h> #include "wm_test.h" #include "wm_test_log.h" #include "wm_test_utils.h" /* Macro*/ #define WM_TEST_TRIAL CONFIG_WIFIMANAGER_TEST_TRIAL #define WM_NSOFTAP_SSID "no_sta_0101" // for auto test #define TAG "[WTS2]" static interop_ap_config_list_s g_apconfig_list; static char *WM_AP_SSID; static char *WM_AP_PASSWORD; static wifi_manager_ap_auth_type_e WM_AP_AUTH; static wifi_manager_ap_crypto_type_e WM_AP_CRYPTO; static char *WM_SOFTAP_SSID; static char *WM_SOFTAP_PASSWORD; static int WM_SOFTAP_CHANNEL; /* * callbacks */ static void wm_sta_connected(wifi_manager_cb_msg_s msg, void *arg); static void wm_sta_disconnected(wifi_manager_cb_msg_s msg, void *arg); static void wm_softap_sta_join(wifi_manager_cb_msg_s msg, void *arg); static void wm_softap_sta_leave(wifi_manager_cb_msg_s msg, void *arg); static void wm_scan_done(wifi_manager_cb_msg_s msg, void *arg); extern int wifi_interop_read_file(interop_ap_config_list_s *ap_config_list, char *file_path); /* * Global */ static wifi_manager_cb_s g_wifi_callbacks = { wm_sta_connected, wm_sta_disconnected, wm_softap_sta_join, wm_softap_sta_leave, wm_scan_done, }; static struct wo_queue *g_wo_queue = NULL; static int g_conn = 0; /* * Callback */ void wm_sta_connected(wifi_manager_cb_msg_s msg, void *arg) { WT_LOG(TAG, "--> res(%d)", msg.res); WO_TEST_SIGNAL(msg.res, g_wo_queue); } void wm_sta_disconnected(wifi_manager_cb_msg_s msg, void *arg) { WT_LOG(TAG, "-->"); WO_TEST_SIGNAL(msg.res, g_wo_queue); } void wm_softap_sta_join(wifi_manager_cb_msg_s msg, void *arg) { WT_LOG(TAG, "-->"); WO_TEST_SIGNAL(-1, g_wo_queue); } void wm_softap_sta_leave(wifi_manager_cb_msg_s msg, void *arg) { WT_LOG(TAG, "-->"); WO_TEST_SIGNAL(-1, g_wo_queue); } void wm_scan_done(wifi_manager_cb_msg_s msg, void *arg) { WT_LOG(TAG, "-->"); /* Make sure you copy the scan results onto a local data structure. * It will be deleted soon eventually as you exit this function. */ if (msg.res != WIFI_MANAGER_SUCCESS || msg.scanlist == NULL) { WO_TEST_SIGNAL(msg.res, g_wo_queue); return; } wt_print_scanlist(msg.scanlist); WO_TEST_SIGNAL(msg.res, g_wo_queue); } static void wm_get_nosoftapinfo(wifi_manager_softap_config_s *ap_config) { strncpy(ap_config->ssid, WM_NSOFTAP_SSID, strlen(WM_NSOFTAP_SSID) + 1); strncpy(ap_config->passphrase, WM_SOFTAP_PASSWORD, strlen(WM_SOFTAP_PASSWORD) + 1); ap_config->channel = WM_SOFTAP_CHANNEL; } /* * station join test */ TEST_SETUP(sta_join) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); ST_END_TEST; } TEST_TEARDOWN(sta_join) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_disconnect_ap()); WO_TEST_WAIT(g_conn, g_wo_queue); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } TEST_F(sta_join) { ST_START_TEST; wifi_manager_ap_config_s apconfig; wm_get_apinfo(&apconfig, WM_AP_SSID, WM_AP_PASSWORD, WM_AP_AUTH, WM_AP_CRYPTO); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_connect_ap(&apconfig)); WO_TEST_WAIT(g_conn, g_wo_queue); ST_END_TEST; } /* * station scan test */ TEST_SETUP(sta_scan) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); ST_END_TEST; } TEST_TEARDOWN(sta_scan) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } TEST_F(sta_scan) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_scan_ap(NULL)); WO_TEST_WAIT(g_conn, g_wo_queue); ST_END_TEST; } /* * station leave test */ TEST_SETUP(sta_leave) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); wifi_manager_ap_config_s apconfig; wm_get_apinfo(&apconfig, WM_AP_SSID, WM_AP_PASSWORD, WM_AP_AUTH, WM_AP_CRYPTO); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_connect_ap(&apconfig)); WO_TEST_WAIT(g_conn, g_wo_queue); ST_END_TEST; } TEST_TEARDOWN(sta_leave) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } TEST_F(sta_leave) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_disconnect_ap()); WO_TEST_WAIT(g_conn, g_wo_queue); ST_END_TEST; } /* * SoftAP Start */ TEST_SETUP(softap_start) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); ST_END_TEST; } TEST_TEARDOWN(softap_start) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } TEST_F(softap_start) { ST_START_TEST; wifi_manager_softap_config_s ap_config; wm_get_nosoftapinfo(&ap_config); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(SOFTAP_MODE, &ap_config)); ST_END_TEST; } /* * SoftAP Scan */ TEST_SETUP(softap_scan) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); wifi_manager_softap_config_s ap_config; wm_get_nosoftapinfo(&ap_config); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(SOFTAP_MODE, &ap_config)); ST_END_TEST; } TEST_TEARDOWN(softap_scan) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } TEST_F(softap_scan) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_scan_ap(NULL)); WO_TEST_WAIT(g_conn, g_wo_queue); ST_END_TEST; } /* * Soft AP scan in joined state */ TEST_SETUP(softap_joined_scan) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); wifi_manager_softap_config_s ap_config; wm_get_softapinfo(&ap_config, WM_SOFTAP_SSID, WM_SOFTAP_PASSWORD, WM_SOFTAP_CHANNEL); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(SOFTAP_MODE, &ap_config)); WO_TEST_WAIT(g_conn, g_wo_queue); ST_END_TEST; } TEST_TEARDOWN(softap_joined_scan) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } TEST_F(softap_joined_scan) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_scan_ap(NULL)); WO_TEST_WAIT(g_conn, g_wo_queue); ST_END_TEST; } /* * SoftAP Stop */ TEST_SETUP(softap_stop) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); wifi_manager_softap_config_s ap_config; wm_get_nosoftapinfo(&ap_config); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(SOFTAP_MODE, &ap_config)); ST_END_TEST; } TEST_TEARDOWN(softap_stop) { ST_START_TEST; ST_END_TEST; } TEST_F(softap_stop) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } /* * SoftAP(joined) Stop */ TEST_SETUP(softap_joined_stop) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); wifi_manager_softap_config_s ap_config; wm_get_softapinfo(&ap_config, WM_SOFTAP_SSID, WM_SOFTAP_PASSWORD, WM_SOFTAP_CHANNEL); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(SOFTAP_MODE, &ap_config)); WO_TEST_WAIT(g_conn, g_wo_queue); ST_END_TEST; } TEST_TEARDOWN(softap_joined_stop) { ST_START_TEST; ST_END_TEST; } TEST_F(softap_joined_stop) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } /* * STA(disconnection) --> SoftAP */ TEST_SETUP(disconn_to_softap) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); ST_END_TEST; } TEST_TEARDOWN(disconn_to_softap) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } TEST_F(disconn_to_softap) { ST_START_TEST; wifi_manager_softap_config_s ap_config; wm_get_nosoftapinfo(&ap_config); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(SOFTAP_MODE, &ap_config)); ST_END_TEST; } /* * STA(connected) --> SoftAP */ TEST_SETUP(conn_to_softap) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); wifi_manager_ap_config_s apconfig; wm_get_apinfo(&apconfig, WM_AP_SSID, WM_AP_PASSWORD, WM_AP_AUTH, WM_AP_CRYPTO); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_connect_ap(&apconfig)); WO_TEST_WAIT(g_conn, g_wo_queue); ST_END_TEST; } TEST_TEARDOWN(conn_to_softap) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } TEST_F(conn_to_softap) { ST_START_TEST; wifi_manager_softap_config_s ap_config; wm_get_nosoftapinfo(&ap_config); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(SOFTAP_MODE, &ap_config)); ST_END_TEST; } /* * SoftAP(no joined STA) --> STA */ TEST_SETUP(leave_to_sta) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); wifi_manager_softap_config_s ap_config; wm_get_nosoftapinfo(&ap_config); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(SOFTAP_MODE, &ap_config)); ST_END_TEST; } TEST_TEARDOWN(leave_to_sta) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } TEST_F(leave_to_sta) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(STA_MODE, NULL)); ST_END_TEST; } /* * SoftAP(joined STA) --> STA */ TEST_SETUP(join_to_sta) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_init(&g_wifi_callbacks)); wifi_manager_softap_config_s ap_config; wm_get_softapinfo(&ap_config, WM_SOFTAP_SSID, WM_SOFTAP_PASSWORD, WM_SOFTAP_CHANNEL); ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(SOFTAP_MODE, &ap_config)); WO_TEST_WAIT(g_conn, g_wo_queue); // wait STA joined ST_END_TEST; } TEST_TEARDOWN(join_to_sta) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_deinit()); ST_END_TEST; } TEST_F(join_to_sta) { ST_START_TEST; ST_EXPECT_EQ(WIFI_MANAGER_SUCCESS, wifi_manager_set_mode(STA_MODE, NULL)); ST_END_TEST; } void wm_run_stress_test2_single_ap(struct wt_options *opt) { WM_AP_SSID = opt->ssid; WM_AP_PASSWORD = opt->password; WM_AP_AUTH = opt->auth_type; WM_AP_CRYPTO = opt->crypto_type; WM_SOFTAP_SSID = opt->softap_ssid; WM_SOFTAP_PASSWORD = opt->softap_password; WM_SOFTAP_CHANNEL = opt->softap_channel; /* Create Queue */ g_wo_queue = wo_create_queue(); if (!g_wo_queue) { WT_LOGE(TAG, "create queue fail"); return; } ST_SET_PACK(wifi); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 10000000, "station join", sta_join); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 10000000, "station scan", sta_scan); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 2000000, "station leave", sta_leave); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 5000000, "softap start", softap_start); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 5000000, "softap scan", softap_scan); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 5000000, "softap(joined) scan", softap_joined_scan); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 5000000, "softap stop", softap_stop); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 5000000, "softap(joined) stop", softap_joined_stop); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 5000000, "sta(disconnected) to softap", disconn_to_softap); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 5000000, "sta(connected) to softap", conn_to_softap); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 5000000, "softap(leave) to sta", leave_to_sta); ST_SET_SMOKE(wifi, WM_TEST_TRIAL, 5000000, "softap(join) to sta", join_to_sta); ST_RUN_TEST(wifi); ST_RESULT_TEST(wifi); /* Destroy queue */ wo_destroy_queue(g_wo_queue); } void wm_run_stress_test2(struct wt_options *opt) { if (!opt->path) { wm_run_stress_test2_single_ap(opt); } else { int ap_count = 0; interop_ap_info_s *ap_info = NULL; memset(&g_apconfig_list, 0, sizeof(g_apconfig_list)); int ret = 0; ret = wifi_interop_read_file(&g_apconfig_list, opt->path); if (ret < 0) { WT_LOGE(TAG, "-->%s: failed to open file \n", __FUNCTION__); return; } print_ap_config_list(&g_apconfig_list); ap_count = g_apconfig_list.ap_count; for (int i = 0; i < ap_count; i++) { ap_info = g_apconfig_list.ap_info + i; opt->ssid = ap_info->ap_config.ssid; opt->password = ap_info->ap_config.passphrase; opt->auth_type = ap_info->ap_config.ap_auth_type; opt->crypto_type = ap_info->ap_config.ap_crypto_type; wm_run_stress_test2_single_ap(opt); } } }
217007e7d2306c33e1f7c422d9cad5bec82ad2a4
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/misc/upclient/files/patch-options.c
13fa3c53a5cdeb9d1ed94120bb642070a469a172
[ "BSD-2-Clause" ]
permissive
freebsd/freebsd-ports
86f2e89d43913412c4f6b2be3e255bc0945eac12
605a2983f245ac63f5420e023e7dce56898ad801
refs/heads/main
2023-08-30T21:46:28.720924
2023-08-30T19:33:44
2023-08-30T19:33:44
1,803,961
916
918
NOASSERTION
2023-09-08T04:06:26
2011-05-26T11:15:35
null
UTF-8
C
false
false
788
c
patch-options.c
--- src/options.c.orig Tue May 27 09:03:43 2003 +++ src/options.c Wed Mar 3 00:47:28 2004 @@ -60,7 +60,7 @@ * Minimum value is enforced. A warning is logged if greater than upper limit. */ #define MINIMUM_INTERVAL 30 /* enforced */ -#define DEFAULT_INTERVAL 300 +#define DEFAULT_INTERVAL 550 #define UPPER_INTERVAL 600 /* warning if exceeded */ /* Macros */ @@ -79,7 +79,7 @@ * These are the configuration options available. */ char cfg_authkey[AUTHKEY_REQUIRED_LEN + 1] = ""; -char cfg_upserver[UPSERVER_MAXLEN + 1] = "uptimes.wonko.com"; +char cfg_upserver[UPSERVER_MAXLEN + 1] = "uptimes.hostingwired.com"; long int cfg_interval = DEFAULT_INTERVAL; char cfg_pidfile[PIDFILE_MAXLEN + 1] = PIDFILE; char cfg_proxyserver[PROXYSERVER_MAXLEN + 1] = "";
51493b6018606445ad0f7af5eea050e0fb000295
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/shark/include/types.h
2bde8b2814ec32df8a9f1021fd709095eb28b0d6
[]
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
306
h
types.h
/* $NetBSD: types.h,v 1.10 2017/01/26 15:55:10 christos Exp $ */ #ifndef _SHARK_TYPES_H_ #define _SHARK_TYPES_H_ #include <arm/arm32/types.h> /* We need to invoke FIQs indirectly. */ #define __ARM_FIQ_INDIRECT #define __HAVE_DEVICE_REGISTER #define __HAVE_COMPAT_NETBSD32 #endif /* _SHARK_TYPES_H_ */
f4b8874119fbe5246d0ce5033ac68008d2275e2e
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/ppapi/c/dev/ppb_printing_dev.h
59e4cc64db27c204e8cc9f66f6576cab73539f70
[ "LicenseRef-scancode-khronos", "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C
false
false
2,091
h
ppb_printing_dev.h
/* Copyright 2012 The Chromium Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From dev/ppb_printing_dev.idl modified Fri Apr 19 10:45:09 2013. */ #ifndef PPAPI_C_DEV_PPB_PRINTING_DEV_H_ #define PPAPI_C_DEV_PPB_PRINTING_DEV_H_ #include "ppapi/c/dev/pp_print_settings_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" #define PPB_PRINTING_DEV_INTERFACE_0_7 "PPB_Printing(Dev);0.7" #define PPB_PRINTING_DEV_INTERFACE PPB_PRINTING_DEV_INTERFACE_0_7 /** * @file * Definition of the PPB_Printing interface. */ /** * @addtogroup Interfaces * @{ */ struct PPB_Printing_Dev_0_7 { /** Create a resource for accessing printing functionality. * * @param[in] instance A <code>PP_Instance</code> identifying one instance * of a module. * * @return A <code>PP_Resource</code> containing the printing resource if * successful or 0 if it could not be created. */ PP_Resource (*Create)(PP_Instance instance); /** * Outputs the default print settings for the default printer into * <code>print_settings</code>. The callback is called with * <code>PP_OK</code> when the settings have been retrieved successfully. * * @param[in] resource The printing resource. * * @param[in] callback A <code>CompletionCallback</code> to be called when * <code>print_settings</code> have been retrieved. * * @return PP_OK_COMPLETIONPENDING if request for the default print settings * was successful, another error code from pp_errors.h on failure. */ int32_t (*GetDefaultPrintSettings)( PP_Resource resource, struct PP_PrintSettings_Dev* print_settings, struct PP_CompletionCallback callback); }; typedef struct PPB_Printing_Dev_0_7 PPB_Printing_Dev; /** * @} */ #endif /* PPAPI_C_DEV_PPB_PRINTING_DEV_H_ */
ec51859b6e51cf960113c1439f63e6a96132791a
5cb3030ed86e12332d109e1ab39f92c0c866677d
/src/strategies/avx2/sao-avx2.c
b4a6e59d16d5bdd2320a3d96c631531c71dc85e3
[ "BSD-3-Clause", "ISC" ]
permissive
ultravideo/kvazaar
9c8ac79644b4782e0c9743f6518f6997e2d9b774
aab6aa9b349d2768f9371ef58680298c200e47e6
refs/heads/master
2023-08-24T03:29:58.344475
2023-07-17T05:51:47
2023-07-17T05:51:47
16,339,396
629
211
BSD-3-Clause
2023-07-03T13:01:52
2014-01-29T08:35:53
C
UTF-8
C
false
false
41,694
c
sao-avx2.c
/***************************************************************************** * This file is part of Kvazaar HEVC encoder. * * Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors * 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 Tampere University or ITU/ISO/IEC 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 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS ****************************************************************************/ #include "strategies/avx2/sao-avx2.h" #if COMPILE_INTEL_AVX2 #include "kvazaar.h" #if KVZ_BIT_DEPTH == 8 #include <immintrin.h> #include <nmmintrin.h> // Use a couple generic functions from here as a worst-case fallback #include "strategies/generic/sao_shared_generics.h" #include "strategies/avx2/avx2_common_functions.h" #include "strategies/missing-intel-intrinsics.h" #include "cu.h" #include "encoder.h" #include "encoderstate.h" #include "sao.h" #include "strategyselector.h" // These optimizations are based heavily on sao-generic.c. // Might be useful to check that if (when) this file // is difficult to understand. // Do the SIGN3 operation for the difference a-b static INLINE __m256i sign3_diff_epu8(const __m256i a, const __m256i b) { // Subtract 0x80 from unsigneds to compare them as signed const __m256i epu2epi = _mm256_set1_epi8 (0x80); const __m256i ones = _mm256_set1_epi8 (0x01); __m256i a_signed = _mm256_sub_epi8 (a, epu2epi); __m256i b_signed = _mm256_sub_epi8 (b, epu2epi); __m256i diff = _mm256_subs_epi8 (a_signed, b_signed); return _mm256_sign_epi8 (ones, diff); } // Mapping of edge_idx values to eo-classes, 32x8b at once static __m256i FIX_W32 calc_eo_cat(const __m256i a, const __m256i b, const __m256i c) { const __m256i twos = _mm256_set1_epi8 (0x02); const __m256i idx_to_cat = _mm256_setr_epi64x(0x0403000201, 0, 0x0403000201, 0); __m256i c_a_sign = sign3_diff_epu8 (c, a); __m256i c_b_sign = sign3_diff_epu8 (c, b); __m256i signsum = _mm256_add_epi8 (c_a_sign, c_b_sign); __m256i eo_idx = _mm256_add_epi8 (signsum, twos); return _mm256_shuffle_epi8(idx_to_cat, eo_idx); } static INLINE __m256i srli_epi8(const __m256i v, const uint32_t shift) { const uint8_t hibit_mask = 0xff >> shift; const __m256i hibit_mask_256 = _mm256_set1_epi8(hibit_mask); __m256i v_shifted = _mm256_srli_epi32(v, shift); __m256i v_masked = _mm256_and_si256 (v_shifted, hibit_mask_256); return v_masked; } static INLINE void cvt_epu8_epi16(const __m256i v, __m256i *res_lo, __m256i *res_hi) { const __m256i zero = _mm256_setzero_si256(); *res_lo = _mm256_unpacklo_epi8(v, zero); *res_hi = _mm256_unpackhi_epi8(v, zero); } static INLINE void cvt_epi8_epi16(const __m256i v, __m256i *res_lo, __m256i *res_hi) { const __m256i zero = _mm256_setzero_si256(); __m256i signs = _mm256_cmpgt_epi8 (zero, v); *res_lo = _mm256_unpacklo_epi8(v, signs); *res_hi = _mm256_unpackhi_epi8(v, signs); } static INLINE void diff_epi8_epi16(const __m256i a, const __m256i b, __m256i *res_lo, __m256i *res_hi) { const __m256i invmask = _mm256_set1_epi16(0xff01); __m256i composite_lo = _mm256_unpacklo_epi8(a, b); __m256i composite_hi = _mm256_unpackhi_epi8(a, b); *res_lo = _mm256_maddubs_epi16(composite_lo, invmask); *res_hi = _mm256_maddubs_epi16(composite_hi, invmask); } // Convert a byte-addressed mask for VPSHUFB into two word-addressed ones, for // example: // 7 3 6 2 5 1 4 0 => e f 6 7 c d 4 5 a b 2 3 8 9 0 1 static INLINE void cvt_shufmask_epi8_epi16(const __m256i v, __m256i *res_lo, __m256i *res_hi) { const __m256i zero = _mm256_setzero_si256(); const __m256i ones = _mm256_set1_epi8(1); // There's no 8-bit shift, so highest bit could bleed into neighboring byte // if set. To avoid it, reset all sign bits with max. The only valid input // values for v are [0, 7] anyway and invalid places should be masked out by // caller, so it doesn't matter that we turn negative bytes into garbage. __m256i v_nonnegs = _mm256_max_epi8 (zero, v); __m256i v_lobytes = _mm256_slli_epi32(v_nonnegs, 1); __m256i v_hibytes = _mm256_add_epi8 (v_lobytes, ones); *res_lo = _mm256_unpacklo_epi8(v_lobytes, v_hibytes); *res_hi = _mm256_unpackhi_epi8(v_lobytes, v_hibytes); } // Check if all 4 dwords of v are in [-128, 127] and can be truncated to // 8 bits each. Returns -1 if everything is fine static INLINE uint16_t epi32v_fits_in_epi8s(const __m128i v) { // Compare most significant 25 bits of SAO bands to the sign bit to assert // that the i32's are between -128 and 127 (only comparing 24 would fail to // detect values of 128...255) __m128i v_ms25b = _mm_srai_epi32 (v, 7); __m128i v_signs = _mm_srai_epi32 (v, 31); __m128i ok_i32s = _mm_cmpeq_epi32 (v_ms25b, v_signs); return _mm_movemask_epi8(ok_i32s); } static INLINE __m128i truncate_epi32_epi8(const __m128i v) { // LSBs of each dword, the values values must fit in 8 bits anyway for // what this intended for (use epi32v_fits_in_epi8s to check if needed) const __m128i trunc_shufmask = _mm_set1_epi32 (0x0c080400); __m128i sbs_8 = _mm_shuffle_epi8(v, trunc_shufmask); return sbs_8; } // Read 0-3 bytes (pixels) into uint32_t static INLINE uint32_t load_border_bytes(const uint8_t *buf, const int32_t start_pos, const int32_t width_rest) { uint32_t last_dword = 0; for (int32_t i = 0; i < width_rest; i++) { uint8_t currb = buf[start_pos + i]; uint32_t currd = ((uint32_t)currb) << (i * 8); last_dword |= currd; } return last_dword; } static INLINE void store_border_bytes( uint8_t *buf, const uint32_t start_pos, const int32_t width_rest, uint32_t data) { for (uint32_t i = 0; i < width_rest; i++) { uint8_t currb = data & 0xff; buf[start_pos + i] = currb; data >>= 8; } } // Mask all inexistent bytes to 0xFF for functions that count particular byte // values, so they won't count anywhere static INLINE __m256i gen_badbyte_mask(const __m256i db4_mask, const int32_t width_rest) { const __m256i zero = _mm256_setzero_si256(); uint32_t last_badbytes = 0xffffffff << (width_rest << 3); __m256i badbyte_mask = _mm256_cmpeq_epi8 (db4_mask, zero); return _mm256_insert_epi32(badbyte_mask, last_badbytes, 7); } // Ok, so the broadcast si128->si256 instruction only works with a memory // source operand.. static INLINE __m256i broadcast_xmm2ymm(const __m128i v) { __m256i res = _mm256_castsi128_si256 (v); return _mm256_inserti128_si256(res, v, 1); } // Used for edge_ddistortion and band_ddistortion static __m256i FIX_W32 calc_diff_off_delta(const __m256i diff_lo, const __m256i diff_hi, const __m256i offsets, const __m256i orig) { const __m256i zero = _mm256_setzero_si256(); const __m256i negate_hiword = _mm256_set1_epi32(0xffff0001); __m256i orig_lo, orig_hi, offsets_lo, offsets_hi; cvt_epu8_epi16(orig, &orig_lo, &orig_hi); cvt_epi8_epi16(offsets, &offsets_lo, &offsets_hi); __m256i offsets_0_lo = _mm256_cmpeq_epi16 (offsets_lo, zero); __m256i offsets_0_hi = _mm256_cmpeq_epi16 (offsets_hi, zero); __m256i delta_lo = _mm256_sub_epi16 (diff_lo, offsets_lo); __m256i delta_hi = _mm256_sub_epi16 (diff_hi, offsets_hi); __m256i diff_lo_m = _mm256_andnot_si256 (offsets_0_lo, diff_lo); __m256i diff_hi_m = _mm256_andnot_si256 (offsets_0_hi, diff_hi); __m256i delta_lo_m = _mm256_andnot_si256 (offsets_0_lo, delta_lo); __m256i delta_hi_m = _mm256_andnot_si256 (offsets_0_hi, delta_hi); __m256i dd0_lo = _mm256_unpacklo_epi16(delta_lo_m, diff_lo_m); __m256i dd0_hi = _mm256_unpackhi_epi16(delta_lo_m, diff_lo_m); __m256i dd1_lo = _mm256_unpacklo_epi16(delta_hi_m, diff_hi_m); __m256i dd1_hi = _mm256_unpackhi_epi16(delta_hi_m, diff_hi_m); __m256i dd0_lo_n = _mm256_sign_epi16 (dd0_lo, negate_hiword); __m256i dd0_hi_n = _mm256_sign_epi16 (dd0_hi, negate_hiword); __m256i dd1_lo_n = _mm256_sign_epi16 (dd1_lo, negate_hiword); __m256i dd1_hi_n = _mm256_sign_epi16 (dd1_hi, negate_hiword); __m256i sum0_lo = _mm256_madd_epi16 (dd0_lo, dd0_lo_n); __m256i sum0_hi = _mm256_madd_epi16 (dd0_hi, dd0_hi_n); __m256i sum1_lo = _mm256_madd_epi16 (dd1_lo, dd1_lo_n); __m256i sum1_hi = _mm256_madd_epi16 (dd1_hi, dd1_hi_n); __m256i sum0 = _mm256_add_epi32 (sum0_lo, sum0_hi); __m256i sum1 = _mm256_add_epi32 (sum1_lo, sum1_hi); return _mm256_add_epi32 (sum0, sum1); } static INLINE __m256i FIX_W32 do_one_edge_ymm(const __m256i a, const __m256i b, const __m256i c, const __m256i orig, const __m256i badbyte_mask, const __m256i offsets_256) { __m256i eo_cat = calc_eo_cat(a, b, c); eo_cat = _mm256_or_si256 (eo_cat, badbyte_mask); __m256i offset = _mm256_shuffle_epi8(offsets_256, eo_cat); __m256i offset_lo, offset_hi; cvt_epi8_epi16(offset, &offset_lo, &offset_hi); __m256i diff_lo, diff_hi; diff_epi8_epi16(orig, c, &diff_lo, &diff_hi); return calc_diff_off_delta(diff_lo, diff_hi, offset, orig); } static int32_t sao_edge_ddistortion_avx2(const uint8_t *orig_data, const uint8_t *rec_data, int32_t block_width, int32_t block_height, int32_t eo_class, const int32_t offsets[NUM_SAO_EDGE_CATEGORIES]) { int32_t y, x; vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0]; vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1]; int32_t scan_width = block_width - 2; uint32_t width_db32 = scan_width & ~31; uint32_t width_db4 = scan_width & ~3; uint32_t width_rest = scan_width & 3; // Form the load&store mask const __m256i wdb4_256 = _mm256_set1_epi32 (width_db4 & 31); const __m256i indexes = _mm256_setr_epi32 (3, 7, 11, 15, 19, 23, 27, 31); const __m256i db4_mask = _mm256_cmpgt_epi32(wdb4_256, indexes); const __m256i zero = _mm256_setzero_si256(); __m128i offsets03 = _mm_loadu_si128((const __m128i *)offsets); __m128i offsets4 = _mm_cvtsi32_si128(offsets[4]); uint16_t offsets_ok = epi32v_fits_in_epi8s(offsets03) & epi32v_fits_in_epi8s(offsets4); assert(NUM_SAO_EDGE_CATEGORIES == 5); if (offsets_ok != 0xffff) { return sao_edge_ddistortion_generic(orig_data, rec_data, block_width, block_height, eo_class, offsets); } __m128i offsets03_8b = truncate_epi32_epi8(offsets03); __m128i offsets4_8b = truncate_epi32_epi8(offsets4); __m128i offsets_8b = _mm_unpacklo_epi32 (offsets03_8b, offsets4_8b); __m256i offsets_256 = broadcast_xmm2ymm (offsets_8b); __m256i sum = _mm256_setzero_si256(); for (y = 1; y < block_height - 1; y++) { for (x = 1; x < width_db32 + 1; x += 32) { uint32_t c_pos = y * block_width + x; uint32_t a_pos = (y + a_ofs.y) * block_width + x + a_ofs.x; uint32_t b_pos = (y + b_ofs.y) * block_width + x + b_ofs.x; __m256i a = _mm256_loadu_si256((const __m256i *)(rec_data + a_pos)); __m256i b = _mm256_loadu_si256((const __m256i *)(rec_data + b_pos)); __m256i c = _mm256_loadu_si256((const __m256i *)(rec_data + c_pos)); __m256i orig = _mm256_loadu_si256((const __m256i *)(orig_data + c_pos)); __m256i curr = do_one_edge_ymm(a, b, c, orig, zero, offsets_256); sum = _mm256_add_epi32(sum, curr); } if (scan_width > width_db32) { const uint32_t curr_cpos = y * block_width + x; const uint32_t rest_cpos = y * block_width + width_db4 + 1; const int32_t curr_apos = (y + a_ofs.y) * block_width + x + a_ofs.x; const int32_t rest_apos = (y + a_ofs.y) * block_width + width_db4 + a_ofs.x + 1; const int32_t curr_bpos = (y + b_ofs.y) * block_width + x + b_ofs.x; const int32_t rest_bpos = (y + b_ofs.y) * block_width + width_db4 + b_ofs.x + 1; // Same trick to read a narrow line as there is in the band SAO routine uint32_t a_last = load_border_bytes(rec_data, rest_apos, width_rest); uint32_t b_last = load_border_bytes(rec_data, rest_bpos, width_rest); uint32_t c_last = load_border_bytes(rec_data, rest_cpos, width_rest); uint32_t orig_last = load_border_bytes(orig_data, rest_cpos, width_rest); const int32_t *a_ptr = (const int32_t *)(rec_data + curr_apos); const int32_t *b_ptr = (const int32_t *)(rec_data + curr_bpos); const int32_t *c_ptr = (const int32_t *)(rec_data + curr_cpos); const int32_t *orig_ptr = (const int32_t *)(orig_data + curr_cpos); __m256i a = _mm256_maskload_epi32(a_ptr, db4_mask); __m256i b = _mm256_maskload_epi32(b_ptr, db4_mask); __m256i c = _mm256_maskload_epi32(c_ptr, db4_mask); __m256i orig = _mm256_maskload_epi32(orig_ptr, db4_mask); a = _mm256_insert_epi32 (a, a_last, 7); b = _mm256_insert_epi32 (b, b_last, 7); c = _mm256_insert_epi32 (c, c_last, 7); orig = _mm256_insert_epi32 (orig, orig_last, 7); // Mask all unused bytes to 0xFF, so they won't count anywhere __m256i badbyte_mask = gen_badbyte_mask(db4_mask, width_rest); __m256i curr = do_one_edge_ymm(a, b, c, orig, badbyte_mask, offsets_256); sum = _mm256_add_epi32(sum, curr); } } return hsum_8x32b(sum); } static void FIX_W32 calc_edge_dir_one_ymm(const __m256i a, const __m256i b, const __m256i c, const __m256i orig, const __m256i badbyte_mask, __m256i *diff_accum, int32_t *hit_cnt) { const __m256i ones_16 = _mm256_set1_epi16(1); __m256i eo_cat = calc_eo_cat (a, b, c); eo_cat = _mm256_or_si256 (eo_cat, badbyte_mask); __m256i diffs_lo, diffs_hi; diff_epi8_epi16(orig, c, &diffs_lo, &diffs_hi); for (uint32_t i = 0; i < 5; i++) { __m256i curr_id = _mm256_set1_epi8 (i); __m256i eoc_mask = _mm256_cmpeq_epi8 (eo_cat, curr_id); uint32_t eoc_bits = _mm256_movemask_epi8(eoc_mask); uint32_t eoc_hits = _mm_popcnt_u32 (eoc_bits); __m256i eoc_mask_lo = _mm256_unpacklo_epi8(eoc_mask, eoc_mask); __m256i eoc_mask_hi = _mm256_unpackhi_epi8(eoc_mask, eoc_mask); __m256i eoc_diffs_lo = _mm256_and_si256 (diffs_lo, eoc_mask_lo); __m256i eoc_diffs_hi = _mm256_and_si256 (diffs_hi, eoc_mask_hi); __m256i eoc_diffs_16 = _mm256_add_epi16 (eoc_diffs_lo, eoc_diffs_hi); __m256i eoc_diffs_32 = _mm256_madd_epi16 (eoc_diffs_16, ones_16); diff_accum[i] = _mm256_add_epi32 (diff_accum[i], eoc_diffs_32); hit_cnt[i] += eoc_hits; } } static void calc_sao_edge_dir_avx2(const uint8_t *orig_data, const uint8_t *rec_data, int32_t eo_class, int32_t block_width, int32_t block_height, int32_t cat_sum_cnt[2][NUM_SAO_EDGE_CATEGORIES]) { vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0]; vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1]; int32_t *diff_sum = cat_sum_cnt[0]; int32_t *hit_cnt = cat_sum_cnt[1]; int32_t scan_width = block_width - 2; int32_t width_db32 = scan_width & ~31; int32_t width_db4 = scan_width & ~3; int32_t width_rest = scan_width & 3; const __m256i zero = _mm256_setzero_si256(); // Form the load&store mask const __m256i wdb4_256 = _mm256_set1_epi32 (width_db4 & 31); const __m256i indexes = _mm256_setr_epi32 (3, 7, 11, 15, 19, 23, 27, 31); const __m256i db4_mask = _mm256_cmpgt_epi32(wdb4_256, indexes); __m256i diff_accum[5] = { _mm256_setzero_si256() }; int32_t y, x; for (y = 1; y < block_height - 1; y++) { for (x = 1; x < width_db32 + 1; x += 32) { const uint32_t a_off = (y + a_ofs.y) * block_width + x + a_ofs.x; const uint32_t b_off = (y + b_ofs.y) * block_width + x + b_ofs.x; const uint32_t c_off = y * block_width + x; __m256i a = _mm256_loadu_si256((const __m256i *)(rec_data + a_off)); __m256i b = _mm256_loadu_si256((const __m256i *)(rec_data + b_off)); __m256i c = _mm256_loadu_si256((const __m256i *)(rec_data + c_off)); __m256i orig = _mm256_loadu_si256((const __m256i *)(orig_data + c_off)); calc_edge_dir_one_ymm(a, b, c, orig, zero, diff_accum, hit_cnt); } if (scan_width > width_db32) { const uint32_t curr_cpos = y * block_width + x; const uint32_t rest_cpos = y * block_width + width_db4 + 1; const int32_t curr_apos = (y + a_ofs.y) * block_width + x + a_ofs.x; const int32_t rest_apos = (y + a_ofs.y) * block_width + width_db4 + a_ofs.x + 1; const int32_t curr_bpos = (y + b_ofs.y) * block_width + x + b_ofs.x; const int32_t rest_bpos = (y + b_ofs.y) * block_width + width_db4 + b_ofs.x + 1; uint32_t a_last = load_border_bytes(rec_data, rest_apos, width_rest); uint32_t b_last = load_border_bytes(rec_data, rest_bpos, width_rest); uint32_t c_last = load_border_bytes(rec_data, rest_cpos, width_rest); uint32_t orig_last = load_border_bytes(orig_data, rest_cpos, width_rest); const int32_t *a_ptr = (const int32_t *)(rec_data + curr_apos); const int32_t *b_ptr = (const int32_t *)(rec_data + curr_bpos); const int32_t *c_ptr = (const int32_t *)(rec_data + curr_cpos); const int32_t *orig_ptr = (const int32_t *)(orig_data + curr_cpos); __m256i a = _mm256_maskload_epi32(a_ptr, db4_mask); __m256i b = _mm256_maskload_epi32(b_ptr, db4_mask); __m256i c = _mm256_maskload_epi32(c_ptr, db4_mask); __m256i orig = _mm256_maskload_epi32(orig_ptr, db4_mask); a = _mm256_insert_epi32 (a, a_last, 7); b = _mm256_insert_epi32 (b, b_last, 7); c = _mm256_insert_epi32 (c, c_last, 7); orig = _mm256_insert_epi32 (orig, orig_last, 7); __m256i badbyte_mask = gen_badbyte_mask(db4_mask, width_rest); calc_edge_dir_one_ymm(a, b, c, orig, badbyte_mask, diff_accum, hit_cnt); } } for (uint32_t i = 0; i < 5; i++) { int32_t sum = hsum_8x32b(diff_accum[i]); diff_sum[i] += sum; } } /* * Calculate an array of intensity correlations for each intensity value. * Return array as 16 YMM vectors, each containing 2x16 unsigned bytes * (to ease array lookup from YMMs using the shuffle trick, the low and * high lanes of each vector are duplicates). Have fun scaling this to * 16-bit picture data! */ static void calc_sao_offset_array_avx2(const encoder_control_t *encoder, const sao_info_t *sao, __m256i *offsets, color_t color_i) { const uint32_t band_pos = (color_i == COLOR_V) ? 1 : 0; const int32_t cur_bp = sao->band_position[band_pos]; const __m256i zero = _mm256_setzero_si256(); const __m256i threes = _mm256_set1_epi8 ( 3); const __m256i band_pos_v = _mm256_set1_epi8 (band_pos << 2); const __m256i cur_bp_v = _mm256_set1_epi8 (cur_bp); const __m256i val_incr = _mm256_set1_epi8 (16); const __m256i band_incr = _mm256_set1_epi8 ( 2); __m256i vals = _mm256_setr_epi8 ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); __m256i bands = _mm256_setr_epi32 (0, 0, 0x01010101, 0x01010101, 0, 0, 0x01010101, 0x01010101); // We'll only ever address SAO offsets 1, 2, 3, 4, 6, 7, 8, 9, so only load // them and truncate into signed 16 bits (anything out of that range will // anyway saturate anything they're used to do) __m128i sao_offs_lo = _mm_loadu_si128((const __m128i *)(sao->offsets + 1)); __m128i sao_offs_hi = _mm_loadu_si128((const __m128i *)(sao->offsets + 6)); __m128i sao_offs_xmm = _mm_packs_epi32 (sao_offs_lo, sao_offs_hi); __m256i sao_offs = broadcast_xmm2ymm(sao_offs_xmm); for (uint32_t i = 0; i < 16; i++) { // bands will always be in [0, 31], and cur_bp in [0, 27], so no overflow // can occur __m256i band_m_bp = _mm256_sub_epi8 (bands, cur_bp_v); // If (x & ~3) != 0 for any signed x, then x < 0 or x > 3 __m256i bmbp_bads = _mm256_andnot_si256(threes, band_m_bp); __m256i in_band = _mm256_cmpeq_epi8 (zero, bmbp_bads); __m256i offset_id = _mm256_add_epi8 (band_m_bp, band_pos_v); __m256i val_lo, val_hi; cvt_epu8_epi16(vals, &val_lo, &val_hi); __m256i offid_lo, offid_hi; cvt_shufmask_epi8_epi16(offset_id, &offid_lo, &offid_hi); __m256i offs_lo = _mm256_shuffle_epi8(sao_offs, offid_lo); __m256i offs_hi = _mm256_shuffle_epi8(sao_offs, offid_hi); __m256i sums_lo = _mm256_adds_epi16 (val_lo, offs_lo); __m256i sums_hi = _mm256_adds_epi16 (val_hi, offs_hi); sums_lo = _mm256_max_epi16 (sums_lo, zero); sums_hi = _mm256_max_epi16 (sums_hi, zero); __m256i offs = _mm256_packus_epi16(sums_lo, sums_hi); offsets[i] = _mm256_blendv_epi8 (vals, offs, in_band); vals = _mm256_add_epi8 (vals, val_incr); bands = _mm256_add_epi8 (bands, band_incr); } } static __m256i lookup_color_band_ymm(const __m256i curr_row, const __m256i *offsets) { const __m256i select_nibble = _mm256_set1_epi8 (0x0f); const __m256i lo_nibbles = _mm256_and_si256 (select_nibble, curr_row); const __m256i hi_nibbles = _mm256_andnot_si256(select_nibble, curr_row); // Loop through the offset vectors, the 0xi'th one always holding // offsets 0xi0...0xif. Use shuffle to do a lookup on the current // offset vector, then check which pixels actually should be looked // up from this vector (ie. whether their values are 0xi0...0xif) and // mask out any but correct ones. __m256i result_row = _mm256_setzero_si256(); for (uint8_t i = 0; i < 16; i += 4) { __m256i curr_hinib0 = _mm256_set1_epi8 ((i + 0) << 4); __m256i curr_hinib1 = _mm256_set1_epi8 ((i + 1) << 4); __m256i curr_hinib2 = _mm256_set1_epi8 ((i + 2) << 4); __m256i curr_hinib3 = _mm256_set1_epi8 ((i + 3) << 4); __m256i hinib_select0 = _mm256_cmpeq_epi8 (curr_hinib0, hi_nibbles); __m256i hinib_select1 = _mm256_cmpeq_epi8 (curr_hinib1, hi_nibbles); __m256i hinib_select2 = _mm256_cmpeq_epi8 (curr_hinib2, hi_nibbles); __m256i hinib_select3 = _mm256_cmpeq_epi8 (curr_hinib3, hi_nibbles); __m256i lonib_lookup0 = _mm256_shuffle_epi8(offsets[i + 0], lo_nibbles); __m256i lonib_lookup1 = _mm256_shuffle_epi8(offsets[i + 1], lo_nibbles); __m256i lonib_lookup2 = _mm256_shuffle_epi8(offsets[i + 2], lo_nibbles); __m256i lonib_lookup3 = _mm256_shuffle_epi8(offsets[i + 3], lo_nibbles); __m256i lookup_mskd0 = _mm256_and_si256 (hinib_select0, lonib_lookup0); __m256i lookup_mskd1 = _mm256_and_si256 (hinib_select1, lonib_lookup1); __m256i lookup_mskd2 = _mm256_and_si256 (hinib_select2, lonib_lookup2); __m256i lookup_mskd3 = _mm256_and_si256 (hinib_select3, lonib_lookup3); __m256i lookup_mskd01 = _mm256_or_si256 (lookup_mskd0, lookup_mskd1); __m256i lookup_mskd23 = _mm256_or_si256 (lookup_mskd2, lookup_mskd3); __m256i lookup_res = _mm256_or_si256 (lookup_mskd01, lookup_mskd23); result_row = _mm256_or_si256 (result_row, lookup_res); } return result_row; } static INLINE void reconstruct_color_band(const encoder_control_t *encoder, const uint8_t *rec_data, uint8_t *new_rec_data, const sao_info_t *sao, int32_t stride, int32_t new_stride, int32_t block_width, int32_t block_height, color_t color_i) { const uint32_t width_db32 = block_width & ~31; const uint32_t width_db4 = block_width & ~3; const uint32_t width_rest = block_width & 3; // Form the load&store mask const __m256i wdb4_256 = _mm256_set1_epi32 (width_db4 & 31); const __m256i indexes = _mm256_setr_epi32 (3, 7, 11, 15, 19, 23, 27, 31); const __m256i db4_mask = _mm256_cmpgt_epi32(wdb4_256, indexes); // Each of the 256 offsets is a byte, but only 16 are held in one YMM since // lanes must be duplicated to use shuffle. __m256i offsets[16]; calc_sao_offset_array_avx2(encoder, sao, offsets, color_i); for (uint32_t y = 0; y < block_height; y++) { uint32_t x = 0; for (; x < width_db32; x += 32) { const uint32_t curr_srcpos = y * stride + x; const uint32_t curr_dstpos = y * new_stride + x; __m256i curr_row = _mm256_loadu_si256((const __m256i *)(rec_data + curr_srcpos)); __m256i result = lookup_color_band_ymm(curr_row, offsets); _mm256_storeu_si256((__m256i *)(new_rec_data + curr_dstpos), result); } if (block_width > width_db32) { const uint32_t curr_srcpos = y * stride + x; const uint32_t curr_dstpos = y * new_stride + x; const uint32_t rest_srcpos = y * stride + width_db4; const uint32_t rest_dstpos = y * new_stride + width_db4; // Read the very last pixels byte by byte and pack them into one dword. // Piggyback said dword as the highest dword of the row vector variable, // that particular place can never be loaded into by the maskmove // (otherwise that vector would go through the divisible-by-32 code // path). uint32_t last_dword = load_border_bytes(rec_data, rest_srcpos, width_rest); const int32_t *src_ptr = (const int32_t *)( rec_data + curr_srcpos); int32_t *dst_ptr = ( int32_t *)(new_rec_data + curr_dstpos); __m256i curr_row = _mm256_maskload_epi32(src_ptr, db4_mask); curr_row = _mm256_insert_epi32 (curr_row, last_dword, 7); __m256i result = lookup_color_band_ymm(curr_row, offsets); _mm256_maskstore_epi32(dst_ptr, db4_mask, result); uint32_t last_dword_dst = _mm256_extract_epi32(result, 7); store_border_bytes(new_rec_data, rest_dstpos, width_rest, last_dword_dst); } } } static __m256i FIX_W32 do_one_nonband_ymm(const __m256i a, const __m256i b, const __m256i c, const __m256i sao_offs) { const __m256i zero = _mm256_setzero_si256(); __m256i eo_cat = calc_eo_cat(a, b, c); __m256i eo_cat_lo, eo_cat_hi, c_lo, c_hi; cvt_shufmask_epi8_epi16(eo_cat, &eo_cat_lo, &eo_cat_hi); cvt_epu8_epi16 (c, &c_lo, &c_hi); __m256i offs_lo = _mm256_shuffle_epi8(sao_offs, eo_cat_lo); __m256i offs_hi = _mm256_shuffle_epi8(sao_offs, eo_cat_hi); __m256i res_lo = _mm256_adds_epi16 (offs_lo, c_lo); __m256i res_hi = _mm256_adds_epi16 (offs_hi, c_hi); res_lo = _mm256_max_epi16 (res_lo, zero); res_hi = _mm256_max_epi16 (res_hi, zero); __m256i res = _mm256_packus_epi16(res_lo, res_hi); return res; } static INLINE void reconstruct_color_other(const encoder_control_t *encoder, const uint8_t *rec_data, uint8_t *new_rec_data, const sao_info_t *sao, int32_t stride, int32_t new_stride, int32_t block_width, int32_t block_height, color_t color_i) { const uint32_t offset_v = color_i == COLOR_V ? 5 : 0; const vector2d_t a_ofs = g_sao_edge_offsets[sao->eo_class][0]; const vector2d_t b_ofs = g_sao_edge_offsets[sao->eo_class][1]; const uint32_t width_db32 = block_width & ~31; const uint32_t width_db4 = block_width & ~3; const uint32_t width_rest = block_width & 3; // Form the load&store mask const __m256i wdb4_256 = _mm256_set1_epi32 (width_db4 & 31); const __m256i indexes = _mm256_setr_epi32 (3, 7, 11, 15, 19, 23, 27, 31); const __m256i db4_mask = _mm256_cmpgt_epi32(wdb4_256, indexes); // Again, saturate offsets to signed 16 bits, because anything outside of // [-255, 255] will saturate anything these are used with const __m128i sao_offs_lo = _mm_loadu_si128 ((const __m128i *)(sao->offsets + offset_v + 0)); const __m128i sao_offs_hi = _mm_cvtsi32_si128(sao->offsets[offset_v + 4]); const __m128i sao_offs_16 = _mm_packs_epi32 (sao_offs_lo, sao_offs_hi); const __m256i sao_offs = broadcast_xmm2ymm(sao_offs_16); for (uint32_t y = 0; y < block_height; y++) { uint32_t x; for (x = 0; x < width_db32; x += 32) { const uint32_t src_pos = y * stride + x; const uint32_t dst_pos = y * new_stride + x; // TODO: these will go negative, but that's a defect of the original // code already since 2013 (98f2a1aedc5f4933c2729ae15412549dea9e5549) const int32_t a_pos = (y + a_ofs.y) * stride + x + a_ofs.x; const int32_t b_pos = (y + b_ofs.y) * stride + x + b_ofs.x; __m256i a = _mm256_loadu_si256((const __m256i *)(rec_data + a_pos)); __m256i b = _mm256_loadu_si256((const __m256i *)(rec_data + b_pos)); __m256i c = _mm256_loadu_si256((const __m256i *)(rec_data + src_pos)); __m256i res = do_one_nonband_ymm(a, b, c, sao_offs); _mm256_storeu_si256((__m256i *)(new_rec_data + dst_pos), res); } if (block_width > width_db32) { const uint32_t curr_srcpos = y * stride + x; const uint32_t rest_srcpos = y * stride + width_db4; const int32_t curr_apos = (y + a_ofs.y) * stride + a_ofs.x + x; const int32_t rest_apos = (y + a_ofs.y) * stride + a_ofs.x + width_db4; const int32_t curr_bpos = (y + b_ofs.y) * stride + b_ofs.x + x; const int32_t rest_bpos = (y + b_ofs.y) * stride + b_ofs.x + width_db4; const uint32_t curr_dstpos = y * new_stride + x; const uint32_t rest_dstpos = y * new_stride + width_db4; uint32_t a_last = load_border_bytes(rec_data, rest_apos, width_rest); uint32_t b_last = load_border_bytes(rec_data, rest_bpos, width_rest); uint32_t c_last = load_border_bytes(rec_data, rest_srcpos, width_rest); const int32_t *a_ptr = (const int32_t *)( rec_data + curr_apos); const int32_t *b_ptr = (const int32_t *)( rec_data + curr_bpos); const int32_t *c_ptr = (const int32_t *)( rec_data + curr_srcpos); int32_t *dst_ptr = ( int32_t *)(new_rec_data + curr_dstpos); __m256i a = _mm256_maskload_epi32(a_ptr, db4_mask); __m256i b = _mm256_maskload_epi32(b_ptr, db4_mask); __m256i c = _mm256_maskload_epi32(c_ptr, db4_mask); a = _mm256_insert_epi32 (a, a_last, 7); b = _mm256_insert_epi32 (b, b_last, 7); c = _mm256_insert_epi32 (c, c_last, 7); __m256i res = do_one_nonband_ymm(a, b, c, sao_offs); _mm256_maskstore_epi32(dst_ptr, db4_mask, res); uint32_t last_dword = _mm256_extract_epi32(res, 7); store_border_bytes(new_rec_data, rest_dstpos, width_rest, last_dword); } } } static void sao_reconstruct_color_avx2(const encoder_control_t *encoder, const uint8_t *rec_data, uint8_t *new_rec_data, const sao_info_t *sao, int32_t stride, int32_t new_stride, int32_t block_width, int32_t block_height, color_t color_i) { if (sao->type == SAO_TYPE_BAND) { reconstruct_color_band (encoder, rec_data, new_rec_data, sao, stride, new_stride, block_width, block_height, color_i); } else { reconstruct_color_other(encoder, rec_data, new_rec_data, sao, stride, new_stride, block_width, block_height, color_i); } } static int32_t sao_band_ddistortion_avx2(const encoder_state_t *state, const uint8_t *orig_data, const uint8_t *rec_data, int32_t block_width, int32_t block_height, int32_t band_pos, const int32_t sao_bands[4]) { const uint32_t bitdepth = 8; const uint32_t shift = bitdepth - 5; // Clamp band_pos to 32 from above. It'll be subtracted from the shifted // rec_data values, which in 8-bit depth will always be clamped to [0, 31], // so if it ever exceeds 32, all the band values will be negative and // ignored. Ditto for less than -4. __m128i bp_128 = _mm_cvtsi32_si128 (band_pos); __m128i hilimit = _mm_cvtsi32_si128 (32); __m128i lolimit = _mm_cvtsi32_si128 (-4); bp_128 = _mm_min_epi8 (bp_128, hilimit); bp_128 = _mm_max_epi8 (bp_128, lolimit); __m256i bp_256 = _mm256_broadcastb_epi8(bp_128); __m128i sbs_32 = _mm_loadu_si128((const __m128i *)sao_bands); __m128i sbs_8 = truncate_epi32_epi8(sbs_32); __m256i sb_256 = broadcast_xmm2ymm (sbs_8); // These should trigger like, never, at least the later condition of block // not being a multiple of 32 wide. Rather safe than sorry though, huge SAO // bands are more tricky of these two because the algorithm needs a complete // reimplementation to work on 16-bit values. if (epi32v_fits_in_epi8s(sbs_32) != 0xffff) goto use_generic; // If VVC or something will start using SAO on blocks with width a multiple // of 16, feel free to implement a XMM variant of this algorithm if ((block_width & 31) != 0) goto use_generic; const __m256i zero = _mm256_setzero_si256(); const __m256i threes = _mm256_set1_epi8 (3); __m256i sum = _mm256_setzero_si256(); for (uint32_t y = 0; y < block_height; y++) { for (uint32_t x = 0; x < block_width; x += 32) { const int32_t curr_pos = y * block_width + x; __m256i rd = _mm256_loadu_si256((const __m256i *)( rec_data + curr_pos)); __m256i orig = _mm256_loadu_si256((const __m256i *)(orig_data + curr_pos)); __m256i orig_lo, orig_hi, rd_lo, rd_hi; cvt_epu8_epi16(orig, &orig_lo, &orig_hi); cvt_epu8_epi16(rd, &rd_lo, &rd_hi); __m256i diff_lo = _mm256_sub_epi16 (orig_lo, rd_lo); __m256i diff_hi = _mm256_sub_epi16 (orig_hi, rd_hi); // The shift will clamp band to 0...31; band_pos on the other // hand is always between 0...32, so band will be -1...31. Anything // below zero is ignored, so we can clamp band_pos to 32. __m256i rd_divd = srli_epi8 (rd, shift); __m256i band = _mm256_sub_epi8 (rd_divd, bp_256); // Force all <0 or >3 bands to 0xff, which will zero the shuffle result __m256i band_lt_0 = _mm256_cmpgt_epi8 (zero, band); __m256i band_gt_3 = _mm256_cmpgt_epi8 (band, threes); __m256i band_inv = _mm256_or_si256 (band_lt_0, band_gt_3); band = _mm256_or_si256 (band, band_inv); __m256i offsets = _mm256_shuffle_epi8 (sb_256, band); __m256i curr_sum = calc_diff_off_delta (diff_lo, diff_hi, offsets, orig); sum = _mm256_add_epi32 (sum, curr_sum); } } return hsum_8x32b(sum); use_generic: return sao_band_ddistortion_generic(state, orig_data, rec_data, block_width, block_height, band_pos, sao_bands); } #endif // KVZ_BIT_DEPTH == 8 #endif //COMPILE_INTEL_AVX2 int kvz_strategy_register_sao_avx2(void* opaque, uint8_t bitdepth) { bool success = true; #if COMPILE_INTEL_AVX2 #if KVZ_BIT_DEPTH == 8 if (bitdepth == 8) { success &= kvz_strategyselector_register(opaque, "sao_edge_ddistortion", "avx2", 40, &sao_edge_ddistortion_avx2); success &= kvz_strategyselector_register(opaque, "calc_sao_edge_dir", "avx2", 40, &calc_sao_edge_dir_avx2); success &= kvz_strategyselector_register(opaque, "sao_reconstruct_color", "avx2", 40, &sao_reconstruct_color_avx2); success &= kvz_strategyselector_register(opaque, "sao_band_ddistortion", "avx2", 40, &sao_band_ddistortion_avx2); } #endif // KVZ_BIT_DEPTH == 8 #endif //COMPILE_INTEL_AVX2 return success; }
91591d165ff6ec0f28d7be80e1ff4ed25e73e98a
0744dcc5394cebf57ebcba343747af6871b67017
/external/iotivity/iotivity_1.2-rel/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/easysetup_wifi_conn.h
15f8b060bda1d6ddff40ec8cc8f783115ceab697
[ "Apache-2.0", "GPL-2.0-only", "MIT", "BSD-3-Clause" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C
false
false
1,687
h
easysetup_wifi_conn.h
//****************************************************************** // // Copyright 2016 Samsung Electronics All Rights Reserved. // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // 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 EASYSETUP_WIFI_CONN_H__ #define EASYSETUP_WIFI_CONN_H__ #ifdef __cplusplus extern "C" { #endif typedef enum { /** No error.*/ WIFI_NO_ERROR = 0, /** Tizen WiFi Init Error.*/ WIFI_INIT_ERROR, /** Tizen WiFi Deinit Error.*/ WIFI_DEINIT_ERROR, /** Tizen WiFi Activate Error.*/ WIFI_ACTIVATE_ERROR, /** Tizen WiFi Scan Error.*/ WIFI_SCAN_ERROR, /** Tizen WiFi Connection Error.*/ WIFI_CONN_ERROR, /** Tizen WiFi Not Found SSID Error.*/ WIFI_NOTFOUND_SSID_ERROR, /** Tizen WiFi Wrong Password Error.*/ WIFI_WRONG_PWD_ERROR, } WiFiConnErrCode; WiFiConnErrCode TizenWiFiInit(void); WiFiConnErrCode TizenWiFiDeinit(void); WiFiConnErrCode TizenWiFiScanStart(void); WiFiConnErrCode TizenWiFiConn(char *ssid, char* passwd); #ifdef __cplusplus } #endif #endif /* EASYSETUP_WIFI_CONN_H__ */
ab21782d57f2a61d30f792e0a3577e7d66c2e93a
213b8cab639c7d45cbf6a4fd46eb23e379d9d374
/c/sizeof.c
eb0f01214f128700b0f7c770b656405363ae92e1
[]
no_license
DevDungeon/Cookbook
f85b04b690ea0a202ddfaeda6460b6ba5797cb70
a49a1c77f2b89dc303fa9f2563bb3c19777e4c6c
refs/heads/master
2023-05-12T06:58:50.606019
2022-03-30T04:48:16
2022-03-30T04:48:16
34,371,982
307
94
null
2023-05-03T22:53:45
2015-04-22T06:02:53
HTML
UTF-8
C
false
false
214
c
sizeof.c
#include <stdio.h> int main() { char c; short sh; int i; long l; printf("Size of:\nChar:\t%lu\nShort:\t%lu\nInt:\t%lu\nLong:\t%lu\n", sizeof(c), sizeof(sh), sizeof(i), sizeof(l)); return 0; }
f0f9d6426863932bd6a6f147c90338ef4e92d402
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/stm32/stm32mp157a-st-discovery/board/ports/OpenAMP/open-amp/lib/include/openamp/virtio.h
463079bf374180937942cfad6acb8ff8409eece3
[ "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
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
4,938
h
virtio.h
/* * SPDX-License-Identifier: BSD-3-Clause * * $FreeBSD$ */ #ifndef _VIRTIO_H_ #define _VIRTIO_H_ #include <openamp/virtqueue.h> #include <metal/spinlock.h> #if defined __cplusplus extern "C" { #endif /* TODO: define this as compiler flags */ #ifndef VIRTIO_MAX_NUM_VRINGS #define VIRTIO_MAX_NUM_VRINGS 2 #endif /* VirtIO device IDs. */ #define VIRTIO_ID_NETWORK 0x01UL #define VIRTIO_ID_BLOCK 0x02UL #define VIRTIO_ID_CONSOLE 0x03UL #define VIRTIO_ID_ENTROPY 0x04UL #define VIRTIO_ID_BALLOON 0x05UL #define VIRTIO_ID_IOMEMORY 0x06UL #define VIRTIO_ID_RPMSG 0x07UL /* remote processor messaging */ #define VIRTIO_ID_SCSI 0x08UL #define VIRTIO_ID_9P 0x09UL #define VIRTIO_DEV_ANY_ID (-1)UL /* Status byte for guest to report progress. */ #define VIRTIO_CONFIG_STATUS_ACK 0x01 #define VIRTIO_CONFIG_STATUS_DRIVER 0x02 #define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04 #define VIRTIO_CONFIG_STATUS_NEEDS_RESET 0x40 #define VIRTIO_CONFIG_STATUS_FAILED 0x80 /* Virtio device role */ #define VIRTIO_DEV_MASTER 0UL #define VIRTIO_DEV_SLAVE 1UL struct virtio_device_id { uint32_t device; uint32_t vendor; }; /* * Generate interrupt when the virtqueue ring is * completely used, even if we've suppressed them. */ #define VIRTIO_F_NOTIFY_ON_EMPTY (1 << 24) /* * The guest should never negotiate this feature; it * is used to detect faulty drivers. */ #define VIRTIO_F_BAD_FEATURE (1 << 30) /* * Some VirtIO feature bits (currently bits 28 through 31) are * reserved for the transport being used (eg. virtio_ring), the * rest are per-device feature bits. */ #define VIRTIO_TRANSPORT_F_START 28 #define VIRTIO_TRANSPORT_F_END 32 typedef void (*virtio_dev_reset_cb)(struct virtio_device *vdev); struct virtio_dispatch; struct virtio_feature_desc { uint32_t vfd_val; const char *vfd_str; }; /** * struct proc_shm * * This structure is maintained by hardware interface layer for * shared memory information. The shared memory provides buffers * for use by the vring to exchange messages between the cores. * */ struct virtio_buffer_info { /* Start address of shared memory used for buffers. */ void *vaddr; /* Start physical address of shared memory used for buffers. */ metal_phys_addr_t paddr; /* sharmed memory I/O region */ struct metal_io_region *io; /* Size of shared memory. */ unsigned long size; }; /** * struct remoteproc_vring - remoteproc vring structure * @vq virtio queue * @va logical address * @notifyid vring notify id * @num_descs number of descriptors * @align vring alignment * @io metal I/O region of the vring memory, can be NULL */ struct virtio_vring_info { struct virtqueue *vq; struct vring_alloc_info info; uint32_t notifyid; struct metal_io_region *io; }; /* * Structure definition for virtio devices for use by the * applications/drivers */ struct virtio_device { uint32_t index; /**< unique position on the virtio bus */ struct virtio_device_id id; /**< the device type identification * (used to match it with a driver */ uint64_t features; /**< the features supported by both ends. */ unsigned int role; /**< if it is virtio backend or front end. */ virtio_dev_reset_cb reset_cb; /**< user registered device callback */ const struct virtio_dispatch *func; /**< Virtio dispatch table */ void *priv; /**< TODO: remove pointer to virtio_device private data */ unsigned int vrings_num; /**< number of vrings */ struct virtio_vring_info *vrings_info; }; /* * Helper functions. */ const char *virtio_dev_name(uint16_t devid); void virtio_describe(struct virtio_device *dev, const char *msg, uint32_t features, struct virtio_feature_desc *feature_desc); /* * Functions for virtio device configuration as defined in Rusty Russell's * paper. * Drivers are expected to implement these functions in their respective codes. */ struct virtio_dispatch { uint8_t (*get_status)(struct virtio_device *dev); void (*set_status)(struct virtio_device *dev, uint8_t status); uint32_t (*get_features)(struct virtio_device *dev); void (*set_features)(struct virtio_device *dev, uint32_t feature); uint32_t (*negotiate_features)(struct virtio_device *dev, uint32_t features); /* * Read/write a variable amount from the device specific (ie, network) * configuration region. This region is encoded in the same endian as * the guest. */ void (*read_config)(struct virtio_device *dev, uint32_t offset, void *dst, int length); void (*write_config)(struct virtio_device *dev, uint32_t offset, void *src, int length); void (*reset_device)(struct virtio_device *dev); void (*notify)(struct virtqueue *vq); }; int virtio_create_virtqueues(struct virtio_device *vdev, unsigned int flags, unsigned int nvqs, const char *names[], vq_callback *callbacks[]); #if defined __cplusplus } #endif #endif /* _VIRTIO_H_ */
b26909859955d4686ec458340e74da451028901a
a8194cf6ffd12f7551eaba53572744080a0bfef3
/module/bdev/null/bdev_null.h
d1e58ebfb233b3045a2495949f62a5cc9df932d0
[ "Intel", "BSD-2-Clause", "BSD-3-Clause" ]
permissive
spdk/spdk
51294f67104b8c3d18f19147d63a212e9486c687
d62a3810364cb87be352c66acf7c7f968508ca17
refs/heads/master
2023-08-08T16:07:41.263000
2023-08-02T09:06:56
2023-08-08T07:01:20
39,042,157
2,708
1,158
NOASSERTION
2023-08-11T09:50:50
2015-07-13T23:15:15
C
UTF-8
C
false
false
1,214
h
bdev_null.h
/* SPDX-License-Identifier: BSD-3-Clause * Copyright (C) 2017 Intel Corporation. All rights reserved. * Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved. */ #ifndef SPDK_BDEV_NULL_H #define SPDK_BDEV_NULL_H #include "spdk/stdinc.h" typedef void (*spdk_delete_null_complete)(void *cb_arg, int bdeverrno); struct spdk_bdev; struct spdk_uuid; struct spdk_null_bdev_opts { const char *name; const struct spdk_uuid *uuid; uint64_t num_blocks; uint32_t block_size; uint32_t physical_block_size; uint32_t md_size; bool md_interleave; enum spdk_dif_type dif_type; bool dif_is_head_of_md; }; int bdev_null_create(struct spdk_bdev **bdev, const struct spdk_null_bdev_opts *opts); /** * Delete null bdev. * * \param bdev_name Name of null bdev. * \param cb_fn Function to call after deletion. * \param cb_arg Argument to pass to cb_fn. */ void bdev_null_delete(const char *bdev_name, spdk_delete_null_complete cb_fn, void *cb_arg); /** * Resize null bdev. * * \param bdev_name Name of null bdev. * \param new_size_in_mb The new size in MiB for this bdev */ int bdev_null_resize(const char *bdev_name, const uint64_t new_size_in_mb); #endif /* SPDK_BDEV_NULL_H */
cf68f6d74df7ebc053af6b4ee1a9c566cdf2a061
6cbc9ef86318b4cfcbe32fc27dc997eea5d0ae94
/nana/src/DL.h
add754ede3c7debb9fe8ed513d3c6e7904da0566
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
sasagawa888/eisl
c60c8307cf4ba1be20be15a4d59005f04b2b348e
450e09dbb59139621981f1104eefcad19957de2a
refs/heads/master
2023-09-03T17:48:38.297684
2023-09-02T05:42:40
2023-09-02T05:42:40
168,798,493
200
25
NOASSERTION
2023-06-17T21:16:28
2019-02-02T05:35:38
Common Lisp
UTF-8
C
false
false
6,111
h
DL.h
/* * DL.h - support for logging (printf...) style debugging using gdb. * * Copyright (c) 1997 Phil Maker * 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 AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Id: DL.h,v 1.1.1.1 1997/11/23 11:45:50 pjm Exp */ #ifndef _DL_h_ #define _DL_h_ 1 #ifdef __cplusplus extern "C" { #endif #ifndef WITHOUT_NANA /* * nana-config.h - the system wide configuration file; we put the ifndef * around it to avoid the file 5 million times during a compile. */ #ifndef _nana_config_h_ #include <nana-config.h> #endif /* * DL_MAKE_VALID_BREAKPOINT() - used to make sure that we can put a * breakpoint at this location. We default to a portable C expression * which simply does an assignment. The configure script may override * this (on an architecture basis) and replace it with something * like asm("nop"); */ #ifndef DL_MAKE_VALID_BREAKPOINT static volatile int _dl_target; #define DL_MAKE_VALID_BREAKPOINT() _dl_target = 0 #endif /* * DL_LEVEL sets the level of logging analogously to NDEBUG in assert.h * * DL_LEVEL == 2: always print. * DL_LEVEL == 1: print iff the guard is true. * DL_LEVEL == 0: never print. */ #ifndef DL_LEVEL /* define DEFAULT for DL_LEVEL */ #define DL_LEVEL 1 #endif /* * DL_DEFAULT_HANDLER - the default print handler; by default we just * the debugger printf. * * @@call (void) printf(f)@@ */ #ifndef DL_DEFAULT_HANDLER /* define default handler */ #define DL_DEFAULT_HANDLER(g,h,p,f...) @@printf f@@ #endif /* DL_DEFAULT_HANDLER */ /* * DL_DEFAULT_GUARD - the default guard expression; a message is printed * iff the guard is true. By default its always true. */ #ifndef DL_DEFAULT_GUARD #define DL_DEFAULT_GUARD (1) #endif /* * DL_DEFAULT_PARAMS - the default value to be passed as the second argument * to the handler macro when an invariant fails. */ #ifndef DL_DEFAULT_PARAMS #define DL_DEFAULT_PARAMS stderr #endif /* * DL_SHOW_TIME - if its defined then each message gets a timestamp in front. */ #ifdef DL_SHOW_TIME unsigned long _L_gettime(void); /* returns the current time */ #define _DL_SHOWTIME(h,p) @@call (void) h (p, "%-8ld ", _L_gettime())@@ #else #define _DL_SHOWTIME(h,p) /* nothing */ #endif /* DL_SHOWTIME */ /* * DLGHP(g,h,p,f...) - print a log message. * * g - the guard; print the message iff this is true * h - the handler function that does the actual printing * p - a parameter for the handler function; e.g. a file descriptor. * f - the format and the data... */ #if DL_LEVEL == 2 /* always log the message */ #ifdef _NANA_FILTER_ #define DLGHP(g,h,p,f...) \ do { \ @@break @__FILE__:__LINE__@@ \ @@command $bpnum@@ \ @@silent@@ \ _DL_SHOWTIME(h,p); \ DL_DEFAULT_HANDLER(g,h,p,##f); \ @@cont@@ \ @@end@@ \ } while(0) #else #define DLGHP(g,h,p,f...) DL_MAKE_VALID_BREAKPOINT() #endif #elif DL_LEVEL == 1 /* log it iff the guard is true */ #ifdef _NANA_FILTER_ #define DLGHP(g,h,p,f...) \ do { \ if(g) { \ @@break @__FILE__:__LINE__@@ \ @@condition $bpnum g@@ \ @@command $bpnum@@ \ @@silent@@ \ _DL_SHOWTIME(h,p); \ DL_DEFAULT_HANDLER(g,h,p,##f); \ @@cont@@ \ @@end@@ \ } \ } while(0) #else #define DLGHP(g,h,p,f...) DL_MAKE_VALID_BREAKPOINT() #endif #elif DL_LEVEL == 0 /* no logging so ignore them */ #define DLGHP(g,h,p,f...) /* nothing */ #endif /* DL_LEVEL */ /* * And the user routines. */ #define DL(f...) \ DLGHP(DL_DEFAULT_GUARD,DL_DEFAULT_HANDLER,DL_DEFAULT_PARAMS,##f) #define DLG(g,f...) \ DLGHP(g,DL_DEFAULT_HANDLER,DL_DEFAULT_PARAMS,##f) #define DLH(h,f...) \ DLGHP(DL_DEFAULT_GUARD,h,DL_DEFAULT_PARAMS,##f) #define DLP(p,f...) \ DLGHP(DL_DEFAULT_GUARD,DL_DEFAULT_HANDLER,p,##f) #define DLGP(g,p,f...) \ DLGHP(g,DL_DEFAULT_HANDLER,p,##f) #define DLHP(h,p,f...) \ DLGHP(DL_DEFAULT_GUARD,h,p,##f) /* * V* - since the DL* macros take a variable numbers of arguments we * have problems compiling calls to L with C preprocessors other * than GNU cccp. The V* macros are called using a bracketed arglist, e.g. * VDL((s,x,y)) * * if we are compiling with GNU C then they simply call the normal * varargs macros. if we are not using GNU C then they map to empty. */ #define VDL(a) DL a #define VDLG(a) DLG a #define VDLH(a) DLH a #define VDLP(a) DLP a #define VDLGP(a) DLGP a #define VDLHP(a) DLHP a #define VDLGHP(a) DLGHP a #else /* defined(WITHOUT_NANA) */ #define VDL(a) /* empty */ #define VDLG(a) /* empty */ #define VDLH(a) /* empty */ #define VDLP(a) /* empty */ #define VDLGP(a) /* empty */ #define VDLHP(a) /* empty */ #define VDLGHP(a) /* empty */ #endif /* !defined(WITHOUT_NANA) */ #ifdef __cplusplus } #endif #endif /* _DL_h_ */
b543ddcfeb35731454e632549da4645e93245c71
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/x11/xf86-video-ati6/patches/patch-src_radeon__video.c
a5bcb880cf2f48ba3a73e6d6f23bfb27d2739a1e
[]
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
6,955
c
patch-src_radeon__video.c
$NetBSD: patch-src_radeon__video.c,v 1.1 2015/04/02 22:16:46 tnn Exp $ --- src/radeon_video.c.orig 2012-06-25 08:32:43.000000000 +0000 +++ src/radeon_video.c @@ -32,9 +32,11 @@ #include "theatre_detect.h" #include "theatre_reg.h" +#ifdef PKGSRC_LEGACY_XORG_SERVER #include "fi1236.h" #include "msp3430.h" #include "tda9885.h" +#endif #define OFF_DELAY 250 /* milliseconds */ #define FREE_DELAY 15000 @@ -1743,8 +1745,10 @@ RADEONStopVideo(ScrnInfoPtr pScrn, point OUTREG(RADEON_CAP0_TRIG_CNTL, 0); RADEONResetVideo(pScrn); pPriv->video_stream_active = FALSE; +#ifdef PKGSRC_LEGACY_XORG_SERVER if(pPriv->msp3430 != NULL) xf86_MSP3430SetVolume(pPriv->msp3430, MSP3430_FAST_MUTE); if(pPriv->uda1380 != NULL) xf86_uda1380_mute(pPriv->uda1380, TRUE); +#endif if(pPriv->i2c != NULL) RADEON_board_setmisc(pPriv); } RADEONFreeVideoMemory(pScrn, pPriv); @@ -1913,11 +1917,13 @@ RADEONSetPortAttribute(ScrnInfoPtr pScr pPriv->encoding = value; if(pPriv->video_stream_active) { +#ifdef PKGSRC_LEGACY_XORG_SERVER if(pPriv->theatre != NULL) RADEON_RT_SetEncoding(pScrn, pPriv); if(pPriv->msp3430 != NULL) RADEON_MSP_SetEncoding(pPriv); if(pPriv->tda9885 != NULL) RADEON_TDA9885_SetEncoding(pPriv); if(pPriv->fi1236 != NULL) RADEON_FI1236_SetEncoding(pPriv); if(pPriv->i2c != NULL) RADEON_board_setmisc(pPriv); +#endif /* put more here to actually change it */ } } @@ -1925,6 +1931,7 @@ RADEONSetPortAttribute(ScrnInfoPtr pScr { pPriv->frequency = value; /* mute volume if it was not muted before */ +#ifdef PKGSRC_LEGACY_XORG_SERVER if((pPriv->msp3430!=NULL)&& !pPriv->mute)xf86_MSP3430SetVolume(pPriv->msp3430, MSP3430_FAST_MUTE); if((pPriv->uda1380!=NULL)&& !pPriv->mute)xf86_uda1380_mute(pPriv->uda1380, TRUE); if(pPriv->fi1236 != NULL) xf86_TUNER_set_frequency(pPriv->fi1236, value); @@ -1933,18 +1940,23 @@ RADEONSetPortAttribute(ScrnInfoPtr pScr xf86_InitMSP3430(pPriv->msp3430); if((pPriv->msp3430 != NULL)&& !pPriv->mute) xf86_MSP3430SetVolume(pPriv->msp3430, MSP3430_VOLUME(pPriv->volume)); if((pPriv->uda1380 != NULL)&& !pPriv->mute) xf86_uda1380_setvolume(pPriv->uda1380, pPriv->volume); +#endif } else if(attribute == xvMute) { pPriv->mute = value; +#ifdef PKGSRC_LEGACY_XORG_SERVER if(pPriv->msp3430 != NULL) xf86_MSP3430SetVolume(pPriv->msp3430, pPriv->mute ? MSP3430_FAST_MUTE : MSP3430_VOLUME(pPriv->volume)); if(pPriv->i2c != NULL) RADEON_board_setmisc(pPriv); if(pPriv->uda1380 != NULL) xf86_uda1380_mute(pPriv->uda1380, pPriv->mute); +#endif } else if(attribute == xvSAP) { pPriv->sap_channel = value; +#ifdef PKGSRC_LEGACY_XORG_SERVER if(pPriv->msp3430 != NULL) xf86_MSP3430SetSAP(pPriv->msp3430, pPriv->sap_channel?4:3); +#endif } else if(attribute == xvVolume) { @@ -1952,9 +1964,11 @@ RADEONSetPortAttribute(ScrnInfoPtr pScr if(value>1000)value = 1000; pPriv->volume = value; pPriv->mute = FALSE; +#ifdef PKGSRC_LEGACY_XORG_SERVER if(pPriv->msp3430 != NULL) xf86_MSP3430SetVolume(pPriv->msp3430, MSP3430_VOLUME(value)); if(pPriv->i2c != NULL) RADEON_board_setmisc(pPriv); if(pPriv->uda1380 != NULL) xf86_uda1380_setvolume(pPriv->uda1380, value); +#endif } else if(attribute == xvOverlayDeinterlacingMethod) { @@ -1982,6 +1996,7 @@ RADEONSetPortAttribute(ScrnInfoPtr pScr pScrn->currentMode->Flags & V_INTERLACE ? " interlaced" : "" , pScrn->currentMode->Flags & V_DBLSCAN ? " doublescan" : "" ); +#ifdef PKGSRC_LEGACY_XORG_SERVER if(pPriv->tda9885 != NULL){ xf86_tda9885_getstatus(pPriv->tda9885); xf86_tda9885_dumpstatus(pPriv->tda9885); @@ -1989,16 +2004,19 @@ RADEONSetPortAttribute(ScrnInfoPtr pScr if(pPriv->fi1236!=NULL){ xf86_fi1236_dump_status(pPriv->fi1236); } +#endif } else if(attribute == xvAdjustment) { pPriv->adjustment=value; xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"Setting pPriv->adjustment to %u\n", (unsigned)pPriv->adjustment); +#ifdef PKGSRC_LEGACY_XORG_SERVER if(pPriv->tda9885!=0){ pPriv->tda9885->top_adjustment=value; RADEON_TDA9885_SetEncoding(pPriv); } +#endif } else return BadMatch; @@ -2090,12 +2108,14 @@ RADEONGetPortAttribute(ScrnInfoPtr pScr *value = pPriv->frequency; else if(attribute == xvTunerStatus) { +#ifdef PKGSRC_LEGACY_XORG_SERVER if(pPriv->fi1236==NULL){ *value=TUNER_OFF; } else { *value = xf86_TUNER_get_afc_hint(pPriv->fi1236); } +#endif } else if(attribute == xvMute) *value = pPriv->mute; @@ -3676,9 +3696,11 @@ RADEONPutVideo( { RADEON_RT_SetEncoding(pScrn, pPriv); } +#ifdef PKGSRC_LEGACY_XORG_SERVER if(pPriv->msp3430 != NULL) RADEON_MSP_SetEncoding(pPriv); if(pPriv->tda9885 != NULL) RADEON_TDA9885_SetEncoding(pPriv); if(pPriv->fi1236 != NULL) RADEON_FI1236_SetEncoding(pPriv); +#endif if(pPriv->i2c != NULL)RADEON_board_setmisc(pPriv); } @@ -3756,6 +3778,7 @@ RADEONPutVideo( static void RADEON_board_setmisc(RADEONPortPrivPtr pPriv) { +#ifdef PKGSRC_LEGACY_XORG_SERVER /* Adjust PAL/SECAM constants for FI1216MF tuner */ if((((pPriv->tuner_type & 0xf)==5) || ((pPriv->tuner_type & 0xf)==11)|| @@ -3775,7 +3798,7 @@ static void RADEON_board_setmisc(RADEONP pPriv->fi1236->parm.band_high = 0x33; } } - +#endif } static void RADEON_RT_SetEncoding(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv) @@ -3867,6 +3890,7 @@ xf86_RT_SetOutputVideoSize(pPriv->theatr static void RADEON_MSP_SetEncoding(RADEONPortPrivPtr pPriv) { +#ifdef PKGSRC_LEGACY_XORG_SERVER xf86_MSP3430SetVolume(pPriv->msp3430, MSP3430_FAST_MUTE); switch(pPriv->encoding){ case 1: @@ -3922,10 +3946,12 @@ switch(pPriv->encoding){ } xf86_InitMSP3430(pPriv->msp3430); xf86_MSP3430SetVolume(pPriv->msp3430, pPriv->mute ? MSP3430_FAST_MUTE : MSP3430_VOLUME(pPriv->volume)); +#endif } static void RADEON_TDA9885_SetEncoding(RADEONPortPrivPtr pPriv) { +#ifdef PKGSRC_LEGACY_XORG_SERVER TDA9885Ptr t=pPriv->tda9885; switch(pPriv->encoding){ @@ -3962,10 +3988,12 @@ switch(pPriv->encoding){ xf86_tda9885_setparameters(pPriv->tda9885); xf86_tda9885_getstatus(pPriv->tda9885); xf86_tda9885_dumpstatus(pPriv->tda9885); +#endif } static void RADEON_FI1236_SetEncoding(RADEONPortPrivPtr pPriv) { +#ifdef PKGSRC_LEGACY_XORG_SERVER /* at the moment this only affect MT2032 */ switch(pPriv->encoding){ /* PAL */ @@ -3994,5 +4022,6 @@ switch(pPriv->encoding){ default: return; } +#endif }
4409b29297e5a3b93ad6ad6da5c46ad565366cd0
549270020f6c8724e2ef1b12e38d11b025579f8d
/recipes/librhash/all/test_package/test_package.c
029374c3a9841c25ba9620dbc327419e2083bd59
[ "MIT" ]
permissive
conan-io/conan-center-index
1bcec065ccd65aa38b1fed93fbd94d9d5fe6bc43
3b17e69bb4e5601a850b6e006e44775e690bac33
refs/heads/master
2023-08-31T11:34:45.403978
2023-08-31T11:13:23
2023-08-31T11:13:23
204,671,232
844
1,820
MIT
2023-09-14T21:22:42
2019-08-27T09:43:58
Python
UTF-8
C
false
false
706
c
test_package.c
#include "rhash.h" #include <stdio.h> #include <string.h> #define MSG "hello world" #define SHA256_REF "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" int main() { rhash_library_init(); unsigned char rhash_bin_buffer[128]; char rhash_char_buffer[128]; rhash_msg(RHASH_SHA256, MSG, strlen(MSG), rhash_bin_buffer); int nb = rhash_print_bytes(rhash_char_buffer, rhash_bin_buffer, rhash_get_hash_length(RHASH_SHA256), RHPR_HEX); rhash_char_buffer[rhash_get_hash_length(RHASH_SHA256)] = '\0'; printf("calculated SHA256 hash= %s\n", rhash_char_buffer); printf("reference SHA256 hash= %s\n", SHA256_REF); return strcmp(rhash_char_buffer, SHA256_REF); }
4f37f491adf701f32d15fbcd59d058d51d90bd6e
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/raspberry-pi/raspi2/driver/bcm283x.h
8339133652a0857d33970fc4dfc055bc8ca1ce99
[ "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
5,360
h
bcm283x.h
#ifndef BCM283X_H__ #define BCM283X_H__ #include <rthw.h> #define PER_BASE (0x3F000000) #define PER_BASE_40000000 (0x40000000) /* * GPIO */ #define GPIO_BASE (PER_BASE + 0x200000) #define GPIO_GPFSEL0 HWREG32(GPIO_BASE + 0x00) /* GPIO Function Select 0 32bit R/W */ #define GPIO_GPFSEL1 HWREG32(GPIO_BASE + 0x04) /* GPIO Function Select 1 32bit R/W */ #define GPIO_GPFSEL2 HWREG32(GPIO_BASE + 0x08) /* GPIO Function Select 2 32bit R/W */ #define GPIO_GPFSEL4 HWREG32(GPIO_BASE + 0x10) /* GPIO Function Select 4 32bit R/W */ #define GPIO_GPSET0 HWREG32(GPIO_BASE + 0x1C) #define GPIO_GPCLR0 HWREG32(GPIO_BASE + 0x28) #define GPIO_GPPUD HWREG32(GPIO_BASE + 0x94) /* GPIO Pin Pull-up/down Enable */ #define GPIO_GPPUDCLK0 HWREG32(GPIO_BASE + 0x98) /* GPIO Pin Pull-up/down Enable Clock 0 */ #define GPIO_GPPUDCLK1 HWREG32(GPIO_BASE + 0x9C) /* GPIO Pin Pull-up/down Enable Clock 1 */ /* * Interrupt Controler */ #define IRQ_BASE (PER_BASE + 0xB200) #define IRQ_PEND_BASIC HWREG32(IRQ_BASE + 0x00) #define IRQ_PEND1 HWREG32(IRQ_BASE + 0x04) #define IRQ_PEND2 HWREG32(IRQ_BASE + 0x08) #define IRQ_FIQ_CONTROL HWREG32(IRQ_BASE + 0x0C) #define IRQ_ENABLE1 HWREG32(IRQ_BASE + 0x10) #define IRQ_ENABLE2 HWREG32(IRQ_BASE + 0x14) #define IRQ_ENABLE_BASIC HWREG32(IRQ_BASE + 0x18) #define IRQ_DISABLE1 HWREG32(IRQ_BASE + 0x1C) #define IRQ_DISABLE2 HWREG32(IRQ_BASE + 0x20) #define IRQ_DISABLE_BASIC HWREG32(IRQ_BASE + 0x24) /* * System Timer */ #define STIMER_BASE (PER_BASE + 0x3000) #define STIMER_CS HWREG32(STIMER_BASE + 0x00) #define STIMER_CLO HWREG32(STIMER_BASE + 0x04) #define STIMER_CHI HWREG32(STIMER_BASE + 0x08) #define STIMER_C0 HWREG32(STIMER_BASE + 0x0C) #define STIMER_C1 HWREG32(STIMER_BASE + 0x10) #define STIMER_C2 HWREG32(STIMER_BASE + 0x14) #define STIMER_C3 HWREG32(STIMER_BASE + 0x18) /* * ARM Timer */ #define ARM_TIMER_BASE (PER_BASE + 0xB000) #define ARM_TIMER_LOAD HWREG32(ARM_TIMER_BASE + 0x400) #define ARM_TIMER_VALUE HWREG32(ARM_TIMER_BASE + 0x404) #define ARM_TIMER_CTRL HWREG32(ARM_TIMER_BASE + 0x408) #define ARM_TIMER_IRQCLR HWREG32(ARM_TIMER_BASE + 0x40C) #define ARM_TIMER_RAWIRQ HWREG32(ARM_TIMER_BASE + 0x410) #define ARM_TIMER_MASKIRQ HWREG32(ARM_TIMER_BASE + 0x414) #define ARM_TIMER_RELOAD HWREG32(ARM_TIMER_BASE + 0x418) #define ARM_TIMER_PREDIV HWREG32(ARM_TIMER_BASE + 0x41C) #define ARM_TIMER_CNTR HWREG32(ARM_TIMER_BASE + 0x420) /* * Core Timer */ #define CTIMER_CTL HWREG32(PER_BASE_40000000 + 0x00) /* Control register */ #define CTIMER_PRE HWREG32(PER_BASE_40000000 + 0x08) /* Core timer prescaler */ #define CTIMER_LS32B HWREG32(PER_BASE_40000000 + 0x1C) /* Core timer access LS 32 bits */ #define CTIMER_MS32B HWREG32(PER_BASE_40000000 + 0x20) /* Core timer access MS 32 bits */ /* * ARM Core Timer */ #define C0TIMER_INTCTL HWREG32(PER_BASE_40000000 + 0x40) /* Core0 timers Interrupt control */ #define C1TIMER_INTCTL HWREG32(PER_BASE_40000000 + 0x44) /* Core1 timers Interrupt control */ #define C2TIMER_INTCTL HWREG32(PER_BASE_40000000 + 0x48) /* Core2 timers Interrupt control */ #define C3TIMER_INTCTL HWREG32(PER_BASE_40000000 + 0x4C) /* Core3 timers Interrupt control */ /* * ARM Core Mailbox interrupt */ #define C0MB_INTCTL HWREG32(PER_BASE_40000000 + 0x50) /* Core0 Mailboxes Interrupt control */ #define C1MB_INTCTL HWREG32(PER_BASE_40000000 + 0x54) /* Core1 Mailboxes Interrupt control */ #define C2MB_INTCTL HWREG32(PER_BASE_40000000 + 0x58) /* Core2 Mailboxes Interrupt control */ #define C3MB_INTCTL HWREG32(PER_BASE_40000000 + 0x5C) /* Core3 Mailboxes Interrupt control */ /* * ARM Core IRQ/FIQ status */ #define C0_IRQSOURCE HWREG32(PER_BASE_40000000 + 0x60) /* Core0 IRQ Source */ #define C1_IRQSOURCE HWREG32(PER_BASE_40000000 + 0x64) /* Core1 IRQ Source */ #define C2_IRQSOURCE HWREG32(PER_BASE_40000000 + 0x68) /* Core2 IRQ Source */ #define C3_IRQSOURCE HWREG32(PER_BASE_40000000 + 0x6C) /* Core3 IRQ Source */ #define C0_FIQSOURCE HWREG32(PER_BASE_40000000 + 0x70) /* Core0 FIQ Source */ #define C1_FIQSOURCE HWREG32(PER_BASE_40000000 + 0x74) /* Core1 FIQ Source */ #define C2_FIQSOURCE HWREG32(PER_BASE_40000000 + 0x78) /* Core2 FIQ Source */ #define C3_FIQSOURCE HWREG32(PER_BASE_40000000 + 0x7C) /* Core3 FIQ Source */ #define IRQ_ARM_TIMER 0 #define IRQ_ARM_MAILBOX 1 #define IRQ_ARM_DB0 2 #define IRQ_ARM_DB1 3 #define IRQ_ARM_GPU0_HALT 4 #define IRQ_ARM_GPU1_HALT 5 #define IRQ_ARM_ILLEGAL_ACC1 6 #define IRQ_ARM_ILLEGAL_ACC0 7 #define IRQ_AUX 29 #define IRQ_IIC_SPI_SLV 43 #define IRQ_PWA0 45 #define IRQ_PWA1 46 #define IRQ_SMI 48 #define IRQ_GPIO0 49 #define IRQ_GPIO1 50 #define IRQ_GPIO2 51 #define IRQ_GPIO3 52 #define IRQ_IIC 53 #define IRQ_SPI 54 #define IRQ_PCM 55 #define IRQ_UART 57 #endif
2f5e3dc67eadf312f15d6e853df1864d000a02a6
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/games/xtron/files/patch-xtron.c
14592683ed5cc005da57df198fee57ebdc5c0e34
[ "BSD-2-Clause" ]
permissive
freebsd/freebsd-ports
86f2e89d43913412c4f6b2be3e255bc0945eac12
605a2983f245ac63f5420e023e7dce56898ad801
refs/heads/main
2023-08-30T21:46:28.720924
2023-08-30T19:33:44
2023-08-30T19:33:44
1,803,961
916
918
NOASSERTION
2023-09-08T04:06:26
2011-05-26T11:15:35
null
UTF-8
C
false
false
170
c
patch-xtron.c
--- xtron.c.orig 1995-04-16 12:48:44 UTC +++ xtron.c @@ -21,6 +21,9 @@ #include "xtron.h" +struct Player p[2]; +struct Board b; + void plr_setup(void) { int i;
de943ec03dcc51496b45429e2a1c4d6be11e2826
eae9cc14ebb3832e07f92c750c196960acf0cc8f
/summary.c
5ca70198da8eb7eefad881304ee6fd4189e369bf
[]
no_license
NetBSDfr/pkgin
80c4d67e3124a431194bcd3e95694973f78ca5f1
0bb4739ee59ab190480c701e9acea3551eff8c7f
refs/heads/master
2023-08-31T12:54:28.369067
2023-08-22T07:12:21
2023-08-22T07:12:21
9,348,059
113
43
null
2023-04-18T08:16:33
2013-04-10T14:32:31
C
UTF-8
C
false
false
21,595
c
summary.c
/* * Copyright (c) 2009-2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Emile "iMil" Heitor <imil@NetBSD.org> . * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /** * Import pkg_summary to SQLite database */ #include <sqlite3.h> #include "pkgin.h" /* * Table name lookup, as a convenience for tables that have identical LOCAL_ * and REMOTE_ entities. */ static const struct Summary { const int type; const char *pkg; const char *conflicts; const char *depends; const char *provides; const char *requires; const char *supersedes; const char *end; } sumsw[] = { [LOCAL_SUMMARY] = { LOCAL_SUMMARY, "LOCAL_PKG", "LOCAL_CONFLICTS", "LOCAL_DEPENDS", "LOCAL_PROVIDES", "LOCAL_REQUIRES", "LOCAL_SUPERSEDES", /* Unused */ NULL }, [REMOTE_SUMMARY] = { REMOTE_SUMMARY, "REMOTE_PKG", "REMOTE_CONFLICTS", "REMOTE_DEPENDS", "REMOTE_PROVIDES", "REMOTE_REQUIRES", "REMOTE_SUPERSEDES", NULL }, }; struct Columns { int num; char **name; } cols; typedef struct Insertlist { char *field; char *value; SLIST_ENTRY(Insertlist) next; } Insertlist; SLIST_HEAD(, Insertlist) inserthead; static struct archive *fetch_summary(char *, time_t *); static void freecols(void); static void free_insertlist(void); static void insert_local_summary(FILE *); static void insert_remote_summary(struct archive *, char *); static void delete_remote_tbl(struct Summary, char *); static void prepare_insert(int, struct Summary); int colnames(void *, int, char **, char **); char *env_repos, **pkg_repos; /* column count for table fields, given by colnames callback */ int colcount = 0; /* force pkg_summary reload */ int force_fetch = 0; /* * Slow machines with limited memory will probably want to define this to * reduce memory usage and speed up decompression, at the cost of increased * bandwidth usage (pkg_summary approx sizes: gz=5MB, bz2=3MB, xz=2MB). */ #if defined(PREFER_GZIP_SUMMARY) static const char *const sumexts[] = { "gz", "bz2", "xz", NULL }; #else static const char *const sumexts[] = { "xz", "bz2", "gz", NULL }; #endif /* * Open a remote summary and return an open libarchive handler to it. */ static struct archive * fetch_summary(char *cur_repo, time_t *repo_mtime) { struct archive *a; struct archive_entry *ae; Sumfile *sum = NULL; int i; char buf[BUFSIZ]; for (i = 0; sumexts[i] != NULL; i++) { /* try all extensions */ if (!force_fetch) *repo_mtime = pkg_sum_mtime(cur_repo); else *repo_mtime = 0; /* 0 sumtime == force reload */ snprintf(buf, BUFSIZ, "%s/%s.%s", cur_repo, PKG_SUMMARY, sumexts[i]); if ((sum = sum_open(buf, repo_mtime)) != NULL) break; /* pkg_summary found and not up-to-date */ if (*repo_mtime < 0) /* pkg_summary found, but up-to-date */ return NULL; } if (sum == NULL) errx(EXIT_FAILURE, MSG_COULDNT_FETCH, buf, fetchLastErrString); if ((a = archive_read_new()) == NULL) errx(EXIT_FAILURE, "Cannot initialise archive"); #if ARCHIVE_VERSION_NUMBER < 3000000 if (archive_read_support_compression_all(a) != ARCHIVE_OK || #else if (archive_read_support_filter_all(a) != ARCHIVE_OK || #endif archive_read_support_format_raw(a) != ARCHIVE_OK || archive_read_open(a, sum, sum_start, sum_read, sum_close) != ARCHIVE_OK) errx(EXIT_FAILURE, "Cannot open pkg_summary: %s", archive_error_string(a)); if (archive_read_next_header(a, &ae) != ARCHIVE_OK) errx(EXIT_FAILURE, "Cannot read pkg_summary: %s", archive_error_string(a)); return a; } static void freecols(void) { int i; for (i = 0; i < cols.num; i++) XFREE(cols.name[i]); XFREE(cols.name); } static void free_insertlist(void) { Insertlist *pi; while (!SLIST_EMPTY(&inserthead)) { pi = SLIST_FIRST(&inserthead); SLIST_REMOVE_HEAD(&inserthead, next); XFREE(pi->field); XFREE(pi->value); XFREE(pi); } } /** * sqlite callback, fill cols.name[] with available columns names */ int colnames(void *unused, int argc, char **argv, char **colname) { int i = 0; colcount++; cols.num = colcount; cols.name = xrealloc(cols.name, (size_t)colcount * sizeof(char *)); for (i = 0; i < argc; i++) if (argv[i] != NULL && strncmp(colname[i], "name", 4) == 0) cols.name[colcount - 1] = xstrdup(argv[i]); return PDB_OK; } /** * for now, values are located on a SLIST, build INSERT line with them */ static void prepare_insert(int pkgid, struct Summary sum) { Insertlist *pi; /* * Currently INSERT lengths are under 1K, this should be plenty until * we support more columns. */ char querybuf[4096]; char tmpbuf[1024]; sqlite3_snprintf(sizeof(querybuf), querybuf, "INSERT INTO %w (PKG_ID", sum.pkg); /* insert fields */ SLIST_FOREACH(pi, &inserthead, next) { sqlite3_snprintf(sizeof(tmpbuf), tmpbuf, ",%w", pi->field); if (strlcat(querybuf, tmpbuf, sizeof(querybuf)) >= sizeof(querybuf)) goto err; } sqlite3_snprintf(sizeof(tmpbuf), tmpbuf, ") VALUES (%d", pkgid); if (strlcat(querybuf, tmpbuf, sizeof(querybuf)) >= sizeof(querybuf)) goto err; /* insert values */ SLIST_FOREACH(pi, &inserthead, next) { sqlite3_snprintf(sizeof(tmpbuf), tmpbuf, ",%Q", pi->value); if (strlcat(querybuf, tmpbuf, sizeof(querybuf)) >= sizeof(querybuf)) goto err; } sqlite3_snprintf(sizeof(tmpbuf), tmpbuf, ");"); if (strlcat(querybuf, tmpbuf, sizeof(querybuf)) >= sizeof(querybuf)) goto err; /* Apply the query */ pkgindb_doquery(querybuf, NULL, NULL); return; err: errx(EXIT_FAILURE, "Increase query buffer"); } /** * add item to the main SLIST */ static void add_to_slist(const char *field, const char *value) { Insertlist *insert; insert = xmalloc(sizeof(Insertlist)); insert->field = xstrdup(field); insert->value = xstrdup(value); SLIST_INSERT_HEAD(&inserthead, insert, next); } /* * Parse a KEY=value line. */ static void parse_entry(struct Summary sum, int pkgid, char *line) { static uint8_t check_machine_arch = 1; int i; char *val, *v, buf[BUFSIZ]; if ((val = strchr(line, '=')) == NULL) errx(EXIT_FAILURE, "Invalid pkg_info entry: %s", line); val++; /* * Check MACHINE_ARCH of the package matches the local machine. */ if (check_machine_arch && strncmp(line, "MACHINE_ARCH=", 13) == 0) { if (strncmp(MACHINE_ARCH, val, strlen(MACHINE_ARCH))) { alarm(0); /* Stop the progress meter */ printf(MSG_ARCH_DONT_MATCH, val, MACHINE_ARCH); if (!check_yesno(DEFAULT_NO)) exit(EXIT_FAILURE); check_machine_arch = 0; alarm(1); /* Restart progress XXX: UPDATE_INTERVAL */ } return; } if (strncmp(line, "CONFLICTS=", 10) == 0) { v = pkgname_from_pattern(val); pkgindb_dovaquery(INSERT_CONFLICTS, sum.conflicts, pkgid, val, v); free(v); return; } if (strncmp(line, "DEPENDS=", 8) == 0) { v = pkgname_from_pattern(val); pkgindb_dovaquery(INSERT_DEPENDS, sum.depends, pkgid, val, v); free(v); return; } if (strncmp(line, "PROVIDES=", 9) == 0) { pkgindb_dovaquery(INSERT_PROVIDES, sum.provides, pkgid, val); return; } if (strncmp(line, "REQUIRES=", 9) == 0) { pkgindb_dovaquery(INSERT_REQUIRES, sum.requires, pkgid, val); return; } if (strncmp(line, "SUPERSEDES=", 11) == 0) { /* * Only remote SUPERSEDES are supported. */ if (sum.type == REMOTE_SUMMARY) { v = pkgname_from_pattern(val); pkgindb_dovaquery(INSERT_SUPERSEDES, sum.supersedes, pkgid, val, v); free(v); } return; } /* * Currently we ignore DESCRIPTION entries as they are multi-line * which aren't supported. */ if (strncmp(line, "DESCRIPTION=", 12) == 0) return; /* * Skip empty values like LICENSE= */ if (*val == '\0') return; /* * Handle remaining columns. */ for (i = 0; i < cols.num; i++) { snprintf(buf, BUFSIZ, "%s=", cols.name[i]); if (strncmp(buf, line, strlen(buf)) == 0) { /* Split PKGNAME into parts */ if (strncmp(cols.name[i], "PKGNAME", 7) == 0) { /* some rare packages have no version */ if (!exact_pkgfmt(val)) { snprintf(buf, BUFSIZ, "%s%s", val, "-0.0"); val = buf; } add_to_slist("FULLPKGNAME", val); /* split PKGNAME and VERSION */ v = strrchr(val, '-'); if (v != NULL) *v++ = '\0'; add_to_slist("PKGNAME", val); add_to_slist("PKGVERS", v); } else add_to_slist(cols.name[i], val); break; } } } /* * Stream the local pkg_info information into the local summary. */ static void insert_local_summary(FILE *fp) { static int pkgid = 1; char buf[BUFSIZ]; uint64_t savepoint; if (fp == NULL) { pkgindb_close(); errx(EXIT_FAILURE, "Couldn't read local pkg_info"); } /* record columns names to cols */ sqlite3_snprintf(BUFSIZ, buf, "PRAGMA table_info(%w);", sumsw[LOCAL_SUMMARY].pkg); pkgindb_doquery(buf, colnames, NULL); SLIST_INIT(&inserthead); savepoint = pkgindb_savepoint(); while (fgets(buf, BUFSIZ, fp) != NULL) { /* * End of current package entry, commit and reset. */ if (*buf == '\n') { prepare_insert(pkgid++, sumsw[LOCAL_SUMMARY]); free_insertlist(); continue; } trimcr(buf); parse_entry(sumsw[LOCAL_SUMMARY], pkgid, buf); } pkgindb_savepoint_release(savepoint); } /* * Stream a remote pkg_summary via libarchive into the local database. */ static void insert_remote_summary(struct archive *a, char *cur_repo) { static int pkgid = 1; size_t buflen, offset; ssize_t r; char *buf, *pe, *pi, *npi; uint64_t savepoint; if (a == NULL) { pkgindb_close(); errx(EXIT_FAILURE, "Couldn't read pkg_summary"); } /* * Initial archive buffer, we grow if required. Try to hit the * sweet spot between memory usage and CPU time required to move * the buffer back to the beginning each time. */ buflen = 32768; buf = xmalloc(buflen + 1); /* record columns names to cols */ sqlite3_snprintf(buflen, buf, "PRAGMA table_info(%w);", sumsw[REMOTE_SUMMARY].pkg); pkgindb_doquery(buf, colnames, NULL); SLIST_INIT(&inserthead); savepoint = pkgindb_savepoint(); /* * Main loop. Read in archive, split into package records and parse * each entry, then insert packge. If we are in the middle of a * package, copy it to the beginning and read the remainder. */ offset = 0; for (;;) { r = archive_read_data(a, buf + offset, buflen - offset); /* We're done with reading from the archive. */ if (r <= 0) break; pi = buf; buf[(size_t)r + offset] = '\0'; /* * Highly unlikely, but if we can't fit a single pkg_info entry * into our reasonably sized buffer, then we have no choice but * to increase the buffer size. */ if (strstr(pi, "\n\n") == NULL) { offset = buflen; buflen *= 2; buf = xrealloc(buf, buflen + 1); continue; } /* * Packages are delimited by an empty line, we split the buffer * by package with pi pointing to the beginning and npi the end. */ for (;;) { /* * No remaining complete package entries, move the * leftover to the beginning and start again. */ if ((npi = strstr(pi, "\n\n")) == NULL) { offset = strlen(pi); memmove(buf, pi, offset + 1); break; } *npi = '\0'; npi += 2; /* * Handle each KEY=value pkg_info entry. */ while ((pe = strsep(&pi, "\n")) != NULL) parse_entry(sumsw[REMOTE_SUMMARY], pkgid, pe); /* Add REPOSITORY information */ add_to_slist("REPOSITORY", cur_repo); /* * At this point we should have a fully populated slist * and all the data we need to construct the INSERT. */ prepare_insert(pkgid++, sumsw[REMOTE_SUMMARY]); /* Set up for next pkg_info */ free_insertlist(); pi = npi; } } XFREE(buf); if (r != ARCHIVE_OK) { pkgindb_savepoint_rollback(savepoint); errx(EXIT_FAILURE, "Short read of pkg_summary: %s", archive_error_string(a)); } pkgindb_savepoint_release(savepoint); #if ARCHIVE_VERSION_NUMBER < 3000000 archive_read_finish(a); #else archive_read_free(a); #endif } static void delete_remote_tbl(struct Summary sum, char *repo) { const char **table; /* * Use results from REMOTE_PKG to delete entries from REMOTE_CONFLICTS * etc first, then finally remove from REMOTE_PKG. */ for (table = &(sum.pkg) + 1; *table != NULL; ++table) { pkgindb_dovaquery(DELETE_REMOTE, *table, repo); } pkgindb_dovaquery(DELETE_REMOTE_PKG_REPO, repo); } /* * The following section is taken verbatim from pkg_install files/admin/main.c * to correctly handle REQUIRED_BY entries. */ struct reqd_by_entry { char *pkgname; SLIST_ENTRY(reqd_by_entry) entries; }; SLIST_HEAD(reqd_by_entry_head, reqd_by_entry); struct pkg_reqd_by { char *pkgname; struct reqd_by_entry_head required_by[PKG_HASH_SIZE]; SLIST_ENTRY(pkg_reqd_by) entries; }; SLIST_HEAD(pkg_reqd_by_head, pkg_reqd_by); static void add_required_by(const char *pattern, const char *pkgname, struct pkg_reqd_by_head *hash) { struct pkg_reqd_by_head *phead; struct pkg_reqd_by *pkg; struct reqd_by_entry_head *ehead; struct reqd_by_entry *entry; char *best_installed; int i; best_installed = find_matching_installed_pkg(pattern, 1, 0); if (best_installed == NULL) { warnx("Dependency %s of %s unresolved", pattern, pkgname); return; } phead = &hash[PKG_HASH_ENTRY(best_installed)]; SLIST_FOREACH(pkg, phead, entries) { if (strcmp(pkg->pkgname, best_installed) == 0) { ehead = &pkg->required_by[PKG_HASH_ENTRY(pkgname)]; SLIST_FOREACH(entry, ehead, entries) { if (strcmp(entry->pkgname, pkgname) == 0) break; } if (entry == NULL) { entry = xmalloc(sizeof(*entry)); entry->pkgname = xstrdup(pkgname); SLIST_INSERT_HEAD(ehead, entry, entries); } break; } } if (pkg == NULL) { pkg = xmalloc(sizeof(*pkg)); pkg->pkgname = xstrdup(best_installed); for (i = 0; i < PKG_HASH_SIZE; i++) SLIST_INIT(&pkg->required_by[i]); ehead = &pkg->required_by[PKG_HASH_ENTRY(pkgname)]; entry = xmalloc(sizeof(*entry)); entry->pkgname = xstrdup(pkgname); SLIST_INSERT_HEAD(ehead, entry, entries); SLIST_INSERT_HEAD(phead, pkg, entries); } free(best_installed); } static int add_depends_of(const char *pkgname, void *cookie) { FILE *fp; struct pkg_reqd_by_head *h = cookie; plist_t *p; package_t plist; char *path; path = pkgdb_pkg_file(pkgname, CONTENTS_FNAME); if ((fp = fopen(path, "r")) == NULL) errx(EXIT_FAILURE, "Cannot read %s of package %s", CONTENTS_FNAME, pkgname); free(path); read_plist(&plist, fp); fclose(fp); for (p = plist.head; p; p = p->next) { if (p->type == PLIST_PKGDEP) add_required_by(p->name, pkgname, h); } free_plist(&plist); return 0; } static void insert_local_required_by(void) { struct pkg_reqd_by_head pkgs[PKG_HASH_SIZE]; struct pkg_reqd_by *p; struct reqd_by_entry *e; int i, j; for (i = 0; i < PKG_HASH_SIZE; i++) SLIST_INIT(&pkgs[i]); if (iterate_pkg_db(add_depends_of, &pkgs) == -1) errx(EXIT_FAILURE, "cannot iterate pkgdb"); for (i = 0; i < PKG_HASH_SIZE; i++) { SLIST_FOREACH(p, &pkgs[i], entries) { for (j = 0; j < PKG_HASH_SIZE; j++) { SLIST_FOREACH(e, &p->required_by[j], entries) { pkgindb_dovaquery(INSERT_REQUIRED_BY, p->pkgname, e->pkgname); free(e->pkgname); } while (!SLIST_EMPTY(&p->required_by[j])) { e = SLIST_FIRST(&p->required_by[j]); SLIST_REMOVE_HEAD(&p->required_by[j], entries); free(e); } } free(p->pkgname); } while (!SLIST_EMPTY(&pkgs[i])) { p = SLIST_FIRST(&pkgs[i]); SLIST_REMOVE_HEAD(&pkgs[i], entries); free(p); } } } static void update_localdb(int verbose) { FILE *pinfo; struct stat st; Pkglist *lpkg; int l; /* * Start a write transaction, excluding other writers until committed. */ if (pkgindb_doquery("BEGIN IMMEDIATE;", NULL, NULL)) errx(EXIT_FAILURE, "failed to begin immediate transaction"); /* * Only replace the database if forced or if the pkgdb changed. */ if (!pkg_db_mtime(&st) && !force_fetch) goto out; /* * Delete and recreate the LOCAL_PKG table, as it's simpler and faster * than updating. */ pkgindb_doquery(DELETE_LOCAL, NULL, NULL); if (verbose) printf(MSG_READING_LOCAL_SUMMARY); if ((pinfo = popen(PKG_INSTALL_DIR "/pkg_info -Xa", "r")) == NULL) errx(EXIT_FAILURE, "Couldn't run pkg_info"); if (verbose) printf(MSG_PROCESSING_LOCAL_SUMMARY); insert_local_summary(pinfo); insert_local_required_by(); pkg_db_update_mtime(&st); pclose(pinfo); /* * Reread the local package list. This updates l_plisthead. */ free_local_pkglist(); init_local_pkglist(); /* * Insert PKG_KEEP database entries based on pkgdb data. */ for (l = 0; l < LOCAL_PKG_HASH_SIZE; l++) { SLIST_FOREACH(lpkg, &l_plisthead[l], next) { if (!is_automatic_installed(lpkg->full)) { pkg_keep(KEEP, lpkg->full); } } } out: if (pkgindb_doquery("COMMIT;", NULL, NULL)) errx(EXIT_FAILURE, "failed to commit transaction"); } static int pdb_clean_remote(void *param, int argc, char **argv, char **colname) { int i; size_t repolen; char **repos = pkg_repos; if (argv == NULL) return PDB_ERR; for (i = 0; repos[i] != NULL; i++) { repolen = strlen(repos[i]); if (repolen == strlen(argv[0]) && strncmp(repos[i], argv[0], repolen) == 0) return PDB_OK; } /* did not find argv[0] (db repository) in pkg_repos */ printf(MSG_CLEANING_DB_FROM_REPO, argv[0]); delete_remote_tbl(sumsw[REMOTE_SUMMARY], argv[0]); pkgindb_dovaquery(DELETE_REPO_URL, argv[0]); /* force pkg_summary reload for available repository */ force_fetch = 1; return PDB_OK; } static void update_remotedb(int verbose) { struct archive *a; time_t repo_mtime; char **prepos; uint8_t cleaned = 0; /* loop through PKG_REPOS */ for (prepos = pkg_repos; *prepos != NULL; prepos++) { if (verbose) printf(MSG_PROCESSING_REMOTE_SUMMARY, *prepos); /* load remote pkg_summary */ if ((a = fetch_summary(*prepos, &repo_mtime)) == NULL) { if (verbose) printf(MSG_DB_IS_UP_TO_DATE, *prepos); continue; } /* * do not cleanup repos before being sure new repo is reachable */ if (!cleaned) { /* delete unused repositories */ pkgindb_doquery(SELECT_REPO_URLS, pdb_clean_remote, NULL); cleaned = 1; } /* delete remote* associated to this repository */ delete_remote_tbl(sumsw[REMOTE_SUMMARY], *prepos); /* update remote* table for this repository */ insert_remote_summary(a, *prepos); /* mark repository as being updated with new mtime */ pkgindb_dovaquery(UPDATE_REPO_MTIME, (long long)repo_mtime, *prepos); } /* remove empty rows (duplicates) */ pkgindb_doquery(DELETE_EMPTY_ROWS, NULL, NULL); } int update_db(int which, int verbose) { if (!have_privs(PRIVS_PKGINDB)) return EXIT_FAILURE; /* always check for LOCAL_SUMMARY updates */ update_localdb(verbose); if (which == REMOTE_SUMMARY) update_remotedb(verbose); /* columns name not needed anymore */ if (cols.name != NULL) { /* reset colums count */ colcount = 0; freecols(); } return EXIT_SUCCESS; } void split_repos(void) { size_t repocount; char *p; if ((p = getenv("PKG_REPOS")) != NULL) { env_repos = xstrdup(p); } else { if ((env_repos = read_repos()) == NULL) errx(EXIT_FAILURE, MSG_MISSING_PKG_REPOS); } repocount = 2; /* 1st elm + NULL */ pkg_repos = xmalloc(repocount * sizeof(char *)); *pkg_repos = env_repos; p = env_repos; while((p = strchr(p, ' ')) != NULL) { *p = '\0'; p++; pkg_repos = xrealloc(pkg_repos, ++repocount * sizeof(char *)); pkg_repos[repocount - 2] = p; } /* NULL last element */ pkg_repos[repocount - 1] = NULL; repo_record(pkg_repos); } /* check if repositories listed in REPO_URL table are still relevant */ static int cmp_repo_list(void *param, int argc, char **argv, char **colname) { int i, j, match; if (argv == NULL) return PDB_ERR; /* no repo yet? */ for (i = 0; i < argc; i++) { match = 0; for (j = 0; pkg_repos[j] != NULL; j++) if (strcmp(argv[i], pkg_repos[j]) == 0) match = 1; if (match == 0) { printf(MSG_CLEANING_DB_FROM_REPO, argv[i]); delete_remote_tbl(sumsw[REMOTE_SUMMARY], argv[i]); pkgindb_dovaquery(DELETE_REPO_URL, argv[i]); force_fetch = 1; } } return PDB_OK; } int chk_repo_list(int force) { pkgindb_doquery(SELECT_REPO_URLS, cmp_repo_list, NULL); if (force) force_fetch = 1; return force_fetch; }
fc506a575afc3d0a7dfb0292988bf5757d02d9df
bec5d52c5185d032b2b81eccd008aa8e4e045790
/ncd/NCDVal.h
a2cedd350d1202fead82dd7a3afe02a0cdbb1004
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
shadowsocks/badvpn
2993b0da7c59870f0a550a842cabe3312761d541
40a0e5010aa4adb6d3ca1d1418dfde345c50107d
refs/heads/shadowsocks-android
2021-12-08T06:17:04.546977
2021-08-23T04:05:27
2021-08-23T04:05:27
45,686,048
166
154
NOASSERTION
2021-08-23T04:05:28
2015-11-06T14:18:20
C
UTF-8
C
false
false
22,662
h
NCDVal.h
/** * @file NCDVal.h * @author Ambroz Bizjak <ambrop7@gmail.com> * * @section LICENSE * * 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 author 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 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. */ #ifndef BADVPN_NCDVAL_H #define BADVPN_NCDVAL_H #include <stddef.h> #include <stdint.h> #include <misc/debug.h> #include <misc/BRefTarget.h> #include <misc/memref.h> #include <ncd/NCDStringIndex.h> #include <ncd/NCDVal_types.h> #define NCDVAL_STRING 1 #define NCDVAL_LIST 2 #define NCDVAL_MAP 3 #define NCDVAL_PLACEHOLDER 4 /** * Initializes a value memory object. * A value memory object holds memory for value structures. Values within * the memory are referenced using {@link NCDValRef} objects, which point * to values within memory objects. * * Values may be added to a memory object using functions such as * {@link NCDVal_NewString}, {@link NCDVal_NewList} and {@link NCDVal_NewMap}, * and {@link NCDVal_NewCopy}, which return references to the new values within * the memory object. * * It is not possible to remove values from the memory object, or modify existing * values other than adding elements to pre-allocated slots in lists and maps. * Once a value is added, it will consume memory as long as its memory object * exists. This is by design - this code is intended and optimized for constructing * and passing around values, not for operating on them in place. In fact, al * values within a memory object are stored in a single memory buffer, as an * embedded data structure with relativepointers. For example, map values use an * embedded AVL tree. */ void NCDValMem_Init (NCDValMem *o, NCDStringIndex *string_index); /** * Frees a value memory object. * All values within the memory object cease to exist, and any {@link NCDValRef} * object pointing to them must no longer be used. */ void NCDValMem_Free (NCDValMem *o); /** * Initializes the memory object to be a copy of an existing memory object. * Value references from the original may be used if they are first turned * to {@link NCDValSafeRef} using {@link NCDVal_ToSafe} and back to * {@link NCDValRef} using {@link NCDVal_FromSafe} with the new memory object * specified. Alternatively, {@link NCDVal_Moved} can be used. * Returns 1 on success and 0 on failure. */ int NCDValMem_InitCopy (NCDValMem *o, NCDValMem *other) WARN_UNUSED; /** * Get the string index of a value memory object. */ NCDStringIndex * NCDValMem_StringIndex (NCDValMem *o); /** * Does nothing. * The value reference object must either point to a valid value within a valid * memory object, or must be an invalid reference (most functions operating on * {@link NCDValRef} implicitly require that). */ void NCDVal_Assert (NCDValRef val); /** * Determines if a value reference is invalid. */ int NCDVal_IsInvalid (NCDValRef val); /** * Determines if a value is a placeholder value. * The value reference must not be an invalid reference. */ int NCDVal_IsPlaceholder (NCDValRef val); /** * Returns the type of the value reference, which must not be an invalid reference. * Possible values are NCDVAL_STRING, NCDVAL_LIST, NCDVAL_MAP and NCDVAL_PLACEHOLDER. * The placeholder type is only used internally in the interpreter for argument * resolution, and is never seen by modules; see {@link NCDVal_NewPlaceholder}. */ int NCDVal_Type (NCDValRef val); /** * Returns an invalid reference. * An invalid reference must not be passed to any function here, except: * {@link NCDVal_Assert}, {@link NCDVal_IsInvalid}, {@link NCDVal_ToSafe}, * {@link NCDVal_FromSafe}, {@link NCDVal_Moved}. */ NCDValRef NCDVal_NewInvalid (void); /** * Returns a new placeholder value reference. A placeholder value is a valid value * containing an integer placeholder identifier. * This always succeeds; however, the caller must ensure the identifier is in the * range [0, NCDVAL_TOPPLID). * * The placeholder type is only used internally in the interpreter for argument * resolution, and is never seen by modules. */ NCDValRef NCDVal_NewPlaceholder (NCDValMem *mem, int plid); /** * Returns the indentifier of a placeholder value. * The value reference must point to a placeholder value. */ int NCDVal_PlaceholderId (NCDValRef val); /** * Copies a value into the specified memory object. The source * must not be an invalid reference, however it may reside in any memory * object (including 'mem'). * Returns a reference to the copied value. On out of memory, returns * an invalid reference. */ NCDValRef NCDVal_NewCopy (NCDValMem *mem, NCDValRef val); /** * Compares two values, both of which must not be invalid references. * Returns -1, 0 or 1. */ int NCDVal_Compare (NCDValRef val1, NCDValRef val2); /** * Converts a value reference to a safe referece format, which remains valid * if the memory object is moved (safe references do not contain a pointer * to the memory object, unlike {@link NCDValRef} references). */ NCDValSafeRef NCDVal_ToSafe (NCDValRef val); /** * Converts a safe value reference to a normal value reference. * This should be used to recover references from safe references * after the memory object is moved. */ NCDValRef NCDVal_FromSafe (NCDValMem *mem, NCDValSafeRef sval); /** * Fixes a value reference after its memory object was moved. */ NCDValRef NCDVal_Moved (NCDValMem *mem, NCDValRef val); /** * Determines whether a safe reference is a placeholder. */ int NCDVal_IsSafeRefPlaceholder (NCDValSafeRef sval); /** * Gets the placeholder ID of a placeholder safe reference. */ int NCDVal_GetSafeRefPlaceholderId (NCDValSafeRef sval); /** * Determines if the value implements the String interface. * The value reference must not be an invalid reference. */ int NCDVal_IsString (NCDValRef val); /** * Determines if the value is a StoredString. * A StoredString implements the String interface. * The value reference must not be an invalid reference. */ int NCDVal_IsStoredString (NCDValRef val); /** * Determines if the value is an IdString. See {@link NCDVal_NewIdString} * for details. * An IdString implements the String interface. * The value reference must not be an invalid reference. */ int NCDVal_IsIdString (NCDValRef val); /** * Determines if a value is an ExternalString. * See {@link NCDVal_NewExternalString} for details. * An ExternalString implements the String interface. * The value reference must not be an invalid reference. */ int NCDVal_IsExternalString (NCDValRef val); /** * Determines if a value is a String which contains no null bytes. * The value reference must not be an invalid reference. */ int NCDVal_IsStringNoNulls (NCDValRef val); /** * Equivalent to NCDVal_NewStringBin(mem, data, strlen(data)). */ NCDValRef NCDVal_NewString (NCDValMem *mem, const char *data); /** * Builds a new StoredString. * Returns a reference to the new value, or an invalid reference * on out of memory. * WARNING: The buffer passed must NOT be part of any value in the * memory object specified. In particular, you may NOT use this * function to copy a string that resides in the same memory object. * * A StoredString is a kind of String which is represented directly in the * value memory object. */ NCDValRef NCDVal_NewStringBin (NCDValMem *mem, const uint8_t *data, size_t len); /** * See NCDVal_NewStringBin. */ NCDValRef NCDVal_NewStringBinMr (NCDValMem *mem, MemRef data); /** * Builds a new StoredString of the given length with undefined contents. * You can define the contents of the string later by copying to the address * returned by {@link NCDVal_StringData}. */ NCDValRef NCDVal_NewStringUninitialized (NCDValMem *mem, size_t len); /** * Builds a new IdString. * Returns a reference to the new value, or an invalid reference * on out of memory. * * An IdString is a kind of String which is represented efficiently as a string * identifier via {@link NCDStringIndex}. */ NCDValRef NCDVal_NewIdString (NCDValMem *mem, NCD_string_id_t string_id); /** * Builds a new ExternalString, pointing to the given external data. A reference to * the external data is taken using {@link BRefTarget}, unless 'ref_target' is * NULL. The data must not change while this value exists. * Returns a reference to the new value, or an invalid reference * on out of memory. * * An ExternalString is a kind of String where the actual string contents are * stored outside of the value memory object. */ NCDValRef NCDVal_NewExternalString (NCDValMem *mem, const char *data, size_t len, BRefTarget *ref_target); /** * Returns a pointer to the data of a String. * WARNING: the string data may not be null-terminated. To get a null-terminated * version, use {@link NCDVal_StringNullTerminate}. * The value reference must point to a String. * WARNING: the returned pointer may become invalid when any new value is inserted * into the residing memory object (due to a realloc of the value memory). */ const char * NCDVal_StringData (NCDValRef string); /** * Returns the length of a String. * The value reference must point to a String. */ size_t NCDVal_StringLength (NCDValRef string); /** * Returns a MemRef interface to the given string value. * WARNING: the returned pointer may become invalid when any new value is inserted * into the residing memory object (due to a realloc of the value memory). */ MemRef NCDVal_StringMemRef (NCDValRef string); /** * Produces a null-terminated version of a String. On success, the result is * stored into an {@link NCDValNullTermString} structure, and the null-terminated * string is available via its 'data' member. This function may either simply pass * through the data pointer (if the string is known to be null-terminated) or * produce a null-terminated dynamically allocated copy. * On success, {@link NCDValNullTermString_Free} should be called to release any allocated * memory when the null-terminated string is no longer needed. This must be called before * the memory object is freed, because it may point to data inside the memory object. * It is guaranteed that *out is not modified on failure. * Returns 1 on success and 0 on failure. */ int NCDVal_StringNullTerminate (NCDValRef string, NCDValNullTermString *out) WARN_UNUSED; /** * Returns a dummy {@link NCDValNullTermString} which can be freed using * {@link NCDValNullTermString_Free}, but need not be. */ NCDValNullTermString NCDValNullTermString_NewDummy (void); /** * Releases any memory which was dynamically allocated by {@link NCDVal_StringNullTerminate} * to null-terminate a string. */ void NCDValNullTermString_Free (NCDValNullTermString *o); /** * Returns the string ID of an IdString. */ NCD_string_id_t NCDVal_IdStringId (NCDValRef idstring); /** * Returns the reference target of an ExternalString. This may be NULL * if the external string is not associated with a reference target. */ BRefTarget * NCDVal_ExternalStringTarget (NCDValRef externalstring); /** * Determines if the String has any null bytes in its contents. */ int NCDVal_StringHasNulls (NCDValRef string); /** * Determines if the String value is equal to the given null-terminated * string. * The value reference must point to a String value. */ int NCDVal_StringEquals (NCDValRef string, const char *data); /** * Determines if the String is equal to the given string represented * by an {@link NCDStringIndex} identifier. */ int NCDVal_StringEqualsId (NCDValRef string, NCD_string_id_t string_id); /** * Compares two String's in a manner similar to memcmp(). * The startN and length arguments must refer to a valid region within * stringN, i.e. startN + length <= length_of_stringN must hold. */ int NCDVal_StringMemCmp (NCDValRef string1, NCDValRef string2, size_t start1, size_t start2, size_t length); /** * Copies a part of a String to a buffer. * \a start and \a length must refer to a valid region within the string, * i.e. start + length <= length_of_string must hold. */ void NCDVal_StringCopyOut (NCDValRef string, size_t start, size_t length, char *dst); /** * Determines if a part of a String is equal to the \a length bytes in \a data. * \a start and \a length must refer to a valid region within the string, * i.e. start + length <= length_of_string must hold. */ int NCDVal_StringRegionEquals (NCDValRef string, size_t start, size_t length, const char *data); /** * Determines if a value is a list value. * The value reference must not be an invalid reference. */ int NCDVal_IsList (NCDValRef val); /** * Builds a new list value. The 'maxcount' argument specifies how * many element slots to preallocate. Not more than that many * elements may be appended to the list using {@link NCDVal_ListAppend}. * Returns a reference to the new value, or an invalid reference * on out of memory. */ NCDValRef NCDVal_NewList (NCDValMem *mem, size_t maxcount); /** * Appends a value to to the list value. * The 'list' reference must point to a list value, and the * 'elem' reference must be non-invalid and point to a value within * the same memory object as the list. * Inserting a value into a list does not in any way change it; * internally, the list only points to it. * You must not modify the element after it has been inserted into the * list. * Returns 1 on success and 0 on failure (depth limit exceeded). */ int NCDVal_ListAppend (NCDValRef list, NCDValRef elem) WARN_UNUSED; /** * Returns the number of elements in a list value, i.e. the number * of times {@link NCDVal_ListAppend} was called. * The 'list' reference must point to a list value. */ size_t NCDVal_ListCount (NCDValRef list); /** * Returns the maximum number of elements a list value may contain, * i.e. the 'maxcount' argument to {@link NCDVal_NewList}. * The 'list' reference must point to a list value. */ size_t NCDVal_ListMaxCount (NCDValRef list); /** * Returns a reference to the value at the given position 'pos' in a list, * starting with zero. * The 'list' reference must point to a list value. * The position 'pos' must refer to an existing element, i.e. * pos < NCDVal_ListCount(). */ NCDValRef NCDVal_ListGet (NCDValRef list, size_t pos); /** * Returns references to elements within a list by writing them * via (NCDValRef *) variable arguments. * If 'num' == NCDVal_ListCount(), succeeds, returing 1 and writing 'num' * references, as mentioned. * If 'num' != NCDVal_ListCount(), fails, returning 0, without writing any * references */ int NCDVal_ListRead (NCDValRef list, int num, ...); /** * Like NCDVal_ListRead but ignores the initial 'start' arguments, * that is, reads 'num' arguments after 'start'. * The 'start' must be <= the length of the list. */ int NCDVal_ListReadStart (NCDValRef list, int start, int num, ...); /** * Like {@link NCDVal_ListRead}, but the list can contain more than 'num' * elements. */ int NCDVal_ListReadHead (NCDValRef list, int num, ...); /** * Determines if a value is a map value. * The value reference must not be an invalid reference. */ int NCDVal_IsMap (NCDValRef val); /** * Builds a new map value. The 'maxcount' argument specifies how * many entry slots to preallocate. Not more than that many * entries may be inserted to the map using {@link NCDVal_MapInsert}. * Returns a reference to the new value, or an invalid reference * on out of memory. */ NCDValRef NCDVal_NewMap (NCDValMem *mem, size_t maxcount); /** * Inserts an entry to the map value. * The 'map' reference must point to a map value, and the * 'key' and 'val' references must be non-invalid and point to values within * the same memory object as the map. * Inserting an entry does not in any way change the 'key'and 'val'; * internally, the map only points to it. * You must not modify the key after inserting it into a map. This is because * the map builds an embedded AVL tree of entries indexed by keys. * If insertion fails due to a maximum depth limit, returns 0. * Otherwise returns 1, and *out_inserted is set to 1 if the key did not * yet exist and the entry was inserted, and to 0 if it did exist and the * entry was not inserted. The 'out_inserted' pointer may be NULL, in which * case *out_inserted is never set. */ int NCDVal_MapInsert (NCDValRef map, NCDValRef key, NCDValRef val, int *out_inserted) WARN_UNUSED; /** * Returns the number of entries in a map value, i.e. the number * of times {@link NCDVal_MapInsert} was called successfully. * The 'map' reference must point to a map value. */ size_t NCDVal_MapCount (NCDValRef map); /** * Returns the maximum number of entries a map value may contain, * i.e. the 'maxcount' argument to {@link NCDVal_NewMap}. * The 'map' reference must point to a map value. */ size_t NCDVal_MapMaxCount (NCDValRef map); /** * Determines if a map entry reference is invalid. This is used in combination * with the map iteration functions to detect the end of iteration. */ int NCDVal_MapElemInvalid (NCDValMapElem me); /** * Returns a reference to the first entry in a map, with respect to some * arbitrary order. * If the map is empty, returns an invalid map entry reference. */ NCDValMapElem NCDVal_MapFirst (NCDValRef map); /** * Returns a reference to the entry in a map that follows the entry referenced * by 'me', with respect to some arbitrary order. * The 'me' argument must be a non-invalid reference to an entry in the map. * If 'me' is the last entry, returns an invalid map entry reference. */ NCDValMapElem NCDVal_MapNext (NCDValRef map, NCDValMapElem me); /** * Like {@link NCDVal_MapFirst}, but with respect to the order defined by * {@link NCDVal_Compare}. * Ordered iteration is slower and should only be used when needed. */ NCDValMapElem NCDVal_MapOrderedFirst (NCDValRef map); /** * Like {@link NCDVal_MapNext}, but with respect to the order defined by * {@link NCDVal_Compare}. * Ordered iteration is slower and should only be used when needed. */ NCDValMapElem NCDVal_MapOrderedNext (NCDValRef map, NCDValMapElem me); /** * Returns a reference to the key of the map entry referenced by 'me'. * The 'me' argument must be a non-invalid reference to an entry in the map. */ NCDValRef NCDVal_MapElemKey (NCDValRef map, NCDValMapElem me); /** * Returns a reference to the value of the map entry referenced by 'me'. * The 'me' argument must be a non-invalid reference to an entry in the map. */ NCDValRef NCDVal_MapElemVal (NCDValRef map, NCDValMapElem me); /** * Looks for a key in the map. The 'key' reference must be a non-invalid * value reference, and may point to a value in a different memory object * than the map. * If the key exists in the map, returns a reference to the corresponding * map entry. * If the key does not exist, returns an invalid map entry reference. */ NCDValMapElem NCDVal_MapFindKey (NCDValRef map, NCDValRef key); /** * Retrieves the value reference to the value of the map entry whose key is a * string value equal to the given null-terminated string. If there is no such * entry, returns an invalid value reference. */ NCDValRef NCDVal_MapGetValue (NCDValRef map, const char *key_str); /** * Builds a placeholder replacement program, which is a list of instructions for * efficiently replacing placeholders in identical values in identical memory * objects. * To actually perform replacements, make copies of the memory object of this value * using {@link NCDValMem_InitCopy}, then call {@link NCDValReplaceProg_Execute} * on the copies. * The value passed must be a valid value, and not a placeholder. * Returns 1 on success, 0 on failure. */ int NCDValReplaceProg_Init (NCDValReplaceProg *o, NCDValRef val); /** * Frees the placeholder replacement program. */ void NCDValReplaceProg_Free (NCDValReplaceProg *o); /** * Callback used by {@link NCDValReplaceProg_Execute} to allow the caller to produce * values of placeholders. * This function should build a new value within the memory object 'mem' (which is * the same as of the memory object where placeholders are being replaced). * On success, it should return 1, writing a valid value reference to *out. * On failure, it can either return 0, or return 1 but write an invalid value reference. * This callback must not access the memory object in any other way than building * new values in it; it must not modify any values that were already present at the * point it was called. */ typedef int (*NCDVal_replace_func) (void *arg, int plid, NCDValMem *mem, NCDValRef *out); /** * Executes the replacement program, replacing placeholders in a value. * The memory object must given be identical to the memory object which was used in * {@link NCDValReplaceProg_Init}; see {@link NCDValMem_InitCopy}. * This will call the callback 'replace', which should build the values to replace * the placeholders. * Returns 1 on success and 0 on failure. On failure, the entire memory object enters * and inconsistent state and must be freed using {@link NCDValMem_Free} before * performing any other operation on it. * The program is passed by value instead of pointer because this appears to be faster. * Is is not modified in any way. */ int NCDValReplaceProg_Execute (NCDValReplaceProg prog, NCDValMem *mem, NCDVal_replace_func replace, void *arg); #endif
6f3916f7e59477ab1d2fe238ca75d06c78dae4ea
626aee78e69e1fad64a4f2fc3d62fd4f049be47f
/lib/ngtcp2_gaptr.h
0f100a81c4286c63a1b31c57453470a90a14eacb
[ "MIT" ]
permissive
ngtcp2/ngtcp2
b85c0972b26ca8da2711b700db826207d1d55c46
54bef1a5b0c975d9a50e1fd953e8d703b856c6d7
refs/heads/main
2023-08-31T03:21:03.773331
2023-08-30T09:27:56
2023-08-30T09:27:56
95,347,622
993
247
MIT
2023-09-12T09:53:46
2017-06-25T08:28:58
C
UTF-8
C
false
false
3,125
h
ngtcp2_gaptr.h
/* * ngtcp2 * * Copyright (c) 2017 ngtcp2 contributors * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef NGTCP2_GAPTR_H #define NGTCP2_GAPTR_H #ifdef HAVE_CONFIG_H # include <config.h> #endif /* HAVE_CONFIG_H */ #include <ngtcp2/ngtcp2.h> #include "ngtcp2_mem.h" #include "ngtcp2_ksl.h" #include "ngtcp2_range.h" /* * ngtcp2_gaptr maintains the gap in the range [0, UINT64_MAX). */ typedef struct ngtcp2_gaptr { /* gap maintains the range of offset which is not received yet. Initially, its range is [0, UINT64_MAX). */ ngtcp2_ksl gap; /* mem is custom memory allocator */ const ngtcp2_mem *mem; } ngtcp2_gaptr; /* * ngtcp2_gaptr_init initializes |gaptr|. */ void ngtcp2_gaptr_init(ngtcp2_gaptr *gaptr, const ngtcp2_mem *mem); /* * ngtcp2_gaptr_free frees resources allocated for |gaptr|. */ void ngtcp2_gaptr_free(ngtcp2_gaptr *gaptr); /* * ngtcp2_gaptr_push adds new data of length |datalen| at the stream * offset |offset|. * * This function returns 0 if it succeeds, or one of the following * negative error codes: * * NGTCP2_ERR_NOMEM * Out of memory */ int ngtcp2_gaptr_push(ngtcp2_gaptr *gaptr, uint64_t offset, uint64_t datalen); /* * ngtcp2_gaptr_first_gap_offset returns the offset to the first gap. * If there is no gap, it returns UINT64_MAX. */ uint64_t ngtcp2_gaptr_first_gap_offset(ngtcp2_gaptr *gaptr); /* * ngtcp2_gaptr_get_first_gap_after returns the first gap which * overlaps or comes after |offset|. */ ngtcp2_range ngtcp2_gaptr_get_first_gap_after(ngtcp2_gaptr *gaptr, uint64_t offset); /* * ngtcp2_gaptr_is_pushed returns nonzero if range [offset, offset + * datalen) is completely pushed into this object. */ int ngtcp2_gaptr_is_pushed(ngtcp2_gaptr *gaptr, uint64_t offset, uint64_t datalen); /* * ngtcp2_gaptr_drop_first_gap deletes the first gap entirely as if * the range is pushed. This function assumes that at least one gap * exists. */ void ngtcp2_gaptr_drop_first_gap(ngtcp2_gaptr *gaptr); #endif /* NGTCP2_GAPTR_H */
416f1953621da73f5631e0483a80f7fa6ecef73c
42ab733e143d02091d13424fb4df16379d5bba0d
/third_party/libpng/contrib/tools/checksum-icc.c
1441306d7f200517e29e0415d0500c2b4daa9917
[ "Libpng", "Apache-2.0", "CC0-1.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
google/filament
11cd37ac68790fcf8b33416b7d8d8870e48181f0
0aa0efe1599798d887fa6e33c412c09e81bea1bf
refs/heads/main
2023-08-29T17:58:22.496956
2023-08-28T17:27:38
2023-08-28T17:27:38
143,455,116
16,631
1,961
Apache-2.0
2023-09-14T16:23:39
2018-08-03T17:26:00
C++
UTF-8
C
false
false
2,461
c
checksum-icc.c
/* checksum-icc.c * * Copyright (c) 2013 John Cunningham Bowler * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h * * Generate crc32 and adler32 checksums of the given input files, used to * generate check-codes for use when matching ICC profiles within libpng. */ #include <stdio.h> #include <zlib.h> static int read_one_file(FILE *ip, const char *name) { uLong length = 0; uLong a32 = adler32(0, NULL, 0); uLong c32 = crc32(0, NULL, 0); Byte header[132]; for (;;) { int ch = getc(ip); Byte b; if (ch == EOF) break; b = (Byte)ch; if (length < sizeof header) header[length] = b; ++length; a32 = adler32(a32, &b, 1); c32 = crc32(c32, &b, 1); } if (ferror(ip)) return 0; /* Success */ printf("PNG_ICC_CHECKSUM(0x%8.8lx, 0x%8.8lx,\n PNG_MD5(" "0x%2.2x%2.2x%2.2x%2.2x, 0x%2.2x%2.2x%2.2x%2.2x, 0x%2.2x%2.2x%2.2x%2.2x," " 0x%2.2x%2.2x%2.2x%2.2x), %d,\n" " \"%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d\", %lu, \"%s\")\n", (unsigned long)a32, (unsigned long)c32, header[84], header[85], header[86], header[87], header[88], header[89], header[90], header[91], header[92], header[93], header[94], header[95], header[96], header[97], header[98], header[99], # define u16(x) (header[x] * 256 + header[x+1]) # define u32(x) (u16(x) * 65536 + u16(x+2)) u32(64), u16(24), u16(26), u16(28), u16(30), u16(32), u16(34), (unsigned long)length, name); return 1; } int main(int argc, char **argv) { int err = 0; printf("/* adler32, crc32, MD5[16], intent, date, length, file-name */\n"); if (argc > 1) { int i; for (i=1; i<argc; ++i) { FILE *ip = fopen(argv[i], "rb"); if (ip == NULL || !read_one_file(ip, argv[i])) { err = 1; perror(argv[i]); fprintf(stderr, "%s: read error\n", argv[i]); printf("/* ERROR: %s */\n", argv[i]); } (void)fclose(ip); } } else { if (!read_one_file(stdin, "-")) { err = 1; perror("stdin"); fprintf(stderr, "stdin: read error\n"); printf("/* ERROR: stdin */\n"); } } return err; }
5190e6b558ae138d851abe6ea512becf473dcc0f
c6759b857e55991fea3ef0b465dbcee53fa38714
/rtos/pmsis/api/include/pmsis/cluster/dma/cl_dma_decompressor.h
1859f00d48fa00ed21f4123e772bb1944f5e3ee8
[ "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
13,013
h
cl_dma_decompressor.h
/* * Copyright (C) 2020 GreenWaves Technologies * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CL_DMA_DECOMPRESSOR_H__ #define __CL_DMA_DECOMPRESSOR_H__ #ifdef __cplusplus extern "C" { #endif #ifdef DEBUG_ASSERT #include "assert.h" #endif //************************************************************************************************* // Decompressor CONF_REG register definition //************************************************************************************************* /** * \brief Decompression/compression mode * * T1 * The decompression scheme T1 consists in data expansion (signed/unsigned) to 8 * 16 or 32 bits, within linear or 2D transfers from L2 to L1. Compressed data can * be any size ranging from 1 to 31 bits. * * T2 * The decompression scheme T2 consists in data transformation and expansion * (signed/unsigned) to 8, 16 or 32 bits. Only linear transfers from L2 to L1 are * supported. The transformation is performed via a look-up table (LUT), where the * compressed data is interpreted as the LUT address, and the content of the LUT * is the corresponding decompressed data. Compressed data (LUT addresses) size is * ranging from 1 to 8 bits (i.e. maximum of 256 LUT entries). * * T3 * The decompression scheme T3 consists in data transformation and expansion * (signed/unsigned) to 8, 16 or 32 bits. Only linear transfers from L2 to L1 are * supported. The T3 scheme introduces a special symbol in the compressed data, * which is encoded with a single bit (0). The T3 engine starts decompressing data * and discriminates between occurancies of the special symbol (encoded with 0) and * other data, which are compressed data using the LUT like in T2. Non special * symbols are therefore encoded with a bit set to 1 (to discriminate from the special * symbol) followed by the 1- to 8-bit LUT address. */ typedef enum { PI_CL_DMA_DECOMPRESSOR_MODE_T1 = ((uint32_t)0), // T1 mode PI_CL_DMA_DECOMPRESSOR_MODE_T2 = ((uint32_t)1), // T2 mode PI_CL_DMA_DECOMPRESSOR_MODE_T3 = ((uint32_t)2), // T3 mode } pi_cl_dma_decompressor_mode_e; /** * \brief type of the decompressed data */ typedef enum { PI_CL_DMA_DECOMPRESSOR_EXT_TYPE_8 = ((uint32_t)0), PI_CL_DMA_DECOMPRESSOR_EXT_TYPE_16 = ((uint32_t)1), PI_CL_DMA_DECOMPRESSOR_EXT_TYPE_32 = ((uint32_t)3), } pi_cl_dma_decompressor_ext_type_e; /** * \brief signedness of decompressed data */ typedef enum { PI_CL_DMA_DECOMPRESSOR_EXT_SIGN_UNSIGNED = ((uint32_t)0), PI_CL_DMA_DECOMPRESSOR_EXT_SIGN_SIGNED = ((uint32_t)1), } pi_cl_dma_decompressor_ext_sign_e; /** * \brief decompressor direction */ typedef enum { PI_CL_DMA_DECOMPRESSOR_DIR_EXT2LOC = ((uint32_t)0), /*!< Decompress data from L2 to TCDM */ PI_CL_DMA_DECOMPRESSOR_DIR_LOC2EXT = ((uint32_t)1), /*!< Compress data from TCDM to L2 (only T1 mode) */ } pi_cl_dma_decompressor_dir_e; // Used in assertion mechanism. Check if the decompression mode is a valid one #define DECOMPRESSOR_IS_VALID_CONF_MODE(decompr_mode) (((decompr_mode) == PI_CL_DMA_DECOMPRESSOR_MODE_T1) || \ ((decompr_mode) == PI_CL_DMA_DECOMPRESSOR_MODE_T2) || \ ((decompr_mode) == PI_CL_DMA_DECOMPRESSOR_MODE_T3)) // Used in assertion mechanism. Check if the extension type is a valid one #define DECOMPRESSOR_IS_VALID_CONF_EXT_TYPE(extension_type) (((extension_type) == PI_CL_DMA_DECOMPRESSOR_EXT_TYPE_8) || \ ((extension_type) == PI_CL_DMA_DECOMPRESSOR_EXT_TYPE_16) || \ ((extension_type) == PI_CL_DMA_DECOMPRESSOR_EXT_TYPE_32)) // Used in assertion mechanism. Check if the item bit width is a valid one #define DECOMPRESSOR_IS_VALID_CONF_ITEM_BIT_WIDTH(item_bit_width,decompr_mode) ((((decompr_mode) == PI_CL_DMA_DECOMPRESSOR_MODE_T1) && ((item_bit_width) >= 1) && ((item_bit_width) <= 31)) || \ ((((decompr_mode) == PI_CL_DMA_DECOMPRESSOR_MODE_T2) || ((decompr_mode) == PI_CL_DMA_DECOMPRESSOR_MODE_T3)) && ((item_bit_width) >= 1) && ((item_bit_width) <= 15))) // Used in assertion mechanism. Check if the sign extension is a valid one #define DECOMPRESSOR_IS_VALID_CONF_SIGN_EXT(sign_extension) (((sign_extension) == PI_CL_DMA_DECOMPRESSOR_EXT_SIGN_UNSIGNED) || \ ((sign_extension) == PI_CL_DMA_DECOMPRESSOR_EXT_SIGN_SIGNED)) // Used in assertion mechanism. Check if the decompression direction is a valid one #define DECOMPRESSOR_IS_VALID_CONF_DIRECTION(decompr_direction) (((decompr_direction) == PI_CL_DMA_DECOMPRESSOR_DIR_EXT2LOC) || \ ((decompr_direction) == PI_CL_DMA_DECOMPRESSOR_DIR_LOC2EXT)) // Used in assertion mechanism. Verify that the configuration (related to CONF_REG register) is valid #define DECOMPRESSOR_IS_VALID_CONF(conf) (DECOMPRESSOR_IS_VALID_CONF_MODE(conf.decompr_mode) && \ DECOMPRESSOR_IS_VALID_CONF_EXT_TYPE(conf.extension_type) && \ DECOMPRESSOR_IS_VALID_CONF_ITEM_BIT_WIDTH(conf.item_bit_width, conf.decompr_mode) && \ DECOMPRESSOR_IS_VALID_CONF_SIGN_EXT(conf.sign_extension) && \ DECOMPRESSOR_IS_VALID_CONF_DIRECTION(conf.decompr_direction)) // Used in assertion mechanism. Check if the command is well parametered for using the LUT. #define DECOMPRESSOR_IS_VALID_LUT_CONFIG(flag, lut, size, mode) ( (!(flag)) || \ ((flag) && ((lut) != NULL) && (size > 0) && (mode != PI_CL_DMA_DECOMPRESSOR_MODE_T1))) /** * @brief Transfer mode (linear or 2D) for source and destination */ typedef enum { PI_CL_DMA_DECOMPRESSOR_TRANSF_EXT_LIN_LOC_LIN = ((uint8_t)0), // linear L2/linear TCDM PI_CL_DMA_DECOMPRESSOR_TRANSF_EXT_2D_LOC_LIN = ((uint8_t)1), // 2D L2/linear TCDM PI_CL_DMA_DECOMPRESSOR_TRANSF_EXT_LIN_LOC_2D = ((uint8_t)2), // linear L2/2D TCDM } pi_cl_dma_decompressor_transfer_type_e; // Used in assertion mechanism. Verify that the transfer type is a valid one #define DECOMPRESSOR_IS_VALID_TRANSFER_TYPE(type) ( ((type) == PI_CL_DMA_DECOMPRESSOR_TRANSF_EXT_LIN_LOC_LIN) || \ ((type) == PI_CL_DMA_DECOMPRESSOR_TRANSF_EXT_LIN_LOC_LIN) || \ ((type) == PI_CL_DMA_DECOMPRESSOR_TRANSF_EXT_LIN_LOC_LIN)) /** * @brief 2D transfer options structure. */ typedef struct pi_cl_dma_decompressor_2d_transfer { uint16_t count; /*!< number of items in a row */ uint16_t stride; /*!< number of items from the start of a row to the next one*/ } pi_cl_dma_decompressor_2d_transfer_t; /** * @brief Decompressor's CONF_REG register description. */ typedef union { struct { uint32_t decompr_mode : 2; //!< Decompression Mode: b00: T1; b01: T2; b11:T3; b10: reserved. uint32_t extension_type : 2; //!< Extension Type: b00: 8-bit; b01: 16-bit; b11: 32bit; b10: reserved. uint32_t item_bit_width : 5; //!< Size of compressed data item in L2. Allowed sizes are 1 to 31 for T1, 1 to 15 for T2 and T3. Warning: An illegal configuration will be handled like a 1-bit width configuration uint32_t sign_extension : 1; //!< Sign extension during decompression: 0: Unsigned; 1: Signed. uint32_t start_bit : 3; //!< Bit offset (in the byte) for L2 start address during decompression or compression. uint32_t decompr_direction : 1; //!< Transfer direction: 0: TX (decompression); 1: RX (compression T1). uint32_t start_byte : 2; //!< Byte offset (in a 32-bit word) in L2 start address during decompression or compression. uint32_t items_to_transfer : 16; //!< Total items to compress/decompress during a transfer. }; uint32_t raw; //!< Register content raw version }__attribute__((packed))pi_cl_dma_decompressor_conf_reg_t; /** * @brief Bitfield structure that gather all decompressor's flags. * These flags are used to write additionnal decompressor * registers from the @ref pi_cl_dma_decompressor_cmd_t. */ typedef union { struct { uint8_t update_lut : 1; //!< Trigger a LUT write process during the Exec command uint8_t update_2d_ext : 1; //!< Allows to write L2 2D transfer registers during the Exec command uint8_t update_2d_loc : 1; //!< Allows to write TCDM 2D transfer registers during the Exec command uint8_t unused : 5; //!< Not used }; uint8_t all; //!< Used to check if at least one flag is set. }pi_cl_decompressor_flag_t; // The L2 address set in L2_ADDR_REG can only be a multiple of "4". This define filter the input value // given by the user and set the "start_byte" bits in CONF_REG register to get the right address value. #define DECOMPRESSOR_L2_ADDRESS_FILTER 0x03 #define DECOMPRESSOR_L2_START_BYTE_MASK 0x0000C000 /** * \brief structure containing command information for decompression/compression */ typedef struct pi_cl_dma_decompressor_cmd_s { uint32_t loc; //!< Cluster TCDM address uint32_t ext; //!< L2 address pi_cl_dma_decompressor_conf_reg_t conf; //!< CONF_REG register content pi_cl_dma_decompressor_transfer_type_e transf_type; //!< L2->TCDM (decompression), TCDM->L2 (compression) pi_cl_dma_decompressor_2d_transfer_t l2_2d; //!< Parameters for the L2 2D transfer pi_cl_dma_decompressor_2d_transfer_t tcdm_2d; //!< Parameters for the TCDM 2 transfer uint32_t special_symbol; //!< special symbol (only used in T3 mode) void *lut; //!< array containing LUT elements. Can be a uin8_t or uint16_t depending item_bit_width uint8_t lut_size; //!< number of elements in the LUT (max 256) uint8_t done; //!< done flag, set by the internal driver to 1 when transfer is done struct pi_cl_dma_decompressor_cmd_s* next_cmd; //!< Pointer to the next command. Reserved for runtime usage pi_cl_decompressor_flag_t flag; //!< Bitfield structure to gather all decompressor's flags. }pi_cl_dma_decompressor_cmd_t; /** * @brief Initialize the decompressor. Enable its interrupt. */ void pi_cl_dma_decompressor_init(void); /** * @brief Write decompressor register from a @ref pi_cl_dma_decompressor_cmd_t object type and initiate a transaction. * * @param cmd Pointer to the command to write/execute * This structure should stay valid during the entirety of the transfer. * Following parameter comes from this cmd object. They are exposed for optimization purpose. * @param ext L2 address * @param loc L1 address * @param conf CONF_REG register structure. It appears here for optimization purpose * @param transfer_type MODE_REG register content. It appears here for optimization purpose * @param lut_size Look up table size. It appers here for optimization purpose */ void pi_cl_dma_decompressor_cmd(pi_cl_dma_decompressor_cmd_t* cmd, uint32_t ext, uint32_t loc, pi_cl_dma_decompressor_conf_reg_t conf, pi_cl_dma_decompressor_transfer_type_e transfer_type, uint8_t lut_size); /** * \brief blocks until the specified transfer ends * * \param cmd A pointer to the structure that represents the transfer */ static inline void pi_cl_dma_decompressor_wait(pi_cl_dma_decompressor_cmd_t* cmd) { while((*(volatile uint8_t *)&cmd->done) == 0) { hal_cl_eu_event_mask_wait_and_clear(1 << CL_DECOMP_DONE_NOTIFY_EVENT); } } #ifdef __cplusplus } #endif #endif
1d859abe8365a2f405fccd52ad7c949cf749ee10
03b2c80dbc41e904b167d504666e27d798da5447
/src/restart.c
4ca7e748928f06f6b80a23bd468e4af62d25daf4
[ "Unlicense" ]
permissive
nptcl/npt
7c1570b497cdce0b8971cb445fbc04cb500232d3
aa714a2370ac9fa5348c2fc96159b40b9de3de07
refs/heads/master
2023-03-20T09:13:54.669118
2022-07-02T11:17:44
2022-07-02T11:17:44
171,985,905
160
12
Unlicense
2023-03-11T01:36:37
2019-02-22T03:11:34
C
UTF-8
C
false
false
3,058
c
restart.c
#include "heap.h" #include "restart.h" #include "restart_value.h" enum Restart_Index { Restart_Name, Restart_Function, Restart_Interactive, Restart_Report, Restart_Test, Restart_Condition, Restart_Associated, Restart_Size }; #define RefRestart RefArrayA2 #define GetRestart GetArrayA2 #define SetRestart SetArrayA2 int restartp(addr pos) { return GetType(pos) == LISPTYPE_RESTART; } void restart_heap(addr *ret, addr name) { addr pos; heap_array2(&pos, LISPTYPE_RESTART, Restart_Size); SetUser(pos, 0); setenable_restart(pos, 1); SetRestart(pos, Restart_Name, name); *ret = pos; } void getname_restart(addr pos, addr *ret) { CheckType(pos, LISPTYPE_RESTART); GetRestart(pos, Restart_Name, ret); } void setname_restart(addr pos, addr value) { CheckType(pos, LISPTYPE_RESTART); SetRestart(pos, Restart_Name, value); } void getfunction_restart(addr pos, addr *ret) { CheckType(pos, LISPTYPE_RESTART); GetRestart(pos, Restart_Function, ret); } void setfunction_restart(addr pos, addr value) { CheckType(pos, LISPTYPE_RESTART); SetRestart(pos, Restart_Function, value); } void getinteractive_restart(addr pos, addr *ret) { CheckType(pos, LISPTYPE_RESTART); GetRestart(pos, Restart_Interactive, ret); } void setinteractive_restart(addr pos, addr value) { CheckType(pos, LISPTYPE_RESTART); SetRestart(pos, Restart_Interactive, value); } void getreport_restart(addr pos, addr *ret) { CheckType(pos, LISPTYPE_RESTART); GetRestart(pos, Restart_Report, ret); } void setreport_restart(addr pos, addr value) { CheckType(pos, LISPTYPE_RESTART); SetRestart(pos, Restart_Report, value); } void gettest_restart(addr pos, addr *ret) { CheckType(pos, LISPTYPE_RESTART); GetRestart(pos, Restart_Test, ret); } void settest_restart(addr pos, addr value) { CheckType(pos, LISPTYPE_RESTART); SetRestart(pos, Restart_Test, value); } void getcondition_restart(addr pos, addr *ret) { CheckType(pos, LISPTYPE_RESTART); GetRestart(pos, Restart_Condition, ret); } void setcondition_restart(addr pos, addr value) { CheckType(pos, LISPTYPE_RESTART); SetRestart(pos, Restart_Condition, value); } void getassociated_restart(addr pos, addr *ret) { CheckType(pos, LISPTYPE_RESTART); GetRestart(pos, Restart_Associated, ret); } void setassociated_restart(addr pos, addr value) { CheckType(pos, LISPTYPE_RESTART); SetRestart(pos, Restart_Associated, value); } void setescape_restart(addr pos, int value) { byte u; CheckType(pos, LISPTYPE_RESTART); u = (byte)GetUser(pos); SetBitByte(u, 0, value); SetUser(pos, u); } int getescape_restart(addr pos) { byte u; CheckType(pos, LISPTYPE_RESTART); u = (byte)GetUser(pos); return GetBitByte(u, 0); } void setenable_restart(addr pos, int value) { byte u; CheckType(pos, LISPTYPE_RESTART); u = (byte)GetUser(pos); SetBitByte(u, 1, value); SetUser(pos, u); } int getenable_restart(addr pos) { byte u; CheckType(pos, LISPTYPE_RESTART); u = (byte)GetUser(pos); return GetBitByte(u, 1); } /* * initialize */ void init_restart(void) { init_restart_value(); }
29951339770063b8d764e0fbc3c19e2869db91b4
ecce427678ecff2a93a47f3b1b664202c7d27617
/levels/wf/areas/1/6/1.inc.c
c94c56d754f57da1a47b107679948f477fac1bd9
[]
no_license
sm64pc/sm64ex
ecf37f31b3f7426c4874254660d856030d789714
54cd27ccee45a2403b45f07a00d6043c51149969
refs/heads/nightly
2023-08-11T12:14:34.424168
2023-07-01T11:45:50
2023-07-01T11:45:50
262,091,731
795
238
null
2023-07-01T11:45:51
2020-05-07T15:43:27
C
UTF-8
C
false
false
8,366
c
1.inc.c
// 0x07005F58 - 0x07005F70 static const Lights1 wf_seg7_lights_07005F58 = gdSPDefLights1( 0x66, 0x66, 0x66, 0xff, 0xff, 0xff, 0x28, 0x28, 0x28 ); // 0x07005F70 - 0x07006060 static const Vtx wf_seg7_vertex_07005F70[] = { {{{ 179, 458, 900}, 0, { 0, 2008}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ 179, 458, 520}, 0, { 0, 3526}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ -178, 458, 520}, 0, { 1398, 3526}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ 179, -88, -239}, 0, { 0, 6558}, {0x00, 0x7e, 0x02, 0xff}}}, {{{ 179, -79, -620}, 0, { 0, 8080}, {0x00, 0x7e, 0x02, 0xff}}}, {{{ -178, -88, -239}, 0, { 1398, 6558}, {0x00, 0x7e, 0x02, 0xff}}}, {{{ -178, -79, -620}, 0, { 1398, 8080}, {0x00, 0x7e, 0x02, 0xff}}}, {{{ 179, 640, 1280}, 0, { 0, 494}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ -178, 640, 900}, 0, { 1398, 2010}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ -178, 640, 1280}, 0, { 1398, 494}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ 179, 640, 900}, 0, { 0, 2010}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ 179, 640, 900}, 0, { 70, 262}, {0x00, 0x00, 0x81, 0xff}}}, {{{ -178, 458, 900}, 0, { 1502, 990}, {0x00, 0x00, 0x81, 0xff}}}, {{{ -178, 640, 900}, 0, { 1502, 262}, {0x00, 0x00, 0x81, 0xff}}}, {{{ 179, 458, 900}, 0, { 70, 990}, {0x00, 0x00, 0x81, 0xff}}}, }; // 0x07006060 - 0x07006150 static const Vtx wf_seg7_vertex_07006060[] = { {{{ 179, 275, 140}, 0, { 70, 1708}, {0x00, 0x00, 0x81, 0xff}}}, {{{ 179, 93, 140}, 0, { 70, 2436}, {0x00, 0x00, 0x81, 0xff}}}, {{{ -178, 93, 140}, 0, { 1502, 2436}, {0x00, 0x00, 0x81, 0xff}}}, {{{ 179, 458, 900}, 0, { 0, 2008}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ -178, 458, 520}, 0, { 1398, 3526}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ -178, 458, 900}, 0, { 1398, 2008}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ 179, 458, 520}, 0, { 70, 986}, {0x00, 0x00, 0x81, 0xff}}}, {{{ -178, 275, 520}, 0, { 1502, 1712}, {0x00, 0x00, 0x81, 0xff}}}, {{{ -178, 458, 520}, 0, { 1502, 986}, {0x00, 0x00, 0x81, 0xff}}}, {{{ 179, 275, 520}, 0, { 70, 1712}, {0x00, 0x00, 0x81, 0xff}}}, {{{ 179, 275, 520}, 0, { 0, 3524}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ -178, 275, 140}, 0, { 1398, 5044}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ -178, 275, 520}, 0, { 1398, 3524}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ 179, 275, 140}, 0, { 0, 5044}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ -178, 275, 140}, 0, { 1502, 1708}, {0x00, 0x00, 0x81, 0xff}}}, }; // 0x07006150 - 0x07006250 static const Vtx wf_seg7_vertex_07006150[] = { {{{ 179, 93, 140}, 0, { 0, 5042}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ -178, 93, -239}, 0, { 1398, 6560}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ -178, 93, 140}, 0, { 1398, 5042}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ 179, 93, -239}, 0, { 0, 6560}, {0x00, 0x7f, 0x00, 0xff}}}, {{{ 179, 93, -239}, 0, { 70, 2432}, {0x00, 0x00, 0x81, 0xff}}}, {{{ -178, -88, -239}, 0, { 1502, 3160}, {0x00, 0x00, 0x81, 0xff}}}, {{{ -178, 93, -239}, 0, { 1502, 2432}, {0x00, 0x00, 0x81, 0xff}}}, {{{ 179, -88, -239}, 0, { 70, 3160}, {0x00, 0x00, 0x81, 0xff}}}, {{{ 179, 275, 520}, 0, { 1980, 1626}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, 458, 520}, 0, { 1982, 900}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, 458, 900}, 0, { 462, 900}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, 640, 900}, 0, { 464, 172}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, 640, 1280}, 0, { -1052, 172}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ -178, -587, -1279}, 0, { 1398, 2234}, {0x00, 0x68, 0xb9, 0xff}}}, {{{ -178, -267, -810}, 0, { 1398, 0}, {0x00, 0x68, 0xb9, 0xff}}}, {{{ 179, -267, -810}, 0, { 0, 0}, {0x00, 0x68, 0xb9, 0xff}}}, }; // 0x07006250 - 0x07006330 static const Vtx wf_seg7_vertex_07006250[] = { {{{ 179, 93, 140}, 0, { 3496, 2354}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, 275, 140}, 0, { 3498, 1626}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, 275, 520}, 0, { 1980, 1626}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, -88, -239}, 0, { 5012, 3082}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, 93, -239}, 0, { 5014, 2354}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, -79, -620}, 0, { 6534, 3046}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, -271, -620}, 0, { 6534, 3812}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, -271, -620}, 0, { 70, 3886}, {0x00, 0x00, 0x81, 0xff}}}, {{{ -178, -271, -620}, 0, { 1502, 3884}, {0x00, 0x00, 0x81, 0xff}}}, {{{ 179, -79, -620}, 0, { 70, 3118}, {0x00, 0x00, 0x81, 0xff}}}, {{{ -178, -79, -620}, 0, { 1502, 3118}, {0x00, 0x00, 0x81, 0xff}}}, {{{ 179, -588, -1279}, 0, { 0, 2236}, {0x00, 0x68, 0xb9, 0xff}}}, {{{ -178, -587, -1279}, 0, { 1398, 2234}, {0x00, 0x68, 0xb9, 0xff}}}, {{{ 179, -267, -810}, 0, { 0, 0}, {0x00, 0x68, 0xb9, 0xff}}}, }; // 0x07006330 - 0x070063A0 static const Vtx wf_seg7_vertex_07006330[] = { {{{ 179, -271, -620}, 0, { 0, 8080}, {0x00, 0x7e, 0x02, 0xff}}}, {{{ 179, -267, -810}, 0, { 0, 8840}, {0x00, 0x7e, 0x02, 0xff}}}, {{{ -178, -267, -810}, 0, { 1398, 8840}, {0x00, 0x7e, 0x02, 0xff}}}, {{{ 179, -267, -810}, 0, { 7294, 3794}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, -271, -620}, 0, { 6534, 3812}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ 179, -588, -1279}, 0, { 9166, 5076}, {0x7f, 0x00, 0x00, 0xff}}}, {{{ -178, -271, -620}, 0, { 1398, 8080}, {0x00, 0x7e, 0x02, 0xff}}}, }; // 0x070063A0 - 0x070064E8 static const Gfx wf_seg7_dl_070063A0[] = { gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, grass_09008000), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), gsSPLight(&wf_seg7_lights_07005F58.l, 1), gsSPLight(&wf_seg7_lights_07005F58.a, 2), gsSPVertex(wf_seg7_vertex_07005F70, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 4, 6, 5, 0x0, 7, 8, 9, 0x0), gsSP2Triangles( 7, 10, 8, 0x0, 11, 12, 13, 0x0), gsSP1Triangle(11, 14, 12, 0x0), gsSPVertex(wf_seg7_vertex_07006060, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 6, 7, 8, 0x0, 6, 9, 7, 0x0), gsSP2Triangles(10, 11, 12, 0x0, 10, 13, 11, 0x0), gsSP1Triangle( 0, 2, 14, 0x0), gsSPVertex(wf_seg7_vertex_07006150, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 3, 1, 0x0), gsSP2Triangles( 4, 5, 6, 0x0, 4, 7, 5, 0x0), gsSP2Triangles( 8, 9, 10, 0x0, 10, 11, 12, 0x0), gsSP1Triangle(13, 14, 15, 0x0), gsSPVertex(wf_seg7_vertex_07006250, 14, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 0, 0x0), gsSP2Triangles( 5, 3, 6, 0x0, 7, 8, 9, 0x0), gsSP2Triangles( 8, 10, 9, 0x0, 11, 12, 13, 0x0), gsSPVertex(wf_seg7_vertex_07006330, 7, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP1Triangle( 0, 2, 6, 0x0), gsSPEndDisplayList(), }; // 0x070064E8 - 0x07006558 const Gfx wf_seg7_dl_070064E8[] = { gsDPPipeSync(), gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), gsSPClearGeometryMode(G_SHADING_SMOOTH), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), gsDPTileSync(), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), gsSPDisplayList(wf_seg7_dl_070063A0), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsDPPipeSync(), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), gsSPSetGeometryMode(G_SHADING_SMOOTH), gsSPEndDisplayList(), };
ae448aa59314bad5a89b7b8296b0192eb9d51de5
61da6274995cf914291af51bd02e60f408fdfedd
/src/num/qform.h
b3a0aed0478598e56b45bae674c8bb818293d129
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
mrirecon/bart
360d518b4c79836d506803aa4a77e8e252ab820b
a3c9dc313f79c4c52f1ba3e617d5831ef088ddf7
refs/heads/master
2023-08-31T11:01:08.932824
2023-08-30T12:15:35
2023-08-30T13:51:18
23,212,230
264
185
BSD-3-Clause
2023-08-03T18:43:36
2014-08-22T03:57:09
C
UTF-8
C
false
false
288
h
qform.h
extern float quadratic_form(const float qf[3], float phi); extern void fit_quadratic_form(float qf[3], int N, const float phi[N], const float v[N]); extern float harmonic(const float qf[3], float phi); extern void fit_harmonic(float qf[3], int N, const float phi[N], const float v[N]);
1d08564b114edaafb85addc28c91eac4e037f64d
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/usr.sbin/tpctl/main.c
4018455ae32946422eeb2e94f8f186a7df8f84cf
[]
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
10,157
c
main.c
/* $NetBSD: main.c,v 1.7 2018/07/16 01:04:47 christos Exp $ */ /*- * Copyright (c) 2002 TAKEMRUA Shin * 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 NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. */ #include <stdio.h> #include <strings.h> #include <stdlib.h> #include <unistd.h> #include <err.h> #include <errno.h> #include <time.h> #include <termios.h> #include <sys/fcntl.h> #include <sys/mman.h> #ifdef __STDC__ #include <stdarg.h> #else #include <varargs.h> #endif #include "tpctl.h" #ifndef lint #include <sys/cdefs.h> __RCSID("$NetBSD: main.c,v 1.7 2018/07/16 01:04:47 christos Exp $"); #endif /* not lint */ void load_data(const char *, struct tpctl_data *); void save_data(const char *, struct tpctl_data *); int do_calibration(const char *, struct tp *, struct wsmouse_calibcoords *); void drawcross(struct fb *, int, int, int, fb_pixel_t); int check_esc(void *); int opt_verbose; int opt_noupdate; int opt_forceupdate; static __dead void usage(void) { fprintf(stderr, "usage: %s [-D dispdev] [-d dev] [-f file] [-hnuv]\n", getprogname()); exit(EXIT_FAILURE); /* NOTREACHED */ } int main(int argc, char *argv[]) { int tpfd, ch; struct tp tp; struct wsmouse_calibcoords *pref; struct tpctl_data data; const char *data_file; const char *dev_name; const char *dispdev_name; /* set default values */ opt_verbose = 0; opt_noupdate = 0; opt_forceupdate = 0; dev_name = TPCTL_TP_DEVICE; dispdev_name = TPCTL_FB_DEVICE; data_file = TPCTL_DB_FILENAME; /* parse command line */ while ((ch = getopt(argc, argv, "d:D:f:hnuv")) != -1) { switch (ch) { case 'D': dispdev_name = optarg; break; case 'd': dev_name = optarg; break; case 'f': data_file = optarg; break; case 'h': usage(); /* NOTREACHED */ case 'n': opt_noupdate = 1; break; case 'u': opt_forceupdate = 1; break; case 'v': opt_verbose = 1; break; default: usage(); /* NOTREACHED */ } } if (argv[optind] != NULL) { usage(); /* NOTREACHED */ } /* load calibrarion parameters from specified file */ load_data(data_file, &data); /* open touch panel device and initialize touch panel routines */ if ((tpfd = open(dev_name, O_RDWR)) < 0) errx(EXIT_FAILURE, "can't open touch panel"); if (tp_init(&tp, tpfd) < 0) errx(EXIT_FAILURE, "can't initialize touch panel"); /* find out saved parameters for the touch panel */ pref = search_data(&data, tp.id); if (opt_forceupdate || pref == NULL) { /* if the parameters wasn't found or '-f' options was specified, do 'calibrarion' */ struct wsmouse_calibcoords coords; /* draw cursors and collect samples */ if (do_calibration(dispdev_name, &tp, &coords) < 0) { /* ESC key was pressed to abort */ exit(EXIT_FAILURE); } /* update parameters with new one */ replace_data(&data, tp.id, &coords); pref = search_data(&data, tp.id); } else { /* nothing is updated, so you don't have to write back the data */ opt_noupdate = 1; } if (opt_verbose) write_coords(stdout, tp.id, pref); /* set calibration parameters into touch panel device */ if (tp_setcalibcoords(&tp, pref) < 0) errx(EXIT_FAILURE, "can't set samples"); /* save calibrarion parameters from specified file */ if (!opt_noupdate) save_data(data_file, &data); /* dispose data */ free_data(&data); exit(EXIT_SUCCESS); /* NOTREACHED */ } /* * load calibrarion parameters from specified file * * return: none (it won't return if some error occurs) */ void load_data(const char *data_file, struct tpctl_data *data) { int error; init_data(data); error = read_data(data_file, data); switch (error) { case ERR_NONE: break; case ERR_NOFILE: fprintf(stderr, "%s: can't open %s\n", getprogname(), data_file); /* it might be OK... */ break; case ERR_IO: fprintf(stderr, "%s: I/O error on %s\n", getprogname(), data_file); exit(EXIT_FAILURE); break; case ERR_SYNTAX: fprintf(stderr, "%s: format error at %s, line %d\n", getprogname(), data_file, data->lineno); exit(EXIT_FAILURE); break; case ERR_DUPNAME: fprintf(stderr, "%s: duplicate entry at %s, line %d\n", getprogname(), data_file, data->lineno); exit(EXIT_FAILURE); break; default: fprintf(stderr, "%s: internal error\n", getprogname()); exit(EXIT_FAILURE); break; } } /* * save calibrarion parameters to specified file * * return: none (it won't return if some error occurs) */ void save_data(const char *data_file, struct tpctl_data *data) { int error; error = write_data(data_file, data); switch (error) { case ERR_NONE: break; case ERR_NOFILE: fprintf(stderr, "%s: can't open %s\n", getprogname(), data_file); exit(EXIT_FAILURE); break; case ERR_IO: fprintf(stderr, "%s: I/O error on %s\n", getprogname(), data_file); exit(EXIT_FAILURE); break; default: fprintf(stderr, "%s: internal error\n", getprogname()); exit(EXIT_FAILURE); break; } } /* * draw cursors on frame buffer and collect samples in * wamouse_calibcoords structure. * * return: 0 succeeded * -1 aborted by user (ESC key was pressed) * (it won't return if some error occurs) */ int do_calibration(const char *dev, struct tp *tp, struct wsmouse_calibcoords *coords) { int fbfd; struct fb fb; int i, x, y, xm, ym, cursize, error, res; /* open frame buffer device and initialize frame buffer routine */ if ((fbfd = open(dev, O_RDWR)) < 0) errx(EXIT_FAILURE, "can't open frame buffer"); if (fb_init(&fb, fbfd) < 0) errx(EXIT_FAILURE, "can't map frame buffer"); memset(coords, 0, sizeof(*coords)); coords->minx = 0; coords->miny = 0; coords->maxx = fb.conf.hf_width - 1; coords->maxy = fb.conf.hf_height - 1; coords->samplelen = 5; cursize = 20; xm = fb.conf.hf_width/10; ym = fb.conf.hf_height/10; /* center */ coords->samples[0].x = fb.conf.hf_width/2; coords->samples[0].y = fb.conf.hf_height/2; /* top left */ coords->samples[1].x = xm; coords->samples[1].y = ym; /* bottom left */ coords->samples[2].x = xm; coords->samples[2].y = fb.conf.hf_height - ym; /* bottom right */ coords->samples[3].x = fb.conf.hf_width - xm; coords->samples[3].y = fb.conf.hf_height - ym; /* top right */ coords->samples[4].x = fb.conf.hf_width - xm; coords->samples[4].y = ym; tp_setrawmode(tp); error = 0; for (i = 0; i < coords->samplelen; i++) { drawcross(&fb, coords->samples[i].x, coords->samples[i].y, cursize, fb.white); fb_flush(&fb); tp_flush(tp); res = tp_get(tp, &x, &y, check_esc, 0 /* stdin */); if (res < 0) { error = errno; break; } if (0 < res) { fb_dispmode(&fb, WSDISPLAYIO_MODE_EMUL); return (-1); /* aborted by user */ } coords->samples[i].rawx = x; coords->samples[i].rawy = y; drawcross(&fb, coords->samples[i].x, coords->samples[i].y, cursize, fb.black); fb_flush(&fb); tp_waitup(tp, 200, check_esc, 0 /* stdin */); } fb_dispmode(&fb, WSDISPLAYIO_MODE_EMUL); close(fbfd); if (opt_verbose) { printf("%s: %dx%d (%dbytes/line) %dbit offset=0x%lx\n", getprogname(), fb.conf.hf_width, fb.conf.hf_height, fb.conf.hf_bytes_per_line, fb.conf.hf_pixel_width, fb.conf.hf_offset); } if (error) { errno = error; errx(EXIT_FAILURE, "can't get samples"); } return (0); } /* * draw cross cursor on frame buffer * * return: none */ void drawcross(struct fb *fb, int x, int y, int size, fb_pixel_t pixel) { size /= 2; fb_drawline(fb, x, y - size + 1, x, y - 1, pixel); fb_drawline(fb, x + 1, y - size + 1, x + 1, y - 1, pixel); fb_drawline(fb, x, y + 2, x, y + size, pixel); fb_drawline(fb, x + 1, y + 2, x + 1, y + size, pixel); fb_drawline(fb, x - size + 1, y, x - 1, y, pixel); fb_drawline(fb, x - size + 1, y + 1, x - 1, y + 1, pixel); fb_drawline(fb, x + 2, y, x + size, y, pixel); fb_drawline(fb, x + 2, y + 1, x + size, y + 1, pixel); } /* * check ESC key * * date: input file descriptor * * return: 0 nothing has occurred * 1 ESC key was pressed * -1 error */ int check_esc(void *data) { int fd = (int)(intptr_t)data; int flg, n, error; char buf[1]; struct termios tm, raw; if (tcgetattr(fd, &tm) < 0) return (-1); raw = tm; cfmakeraw(&raw); if (tcsetattr(fd, TCSANOW, &raw) < 0) return (-1); if ((flg = fcntl(fd, F_GETFL)) == -1) return (-1); if (fcntl(fd, F_SETFL, flg | O_NONBLOCK) == -1) return (-1); n = read(fd, buf, 1); error = errno; fcntl(fd, F_SETFL, flg); tcsetattr(fd, TCSANOW, &tm); if (n < 0) return (error == EWOULDBLOCK ? 0 : -1); if (n == 0) return (0); /* EOF */ if (*buf == 0x1b) return (1); /* ESC */ return (0); }
70e37a4afcca1aa05f758f3149f06575154eac00
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/www/webkit-gtk/patches/patch-Source_WTF_wtf_PlatformEnable.h
95d347c82ef9b878bfbf20e1c8d138e769b909f1
[]
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
942
h
patch-Source_WTF_wtf_PlatformEnable.h
$NetBSD: patch-Source_WTF_wtf_PlatformEnable.h,v 1.1 2020/03/10 18:14:04 leot Exp $ Enable the JIT on NetBSD. --- Source/WTF/wtf/PlatformEnable.h.orig 2020-02-04 10:24:07.000000000 +0000 +++ Source/WTF/wtf/PlatformEnable.h @@ -625,12 +625,12 @@ #if !defined(ENABLE_DFG_JIT) && ENABLE(JIT) /* Enable the DFG JIT on X86 and X86_64. */ -#if CPU(X86_64) && (OS(DARWIN) || OS(LINUX) || OS(FREEBSD) || OS(HURD) || OS(WINDOWS)) +#if CPU(X86_64) && (OS(DARWIN) || OS(LINUX) || OS(FREEBSD) || OS(NETBSD) || OS(HURD) || OS(WINDOWS)) #define ENABLE_DFG_JIT 1 #endif -/* Enable the DFG JIT on ARMv7. Only tested on iOS, Linux, and FreeBSD. */ -#if (CPU(ARM_THUMB2) || CPU(ARM64)) && (OS(DARWIN) || OS(LINUX) || OS(FREEBSD)) +/* Enable the DFG JIT on ARMv7. Only tested on iOS, Linux, and FreeBSD and NetBSD. */ +#if (CPU(ARM_THUMB2) || CPU(ARM64)) && (OS(DARWIN) || OS(LINUX) || OS(FREEBSD) || OS(NETBSD)) #define ENABLE_DFG_JIT 1 #endif
c9cb90adca67f7ed5715ec560f87e639b0d73015
9877916b83363457a4f784b8405446b1cc623021
/api/include/SAM_Iec61853interp.h
42bbe32864213d1461ec6e7cd6cf347cdf131188
[ "LGPL-2.0-or-later", "LGPL-3.0-only", "BSD-3-Clause" ]
permissive
NREL/SAM
aa32da81d94de272af6dff30cf93f4d53ae21968
04f5e3b04608e9212d50586a01d55eb5b458fc72
refs/heads/develop
2023-08-19T00:58:25.421464
2023-08-17T00:15:48
2023-08-17T00:15:48
7,533,354
299
148
BSD-3-Clause
2023-09-14T20:02:55
2013-01-10T02:52:47
PowerBuilder
UTF-8
C
false
false
2,627
h
SAM_Iec61853interp.h
#ifndef SAM_IEC61853INTERP_H_ #define SAM_IEC61853INTERP_H_ #include "visibility.h" #include "SAM_api.h" #include <stdint.h> #ifdef __cplusplus extern "C" { #endif // // Iec61853interp Technology Model // /** * Create a Iec61853interp variable table. * @param def: the set of financial model-dependent defaults to use (None, Residential, ...) * @param[in,out] err: a pointer to an error object */ SAM_EXPORT typedef void * SAM_Iec61853interp; /// verbosity level 0 or 1. Returns 1 on success SAM_EXPORT int SAM_Iec61853interp_execute(SAM_table data, int verbosity, SAM_error* err); // // IEC61853 parameters // /** * Set input: IEC-61853 matrix test data [various] * options: [IRR,TC,PMP,VMP,VOC,ISC] * constraints: None * required if: * */ SAM_EXPORT void SAM_Iec61853interp_IEC61853_input_mset(SAM_table ptr, double* mat, int nrows, int ncols, SAM_error *err); /** * Set param: Parameter solution matrix * options: [IL,IO,RS,RSH,A] * constraints: None * required if: * */ SAM_EXPORT void SAM_Iec61853interp_IEC61853_param_mset(SAM_table ptr, double* mat, int nrows, int ncols, SAM_error *err); // // SingleDiodeModel parameters // /** * Set I: Irradiance [W/m2] * options: None * constraints: None * required if: * */ SAM_EXPORT void SAM_Iec61853interp_SingleDiodeModel_I_nset(SAM_table ptr, double number, SAM_error *err); /** * Set T: Temperature [C] * options: None * constraints: None * required if: * */ SAM_EXPORT void SAM_Iec61853interp_SingleDiodeModel_T_nset(SAM_table ptr, double number, SAM_error *err); /** * IEC61853 Getters */ SAM_EXPORT double* SAM_Iec61853interp_IEC61853_input_mget(SAM_table ptr, int* nrows, int* ncols, SAM_error *err); SAM_EXPORT double* SAM_Iec61853interp_IEC61853_param_mget(SAM_table ptr, int* nrows, int* ncols, SAM_error *err); /** * SingleDiodeModel Getters */ SAM_EXPORT double SAM_Iec61853interp_SingleDiodeModel_I_nget(SAM_table ptr, SAM_error *err); SAM_EXPORT double SAM_Iec61853interp_SingleDiodeModel_T_nget(SAM_table ptr, SAM_error *err); /** * Outputs Getters */ SAM_EXPORT double SAM_Iec61853interp_Outputs_Il_nget(SAM_table ptr, SAM_error *err); SAM_EXPORT double SAM_Iec61853interp_Outputs_Io_nget(SAM_table ptr, SAM_error *err); SAM_EXPORT double SAM_Iec61853interp_Outputs_Rs_nget(SAM_table ptr, SAM_error *err); SAM_EXPORT double SAM_Iec61853interp_Outputs_Rsh_nget(SAM_table ptr, SAM_error *err); SAM_EXPORT double SAM_Iec61853interp_Outputs_a_nget(SAM_table ptr, SAM_error *err); #ifdef __cplusplus } /* end of extern "C" { */ #endif #endif
d5027169e98d434a3af9a514250efe6e7d250f9c
5ab69c8644a936a3d9dec1669a86c7369c911bf8
/os/net/ipv6/uip6.c
36cfe98633d8da34df21936b00553dcd94989132
[ "BSD-3-Clause" ]
permissive
contiki-ng/contiki-ng
393d36f68b98f5ee3544ea32502cf662ffb2fe9f
31fcaadf7a0dc8ceea07f438cd69db73174879e6
refs/heads/develop
2023-09-01T20:10:30.000765
2023-09-01T14:37:12
2023-09-01T14:37:12
91,191,972
1,242
788
BSD-3-Clause
2023-09-14T19:08:35
2017-05-13T17:37:59
C
UTF-8
C
false
false
76,200
c
uip6.c
/* * Copyright (c) 2001-2003, Adam Dunkels. * 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. * * This file is part of the uIP TCP/IP stack. * * */ /** * \addtogroup uip * @{ */ /** * \file * The uIP TCP/IPv6 stack code. * * \author Adam Dunkels <adam@sics.se> * \author Julien Abeille <jabeille@cisco.com> (IPv6 related code) * \author Mathilde Durvy <mdurvy@cisco.com> (IPv6 related code) */ /* * uIP is a small implementation of the IP, UDP and TCP protocols (as * well as some basic ICMP stuff). The implementation couples the IP, * UDP, TCP and the application layers very tightly. To keep the size * of the compiled code down, this code frequently uses the goto * statement. While it would be possible to break the uip_process() * function into many smaller functions, this would increase the code * size because of the overhead of parameter passing and the fact that * the optimizer would not be as efficient. * * The principle is that we have a small buffer, called the uip_buf, * in which the device driver puts an incoming packet. The TCP/IP * stack parses the headers in the packet, and calls the * application. If the remote host has sent data to the application, * this data is present in the uip_buf and the application read the * data from there. It is up to the application to put this data into * a byte stream if needed. The application will not be fed with data * that is out of sequence. * * If the application wishes to send data to the peer, it should put * its data into the uip_buf. The uip_appdata pointer points to the * first available byte. The TCP/IP stack will calculate the * checksums, and fill in the necessary header fields and finally send * the packet back to the peer. */ #include "sys/cc.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-arch.h" #include "net/ipv6/uipopt.h" #include "net/ipv6/uip-icmp6.h" #include "net/ipv6/uip-nd6.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/multicast/uip-mcast6.h" #include "net/routing/routing.h" #if UIP_ND6_SEND_NS #include "net/ipv6/uip-ds6-nbr.h" #endif /* UIP_ND6_SEND_NS */ /* Log configuration */ #include "sys/log.h" #define LOG_MODULE "IPv6" #define LOG_LEVEL LOG_LEVEL_IPV6 #if UIP_STATISTICS == 1 struct uip_stats uip_stat; #endif /* UIP_STATISTICS == 1 */ /*---------------------------------------------------------------------------*/ /** * \name Layer 2 variables * @{ */ /*---------------------------------------------------------------------------*/ /** Host L2 address */ #if UIP_CONF_LL_802154 uip_lladdr_t uip_lladdr; #else /*UIP_CONF_LL_802154*/ uip_lladdr_t uip_lladdr = {{0x00,0x06,0x98,0x00,0x02,0x32}}; #endif /*UIP_CONF_LL_802154*/ /** @} */ /*---------------------------------------------------------------------------*/ /** * \name Layer 3 variables * @{ */ /*---------------------------------------------------------------------------*/ /** \brief bitmap we use to record which IPv6 headers we have already seen */ uint8_t uip_ext_bitmap = 0; /** * \brief Total length of all IPv6 extension headers */ uint16_t uip_ext_len = 0; /** \brief The final protocol after IPv6 extension headers: * UIP_PROTO_TCP, UIP_PROTO_UDP or UIP_PROTO_ICMP6 */ uint8_t uip_last_proto = 0; /** @} */ /*---------------------------------------------------------------------------*/ /* Buffers */ /*---------------------------------------------------------------------------*/ /** * \name Reassembly buffer definition * @{ */ #define FBUF ((struct uip_ip_hdr *)&uip_reassbuf[0]) /** @} */ /** * \name Buffer variables * @{ */ /** Packet buffer for incoming and outgoing packets */ #ifndef UIP_CONF_EXTERNAL_BUFFER uip_buf_t uip_aligned_buf; #endif /* UIP_CONF_EXTERNAL_BUFFER */ /* The uip_appdata pointer points to application data. */ void *uip_appdata; /* The uip_appdata pointer points to the application data which is to be sent*/ void *uip_sappdata; #if UIP_URGDATA > 0 /* The uip_urgdata pointer points to urgent data (out-of-band data), if present */ void *uip_urgdata; uint16_t uip_urglen, uip_surglen; #endif /* UIP_URGDATA > 0 */ /* The uip_len is either 8 or 16 bits, depending on the maximum packet size.*/ uint16_t uip_len, uip_slen; /** @} */ /*---------------------------------------------------------------------------*/ /** * \name General variables * @{ */ /*---------------------------------------------------------------------------*/ /* The uip_flags variable is used for communication between the TCP/IP stack and the application program. */ uint8_t uip_flags; /* uip_conn always points to the current connection (set to NULL for UDP). */ struct uip_conn *uip_conn; #if UIP_ACTIVE_OPEN || UIP_UDP /* Keeps track of the last port used for a new connection. */ static uint16_t lastport; #endif /* UIP_ACTIVE_OPEN || UIP_UDP */ /** @} */ /*---------------------------------------------------------------------------*/ /* TCP */ /*---------------------------------------------------------------------------*/ /** * \name TCP defines *@{ */ /* Structures and definitions. */ #define TCP_FIN 0x01 #define TCP_SYN 0x02 #define TCP_RST 0x04 #define TCP_PSH 0x08 #define TCP_ACK 0x10 #define TCP_URG 0x20 #define TCP_CTL 0x3f #define TCP_OPT_END 0 /* End of TCP options list */ #define TCP_OPT_NOOP 1 /* "No-operation" TCP option */ #define TCP_OPT_MSS 2 /* Maximum segment size TCP option */ #define TCP_OPT_MSS_LEN 4 /* Length of TCP MSS option. */ /** @} */ /** * \name TCP variables *@{ */ #if UIP_TCP /* The uip_conns array holds all TCP connections. */ struct uip_conn uip_conns[UIP_TCP_CONNS]; /* The uip_listenports list all currently listning ports. */ uint16_t uip_listenports[UIP_LISTENPORTS]; /* The iss variable is used for the TCP initial sequence number. */ static uint8_t iss[4]; /* Temporary variables. */ uint8_t uip_acc32[4]; #endif /* UIP_TCP */ /** @} */ /*---------------------------------------------------------------------------*/ /** * \name UDP variables * @{ */ /*---------------------------------------------------------------------------*/ #if UIP_UDP struct uip_udp_conn *uip_udp_conn; struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS]; #endif /* UIP_UDP */ /** @} */ /*---------------------------------------------------------------------------*/ /** * \name ICMPv6 variables * @{ */ /*---------------------------------------------------------------------------*/ #if UIP_CONF_ICMP6 /** single possible icmpv6 "connection" */ struct uip_icmp6_conn uip_icmp6_conns; #endif /*UIP_CONF_ICMP6*/ /** @} */ /*---------------------------------------------------------------------------*/ /* Functions */ /*---------------------------------------------------------------------------*/ #if UIP_TCP void uip_add32(uint8_t *op32, uint16_t op16) { uip_acc32[3] = op32[3] + (op16 & 0xff); uip_acc32[2] = op32[2] + (op16 >> 8); uip_acc32[1] = op32[1]; uip_acc32[0] = op32[0]; if(uip_acc32[2] < (op16 >> 8)) { ++uip_acc32[1]; if(uip_acc32[1] == 0) { ++uip_acc32[0]; } } if(uip_acc32[3] < (op16 & 0xff)) { ++uip_acc32[2]; if(uip_acc32[2] == 0) { ++uip_acc32[1]; if(uip_acc32[1] == 0) { ++uip_acc32[0]; } } } } #endif /* UIP_TCP */ #if ! UIP_ARCH_CHKSUM /*---------------------------------------------------------------------------*/ static uint16_t chksum(uint16_t sum, const uint8_t *data, uint16_t len) { uint16_t t; const uint8_t *dataptr; const uint8_t *last_byte; dataptr = data; last_byte = data + len - 1; while(dataptr < last_byte) { /* At least two more bytes */ t = (dataptr[0] << 8) + dataptr[1]; sum += t; if(sum < t) { sum++; /* carry */ } dataptr += 2; } if(dataptr == last_byte) { t = (dataptr[0] << 8) + 0; sum += t; if(sum < t) { sum++; /* carry */ } } /* Return sum in host byte order. */ return sum; } /*---------------------------------------------------------------------------*/ uint16_t uip_chksum(uint16_t *data, uint16_t len) { return uip_htons(chksum(0, (uint8_t *)data, len)); } /*---------------------------------------------------------------------------*/ #ifndef UIP_ARCH_IPCHKSUM uint16_t uip_ipchksum(void) { uint16_t sum; sum = chksum(0, uip_buf, UIP_IPH_LEN); LOG_DBG("uip_ipchksum: sum 0x%04x\n", sum); return (sum == 0) ? 0xffff : uip_htons(sum); } #endif /*---------------------------------------------------------------------------*/ static uint16_t upper_layer_chksum(uint8_t proto) { /* gcc 4.4.0 - 4.6.1 (maybe 4.3...) with -Os on 8 bit CPUS incorrectly compiles: * int bar (int); * int foo (unsigned char a, unsigned char b) { * int len = (a << 8) + b; //len becomes 0xff00&<random>+b * return len + bar (len); * } * upper_layer_len triggers this bug unless it is declared volatile. * See https://sourceforge.net/apps/mantisbt/contiki/view.php?id=3 */ volatile uint16_t upper_layer_len; uint16_t sum; upper_layer_len = uipbuf_get_len_field(UIP_IP_BUF) - uip_ext_len; LOG_DBG("Upper layer checksum len: %d from: %d\n", upper_layer_len, (int)(UIP_IP_PAYLOAD(uip_ext_len) - uip_buf)); /* First sum pseudoheader. */ /* IP protocol and length fields. This addition cannot carry. */ sum = upper_layer_len + proto; /* Sum IP source and destination addresses. */ sum = chksum(sum, (uint8_t *)&UIP_IP_BUF->srcipaddr, 2 * sizeof(uip_ipaddr_t)); /* Sum upper-layer header and data. */ sum = chksum(sum, UIP_IP_PAYLOAD(uip_ext_len), upper_layer_len); return (sum == 0) ? 0xffff : uip_htons(sum); } /*---------------------------------------------------------------------------*/ uint16_t uip_icmp6chksum(void) { return upper_layer_chksum(UIP_PROTO_ICMP6); } /*---------------------------------------------------------------------------*/ #if UIP_TCP uint16_t uip_tcpchksum(void) { return upper_layer_chksum(UIP_PROTO_TCP); } #endif /* UIP_TCP */ /*---------------------------------------------------------------------------*/ #if UIP_UDP && UIP_UDP_CHECKSUMS uint16_t uip_udpchksum(void) { return upper_layer_chksum(UIP_PROTO_UDP); } #endif /* UIP_UDP && UIP_UDP_CHECKSUMS */ #endif /* UIP_ARCH_CHKSUM */ /*---------------------------------------------------------------------------*/ void uip_init(void) { uipbuf_init(); uip_ds6_init(); uip_icmp6_init(); uip_nd6_init(); #if UIP_TCP for(int c = 0; c < UIP_LISTENPORTS; ++c) { uip_listenports[c] = 0; } for(int c = 0; c < UIP_TCP_CONNS; ++c) { uip_conns[c].tcpstateflags = UIP_CLOSED; } #endif /* UIP_TCP */ #if UIP_ACTIVE_OPEN || UIP_UDP lastport = 1024; #endif /* UIP_ACTIVE_OPEN || UIP_UDP */ #if UIP_UDP for(int c = 0; c < UIP_UDP_CONNS; ++c) { uip_udp_conns[c].lport = 0; } #endif /* UIP_UDP */ #if UIP_IPV6_MULTICAST UIP_MCAST6.init(); #endif } /*---------------------------------------------------------------------------*/ #if UIP_TCP && UIP_ACTIVE_OPEN struct uip_conn * uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport) { register struct uip_conn *conn, *cconn; int c; /* Find an unused local port. */ again: ++lastport; if(lastport >= 32000) { lastport = 4096; } /* Check if this port is already in use, and if so try to find another one. */ for(c = 0; c < UIP_TCP_CONNS; ++c) { conn = &uip_conns[c]; if(conn->tcpstateflags != UIP_CLOSED && conn->lport == uip_htons(lastport)) { goto again; } } conn = 0; for(c = 0; c < UIP_TCP_CONNS; ++c) { cconn = &uip_conns[c]; if(cconn->tcpstateflags == UIP_CLOSED) { conn = cconn; break; } if(cconn->tcpstateflags == UIP_TIME_WAIT) { if(conn == 0 || cconn->timer > conn->timer) { conn = cconn; } } } if(conn == 0) { return 0; } conn->tcpstateflags = UIP_SYN_SENT; conn->snd_nxt[0] = iss[0]; conn->snd_nxt[1] = iss[1]; conn->snd_nxt[2] = iss[2]; conn->snd_nxt[3] = iss[3]; conn->rcv_nxt[0] = 0; conn->rcv_nxt[1] = 0; conn->rcv_nxt[2] = 0; conn->rcv_nxt[3] = 0; conn->initialmss = conn->mss = UIP_TCP_MSS; conn->len = 1; /* TCP length of the SYN is one. */ conn->nrtx = 0; conn->timer = 1; /* Send the SYN next time around. */ conn->rto = UIP_RTO; conn->sa = 0; conn->sv = 16; /* Initial value of the RTT variance. */ conn->lport = uip_htons(lastport); conn->rport = rport; uip_ipaddr_copy(&conn->ripaddr, ripaddr); return conn; } #endif /* UIP_TCP && UIP_ACTIVE_OPEN */ /*---------------------------------------------------------------------------*/ bool uip_remove_ext_hdr(void) { /* Remove ext header before TCP/UDP processing. */ if(uip_ext_len > 0) { LOG_DBG("Removing IPv6 extension headers (extlen: %d, uiplen: %d)\n", uip_ext_len, uip_len); if(uip_len < UIP_IPH_LEN + uip_ext_len) { LOG_ERR("uip_len too short compared to ext len\n"); uipbuf_clear(); return false; } /* Set proto */ UIP_IP_BUF->proto = uip_last_proto; /* Move IP payload to the "left"*/ memmove(UIP_IP_PAYLOAD(0), UIP_IP_PAYLOAD(uip_ext_len), uip_len - UIP_IPH_LEN - uip_ext_len); /* Update the IP length. */ if(uipbuf_add_ext_hdr(-uip_ext_len) == false) { return false; } uipbuf_set_len_field(UIP_IP_BUF, uip_len - UIP_IPH_LEN); } return true; } /*---------------------------------------------------------------------------*/ #if UIP_UDP struct uip_udp_conn * uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport) { int c; register struct uip_udp_conn *conn; /* Find an unused local port. */ again: ++lastport; if(lastport >= 32000) { lastport = 4096; } for(c = 0; c < UIP_UDP_CONNS; ++c) { if(uip_udp_conns[c].lport == uip_htons(lastport)) { goto again; } } conn = 0; for(c = 0; c < UIP_UDP_CONNS; ++c) { if(uip_udp_conns[c].lport == 0) { conn = &uip_udp_conns[c]; break; } } if(conn == 0) { return 0; } conn->lport = UIP_HTONS(lastport); conn->rport = rport; if(ripaddr == NULL) { memset(&conn->ripaddr, 0, sizeof(uip_ipaddr_t)); } else { uip_ipaddr_copy(&conn->ripaddr, ripaddr); } conn->ttl = uip_ds6_if.cur_hop_limit; return conn; } #endif /* UIP_UDP */ /*---------------------------------------------------------------------------*/ #if UIP_TCP void uip_unlisten(uint16_t port) { int c; for(c = 0; c < UIP_LISTENPORTS; ++c) { if(uip_listenports[c] == port) { uip_listenports[c] = 0; return; } } } /*---------------------------------------------------------------------------*/ void uip_listen(uint16_t port) { int c; for(c = 0; c < UIP_LISTENPORTS; ++c) { if(uip_listenports[c] == 0) { uip_listenports[c] = port; return; } } } #endif /*---------------------------------------------------------------------------*/ #if UIP_CONF_IPV6_REASSEMBLY #define UIP_REASS_BUFSIZE (UIP_BUFSIZE) static uint8_t uip_reassbuf[UIP_REASS_BUFSIZE]; static uint8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)]; /*the first byte of an IP fragment is aligned on an 8-byte boundary */ static const uint8_t bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01}; static uint16_t uip_reasslen; static uint8_t uip_reassflags; #define UIP_REASS_FLAG_LASTFRAG 0x01 #define UIP_REASS_FLAG_FIRSTFRAG 0x02 #define UIP_REASS_FLAG_ERROR_MSG 0x04 /* * See RFC 2460 for a description of fragmentation in IPv6 * A typical Ipv6 fragment * +------------------+--------+--------------+ * | Unfragmentable |Fragment| first | * | Part | Header | fragment | * +------------------+--------+--------------+ */ struct etimer uip_reass_timer; /**< Timer for reassembly */ uint8_t uip_reass_on; /* equal to 1 if we are currently reassembling a packet */ static uint32_t uip_id; /* For every packet that is to be fragmented, the source node generates an Identification value that is present in all the fragments */ #define IP_MF 0x0001 static uint16_t uip_reass(uint8_t *prev_proto_ptr) { uint16_t offset=0; uint16_t len; uint16_t i; struct uip_frag_hdr *frag_buf = (struct uip_frag_hdr *)UIP_IP_PAYLOAD(uip_ext_len); /* If ip_reasstmr is zero, no packet is present in the buffer */ /* We first write the unfragmentable part of IP header into the reassembly buffer. The reset the other reassembly variables. */ if(uip_reass_on == 0) { LOG_INFO("Starting reassembly\n"); memcpy(FBUF, UIP_IP_BUF, uip_ext_len + UIP_IPH_LEN); /* temporary in case we do not receive the fragment with offset 0 first */ etimer_set(&uip_reass_timer, UIP_REASS_MAXAGE*CLOCK_SECOND); uip_reass_on = 1; uip_reassflags = 0; uip_id = frag_buf->id; /* Clear the bitmap. */ memset(uip_reassbitmap, 0, sizeof(uip_reassbitmap)); } /* * Check if the incoming fragment matches the one currently present * in the reasembly buffer. If so, we proceed with copying the fragment * into the buffer. */ if(uip_ipaddr_cmp(&FBUF->srcipaddr, &UIP_IP_BUF->srcipaddr) && uip_ipaddr_cmp(&FBUF->destipaddr, &UIP_IP_BUF->destipaddr) && frag_buf->id == uip_id) { len = uip_len - uip_ext_len - UIP_IPH_LEN - UIP_FRAGH_LEN; offset = (uip_ntohs(frag_buf->offsetresmore) & 0xfff8); /* in byte, originaly in multiple of 8 bytes*/ LOG_INFO("len %d\n", len); LOG_INFO("offset %d\n", offset); if(offset == 0){ uip_reassflags |= UIP_REASS_FLAG_FIRSTFRAG; /* * The Next Header field of the last header of the Unfragmentable * Part is obtained from the Next Header field of the first * fragment's Fragment header. */ *prev_proto_ptr = frag_buf->next; memcpy(FBUF, UIP_IP_BUF, uip_ext_len + UIP_IPH_LEN); LOG_INFO("src "); LOG_INFO_6ADDR(&FBUF->srcipaddr); LOG_INFO_("dest "); LOG_INFO_6ADDR(&FBUF->destipaddr); LOG_INFO_("next %d\n", UIP_IP_BUF->proto); } /* If the offset or the offset + fragment length overflows the reassembly buffer, we discard the entire packet. */ if(offset > UIP_REASS_BUFSIZE || offset + len > UIP_REASS_BUFSIZE) { uip_reass_on = 0; etimer_stop(&uip_reass_timer); return 0; } /* If this fragment has the More Fragments flag set to zero, it is the last fragment*/ if((uip_ntohs(frag_buf->offsetresmore) & IP_MF) == 0) { uip_reassflags |= UIP_REASS_FLAG_LASTFRAG; /*calculate the size of the entire packet*/ uip_reasslen = offset + len; LOG_INFO("last fragment reasslen %d\n", uip_reasslen); } else { /* If len is not a multiple of 8 octets and the M flag of that fragment is 1, then that fragment must be discarded and an ICMP Parameter Problem, Code 0, message should be sent to the source of the fragment, pointing to the Payload Length field of the fragment packet. */ if(len % 8 != 0){ uip_icmp6_error_output(ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, 4); uip_reassflags |= UIP_REASS_FLAG_ERROR_MSG; /* not clear if we should interrupt reassembly, but it seems so from the conformance tests */ uip_reass_on = 0; etimer_stop(&uip_reass_timer); return uip_len; } } /* Copy the fragment into the reassembly buffer, at the right offset. */ memcpy((uint8_t *)FBUF + UIP_IPH_LEN + uip_ext_len + offset, (uint8_t *)frag_buf + UIP_FRAGH_LEN, len); /* Update the bitmap. */ if(offset >> 6 == (offset + len) >> 6) { uip_reassbitmap[offset >> 6] |= bitmap_bits[(offset >> 3) & 7] & ~bitmap_bits[((offset + len) >> 3) & 7]; } else { /* If the two endpoints are in different bytes, we update the bytes in the endpoints and fill the stuff inbetween with 0xff. */ uip_reassbitmap[offset >> 6] |= bitmap_bits[(offset >> 3) & 7]; for(i = (1 + (offset >> 6)); i < ((offset + len) >> 6); ++i) { uip_reassbitmap[i] = 0xff; } uip_reassbitmap[(offset + len) >> 6] |= ~bitmap_bits[((offset + len) >> 3) & 7]; } /* Finally, we check if we have a full packet in the buffer. We do this by checking if we have the last fragment and if all bits in the bitmap are set. */ if(uip_reassflags & UIP_REASS_FLAG_LASTFRAG) { /* Check all bytes up to and including all but the last byte in the bitmap. */ for(i = 0; i < (uip_reasslen >> 6); ++i) { if(uip_reassbitmap[i] != 0xff) { return 0; } } /* Check the last byte in the bitmap. It should contain just the right amount of bits. */ if(uip_reassbitmap[uip_reasslen >> 6] != (uint8_t)~bitmap_bits[(uip_reasslen >> 3) & 7]) { return 0; } /* If we have come this far, we have a full packet in the buffer, so we copy it to uip_buf. We also reset the timer. */ uip_reass_on = 0; etimer_stop(&uip_reass_timer); uip_reasslen += UIP_IPH_LEN + uip_ext_len; memcpy(UIP_IP_BUF, FBUF, uip_reasslen); uipbuf_set_len_field(UIP_IP_BUF, uip_reasslen - UIP_IPH_LEN); LOG_INFO("reassembled packet %d (%d)\n", uip_reasslen, uipbuf_get_len_field(UIP_IP_BUF)); return uip_reasslen; } } else { LOG_WARN("Already reassembling another paquet\n"); } return 0; } void uip_reass_over(void) { /* to late, we abandon the reassembly of the packet */ uip_reass_on = 0; etimer_stop(&uip_reass_timer); if(uip_reassflags & UIP_REASS_FLAG_FIRSTFRAG){ LOG_ERR("fragmentation timeout\n"); /* If the first fragment has been received, an ICMP Time Exceeded -- Fragment Reassembly Time Exceeded message should be sent to the source of that fragment. */ /** \note * We don't have a complete packet to put in the error message. * We could include the first fragment but since its not mandated by * any RFC, we decided not to include it as it reduces the size of * the packet. */ uipbuf_clear(); memcpy(UIP_IP_BUF, FBUF, UIP_IPH_LEN); /* copy the header for src and dest address*/ uip_icmp6_error_output(ICMP6_TIME_EXCEEDED, ICMP6_TIME_EXCEED_REASSEMBLY, 0); UIP_STAT(++uip_stat.ip.sent); uip_flags = 0; } } #endif /* UIP_CONF_IPV6_REASSEMBLY */ /*---------------------------------------------------------------------------*/ #if UIP_TCP static void uip_add_rcv_nxt(uint16_t n) { uip_add32(uip_conn->rcv_nxt, n); uip_conn->rcv_nxt[0] = uip_acc32[0]; uip_conn->rcv_nxt[1] = uip_acc32[1]; uip_conn->rcv_nxt[2] = uip_acc32[2]; uip_conn->rcv_nxt[3] = uip_acc32[3]; } #endif /*---------------------------------------------------------------------------*/ /** * \brief Process the options in Destination and Hop By Hop extension headers */ static uint8_t ext_hdr_options_process(uint8_t *ext_buf) { /* * Length field in the extension header: length of the header in units of * 8 bytes, excluding the first 8 bytes * length field in an option : the length of data in the option */ uint16_t opt_offset = 2; /* 2 first bytes in ext header */ struct uip_hbho_hdr *ext_hdr = (struct uip_hbho_hdr *)ext_buf; uint16_t ext_hdr_len = (ext_hdr->len << 3) + 8; while(opt_offset + 2 <= ext_hdr_len) { /* + 2 for opt header */ struct uip_ext_hdr_opt *opt_hdr = (struct uip_ext_hdr_opt *)(ext_buf + opt_offset); uint16_t opt_len = opt_hdr->len + 2; if(opt_offset + opt_len > ext_hdr_len) { LOG_ERR("Extension header option too long: dropping packet\n"); uip_icmp6_error_output(ICMP6_PARAM_PROB, ICMP6_PARAMPROB_OPTION, (ext_buf + opt_offset) - uip_buf); return 2; } switch(opt_hdr->type) { /* * for now we do not support any options except padding ones * PAD1 does not make sense as the header must be 8bytes aligned, * hence we can only have */ case UIP_EXT_HDR_OPT_PAD1: LOG_DBG("Processing PAD1 option\n"); opt_offset += 1; break; case UIP_EXT_HDR_OPT_PADN: LOG_DBG("Processing PADN option\n"); opt_offset += opt_len; break; case UIP_EXT_HDR_OPT_RPL: /* Fixes situation when a node that is not using RPL * joins a network which does. The received packages will include the * RPL header and processed by the "default" case of the switch * (0x63 & 0xC0 = 0x40). Hence, the packet is discarded as the header * is considered invalid. * Using this fix, the header is ignored, and the next header (if * present) is processed. */ LOG_DBG("Processing RPL option\n"); if(!NETSTACK_ROUTING.ext_header_hbh_update(ext_buf, opt_offset)) { LOG_ERR("RPL Option Error: Dropping Packet\n"); return 1; } opt_offset += opt_len; break; #if UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_MPL case UIP_EXT_HDR_OPT_MPL: /* MPL (RFC7731) Introduces the 0x6D hop by hop option. Hosts that do not * recognise the option should drop the packet. Since we want to keep the packet, * we want to process the option and not revert to the default case. */ LOG_DBG("Processing MPL option\n"); opt_offset += opt_len + opt_len; break; #endif default: /* * check the two highest order bits of the option * - 00 skip over this option and continue processing the header. * - 01 discard the packet. * - 10 discard the packet and, regardless of whether or not the * packet's Destination Address was a multicast address, send an * ICMP Parameter Problem, Code 2, message to the packet's * Source Address, pointing to the unrecognized Option Type. * - 11 discard the packet and, only if the packet's Destination * Address was not a multicast address, send an ICMP Parameter * Problem, Code 2, message to the packet's Source Address, * pointing to the unrecognized Option Type. */ LOG_DBG("Unrecognized option, MSB 0x%x\n", opt_hdr->type); switch(opt_hdr->type & 0xC0) { case 0: break; case 0x40: return 1; case 0xC0: if(uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) { return 1; } case 0x80: uip_icmp6_error_output(ICMP6_PARAM_PROB, ICMP6_PARAMPROB_OPTION, (ext_buf + opt_offset) - uip_buf); return 2; } /* in the cases were we did not discard, update ext_opt* */ opt_offset += opt_len; break; } } return 0; } /*---------------------------------------------------------------------------*/ #if UIP_TCP static void process_tcp_options(struct uip_conn *conn) { if((UIP_TCP_BUF->tcpoffset & 0xf0) <= 0x50) { return; } /* Parse the TCP MSS option, if present. */ for(unsigned c = 0; c < ((UIP_TCP_BUF->tcpoffset >> 4) - 5) << 2 ;) { if(UIP_IPTCPH_LEN + c >= UIP_BUFSIZE) { /* TCP option data out of bounds. */ return; } uint8_t opt = uip_buf[UIP_IPTCPH_LEN + c]; switch(opt) { case TCP_OPT_END: /* Stop processing options. */ return; case TCP_OPT_NOOP: c++; break; case TCP_OPT_MSS: if(UIP_IPTCPH_LEN + 3 + c >= UIP_BUFSIZE || uip_buf[UIP_IPTCPH_LEN + 1 + c] != TCP_OPT_MSS_LEN) { /* TCP option data out of bounds or invalid MSS option length. */ return; } /* An MSS option with the right option length. */ uint16_t tmp16 = (uip_buf[UIP_IPTCPH_LEN + 2 + c] << 8) | uip_buf[UIP_IPTCPH_LEN + 3 + c]; conn->initialmss = conn->mss = tmp16 > UIP_TCP_MSS ? UIP_TCP_MSS : tmp16; /* Stop processing options. */ return; default: if(UIP_IPTCPH_LEN + 1 + c >= UIP_BUFSIZE) { /* TCP option data out of bounds. */ return; } /* All other options have a length field, so that we easily can skip past them. */ if(uip_buf[UIP_IPTCPH_LEN + 1 + c] == 0) { /* If the length field is zero, the options are malformed and we don't process them further. */ return; } c += uip_buf[UIP_IPTCPH_LEN + 1 + c]; break; } } } #endif /* UIP_TCP */ /*---------------------------------------------------------------------------*/ static bool uip_check_mtu(void) { if(uip_len > UIP_LINK_MTU) { uip_icmp6_error_output(ICMP6_PACKET_TOO_BIG, 0, UIP_LINK_MTU); UIP_STAT(++uip_stat.ip.drop); return false; } else { return true; } } /*---------------------------------------------------------------------------*/ static bool uip_update_ttl(void) { if(UIP_IP_BUF->ttl <= 1) { uip_icmp6_error_output(ICMP6_TIME_EXCEEDED, ICMP6_TIME_EXCEED_TRANSIT, 0); UIP_STAT(++uip_stat.ip.drop); return false; } else { UIP_IP_BUF->ttl = UIP_IP_BUF->ttl - 1; return true; } } /*---------------------------------------------------------------------------*/ void uip_process(uint8_t flag) { uint8_t *last_header; uint8_t protocol; uint8_t *next_header; struct uip_ext_hdr *ext_ptr; #if UIP_TCP int c; register struct uip_conn *uip_connr = uip_conn; #endif /* UIP_TCP */ #if UIP_UDP if(flag == UIP_UDP_SEND_CONN) { goto udp_send; } #endif /* UIP_UDP */ uip_sappdata = uip_appdata = &uip_buf[UIP_IPTCPH_LEN]; /* Check if we were invoked because of a poll request for a particular connection. */ if(flag == UIP_POLL_REQUEST) { #if UIP_TCP if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED && !uip_outstanding(uip_connr)) { uip_flags = UIP_POLL; UIP_APPCALL(); goto appsend; #if UIP_ACTIVE_OPEN } else if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) { /* In the SYN_SENT state, we retransmit out SYN. */ UIP_TCP_BUF->flags = 0; goto tcp_send_syn; #endif /* UIP_ACTIVE_OPEN */ } goto drop; #endif /* UIP_TCP */ /* Check if we were invoked because of the perodic timer fireing. */ } else if(flag == UIP_TIMER) { /* Reset the length variables. */ #if UIP_TCP uipbuf_clear(); uip_slen = 0; /* Increase the initial sequence number. */ if(++iss[3] == 0) { if(++iss[2] == 0) { if(++iss[1] == 0) { ++iss[0]; } } } /* * Check if the connection is in a state in which we simply wait * for the connection to time out. If so, we increase the * connection's timer and remove the connection if it times * out. */ if(uip_connr->tcpstateflags == UIP_TIME_WAIT || uip_connr->tcpstateflags == UIP_FIN_WAIT_2) { ++(uip_connr->timer); if(uip_connr->timer == UIP_TIME_WAIT_TIMEOUT) { uip_connr->tcpstateflags = UIP_CLOSED; } } else if(uip_connr->tcpstateflags != UIP_CLOSED) { /* * If the connection has outstanding data, we increase the * connection's timer and see if it has reached the RTO value * in which case we retransmit. */ if(uip_outstanding(uip_connr)) { if(uip_connr->timer-- == 0) { if(uip_connr->nrtx == UIP_MAXRTX || ((uip_connr->tcpstateflags == UIP_SYN_SENT || uip_connr->tcpstateflags == UIP_SYN_RCVD) && uip_connr->nrtx == UIP_MAXSYNRTX)) { uip_connr->tcpstateflags = UIP_CLOSED; /* * We call UIP_APPCALL() with uip_flags set to * UIP_TIMEDOUT to inform the application that the * connection has timed out. */ uip_flags = UIP_TIMEDOUT; UIP_APPCALL(); /* We also send a reset packet to the remote host. */ UIP_TCP_BUF->flags = TCP_RST | TCP_ACK; goto tcp_send_nodata; } /* Exponential backoff. */ uip_connr->timer = UIP_RTO << (uip_connr->nrtx > 4? 4: uip_connr->nrtx); ++(uip_connr->nrtx); /* * Ok, so we need to retransmit. We do this differently * depending on which state we are in. In ESTABLISHED, we * call upon the application so that it may prepare the * data for the retransmit. In SYN_RCVD, we resend the * SYNACK that we sent earlier and in LAST_ACK we have to * retransmit our FINACK. */ UIP_STAT(++uip_stat.tcp.rexmit); switch(uip_connr->tcpstateflags & UIP_TS_MASK) { case UIP_SYN_RCVD: /* In the SYN_RCVD state, we should retransmit our SYNACK. */ goto tcp_send_synack; #if UIP_ACTIVE_OPEN case UIP_SYN_SENT: /* In the SYN_SENT state, we retransmit out SYN. */ UIP_TCP_BUF->flags = 0; goto tcp_send_syn; #endif /* UIP_ACTIVE_OPEN */ case UIP_ESTABLISHED: /* * In the ESTABLISHED state, we call upon the application * to do the actual retransmit after which we jump into * the code for sending out the packet (the apprexmit * label). */ uip_flags = UIP_REXMIT; UIP_APPCALL(); goto apprexmit; case UIP_FIN_WAIT_1: case UIP_CLOSING: case UIP_LAST_ACK: /* In all these states we should retransmit a FINACK. */ goto tcp_send_finack; } } } else if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED) { /* * If there was no need for a retransmission, we poll the * application for new data. */ uip_flags = UIP_POLL; UIP_APPCALL(); goto appsend; } } goto drop; #endif /* UIP_TCP */ } #if UIP_UDP if(flag == UIP_UDP_TIMER) { if(uip_udp_conn->lport != 0) { uip_conn = NULL; uip_sappdata = uip_appdata = &uip_buf[UIP_IPUDPH_LEN]; uip_len = uip_slen = 0; uip_flags = UIP_POLL; UIP_UDP_APPCALL(); goto udp_send; } else { goto drop; } } #endif /* UIP_UDP */ /* This is where the input processing starts. */ UIP_STAT(++uip_stat.ip.recv); /* Start of IP input header processing code. */ /* First check that we have received a full IPv6 header. */ if(uip_len < UIP_IPH_LEN) { UIP_STAT(++uip_stat.ip.drop); LOG_WARN("incomplete IPv6 header received (%d bytes)\n", (int)uip_len); goto drop; } /* Check validity of the IP header. */ if((UIP_IP_BUF->vtc & 0xf0) != 0x60) { /* IP version and header length. */ UIP_STAT(++uip_stat.ip.drop); UIP_STAT(++uip_stat.ip.vhlerr); LOG_ERR("invalid version\n"); goto drop; } /* * Check the size of the packet. If the size reported to us in * uip_len is smaller the size reported in the IP header, we assume * that the packet has been corrupted in transit. * * If the size of uip_len is larger than the size reported in the IP * packet header, the packet has been padded, and we set uip_len to * the correct value. */ if(uip_len < uipbuf_get_len_field(UIP_IP_BUF)) { UIP_STAT(++uip_stat.ip.drop); LOG_ERR("packet shorter than reported in IP header\n"); goto drop; } /* * The length reported in the IPv6 header is the length of the * payload that follows the header. However, uIP uses the uip_len * variable for holding the size of the entire packet, including the * IP header. For IPv4 this is not a problem as the length field in * the IPv4 header contains the length of the entire packet. But for * IPv6 we need to add the size of the IPv6 header (40 bytes). */ uip_len = uipbuf_get_len_field(UIP_IP_BUF) + UIP_IPH_LEN; /* Check that the packet length is acceptable given our IP buffer size. */ if(uip_len > sizeof(uip_buf)) { UIP_STAT(++uip_stat.ip.drop); LOG_WARN("dropping packet with length %d > %d\n", (int)uip_len, (int)sizeof(uip_buf)); goto drop; } /* Check sanity of extension headers, and compute the total extension header * length (uip_ext_len) as well as the final protocol (uip_last_proto) */ uip_last_proto = 0; last_header = uipbuf_get_last_header(uip_buf, uip_len, &uip_last_proto); if(last_header == NULL) { LOG_ERR("invalid extension header chain\n"); goto drop; } /* Set uip_ext_len */ uip_ext_len = last_header - UIP_IP_PAYLOAD(0); LOG_INFO("packet received from "); LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr); LOG_INFO_(" to "); LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr); LOG_INFO_("\n"); if(uip_is_addr_mcast(&UIP_IP_BUF->srcipaddr)){ UIP_STAT(++uip_stat.ip.drop); LOG_ERR("Dropping packet, src is mcast\n"); goto drop; } /* Refresh neighbor state after receiving a unicast message */ #if UIP_ND6_SEND_NS if(!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) { uip_ds6_nbr_refresh_reachable_state(&UIP_IP_BUF->srcipaddr); } #endif /* UIP_ND6_SEND_NS */ #if UIP_CONF_ROUTER /* * If present, the Hop-by-Hop Option must be processed before forwarding * the packet. */ next_header = uipbuf_get_next_header(uip_buf, uip_len, &protocol, true); if(next_header != NULL && protocol == UIP_PROTO_HBHO) { switch(ext_hdr_options_process(next_header)) { case 0: break; /* done */ case 1: goto drop; /* silently discard */ case 2: goto send; /* send icmp error message (created in ext_hdr_options_process) and discard */ } } /* * Process Packets with a routable multicast destination: * - We invoke the multicast engine and let it do its thing * (cache, forward etc). * - We never execute the datagram forwarding logic in this file here. When * the engine returns, forwarding has been handled if and as required. * - Depending on the return value, we either discard or deliver up the stack * * All multicast engines must hook in here. After this function returns, we * expect UIP_BUF to be unmodified */ #if UIP_IPV6_MULTICAST if(uip_is_addr_mcast_routable(&UIP_IP_BUF->destipaddr)) { if(UIP_MCAST6.in() == UIP_MCAST6_ACCEPT) { /* Deliver up the stack */ goto process; } else { /* Don't deliver up the stack */ goto drop; } } #endif /* UIP_IPV6_MULTICAST */ /* TBD Some Parameter problem messages */ if(!uip_ds6_is_my_addr(&UIP_IP_BUF->destipaddr) && !uip_ds6_is_my_maddr(&UIP_IP_BUF->destipaddr)) { if(!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr) && !uip_is_addr_linklocal(&UIP_IP_BUF->destipaddr) && !uip_is_addr_linklocal(&UIP_IP_BUF->srcipaddr) && !uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr) && !uip_is_addr_loopback(&UIP_IP_BUF->destipaddr)) { if(!uip_check_mtu() || !uip_update_ttl()) { /* Send ICMPv6 error, prepared by the function that just returned false */ goto send; } LOG_INFO("Forwarding packet to next hop, dest: "); LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr); LOG_INFO_("\n"); UIP_STAT(++uip_stat.ip.forwarded); goto send; } else { if((uip_is_addr_linklocal(&UIP_IP_BUF->srcipaddr)) && (!uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) && (!uip_is_addr_loopback(&UIP_IP_BUF->destipaddr)) && (!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) && (!uip_ds6_is_addr_onlink((&UIP_IP_BUF->destipaddr)))) { LOG_ERR("LL source address with off link destination, dropping\n"); uip_icmp6_error_output(ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOTNEIGHBOR, 0); goto send; } LOG_ERR("Dropping packet, not for me and link local or multicast\n"); UIP_STAT(++uip_stat.ip.drop); goto drop; } } #else /* UIP_CONF_ROUTER */ if(!uip_ds6_is_my_addr(&UIP_IP_BUF->destipaddr) && !uip_ds6_is_my_maddr(&UIP_IP_BUF->destipaddr) && !uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) { LOG_ERR("Dropping packet, not for me\n"); UIP_STAT(++uip_stat.ip.drop); goto drop; } #endif /* UIP_CONF_ROUTER */ #if UIP_IPV6_MULTICAST && UIP_CONF_ROUTER process: #endif /* UIP_IPV6_MULTICAST && UIP_CONF_ROUTER */ /* IPv6 extension header processing: loop until reaching upper-layer protocol */ uip_ext_bitmap = 0; for(next_header = uipbuf_get_next_header(uip_buf, uip_len, &protocol, true); next_header != NULL && uip_is_proto_ext_hdr(protocol); next_header = uipbuf_get_next_header(next_header, uip_len - (next_header - uip_buf), &protocol, false)) { ext_ptr = (struct uip_ext_hdr *)next_header; switch(protocol) { case UIP_PROTO_HBHO: LOG_DBG("Processing hbh header\n"); /* Hop by hop option header */ #if UIP_CONF_IPV6_CHECKS /* Hop by hop option header. If we saw one HBH already, drop */ if(uip_ext_bitmap & UIP_EXT_HDR_BITMAP_HBHO) { goto bad_hdr; } else { uip_ext_bitmap |= UIP_EXT_HDR_BITMAP_HBHO; } #endif /*UIP_CONF_IPV6_CHECKS*/ switch(ext_hdr_options_process(next_header)) { case 0: break; /* done */ case 1: goto drop; /* silently discard */ case 2: goto send; /* send icmp error message (created in ext_hdr_options_process) and discard */ } break; case UIP_PROTO_DESTO: #if UIP_CONF_IPV6_CHECKS /* Destination option header. if we saw two already, drop */ LOG_DBG("Processing desto header\n"); if(uip_ext_bitmap & UIP_EXT_HDR_BITMAP_DESTO1) { if(uip_ext_bitmap & UIP_EXT_HDR_BITMAP_DESTO2) { goto bad_hdr; } else{ uip_ext_bitmap |= UIP_EXT_HDR_BITMAP_DESTO2; } } else { uip_ext_bitmap |= UIP_EXT_HDR_BITMAP_DESTO1; } #endif /*UIP_CONF_IPV6_CHECKS*/ switch(ext_hdr_options_process(next_header)) { case 0: break; /* done */ case 1: goto drop; /* silently discard */ case 2: goto send; /* send icmp error message (created in ext_hdr_options_process) and discard */ } break; case UIP_PROTO_ROUTING: #if UIP_CONF_IPV6_CHECKS /* Routing header. If we saw one already, drop */ if(uip_ext_bitmap & UIP_EXT_HDR_BITMAP_ROUTING) { goto bad_hdr; } else { uip_ext_bitmap |= UIP_EXT_HDR_BITMAP_ROUTING; } #endif /*UIP_CONF_IPV6_CHECKS*/ /* * Routing Header length field is in units of 8 bytes, excluding * As per RFC2460 section 4.4, if routing type is unrecognized: * if segments left = 0, ignore the header * if segments left > 0, discard packet and send icmp error pointing * to the routing type */ LOG_DBG("Processing Routing header\n"); if(((struct uip_routing_hdr *)ext_ptr)->seg_left > 0) { /* Process source routing header */ if(NETSTACK_ROUTING.ext_header_srh_update()) { /* The MTU and TTL were not checked and updated yet, because with * a routing header, the IPv6 destination address was set to us * even though we act only as forwarder. Check MTU and TTL now */ if(!uip_check_mtu() || !uip_update_ttl()) { /* Send ICMPv6 error, prepared by the function that just returned false */ goto send; } LOG_INFO("Forwarding packet to next hop, dest: "); LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr); LOG_INFO_("\n"); UIP_STAT(++uip_stat.ip.forwarded); goto send; /* Proceed to forwarding */ } else { LOG_ERR("Unrecognized routing type\n"); goto bad_hdr; } } break; case UIP_PROTO_FRAG: /* Fragmentation header:call the reassembly function, then leave */ #if UIP_CONF_IPV6_REASSEMBLY LOG_INFO("Processing fragmentation header\n"); uip_len = uip_reass(&ext_ptr->next); if(uip_len == 0) { goto drop; } if(uip_reassflags & UIP_REASS_FLAG_ERROR_MSG) { /* we are not done with reassembly, this is an error message */ goto send; } /* packet is reassembled. Restart the parsing of the reassembled pkt */ LOG_INFO("Processing reassembled packet\n"); uip_ext_bitmap = 0; next_header = uipbuf_get_next_header(uip_buf, uip_len, &protocol, true); break; #else /* UIP_CONF_IPV6_REASSEMBLY */ UIP_STAT(++uip_stat.ip.drop); UIP_STAT(++uip_stat.ip.fragerr); LOG_ERR("fragment dropped."); goto drop; #endif /* UIP_CONF_IPV6_REASSEMBLY */ case UIP_PROTO_NONE: goto drop; default: goto bad_hdr; } } /* Process upper-layer input */ if(next_header != NULL) { switch(protocol) { #if UIP_TCP case UIP_PROTO_TCP: /* TCP, for both IPv4 and IPv6 */ goto tcp_input; #endif #if UIP_UDP case UIP_PROTO_UDP: /* UDP, for both IPv4 and IPv6 */ goto udp_input; #endif case UIP_PROTO_ICMP6: /* ICMPv6 */ goto icmp6_input; } } bad_hdr: /* * RFC 2460 send error message parameterr problem, code unrecognized * next header, pointing to the next header field */ uip_icmp6_error_output(ICMP6_PARAM_PROB, ICMP6_PARAMPROB_NEXTHEADER, (uint32_t)(next_header - uip_buf)); UIP_STAT(++uip_stat.ip.drop); UIP_STAT(++uip_stat.ip.protoerr); LOG_ERR("unrecognized header\n"); goto send; /* End of headers processing */ icmp6_input: /* This is IPv6 ICMPv6 processing code. */ LOG_INFO("icmpv6 input length %d type: %d \n", uip_len, UIP_ICMP_BUF->type); #if UIP_CONF_IPV6_CHECKS /* Compute and check the ICMP header checksum */ if(uip_icmp6chksum() != 0xffff) { UIP_STAT(++uip_stat.icmp.drop); UIP_STAT(++uip_stat.icmp.chkerr); LOG_ERR("icmpv6 bad checksum\n"); goto drop; } #endif /*UIP_CONF_IPV6_CHECKS*/ UIP_STAT(++uip_stat.icmp.recv); /* * Here we process incoming ICMPv6 packets * For echo request, we send echo reply * For ND pkts, we call the appropriate function in uip-nd6.c * We do not treat Error messages for now * If no pkt is to be sent as an answer to the incoming one, we * "goto drop". Else we just break; then at the after the "switch" * we "goto send" */ #if UIP_CONF_ICMP6 UIP_ICMP6_APPCALL(UIP_ICMP_BUF->type); #endif /*UIP_CONF_ICMP6*/ /* * Search generic input handlers. * The handler is in charge of setting uip_len to 0 */ if(uip_icmp6_input(UIP_ICMP_BUF->type, UIP_ICMP_BUF->icode) == UIP_ICMP6_INPUT_ERROR) { LOG_ERR("Unknown ICMPv6 message type/code %d\n", UIP_ICMP_BUF->type); UIP_STAT(++uip_stat.icmp.drop); UIP_STAT(++uip_stat.icmp.typeerr); uipbuf_clear(); } if(uip_len > 0) { goto send; } else { goto drop; } /* End of IPv6 ICMP processing. */ #if UIP_UDP /* UDP input processing. */ udp_input: uip_remove_ext_hdr(); LOG_INFO("Receiving UDP packet\n"); /* UDP processing is really just a hack. We don't do anything to the UDP/IP headers, but let the UDP application do all the hard work. If the application sets uip_slen, it has a packet to send. */ #if UIP_UDP_CHECKSUMS /* XXX hack: UDP/IPv6 receivers should drop packets with UDP checksum 0. Here, we explicitly receive UDP packets with checksum 0. This is to be able to debug code that for one reason or another miscomputes UDP checksums. The reception of zero UDP checksums should be turned into a configration option. */ if(UIP_UDP_BUF->udpchksum != 0 && uip_udpchksum() != 0xffff) { UIP_STAT(++uip_stat.udp.drop); UIP_STAT(++uip_stat.udp.chkerr); LOG_ERR("udp: bad checksum 0x%04x 0x%04x\n", UIP_UDP_BUF->udpchksum, uip_udpchksum()); goto drop; } #endif /* UIP_UDP_CHECKSUMS */ /* Make sure that the UDP destination port number is not zero. */ if(UIP_UDP_BUF->destport == 0) { LOG_ERR("udp: zero port.\n"); goto drop; } /* Demultiplex this UDP packet between the UDP "connections". */ for(uip_udp_conn = &uip_udp_conns[0]; uip_udp_conn < &uip_udp_conns[UIP_UDP_CONNS]; ++uip_udp_conn) { /* If the local UDP port is non-zero, the connection is considered to be used. If so, the local port number is checked against the destination port number in the received packet. If the two port numbers match, the remote port number is checked if the connection is bound to a remote port. Finally, if the connection is bound to a remote IP address, the source IP address of the packet is checked. */ if(uip_udp_conn->lport != 0 && UIP_UDP_BUF->destport == uip_udp_conn->lport && (uip_udp_conn->rport == 0 || UIP_UDP_BUF->srcport == uip_udp_conn->rport) && (uip_is_addr_unspecified(&uip_udp_conn->ripaddr) || uip_ipaddr_cmp(&UIP_IP_BUF->srcipaddr, &uip_udp_conn->ripaddr))) { goto udp_found; } } LOG_ERR("udp: no matching connection found\n"); UIP_STAT(++uip_stat.udp.drop); uip_icmp6_error_output(ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0); goto send; udp_found: LOG_DBG("In udp_found\n"); UIP_STAT(++uip_stat.udp.recv); uip_len = uip_len - UIP_IPUDPH_LEN; uip_appdata = &uip_buf[UIP_IPUDPH_LEN]; uip_conn = NULL; uip_flags = UIP_NEWDATA; uip_sappdata = uip_appdata = &uip_buf[UIP_IPUDPH_LEN]; uip_slen = 0; UIP_UDP_APPCALL(); udp_send: LOG_DBG("In udp_send\n"); if(uip_slen == 0) { goto drop; } uip_len = uip_slen + UIP_IPUDPH_LEN; /* For IPv6, the IP length field does not include the IPv6 IP header length. */ uipbuf_set_len_field(UIP_IP_BUF, uip_len - UIP_IPH_LEN); UIP_IP_BUF->vtc = 0x60; UIP_IP_BUF->tcflow = 0x00; UIP_IP_BUF->ttl = uip_udp_conn->ttl; UIP_IP_BUF->proto = UIP_PROTO_UDP; UIP_UDP_BUF->udplen = UIP_HTONS(uip_slen + UIP_UDPH_LEN); UIP_UDP_BUF->udpchksum = 0; UIP_UDP_BUF->srcport = uip_udp_conn->lport; UIP_UDP_BUF->destport = uip_udp_conn->rport; uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &uip_udp_conn->ripaddr); uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr); uip_appdata = &uip_buf[UIP_IPTCPH_LEN]; #if UIP_UDP_CHECKSUMS /* Calculate UDP checksum. */ UIP_UDP_BUF->udpchksum = ~(uip_udpchksum()); if(UIP_UDP_BUF->udpchksum == 0) { UIP_UDP_BUF->udpchksum = 0xffff; } #endif /* UIP_UDP_CHECKSUMS */ UIP_STAT(++uip_stat.udp.sent); goto ip_send_nolen; #endif /* UIP_UDP */ #if UIP_TCP /* TCP input processing. */ tcp_input: uip_remove_ext_hdr(); UIP_STAT(++uip_stat.tcp.recv); LOG_INFO("Receiving TCP packet\n"); /* Start of TCP input header processing code. */ if(uip_tcpchksum() != 0xffff) { /* Compute and check the TCP checksum. */ UIP_STAT(++uip_stat.tcp.drop); UIP_STAT(++uip_stat.tcp.chkerr); LOG_ERR("tcp: bad checksum 0x%04x 0x%04x\n", UIP_TCP_BUF->tcpchksum, uip_tcpchksum()); goto drop; } /* Make sure that the TCP port number is not zero. */ if(UIP_TCP_BUF->destport == 0 || UIP_TCP_BUF->srcport == 0) { LOG_ERR("tcp: zero port\n"); goto drop; } /* Demultiplex this segment. */ /* First check any active connections. */ for(uip_connr = &uip_conns[0]; uip_connr <= &uip_conns[UIP_TCP_CONNS - 1]; ++uip_connr) { if(uip_connr->tcpstateflags != UIP_CLOSED && UIP_TCP_BUF->destport == uip_connr->lport && UIP_TCP_BUF->srcport == uip_connr->rport && uip_ipaddr_cmp(&UIP_IP_BUF->srcipaddr, &uip_connr->ripaddr)) { goto found; } } /* If we didn't find and active connection that expected the packet, either this packet is an old duplicate, or this is a SYN packet destined for a connection in LISTEN. If the SYN flag isn't set, it is an old packet and we send a RST. */ if((UIP_TCP_BUF->flags & TCP_CTL) != TCP_SYN) { goto reset; } uint16_t tmp16 = UIP_TCP_BUF->destport; /* Next, check listening connections. */ for(c = 0; c < UIP_LISTENPORTS; ++c) { if(tmp16 == uip_listenports[c]) { goto found_listen; } } /* No matching connection found, so we send a RST packet. */ UIP_STAT(++uip_stat.tcp.synrst); reset: LOG_WARN("In reset\n"); /* We do not send resets in response to resets. */ if(UIP_TCP_BUF->flags & TCP_RST) { goto drop; } UIP_STAT(++uip_stat.tcp.rst); UIP_TCP_BUF->flags = TCP_RST | TCP_ACK; uip_len = UIP_IPTCPH_LEN; UIP_TCP_BUF->tcpoffset = 5 << 4; /* Flip the seqno and ackno fields in the TCP header. */ c = UIP_TCP_BUF->seqno[3]; UIP_TCP_BUF->seqno[3] = UIP_TCP_BUF->ackno[3]; UIP_TCP_BUF->ackno[3] = c; c = UIP_TCP_BUF->seqno[2]; UIP_TCP_BUF->seqno[2] = UIP_TCP_BUF->ackno[2]; UIP_TCP_BUF->ackno[2] = c; c = UIP_TCP_BUF->seqno[1]; UIP_TCP_BUF->seqno[1] = UIP_TCP_BUF->ackno[1]; UIP_TCP_BUF->ackno[1] = c; c = UIP_TCP_BUF->seqno[0]; UIP_TCP_BUF->seqno[0] = UIP_TCP_BUF->ackno[0]; UIP_TCP_BUF->ackno[0] = c; /* We also have to increase the sequence number we are acknowledging. If the least significant byte overflowed, we need to propagate the carry to the other bytes as well. */ if(++UIP_TCP_BUF->ackno[3] == 0) { if(++UIP_TCP_BUF->ackno[2] == 0) { if(++UIP_TCP_BUF->ackno[1] == 0) { ++UIP_TCP_BUF->ackno[0]; } } } /* Swap port numbers. */ tmp16 = UIP_TCP_BUF->srcport; UIP_TCP_BUF->srcport = UIP_TCP_BUF->destport; UIP_TCP_BUF->destport = tmp16; /* Swap IP addresses. */ uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &UIP_IP_BUF->srcipaddr); uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr); /* And send out the RST packet! */ goto tcp_send_noconn; /* This label will be jumped to if we matched the incoming packet with a connection in LISTEN. In that case, we should create a new connection and send a SYNACK in return. */ found_listen: LOG_DBG("In found listen\n"); /* First we check if there are any connections avaliable. Unused connections are kept in the same table as used connections, but unused ones have the tcpstate set to CLOSED. Also, connections in TIME_WAIT are kept track of and we'll use the oldest one if no CLOSED connections are found. Thanks to Eddie C. Dost for a very nice algorithm for the TIME_WAIT search. */ uip_connr = 0; for(c = 0; c < UIP_TCP_CONNS; ++c) { if(uip_conns[c].tcpstateflags == UIP_CLOSED) { uip_connr = &uip_conns[c]; break; } if(uip_conns[c].tcpstateflags == UIP_TIME_WAIT) { if(uip_connr == 0 || uip_conns[c].timer > uip_connr->timer) { uip_connr = &uip_conns[c]; } } } if(uip_connr == 0) { /* All connections are used already, we drop packet and hope that the remote end will retransmit the packet at a time when we have more spare connections. */ UIP_STAT(++uip_stat.tcp.syndrop); LOG_ERR("tcp: found no unused connections\n"); goto drop; } uip_conn = uip_connr; /* Fill in the necessary fields for the new connection. */ uip_connr->rto = uip_connr->timer = UIP_RTO; uip_connr->sa = 0; uip_connr->sv = 4; uip_connr->nrtx = 0; uip_connr->lport = UIP_TCP_BUF->destport; uip_connr->rport = UIP_TCP_BUF->srcport; uip_ipaddr_copy(&uip_connr->ripaddr, &UIP_IP_BUF->srcipaddr); uip_connr->tcpstateflags = UIP_SYN_RCVD; uip_connr->snd_nxt[0] = iss[0]; uip_connr->snd_nxt[1] = iss[1]; uip_connr->snd_nxt[2] = iss[2]; uip_connr->snd_nxt[3] = iss[3]; uip_connr->len = 1; /* rcv_nxt should be the seqno from the incoming packet + 1. */ uip_connr->rcv_nxt[0] = UIP_TCP_BUF->seqno[0]; uip_connr->rcv_nxt[1] = UIP_TCP_BUF->seqno[1]; uip_connr->rcv_nxt[2] = UIP_TCP_BUF->seqno[2]; uip_connr->rcv_nxt[3] = UIP_TCP_BUF->seqno[3]; uip_add_rcv_nxt(1); process_tcp_options(uip_connr); /* Our response will be a SYNACK. */ #if UIP_ACTIVE_OPEN tcp_send_synack: UIP_TCP_BUF->flags = TCP_ACK; tcp_send_syn: UIP_TCP_BUF->flags |= TCP_SYN; #else /* UIP_ACTIVE_OPEN */ tcp_send_synack: UIP_TCP_BUF->flags = TCP_SYN | TCP_ACK; #endif /* UIP_ACTIVE_OPEN */ /* We send out the TCP Maximum Segment Size option with our SYNACK. */ UIP_TCP_BUF->optdata[0] = TCP_OPT_MSS; UIP_TCP_BUF->optdata[1] = TCP_OPT_MSS_LEN; UIP_TCP_BUF->optdata[2] = (UIP_TCP_MSS) / 256; UIP_TCP_BUF->optdata[3] = (UIP_TCP_MSS) & 255; uip_len = UIP_IPTCPH_LEN + TCP_OPT_MSS_LEN; UIP_TCP_BUF->tcpoffset = ((UIP_TCPH_LEN + TCP_OPT_MSS_LEN) / 4) << 4; goto tcp_send; /* This label will be jumped to if we found an active connection. */ found: LOG_DBG("In found\n"); uip_conn = uip_connr; uip_flags = 0; /* We do a very naive form of TCP reset processing; we just accept any RST and kill our connection. We should in fact check if the sequence number of this reset is wihtin our advertised window before we accept the reset. */ if(UIP_TCP_BUF->flags & TCP_RST) { uip_connr->tcpstateflags = UIP_CLOSED; LOG_WARN("tcp: got reset, aborting connection."); uip_flags = UIP_ABORT; UIP_APPCALL(); goto drop; } /* Calculate the length of the data, if the application has sent any data to us. */ c = (UIP_TCP_BUF->tcpoffset >> 4) << 2; /* Check that the indicated length of the TCP header is not too large for the total packet length. */ if(uip_len < c + UIP_IPH_LEN) { LOG_WARN("Dropping TCP packet with too large data offset (%u bytes)\n", (unsigned)c); goto drop; } /* uip_len will contain the length of the actual TCP data. This is calculated by subtracing the length of the TCP header (in c) and the length of the IP header (20 bytes). */ uip_len = uip_len - c - UIP_IPH_LEN; /* First, check if the sequence number of the incoming packet is what we're expecting next. If not, we send out an ACK with the correct numbers in, unless we are in the SYN_RCVD state and receive a SYN, in which case we should retransmit our SYNACK (which is done futher down). */ if(!((((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) && ((UIP_TCP_BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK))) || (((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_RCVD) && ((UIP_TCP_BUF->flags & TCP_CTL) == TCP_SYN)))) { if((uip_len > 0 || ((UIP_TCP_BUF->flags & (TCP_SYN | TCP_FIN)) != 0)) && (UIP_TCP_BUF->seqno[0] != uip_connr->rcv_nxt[0] || UIP_TCP_BUF->seqno[1] != uip_connr->rcv_nxt[1] || UIP_TCP_BUF->seqno[2] != uip_connr->rcv_nxt[2] || UIP_TCP_BUF->seqno[3] != uip_connr->rcv_nxt[3])) { if((UIP_TCP_BUF->flags & TCP_SYN)) { if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_RCVD) { goto tcp_send_synack; #if UIP_ACTIVE_OPEN } else if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) { goto tcp_send_syn; #endif } } goto tcp_send_ack; } } /* Next, check if the incoming segment acknowledges any outstanding data. If so, we update the sequence number, reset the length of the outstanding data, calculate RTT estimations, and reset the retransmission timer. */ if((UIP_TCP_BUF->flags & TCP_ACK) && uip_outstanding(uip_connr)) { uip_add32(uip_connr->snd_nxt, uip_connr->len); if(UIP_TCP_BUF->ackno[0] == uip_acc32[0] && UIP_TCP_BUF->ackno[1] == uip_acc32[1] && UIP_TCP_BUF->ackno[2] == uip_acc32[2] && UIP_TCP_BUF->ackno[3] == uip_acc32[3]) { /* Update sequence number. */ uip_connr->snd_nxt[0] = uip_acc32[0]; uip_connr->snd_nxt[1] = uip_acc32[1]; uip_connr->snd_nxt[2] = uip_acc32[2]; uip_connr->snd_nxt[3] = uip_acc32[3]; /* Do RTT estimation, unless we have done retransmissions. */ if(uip_connr->nrtx == 0) { signed char m; m = uip_connr->rto - uip_connr->timer; /* This is taken directly from VJs original code in his paper */ m = m - (uip_connr->sa >> 3); uip_connr->sa += m; if(m < 0) { m = -m; } m = m - (uip_connr->sv >> 2); uip_connr->sv += m; uip_connr->rto = (uip_connr->sa >> 3) + uip_connr->sv; } /* Set the acknowledged flag. */ uip_flags = UIP_ACKDATA; /* Reset the retransmission timer. */ uip_connr->timer = uip_connr->rto; /* Reset length of outstanding data. */ uip_connr->len = 0; } } /* Do different things depending on in what state the connection is. */ switch(uip_connr->tcpstateflags & UIP_TS_MASK) { /* CLOSED and LISTEN are not handled here. CLOSE_WAIT is not implemented, since we force the application to close when the peer sends a FIN (hence the application goes directly from ESTABLISHED to LAST_ACK). */ case UIP_SYN_RCVD: /* In SYN_RCVD we have sent out a SYNACK in response to a SYN, and we are waiting for an ACK that acknowledges the data we sent out the last time. Therefore, we want to have the UIP_ACKDATA flag set. If so, we enter the ESTABLISHED state. */ if(uip_flags & UIP_ACKDATA) { uip_connr->tcpstateflags = UIP_ESTABLISHED; uip_flags = UIP_CONNECTED; uip_connr->len = 0; if(uip_len > 0) { uip_flags |= UIP_NEWDATA; uip_add_rcv_nxt(uip_len); } uip_slen = 0; UIP_APPCALL(); goto appsend; } /* We need to retransmit the SYNACK */ if((UIP_TCP_BUF->flags & TCP_CTL) == TCP_SYN) { goto tcp_send_synack; } goto drop; #if UIP_ACTIVE_OPEN case UIP_SYN_SENT: /* In SYN_SENT, we wait for a SYNACK that is sent in response to our SYN. The rcv_nxt is set to sequence number in the SYNACK plus one, and we send an ACK. We move into the ESTABLISHED state. */ if((uip_flags & UIP_ACKDATA) && (UIP_TCP_BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK)) { process_tcp_options(uip_connr); uip_connr->tcpstateflags = UIP_ESTABLISHED; uip_connr->rcv_nxt[0] = UIP_TCP_BUF->seqno[0]; uip_connr->rcv_nxt[1] = UIP_TCP_BUF->seqno[1]; uip_connr->rcv_nxt[2] = UIP_TCP_BUF->seqno[2]; uip_connr->rcv_nxt[3] = UIP_TCP_BUF->seqno[3]; uip_add_rcv_nxt(1); uip_flags = UIP_CONNECTED | UIP_NEWDATA; uip_connr->len = 0; uipbuf_clear(); uip_slen = 0; UIP_APPCALL(); goto appsend; } /* Inform the application that the connection failed */ uip_flags = UIP_ABORT; UIP_APPCALL(); /* The connection is closed after we send the RST */ uip_conn->tcpstateflags = UIP_CLOSED; goto reset; #endif /* UIP_ACTIVE_OPEN */ case UIP_ESTABLISHED: /* In the ESTABLISHED state, we call upon the application to feed data into the uip_buf. If the UIP_ACKDATA flag is set, the application should put new data into the buffer, otherwise we are retransmitting an old segment, and the application should put that data into the buffer. If the incoming packet is a FIN, we should close the connection on this side as well, and we send out a FIN and enter the LAST_ACK state. We require that there is no outstanding data; otherwise the sequence numbers will be screwed up. */ if(UIP_TCP_BUF->flags & TCP_FIN && !(uip_connr->tcpstateflags & UIP_STOPPED)) { if(uip_outstanding(uip_connr)) { goto drop; } uip_add_rcv_nxt(1 + uip_len); uip_flags |= UIP_CLOSE; if(uip_len > 0) { uip_flags |= UIP_NEWDATA; } UIP_APPCALL(); uip_connr->len = 1; uip_connr->tcpstateflags = UIP_LAST_ACK; uip_connr->nrtx = 0; tcp_send_finack: UIP_TCP_BUF->flags = TCP_FIN | TCP_ACK; goto tcp_send_nodata; } /* Check the URG flag. If this is set, the segment carries urgent data that we must pass to the application. */ if((UIP_TCP_BUF->flags & TCP_URG) != 0) { tmp16 = (UIP_TCP_BUF->urgp[0] << 8) | UIP_TCP_BUF->urgp[1]; if(tmp16 > uip_len) { /* There is more urgent data in the next segment to come. Cap the urgent data length at the segment length for further processing. */ tmp16 = uip_len; } #if UIP_URGDATA > 0 uip_urglen = tmp16; uip_add_rcv_nxt(uip_urglen); uip_len -= uip_urglen; uip_urgdata = uip_appdata; uip_appdata += uip_urglen; } else { uip_urglen = 0; #else /* UIP_URGDATA > 0 */ /* Ignore and discard any urgent data in this segment. */ uip_appdata = ((char *)uip_appdata) + tmp16; uip_len -= tmp16; #endif /* UIP_URGDATA > 0 */ } /* If uip_len > 0 we have TCP data in the packet, and we flag this by setting the UIP_NEWDATA flag and update the sequence number we acknowledge. If the application has stopped the dataflow using uip_stop(), we must not accept any data packets from the remote host. */ if(uip_len > 0 && !(uip_connr->tcpstateflags & UIP_STOPPED)) { uip_flags |= UIP_NEWDATA; uip_add_rcv_nxt(uip_len); } /* Check if the available buffer space advertised by the other end is smaller than the initial MSS for this connection. If so, we set the current MSS to the window size to ensure that the application does not send more data than the other end can handle. If the remote host advertises a zero window, we set the MSS to the initial MSS so that the application will send an entire MSS of data. This data will not be acknowledged by the receiver, and the application will retransmit it. This is called the "persistent timer" and uses the retransmission mechanim. */ tmp16 = ((uint16_t)UIP_TCP_BUF->wnd[0] << 8) + (uint16_t)UIP_TCP_BUF->wnd[1]; if(tmp16 > uip_connr->initialmss || tmp16 == 0) { tmp16 = uip_connr->initialmss; } uip_connr->mss = tmp16; /* If this packet constitutes an ACK for outstanding data (flagged by the UIP_ACKDATA flag, we should call the application since it might want to send more data. If the incoming packet had data from the peer (as flagged by the UIP_NEWDATA flag), the application must also be notified. When the application is called, the global variable uip_len contains the length of the incoming data. The application can access the incoming data through the global pointer uip_appdata, which usually points UIP_IPTCPH_LEN bytes into the uip_buf array. If the application wishes to send any data, this data should be put into the uip_appdata and the length of the data should be put into uip_len. If the application don't have any data to send, uip_len must be set to 0. */ if(uip_flags & (UIP_NEWDATA | UIP_ACKDATA)) { uip_slen = 0; UIP_APPCALL(); appsend: if(uip_flags & UIP_ABORT) { uip_slen = 0; uip_connr->tcpstateflags = UIP_CLOSED; UIP_TCP_BUF->flags = TCP_RST | TCP_ACK; goto tcp_send_nodata; } if(uip_flags & UIP_CLOSE) { uip_slen = 0; uip_connr->len = 1; uip_connr->tcpstateflags = UIP_FIN_WAIT_1; uip_connr->nrtx = 0; UIP_TCP_BUF->flags = TCP_FIN | TCP_ACK; goto tcp_send_nodata; } /* If uip_slen > 0, the application has data to be sent. */ if(uip_slen > 0) { /* If the connection has acknowledged data, the contents of the ->len variable should be discarded. */ if((uip_flags & UIP_ACKDATA) != 0) { uip_connr->len = 0; } /* If the ->len variable is non-zero the connection has already data in transit and cannot send anymore right now. */ if(uip_connr->len == 0) { /* The application cannot send more than what is allowed by the mss (the minumum of the MSS and the available window). */ if(uip_slen > uip_connr->mss) { uip_slen = uip_connr->mss; } /* Remember how much data we send out now so that we know when everything has been acknowledged. */ uip_connr->len = uip_slen; } else { /* If the application already had unacknowledged data, we make sure that the application does not send (i.e., retransmit) out more than it previously sent out. */ uip_slen = uip_connr->len; } } uip_connr->nrtx = 0; apprexmit: uip_appdata = uip_sappdata; /* If the application has data to be sent, or if the incoming packet had new data in it, we must send out a packet. */ if(uip_slen > 0 && uip_connr->len > 0) { /* Add the length of the IP and TCP headers. */ uip_len = uip_connr->len + UIP_IPTCPH_LEN; /* We always set the ACK flag in response packets. */ UIP_TCP_BUF->flags = TCP_ACK | TCP_PSH; /* Send the packet. */ goto tcp_send_noopts; } /* If there is no data to send, just send out a pure ACK if there is newdata. */ if(uip_flags & UIP_NEWDATA) { uip_len = UIP_IPTCPH_LEN; UIP_TCP_BUF->flags = TCP_ACK; goto tcp_send_noopts; } } goto drop; case UIP_LAST_ACK: /* We can close this connection if the peer has acknowledged our FIN. This is indicated by the UIP_ACKDATA flag. */ if(uip_flags & UIP_ACKDATA) { uip_connr->tcpstateflags = UIP_CLOSED; uip_flags = UIP_CLOSE; UIP_APPCALL(); } break; case UIP_FIN_WAIT_1: /* The application has closed the connection, but the remote host hasn't closed its end yet. Thus we do nothing but wait for a FIN from the other side. */ if(uip_len > 0) { uip_add_rcv_nxt(uip_len); } if(UIP_TCP_BUF->flags & TCP_FIN) { if(uip_flags & UIP_ACKDATA) { uip_connr->tcpstateflags = UIP_TIME_WAIT; uip_connr->timer = 0; uip_connr->len = 0; } else { uip_connr->tcpstateflags = UIP_CLOSING; } uip_add_rcv_nxt(1); uip_flags = UIP_CLOSE; UIP_APPCALL(); goto tcp_send_ack; } else if(uip_flags & UIP_ACKDATA) { uip_connr->tcpstateflags = UIP_FIN_WAIT_2; uip_connr->len = 0; goto drop; } if(uip_len > 0) { goto tcp_send_ack; } goto drop; case UIP_FIN_WAIT_2: if(uip_len > 0) { uip_add_rcv_nxt(uip_len); } if(UIP_TCP_BUF->flags & TCP_FIN) { uip_connr->tcpstateflags = UIP_TIME_WAIT; uip_connr->timer = 0; uip_add_rcv_nxt(1); uip_flags = UIP_CLOSE; UIP_APPCALL(); goto tcp_send_ack; } if(uip_len > 0) { goto tcp_send_ack; } goto drop; case UIP_TIME_WAIT: goto tcp_send_ack; case UIP_CLOSING: if(uip_flags & UIP_ACKDATA) { uip_connr->tcpstateflags = UIP_TIME_WAIT; uip_connr->timer = 0; } } goto drop; /* We jump here when we are ready to send the packet, and just want to set the appropriate TCP sequence numbers in the TCP header. */ tcp_send_ack: UIP_TCP_BUF->flags = TCP_ACK; tcp_send_nodata: uip_len = UIP_IPTCPH_LEN; tcp_send_noopts: UIP_TCP_BUF->tcpoffset = (UIP_TCPH_LEN / 4) << 4; /* We're done with the input processing. We are now ready to send a reply. Our job is to fill in all the fields of the TCP and IP headers before calculating the checksum and finally send the packet. */ tcp_send: LOG_DBG("In tcp_send\n"); UIP_TCP_BUF->ackno[0] = uip_connr->rcv_nxt[0]; UIP_TCP_BUF->ackno[1] = uip_connr->rcv_nxt[1]; UIP_TCP_BUF->ackno[2] = uip_connr->rcv_nxt[2]; UIP_TCP_BUF->ackno[3] = uip_connr->rcv_nxt[3]; UIP_TCP_BUF->seqno[0] = uip_connr->snd_nxt[0]; UIP_TCP_BUF->seqno[1] = uip_connr->snd_nxt[1]; UIP_TCP_BUF->seqno[2] = uip_connr->snd_nxt[2]; UIP_TCP_BUF->seqno[3] = uip_connr->snd_nxt[3]; UIP_TCP_BUF->srcport = uip_connr->lport; UIP_TCP_BUF->destport = uip_connr->rport; UIP_IP_BUF->vtc = 0x60; UIP_IP_BUF->tcflow = 0x00; uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &uip_connr->ripaddr); uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr); LOG_INFO("Sending TCP packet to "); LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr); LOG_INFO_(" from "); LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr); LOG_INFO_("\n"); if(uip_connr->tcpstateflags & UIP_STOPPED) { /* If the connection has issued uip_stop(), we advertise a zero window so that the remote host will stop sending data. */ UIP_TCP_BUF->wnd[0] = UIP_TCP_BUF->wnd[1] = 0; } else { UIP_TCP_BUF->wnd[0] = ((UIP_RECEIVE_WINDOW) >> 8); UIP_TCP_BUF->wnd[1] = ((UIP_RECEIVE_WINDOW) & 0xff); } tcp_send_noconn: UIP_IP_BUF->proto = UIP_PROTO_TCP; UIP_IP_BUF->ttl = uip_ds6_if.cur_hop_limit; uipbuf_set_len_field(UIP_IP_BUF, uip_len - UIP_IPH_LEN); UIP_TCP_BUF->urgp[0] = UIP_TCP_BUF->urgp[1] = 0; /* Calculate TCP checksum. */ UIP_TCP_BUF->tcpchksum = 0; UIP_TCP_BUF->tcpchksum = ~(uip_tcpchksum()); UIP_STAT(++uip_stat.tcp.sent); #endif /* UIP_TCP */ #if UIP_UDP ip_send_nolen: #endif UIP_IP_BUF->flow = 0x00; send: LOG_INFO("Sending packet with length %d (%d)\n", uip_len, uipbuf_get_len_field(UIP_IP_BUF)); UIP_STAT(++uip_stat.ip.sent); /* Return and let the caller do the actual transmission. */ uip_flags = 0; return; drop: uipbuf_clear(); uip_ext_bitmap = 0; uip_flags = 0; return; } /*---------------------------------------------------------------------------*/ uint16_t uip_htons(uint16_t val) { return UIP_HTONS(val); } uint32_t uip_htonl(uint32_t val) { return UIP_HTONL(val); } /*---------------------------------------------------------------------------*/ void uip_send(const void *data, int len) { int copylen; if(uip_sappdata != NULL) { copylen = MIN(len, UIP_BUFSIZE - UIP_IPTCPH_LEN - (int)((char *)uip_sappdata - (char *)UIP_TCP_PAYLOAD)); } else { copylen = MIN(len, UIP_BUFSIZE - UIP_IPTCPH_LEN); } if(copylen > 0) { uip_slen = copylen; if(data != uip_sappdata) { if(uip_sappdata == NULL) { memcpy(UIP_TCP_PAYLOAD, (data), uip_slen); } else { memcpy(uip_sappdata, (data), uip_slen); } } } } /*---------------------------------------------------------------------------*/ /** @} */
f72ea4f7a9683a26fc9500c0dc0d9b0920bd5045
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
/AKWF-c/AKWF_0016/AKWF_1564.h
f68899a5971aecdae1cd80afb8f34c8c4a04c05c
[ "CC0-1.0" ]
permissive
KristofferKarlAxelEkstrand/AKWF-FREE
b2defa1a2d389d309be6dd2e9f968923daf80d1b
cf8171df36e9fec25416b5f568b72a6e2cb69194
refs/heads/master
2023-07-23T18:22:36.939705
2023-07-10T17:14:40
2023-07-10T17:14:40
145,817,187
359
59
CC0-1.0
2023-07-10T17:14:41
2018-08-23T07:26:56
null
UTF-8
C
false
false
4,672
h
AKWF_1564.h
/* Adventure Kid Waveforms (AKWF) converted for use with Teensy Audio Library * * Adventure Kid Waveforms(AKWF) Open waveforms library * https://www.adventurekid.se/akrt/waveforms/adventure-kid-waveforms/ * * This code is in the public domain, CC0 1.0 Universal (CC0 1.0) * https://creativecommons.org/publicdomain/zero/1.0/ * * Converted by Brad Roy, https://github.com/prosper00 */ /* AKWF_1564 256 samples +-----------------------------------------------------------------------------------------------------------------+ | ****** ********* * | | ***** ******* * | | **** ****** * | | *** ****** * | |** ***** * * | | ***** ** ** **| | ***** ** ** *** | | ***** *** * *** | | ***** *** * ** | | ******* * *** | | *** * ** | | ** *** *** | | * *** ** | | * *** | | ******* | +-----------------------------------------------------------------------------------------------------------------+ */ const uint16_t AKWF_1564 [] = { 33031, 33790, 34438, 35094, 35699, 36292, 36859, 37433, 37987, 38534, 39068, 39576, 40062, 40536, 40984, 41424, 41847, 42262, 42689, 43067, 43446, 43796, 44144, 44494, 44839, 45137, 45443, 45734, 46003, 46270, 46522, 46769, 46983, 47200, 47405, 47597, 47784, 47960, 48114, 48270, 48419, 48552, 48662, 48770, 48898, 48992, 49066, 49141, 49206, 49267, 49313, 49355, 49387, 49399, 49406, 49430, 49413, 49404, 49401, 49386, 49364, 49322, 49285, 49235, 49185, 49126, 49060, 48979, 48906, 48821, 48725, 48625, 48517, 48405, 48296, 48172, 48047, 47916, 47786, 47647, 47492, 47347, 47196, 47035, 46878, 46713, 46537, 46372, 46175, 46006, 45812, 45617, 45421, 45215, 45035, 44823, 44602, 44387, 44179, 43969, 43745, 43521, 43284, 43057, 42840, 42586, 42357, 42119, 41874, 41628, 41374, 41121, 40871, 40622, 40364, 40102, 39836, 39579, 39316, 39040, 38775, 38511, 38224, 37971, 37691, 37416, 37144, 36858, 36566, 36302, 35994, 35732, 35438, 35159, 34841, 34574, 34270, 33990, 33678, 33391, 33085, 32798, 32511, 32193, 31910, 31583, 31326, 30964, 30719, 30344, 30126, 29731, 29538, 29109, 28922, 28485, 28306, 27874, 27704, 27251, 27056, 26652, 26411, 26059, 25763, 25474, 25107, 24908, 24432, 24349, 23764, 23800, 23069, 23235, 22378, 22681, 21711, 22113, 21036, 21538, 20404, 20912, 19797, 20266, 19247, 19559, 18793, 18708, 18500, 17628, 18731, 15070, 36972, 18803, 7470, 19898, 25057, 34817, 32718, 28939, 18284, 12185, 7457, 9114, 10588, 12458, 10490, 7218, 2937, 488, 103, 1303, 2895, 3328, 2906, 1342, 557, 154, 1333, 2449, 4008, 4450, 4922, 4748, 5291, 5924, 7306, 8485, 9706, 10447, 11163, 11747, 12596, 13603, 14748, 15871, 16830, 17712, 18451, 19302, 20153, 21149, 22084, 23071, 23876, 24714, 25441, 26250, 27033, 27878, 28664, 29479, 30188, 30905, 31555, 32293, };
43f557100d0538b9f759bea29da629dfd6d39c23
54629ec7abd6c33a698a5ab64ae982409f7f9af7
/extras/fixture/test/unity_fixture_TestRunner.c
7b78c49c0eb15c0b3be0f7c93cda202f677afa3c
[ "MIT" ]
permissive
ThrowTheSwitch/Unity
73b404bbce03eea3d961a870be5ad168cb3c9d16
cb03c3afa777b004a809f72535648a475c84a6e1
refs/heads/master
2023-09-03T10:29:14.862864
2023-08-16T15:04:42
2023-08-16T15:04:42
3,276,860
3,386
1,072
MIT
2023-08-25T18:49:27
2012-01-26T19:52:36
C
UTF-8
C
false
false
1,479
c
unity_fixture_TestRunner.c
/* Copyright (c) 2010 James Grenning and Contributed to Unity Project * ========================================== * Unity Project - A Test Framework for C * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams * [Released under MIT License. Please refer to license.txt for details] * ========================================== */ #include "unity_fixture.h" TEST_GROUP_RUNNER(UnityFixture) { RUN_TEST_CASE(UnityFixture, PointerSetting); RUN_TEST_CASE(UnityFixture, PointerSet); RUN_TEST_CASE(UnityFixture, FreeNULLSafety); RUN_TEST_CASE(UnityFixture, ConcludeTestIncrementsFailCount); } TEST_GROUP_RUNNER(UnityCommandOptions) { RUN_TEST_CASE(UnityCommandOptions, DefaultOptions); RUN_TEST_CASE(UnityCommandOptions, OptionVerbose); RUN_TEST_CASE(UnityCommandOptions, OptionSelectTestByGroup); RUN_TEST_CASE(UnityCommandOptions, OptionSelectTestByName); RUN_TEST_CASE(UnityCommandOptions, OptionSelectRepeatTestsDefaultCount); RUN_TEST_CASE(UnityCommandOptions, OptionSelectRepeatTestsSpecificCount); RUN_TEST_CASE(UnityCommandOptions, MultipleOptions); RUN_TEST_CASE(UnityCommandOptions, MultipleOptionsDashRNotLastAndNoValueSpecified); RUN_TEST_CASE(UnityCommandOptions, UnknownCommandIsIgnored); RUN_TEST_CASE(UnityCommandOptions, GroupOrNameFilterWithoutStringFails); RUN_TEST_CASE(UnityCommandOptions, GroupFilterReallyFilters); RUN_TEST_CASE(UnityCommandOptions, TestShouldBeIgnored); }
e3c47b9b67b03cc888051778794f84b925ea5262
33377c4d113cf9ea1338077af6bd645f3c5796b3
/extensions/android/ringlibsdl/project/jni/SDL2_image/IMG_pcx.c
6c3ba31162785bee3e3b134fc2a9a774e778a704
[ "Zlib", "LicenseRef-scancode-free-unknown", "MIT" ]
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,217
c
IMG_pcx.c
/* SDL_image: An example image loading library for use with SDL Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * PCX file reader: * Supports: * 1..4 bits/pixel in multiplanar format (1 bit/plane/pixel) * 8 bits/pixel in single-planar format (8 bits/plane/pixel) * 24 bits/pixel in 3-plane format (8 bits/plane/pixel) * * (The <8bpp formats are expanded to 8bpp surfaces) * * Doesn't support: * single-planar packed-pixel formats other than 8bpp * 4-plane 32bpp format with a fourth "intensity" plane */ #include <stdio.h> #include <stdlib.h> #include "SDL_endian.h" #include "SDL_image.h" #ifdef LOAD_PCX struct PCXheader { Uint8 Manufacturer; Uint8 Version; Uint8 Encoding; Uint8 BitsPerPixel; Sint16 Xmin, Ymin, Xmax, Ymax; Sint16 HDpi, VDpi; Uint8 Colormap[48]; Uint8 Reserved; Uint8 NPlanes; Sint16 BytesPerLine; Sint16 PaletteInfo; Sint16 HscreenSize; Sint16 VscreenSize; Uint8 Filler[54]; }; /* See if an image is contained in a data source */ int IMG_isPCX(SDL_RWops *src) { Sint64 start; int is_PCX; const int ZSoft_Manufacturer = 10; const int PC_Paintbrush_Version = 5; const int PCX_Uncompressed_Encoding = 0; const int PCX_RunLength_Encoding = 1; struct PCXheader pcxh; if ( !src ) return 0; start = SDL_RWtell(src); is_PCX = 0; if ( SDL_RWread(src, &pcxh, sizeof(pcxh), 1) == 1 ) { if ( (pcxh.Manufacturer == ZSoft_Manufacturer) && (pcxh.Version == PC_Paintbrush_Version) && (pcxh.Encoding == PCX_RunLength_Encoding || pcxh.Encoding == PCX_Uncompressed_Encoding) ) { is_PCX = 1; } } SDL_RWseek(src, start, RW_SEEK_SET); return(is_PCX); } /* Load a PCX type image from an SDL datasource */ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) { Sint64 start; struct PCXheader pcxh; Uint32 Rmask; Uint32 Gmask; Uint32 Bmask; Uint32 Amask; SDL_Surface *surface = NULL; int width, height; int y, bpl; Uint8 *row, *buf = NULL; char *error = NULL; int bits, src_bits; if ( !src ) { /* The error message has been set in SDL_RWFromFile */ return NULL; } start = SDL_RWtell(src); if ( ! SDL_RWread(src, &pcxh, sizeof(pcxh), 1) ) { error = "file truncated"; goto done; } pcxh.Xmin = SDL_SwapLE16(pcxh.Xmin); pcxh.Ymin = SDL_SwapLE16(pcxh.Ymin); pcxh.Xmax = SDL_SwapLE16(pcxh.Xmax); pcxh.Ymax = SDL_SwapLE16(pcxh.Ymax); pcxh.BytesPerLine = SDL_SwapLE16(pcxh.BytesPerLine); /* Create the surface of the appropriate type */ width = (pcxh.Xmax - pcxh.Xmin) + 1; height = (pcxh.Ymax - pcxh.Ymin) + 1; Rmask = Gmask = Bmask = Amask = 0; src_bits = pcxh.BitsPerPixel * pcxh.NPlanes; if((pcxh.BitsPerPixel == 1 && pcxh.NPlanes >= 1 && pcxh.NPlanes <= 4) || (pcxh.BitsPerPixel == 8 && pcxh.NPlanes == 1)) { bits = 8; } else if(pcxh.BitsPerPixel == 8 && pcxh.NPlanes == 3) { bits = 24; #if SDL_BYTEORDER == SDL_LIL_ENDIAN Rmask = 0x000000FF; Gmask = 0x0000FF00; Bmask = 0x00FF0000; #else Rmask = 0xFF0000; Gmask = 0x00FF00; Bmask = 0x0000FF; #endif } else { error = "unsupported PCX format"; goto done; } surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, bits, Rmask, Gmask, Bmask, Amask); if ( surface == NULL ) goto done; bpl = pcxh.NPlanes * pcxh.BytesPerLine; if (bpl > surface->pitch) { error = "bytes per line is too large (corrupt?)"; } buf = (Uint8 *)SDL_malloc(bpl); row = (Uint8 *)surface->pixels; for ( y=0; y<surface->h; ++y ) { /* decode a scan line to a temporary buffer first */ int i, count = 0; Uint8 ch; Uint8 *dst = (src_bits == 8) ? row : buf; if ( pcxh.Encoding == 0 ) { if(!SDL_RWread(src, dst, bpl, 1)) { error = "file truncated"; goto done; } } else { for(i = 0; i < bpl; i++) { if(!count) { if(!SDL_RWread(src, &ch, 1, 1)) { error = "file truncated"; goto done; } if( (ch & 0xc0) == 0xc0) { count = ch & 0x3f; if(!SDL_RWread(src, &ch, 1, 1)) { error = "file truncated"; goto done; } } else count = 1; } dst[i] = ch; count--; } } if(src_bits <= 4) { /* expand planes to 1 byte/pixel */ Uint8 *innerSrc = buf; int plane; for(plane = 0; plane < pcxh.NPlanes; plane++) { int j, k, x = 0; for(j = 0; j < pcxh.BytesPerLine; j++) { Uint8 byte = *innerSrc++; for(k = 7; k >= 0; k--) { unsigned bit = (byte >> k) & 1; /* skip padding bits */ if (j * 8 + k >= width) continue; row[x++] |= bit << plane; } } } } else if(src_bits == 24) { /* de-interlace planes */ Uint8 *innerSrc = buf; int plane; for(plane = 0; plane < pcxh.NPlanes; plane++) { int x; dst = row + plane; for(x = 0; x < width; x++) { *dst = *innerSrc++; dst += pcxh.NPlanes; } } } row += surface->pitch; } if(bits == 8) { SDL_Color *colors = surface->format->palette->colors; int nc = 1 << src_bits; int i; surface->format->palette->ncolors = nc; if(src_bits == 8) { Uint8 ch; /* look for a 256-colour palette */ do { if ( !SDL_RWread(src, &ch, 1, 1)) { error = "file truncated"; goto done; } } while ( ch != 12 ); for(i = 0; i < 256; i++) { SDL_RWread(src, &colors[i].r, 1, 1); SDL_RWread(src, &colors[i].g, 1, 1); SDL_RWread(src, &colors[i].b, 1, 1); } } else { for(i = 0; i < nc; i++) { colors[i].r = pcxh.Colormap[i * 3]; colors[i].g = pcxh.Colormap[i * 3 + 1]; colors[i].b = pcxh.Colormap[i * 3 + 2]; } } } done: SDL_free(buf); if ( error ) { SDL_RWseek(src, start, RW_SEEK_SET); if ( surface ) { SDL_FreeSurface(surface); surface = NULL; } IMG_SetError("%s", error); } return(surface); } #else /* See if an image is contained in a data source */ int IMG_isPCX(SDL_RWops *src) { return(0); } /* Load a PCX type image from an SDL datasource */ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) { return(NULL); } #endif /* LOAD_PCX */
a621a8df49f2488dcd6df82459fb5d5af54ad853
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/net/if_mpls.c
729fe89ec7aa0a6acec6a19ed872ba045f20d4a5
[ "BSD-3-Clause" ]
permissive
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
16,573
c
if_mpls.c
/* $NetBSD: if_mpls.c,v 1.41 2022/09/03 20:29:31 thorpej Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Mihai Chelaru <kefren@NetBSD.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. */ #include <sys/cdefs.h> __KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.41 2022/09/03 20:29:31 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" #include "opt_mpls.h" #endif #include <sys/param.h> #include <sys/errno.h> #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/sysctl.h> #include <net/bpf.h> #include <net/if.h> #include <net/if_types.h> #include <net/route.h> #include <sys/device.h> #include <sys/module.h> #include <sys/atomic.h> #ifdef INET #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/in_var.h> #include <netinet/ip.h> #include <netinet/ip_var.h> #endif #ifdef INET6 #include <netinet/ip6.h> #include <netinet6/in6_var.h> #include <netinet6/ip6_var.h> #endif #include <netmpls/mpls.h> #include <netmpls/mpls_var.h> #include "if_mpls.h" #include "ioconf.h" static int mpls_clone_create(struct if_clone *, int); static int mpls_clone_destroy(struct ifnet *); static struct if_clone mpls_if_cloner = IF_CLONE_INITIALIZER("mpls", mpls_clone_create, mpls_clone_destroy); static void mpls_input(struct ifnet *, struct mbuf *); static int mpls_output(struct ifnet *, struct mbuf *, const struct sockaddr *, const struct rtentry *); static int mpls_ioctl(struct ifnet *, u_long, void *); static int mpls_send_frame(struct mbuf *, struct ifnet *, const struct rtentry *); static int mpls_lse(struct mbuf *); #ifdef INET static struct mbuf *mpls_unlabel_inet(struct mbuf *, int *error); static struct mbuf *mpls_label_inet(struct mbuf *, union mpls_shim *, uint); #endif #ifdef INET6 static struct mbuf *mpls_unlabel_inet6(struct mbuf *, int *error); static struct mbuf *mpls_label_inet6(struct mbuf *, union mpls_shim *, uint); #endif static struct mbuf *mpls_prepend_shim(struct mbuf *, union mpls_shim *); extern int mpls_defttl, mpls_mapttl_inet, mpls_mapttl_inet6, mpls_icmp_respond, mpls_forwarding, mpls_frame_accept, mpls_mapprec_inet, mpls_mapclass_inet6, mpls_rfc4182; static u_int mpls_count; void mplsattach(int); /* ARGSUSED */ void mplsattach(int count) { /* * Nothing to do here, initialization is handled by the * module initialization code in mplsinit() below). */ } static void mplsinit(void) { if_clone_attach(&mpls_if_cloner); } static int mplsdetach(void) { int error = 0; if (mpls_count != 0) error = EBUSY; if (error == 0) if_clone_detach(&mpls_if_cloner); return error; } static int mpls_clone_create(struct if_clone *ifc, int unit) { struct mpls_softc *sc; atomic_inc_uint(&mpls_count); sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); if_initname(&sc->sc_if, ifc->ifc_name, unit); sc->sc_if.if_softc = sc; sc->sc_if.if_type = IFT_MPLS; sc->sc_if.if_addrlen = 0; sc->sc_if.if_hdrlen = sizeof(union mpls_shim); sc->sc_if.if_dlt = DLT_NULL; sc->sc_if.if_mtu = 1500; sc->sc_if.if_flags = 0; sc->sc_if._if_input = mpls_input; sc->sc_if.if_output = mpls_output; sc->sc_if.if_ioctl = mpls_ioctl; if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); bpf_attach(&sc->sc_if, DLT_NULL, sizeof(uint32_t)); return 0; } static int mpls_clone_destroy(struct ifnet *ifp) { bpf_detach(ifp); if_detach(ifp); free(ifp->if_softc, M_DEVBUF); atomic_dec_uint(&mpls_count); return 0; } static void mpls_input(struct ifnet *ifp, struct mbuf *m) { #if 0 /* * TODO - kefren * I'd love to unshim the packet, guess family * and pass it to bpf */ bpf_mtap_af(ifp, AF_MPLS, m, BPF_D_IN); #endif mpls_lse(m); } void mplsintr(void *arg __unused) { struct mbuf *m; while ((m = pktq_dequeue(mpls_pktq)) != NULL) { if (((m->m_flags & M_PKTHDR) == 0) || (m->m_pkthdr.rcvif_index == 0)) panic("mplsintr(): no pkthdr or rcvif"); #ifdef MBUFTRACE m_claimm(m, &mpls_owner); #endif mpls_input(m_get_rcvif_NOMPSAFE(m), m); } } /* * prepend shim and deliver */ static int mpls_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, const struct rtentry *rt) { union mpls_shim mh, *pms; struct rtentry *rt1; int err; uint psize = sizeof(struct sockaddr_mpls); KASSERT(KERNEL_LOCKED_P()); if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) { m_freem(m); return ENETDOWN; } if (rt_gettag(rt) == NULL || rt_gettag(rt)->sa_family != AF_MPLS) { m_freem(m); return EINVAL; } bpf_mtap_af(ifp, dst->sa_family, m, BPF_D_OUT); memset(&mh, 0, sizeof(mh)); mh.s_addr = MPLS_GETSADDR(rt); mh.shim.bos = 1; mh.shim.exp = 0; mh.shim.ttl = mpls_defttl; pms = &((struct sockaddr_mpls*)rt_gettag(rt))->smpls_addr; while (psize <= rt_gettag(rt)->sa_len - sizeof(mh)) { pms++; if (mh.shim.label != MPLS_LABEL_IMPLNULL && ((m = mpls_prepend_shim(m, &mh)) == NULL)) return ENOBUFS; memset(&mh, 0, sizeof(mh)); mh.s_addr = ntohl(pms->s_addr); mh.shim.bos = mh.shim.exp = 0; mh.shim.ttl = mpls_defttl; psize += sizeof(mh); } switch (dst->sa_family) { #ifdef INET case AF_INET: m = mpls_label_inet(m, &mh, psize - sizeof(struct sockaddr_mpls)); break; #endif #ifdef INET6 case AF_INET6: m = mpls_label_inet6(m, &mh, psize - sizeof(struct sockaddr_mpls)); break; #endif default: m = mpls_prepend_shim(m, &mh); break; } if (m == NULL) { IF_DROP(&ifp->if_snd); if_statinc(ifp, if_oerrors); return ENOBUFS; } if_statadd2(ifp, if_opackets, 1, if_obytes, m->m_pkthdr.len); if ((rt1 = rtalloc1(rt->rt_gateway, 1)) == NULL) { m_freem(m); return EHOSTUNREACH; } err = mpls_send_frame(m, rt1->rt_ifp, rt); rt_unref(rt1); return err; } static int mpls_ioctl(struct ifnet *ifp, u_long cmd, void *data) { int error = 0, s = splnet(); struct ifreq *ifr = data; switch(cmd) { case SIOCINITIFADDR: ifp->if_flags |= IFF_UP | IFF_RUNNING; break; case SIOCSIFMTU: if (ifr != NULL && ifr->ifr_mtu < 576) { error = EINVAL; break; } /* FALLTHROUGH */ case SIOCGIFMTU: if ((error = ifioctl_common(ifp, cmd, data)) == ENETRESET) error = 0; break; case SIOCSIFFLAGS: if ((error = ifioctl_common(ifp, cmd, data)) != 0) break; if (ifp->if_flags & IFF_UP) ifp->if_flags |= IFF_RUNNING; break; default: error = ifioctl_common(ifp, cmd, data); break; } splx(s); return error; } static inline struct mbuf * mpls_trim_label(struct mbuf *m, union mpls_shim *sh) { m_adj(m, sizeof(union mpls_shim)); if (m->m_len < sizeof(union mpls_shim) && (m = m_pullup(m, sizeof(union mpls_shim))) == NULL) return NULL; sh->s_addr = ntohl(mtod(m, union mpls_shim *)->s_addr); return m; } /* * MPLS Label Switch Engine */ static int mpls_lse(struct mbuf *m) { struct sockaddr_mpls dst; union mpls_shim tshim, *htag; struct rtentry *rt = NULL; int error = ENOBUFS; uint psize = sizeof(struct sockaddr_mpls); bool push_back_alert = false; /* If we're not accepting MPLS frames, leave now. */ if (!mpls_frame_accept) { error = EINVAL; goto done; } if (m->m_len < sizeof(union mpls_shim) && (m = m_pullup(m, sizeof(union mpls_shim))) == NULL) goto done; dst.smpls_len = sizeof(struct sockaddr_mpls); dst.smpls_family = AF_MPLS; dst.smpls_addr.s_addr = ntohl(mtod(m, union mpls_shim *)->s_addr); error = EINVAL; /* TTL decrement */ if ((m = mpls_ttl_dec(m)) == NULL) goto done; /* RFC 4182 */ if (mpls_rfc4182 != 0) { while ((dst.smpls_addr.shim.label == MPLS_LABEL_IPV4NULL || dst.smpls_addr.shim.label == MPLS_LABEL_IPV6NULL) && __predict_false(dst.smpls_addr.shim.bos == 0)) { m = mpls_trim_label(m, &dst.smpls_addr); if (m == NULL) { goto done; } } } /* RFC 3032 Section 2.1 Page 4 */ if (__predict_false(dst.smpls_addr.shim.label == MPLS_LABEL_RTALERT) && dst.smpls_addr.shim.bos == 0) { m = mpls_trim_label(m, &dst.smpls_addr); if (m == NULL) { goto done; } push_back_alert = true; } if (dst.smpls_addr.shim.label <= MPLS_LABEL_RESMAX) { /* Don't swap reserved labels */ switch (dst.smpls_addr.shim.label) { #ifdef INET case MPLS_LABEL_IPV4NULL: /* Pop shim and push mbuf to IP stack */ if (dst.smpls_addr.shim.bos) { m = mpls_unlabel_inet(m, &error); } break; #endif #ifdef INET6 case MPLS_LABEL_IPV6NULL: /* Pop shim and push mbuf to IPv6 stack */ if (dst.smpls_addr.shim.bos) { m = mpls_unlabel_inet6(m, &error); } break; #endif case MPLS_LABEL_RTALERT: /* Yeah, I'm all alerted */ case MPLS_LABEL_IMPLNULL: /* This is logical only */ default: /* Rest are not allowed */ break; } goto done; } /* Check if we should do MPLS forwarding */ error = EHOSTUNREACH; if (!mpls_forwarding) goto done; /* Get a route to dst */ dst.smpls_addr.shim.ttl = 0; dst.smpls_addr.shim.bos = 0; dst.smpls_addr.shim.exp = 0; dst.smpls_addr.s_addr = htonl(dst.smpls_addr.s_addr); if ((rt = rtalloc1((const struct sockaddr*)&dst, 1)) == NULL) goto done; /* MPLS packet with no MPLS tagged route ? */ if ((rt->rt_flags & RTF_GATEWAY) == 0 || rt_gettag(rt) == NULL || rt_gettag(rt)->sa_family != AF_MPLS) goto done; tshim.s_addr = MPLS_GETSADDR(rt); /* Swap labels */ if ((m->m_len < sizeof(union mpls_shim)) && (m = m_pullup(m, sizeof(union mpls_shim))) == 0) { error = ENOBUFS; goto done; } /* Replace only the label */ htag = mtod(m, union mpls_shim *); htag->s_addr = ntohl(htag->s_addr); htag->shim.label = tshim.shim.label; htag->s_addr = htonl(htag->s_addr); /* check if there is anything more to prepend */ htag = &((struct sockaddr_mpls*)rt_gettag(rt))->smpls_addr; while (psize <= rt_gettag(rt)->sa_len - sizeof(tshim)) { htag++; memset(&tshim, 0, sizeof(tshim)); tshim.s_addr = ntohl(htag->s_addr); tshim.shim.bos = tshim.shim.exp = 0; tshim.shim.ttl = mpls_defttl; if (tshim.shim.label != MPLS_LABEL_IMPLNULL && ((m = mpls_prepend_shim(m, &tshim)) == NULL)) { error = ENOBUFS; goto done; } psize += sizeof(tshim); } if (__predict_false(push_back_alert == true)) { /* re-add the router alert label */ memset(&tshim, 0, sizeof(tshim)); tshim.s_addr = MPLS_LABEL_RTALERT; tshim.shim.bos = tshim.shim.exp = 0; tshim.shim.ttl = mpls_defttl; if ((m = mpls_prepend_shim(m, &tshim)) == NULL) { error = ENOBUFS; goto done; } } if ((rt->rt_flags & RTF_GATEWAY) == 0) { error = EHOSTUNREACH; goto done; } rt->rt_use++; error = mpls_send_frame(m, rt->rt_ifp, rt); done: if (error != 0 && m != NULL) m_freem(m); if (rt != NULL) rt_unref(rt); return error; } static int mpls_send_frame(struct mbuf *m, struct ifnet *ifp, const struct rtentry *rt) { union mpls_shim msh; int ret; msh.s_addr = MPLS_GETSADDR(rt); if (msh.shim.label == MPLS_LABEL_IMPLNULL || (m->m_flags & (M_MCAST | M_BCAST))) { m_adj(m, sizeof(union mpls_shim)); m->m_pkthdr.csum_flags = 0; } switch(ifp->if_type) { /* only these are supported for now */ case IFT_ETHER: case IFT_TUNNEL: case IFT_LOOP: #ifdef INET ret = ip_if_output(ifp, m, rt->rt_gateway, rt); #else ret = if_output_lock(ifp, ifp, m, rt->rt_gateway, rt); #endif return ret; break; default: return ENETUNREACH; } return 0; } #ifdef INET static struct mbuf * mpls_unlabel_inet(struct mbuf *m, int *error) { struct ip *iph; union mpls_shim ms; int iphlen; if (mpls_mapttl_inet || mpls_mapprec_inet) { /* get shim info */ ms.s_addr = ntohl(mtod(m, union mpls_shim *)->s_addr); /* and get rid of it */ m_adj(m, sizeof(union mpls_shim)); /* get ip header */ if (m->m_len < sizeof(struct ip) && (m = m_pullup(m, sizeof(struct ip))) == NULL) { *error = ENOBUFS; return NULL; } iph = mtod(m, struct ip *); iphlen = iph->ip_hl << 2; /* get it all */ if (m->m_len < iphlen) { if ((m = m_pullup(m, iphlen)) == NULL) { *error = ENOBUFS; return NULL; } iph = mtod(m, struct ip *); } /* check ipsum */ if (in_cksum(m, iphlen) != 0) { m_freem(m); *error = EINVAL; return NULL; } /* set IP ttl from MPLS ttl */ if (mpls_mapttl_inet) iph->ip_ttl = ms.shim.ttl; /* set IP Precedence from MPLS Exp */ if (mpls_mapprec_inet) { iph->ip_tos = (iph->ip_tos << 3) >> 3; iph->ip_tos |= ms.shim.exp << 5; } /* reset ipsum because we modified TTL and TOS */ iph->ip_sum = 0; iph->ip_sum = in_cksum(m, iphlen); } else { m_adj(m, sizeof(union mpls_shim)); } /* Put it on IP queue */ if (__predict_false(!pktq_enqueue(ip_pktq, m, 0))) { m_freem(m); *error = ENOBUFS; return NULL; } *error = 0; return m; } /* * Prepend MPLS label */ static struct mbuf * mpls_label_inet(struct mbuf *m, union mpls_shim *ms, uint offset) { struct ip iphdr; if (mpls_mapttl_inet || mpls_mapprec_inet) { /* XXX Maybe just check m->m_pkthdr.len instead? */ if ((m->m_len < offset + sizeof(struct ip)) && (m = m_pullup(m, offset + sizeof(struct ip))) == 0) return NULL; m_copydata(m, offset, sizeof(struct ip), &iphdr); /* Map TTL */ if (mpls_mapttl_inet) ms->shim.ttl = iphdr.ip_ttl; /* Copy IP precedence to EXP */ if (mpls_mapprec_inet) ms->shim.exp = ((u_int8_t)iphdr.ip_tos) >> 5; } if ((m = mpls_prepend_shim(m, ms)) == NULL) return NULL; return m; } #endif /* INET */ #ifdef INET6 static struct mbuf * mpls_unlabel_inet6(struct mbuf *m, int *error) { struct ip6_hdr *ip6hdr; union mpls_shim ms; /* TODO: mapclass */ if (mpls_mapttl_inet6) { ms.s_addr = ntohl(mtod(m, union mpls_shim *)->s_addr); m_adj(m, sizeof(union mpls_shim)); if (m->m_len < sizeof(struct ip6_hdr) && (m = m_pullup(m, sizeof(struct ip6_hdr))) == 0) { *error = ENOBUFS; return NULL; } ip6hdr = mtod(m, struct ip6_hdr *); /* Because we just decremented this in mpls_lse */ ip6hdr->ip6_hlim = ms.shim.ttl + 1; } else { m_adj(m, sizeof(union mpls_shim)); } /* Put it back on IPv6 queue. */ if (__predict_false(!pktq_enqueue(ip6_pktq, m, 0))) { m_freem(m); *error = ENOBUFS; return NULL; } *error = 0; return m; } static struct mbuf * mpls_label_inet6(struct mbuf *m, union mpls_shim *ms, uint offset) { struct ip6_hdr ip6h; if (mpls_mapttl_inet6 || mpls_mapclass_inet6) { /* XXX Maybe just check m->m_pkthdr.len instead? */ if ((m->m_len < offset + sizeof(struct ip6_hdr)) && (m = m_pullup(m, offset + sizeof(struct ip6_hdr))) == 0) return NULL; m_copydata(m, offset, sizeof(struct ip6_hdr), &ip6h); if (mpls_mapttl_inet6) ms->shim.ttl = ip6h.ip6_hlim; if (mpls_mapclass_inet6) ms->shim.exp = ip6h.ip6_vfc << 1 >> 5; } if ((m = mpls_prepend_shim(m, ms)) == NULL) return NULL; return m; } #endif /* INET6 */ static struct mbuf * mpls_prepend_shim(struct mbuf *m, union mpls_shim *ms) { union mpls_shim *shim; M_PREPEND(m, sizeof(*ms), M_DONTWAIT); if (m == NULL) return NULL; if (m->m_len < sizeof(union mpls_shim) && (m = m_pullup(m, sizeof(union mpls_shim))) == 0) return NULL; shim = mtod(m, union mpls_shim *); memcpy(shim, ms, sizeof(*shim)); shim->s_addr = htonl(shim->s_addr); return m; } /* * Module infrastructure */ #include "if_module.h" IF_MODULE(MODULE_CLASS_DRIVER, mpls, NULL)
0e1ab7295c8ab9f1a533fb107cf69683fd49cef4
6432ea7a083ff6ba21ea17af9ee47b9c371760f7
/stage0/stdlib/Init/Data/Array/Basic.c
d649326662fa596a202f590b6274670b69409989
[ "Apache-2.0", "LLVM-exception", "NCSA", "LGPL-3.0-only", "LicenseRef-scancode-inner-net-2.0", "BSD-3-Clause", "LGPL-2.0-or-later", "Spencer-94", "LGPL-2.1-or-later", "HPND", "LicenseRef-scancode-pcre", "ISC", "LGPL-2.1-only", "LicenseRef-scancode-other-permissive", "SunPro", "CMU-Mach" ]
permissive
leanprover/lean4
4bdf9790294964627eb9be79f5e8f6157780b4cc
f1f9dc0f2f531af3312398999d8b8303fa5f096b
refs/heads/master
2023-08-30T01:57:45.786981
2023-08-29T23:14:28
2023-08-29T23:14:28
129,571,436
2,827
311
Apache-2.0
2023-09-14T18:29:16
2018-04-15T02:49:20
Lean
UTF-8
C
false
false
321,886
c
Basic.c
// Lean compiler output // Module: Init.Data.Array.Basic // Imports: Init.WFTactics Init.Data.Nat.Basic Init.Data.Fin.Basic Init.Data.UInt.Basic Init.Data.Repr Init.Data.ToString.Basic Init.Util #include <lean/lean.h> #if defined(__clang__) #pragma clang diagnostic ignored "-Wunused-parameter" #pragma clang diagnostic ignored "-Wunused-label" #elif defined(__GNUC__) && !defined(__CLANG__) #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-label" #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #ifdef __cplusplus extern "C" { #endif static lean_object* l_Array_swapAt_x21___rarg___closed__3; LEAN_EXPORT lean_object* l_Array_filterM___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_concatMapM(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_takeWhile(lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__2___rarg(lean_object*, size_t, size_t, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__5; LEAN_EXPORT lean_object* l_Array_isPrefixOf(lean_object*); static lean_object* l_Array_instEmptyCollectionArray___closed__1; LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_foldl___spec__1___rarg(lean_object*, lean_object*, size_t, size_t, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__15; LEAN_EXPORT lean_object* l_Array_findRev_x3f___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrM_fold___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__4(lean_object*, size_t, lean_object*, lean_object*, lean_object*, lean_object*, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_uget___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT uint8_t l_Array_isEqvAux___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_panic___at_Array_swapAt_x21___spec__1(lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_allDiffAux(lean_object*); static lean_object* l_Array_instGetElemArrayUSizeLtNatInstLTNatToNatSize___closed__1; lean_object* lean_mk_empty_array_with_capacity(lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_contains___spec__1(lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__14; LEAN_EXPORT lean_object* l_Array_foldlM_loop___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeM_x3f___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_insertAt_loop___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_filterMapM___at_Array_filterMap___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe(lean_object*, lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__6; LEAN_EXPORT lean_object* l_Array_findSome_x21___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__List_drop_match__1_splitter___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_modifyMUnsafe___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_find_x3f___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___lambda__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forIn_loop___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findM_x3f___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__List_toArrayAux_match__1_splitter___rarg(lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__3; LEAN_EXPORT lean_object* l_Array_all(lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_foldl___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_getMax_x3f___rarg___lambda__1(lean_object*, lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__12; LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_getEvenElems___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__2___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__7; LEAN_EXPORT lean_object* l_Array_erase___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_swapAt_x21(lean_object*); LEAN_EXPORT lean_object* l_Array_filterMapM___rarg___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_zip___rarg___boxed(lean_object*, lean_object*); static lean_object* l_Array_instReprArray___rarg___closed__9; lean_object* lean_array_swap(lean_object*, lean_object*, lean_object*); lean_object* lean_array_fswap(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_partition___spec__1(lean_object*); static lean_object* l_Array_instReprArray___rarg___closed__8; LEAN_EXPORT lean_object* l_Array_anyMUnsafe___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_popWhile(lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_mapM_map(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_uset___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_filterMapM___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_reverse(lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRev_x3f___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findIdx_x3f_loop___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_allDiff___rarg___boxed(lean_object*, lean_object*); lean_object* lean_array_push(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterMap___spec__2___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__2(size_t, lean_object*, lean_object*, lean_object*, lean_object*, size_t, uint8_t); LEAN_EXPORT lean_object* l_Array_modifyMUnsafe___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x3f___spec__1___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_mapIdxM(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_append___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_mk_array(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_allDiff(lean_object*); uint8_t lean_usize_dec_eq(size_t, size_t); LEAN_EXPORT lean_object* l_Array_anyM_loop___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Array_swapAt_x21___rarg___closed__2; LEAN_EXPORT lean_object* l_Array_foldlMUnsafe___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Syntax_getArgs(lean_object*); LEAN_EXPORT lean_object* l_Array_contains___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_find_x3f___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_panic___at_Array_swapAt_x21___spec__1___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_getLit___rarg(lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_array_fget(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); lean_object* lean_array_fset(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_List_foldl___at_Array_instReprArray___spec__2(lean_object*); LEAN_EXPORT lean_object* l_Array_getIdx_x3f(lean_object*); LEAN_EXPORT lean_object* l_Array_elem___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_insertAt_loop___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_partition___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_indexOf_x3f___rarg(lean_object*, lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__4; LEAN_EXPORT lean_object* l_Array_eraseIdxSzAux(lean_object*); LEAN_EXPORT uint8_t l_Array_anyMUnsafe_any___at_Array_contains___spec__1___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t); LEAN_EXPORT lean_object* l_Array_findIdx_x3f_loop___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__2___rarg(lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__List_drop_match__1_splitter(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyM_loop___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRev_x3f___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_all___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_unzip(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_instHAppendArrayList(lean_object*); LEAN_EXPORT lean_object* l_Array_forIn_loop___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__4___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findIdx_x3f_loop(lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__3___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_shrink(lean_object*); LEAN_EXPORT uint8_t l___private_Init_Data_Array_Basic_0__Array_allDiffAuxAux___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); uint8_t l_Lean_Syntax_isOfKind(lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__List_drop_match__1_splitter___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT uint8_t l_Array_isEqv___rarg(lean_object*, lean_object*, lean_object*); lean_object* l_List_toString___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_zipWith___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_filterMapM(lean_object*, lean_object*, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__4; LEAN_EXPORT lean_object* l_Array_back(lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findSomeRev_x3f___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mkArray___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_swapAt(lean_object*); LEAN_EXPORT lean_object* l_Array_zipWithAux(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyM_loop(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeM_x3f___rarg___lambda__1(lean_object*, lean_object*, lean_object*); LEAN_EXPORT uint8_t l_Array_any___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_getLit(lean_object*, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__5; LEAN_EXPORT lean_object* l_Array_getIdx_x3f___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg___lambda__1(size_t, lean_object*, lean_object*, lean_object*, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_findSome_x3f___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSome_x21(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldl___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_getIdx_x3f___rarg___lambda__1(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__18; LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Std_Format_joinSep___at_Array_instReprArray___spec__1(lean_object*); static lean_object* l_Array_find_x3f___rarg___closed__2; LEAN_EXPORT lean_object* l_Array_forRevM___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_split___spec__1___rarg(lean_object*, lean_object*, size_t, size_t, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__1; LEAN_EXPORT lean_object* l_Array_concatMap___rarg___boxed(lean_object*, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__10; LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x21___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_isEqv(lean_object*); LEAN_EXPORT lean_object* l_Array_mapIdx(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Array_unzip___rarg___closed__1; LEAN_EXPORT lean_object* l_Array_mapIdxM_map(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrM_fold(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_modify(lean_object*); LEAN_EXPORT lean_object* l_Array_forIn_loop___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlM_loop(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlM_loop___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_foldl___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_swapAt_x21___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapIdx___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_isEmpty(lean_object*); LEAN_EXPORT lean_object* l_Array_mapM_map___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_singleton(lean_object*); LEAN_EXPORT lean_object* l_Array_feraseIdx___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeM_x3f___rarg___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*); size_t lean_usize_of_nat(lean_object*); LEAN_EXPORT lean_object* l_Array_map(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_concatMapM___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__1___boxed(lean_object*, lean_object*); lean_object* l_panic___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_append___spec__1___rarg(lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_mapMUnsafe(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_reverse___rarg(lean_object*); LEAN_EXPORT lean_object* l_Array_all___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findSomeRev_x3f___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_instReprArray___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_any(lean_object*); static lean_object* l_Array_instReprArray___rarg___closed__3; uint8_t lean_nat_dec_eq(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___at_Array_map___spec__1___rarg(lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_findSome_x3f___rarg(lean_object*, lean_object*); LEAN_EXPORT uint8_t l_Array_elem___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlM_loop___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_find_x3f___spec__1___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_zip___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_getMax_x3f(lean_object*); LEAN_EXPORT uint8_t l___private_Init_Data_Array_Basic_0__Array_allDiffAux___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_unzip___rarg(lean_object*); LEAN_EXPORT lean_object* l_Array_feraseIdx___rarg(lean_object*, lean_object*); lean_object* l_Lean_SourceInfo_fromRef(lean_object*, uint8_t); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_zipWithAux___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_nat_to_int(lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_contains___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT uint8_t l_Array_isPrefixOf___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__2(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_isEqv___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_appendList(lean_object*); LEAN_EXPORT lean_object* l_Array_takeWhile___rarg(lean_object*, lean_object*); static lean_object* l_Array_instAppendArray___closed__1; LEAN_EXPORT lean_object* l_Array_filter___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_allM___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_toArrayLit___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyM_loop___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, uint8_t); LEAN_EXPORT lean_object* l_Array_mapIdxM_map___at_Array_mapIdx___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findSomeRev_x3f___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_indexOf_x3f___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findIdxM_x3f___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findIdx_x3f___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_append___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_modifyOp(lean_object*); static lean_object* l_Array_instReprArray___rarg___closed__2; LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_takeWhile_go___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filter___spec__1___rarg(lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_mapMUnsafe___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, uint8_t); static lean_object* l_Array_findSomeM_x3f___rarg___closed__1; LEAN_EXPORT lean_object* l_Array_indexOfAux(lean_object*); LEAN_EXPORT lean_object* l_Array_toListLitAux___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_insertAt_x21(lean_object*); LEAN_EXPORT lean_object* l_Array_back_x3f___rarg(lean_object*); LEAN_EXPORT lean_object* l_Array_partition___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSome_x21___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_back_x3f___rarg___boxed(lean_object*); lean_object* lean_array_pop(lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___lambda__2(size_t, lean_object*, lean_object*, lean_object*, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Array_findSome_x21___rarg___closed__3; LEAN_EXPORT lean_object* l_Array_mapIdxM_map___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMap___spec__1___rarg(lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* lean_array_to_list(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__3(lean_object*, size_t, lean_object*, lean_object*, lean_object*, lean_object*, size_t, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__13; static lean_object* l_Array_instReprArray___rarg___closed__11; LEAN_EXPORT lean_object* l_Array_modifyOp___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__2___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_unzip___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1(lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Syntax_node3(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Array_insertAt_x21___rarg___closed__1; static lean_object* l_term_x23_x5b___x2c_x5d___closed__12; LEAN_EXPORT lean_object* l_Array_foldl(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_concatMap(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_modifyMUnsafe(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x21___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMap___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_allDiffAuxAux___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT uint8_t l_Array_isPrefixOfAux___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_insertAt_x21___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__1___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_partition___spec__1___rarg(lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t); LEAN_EXPORT lean_object* l_Array_foldr(lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__19; LEAN_EXPORT lean_object* l_Array_feraseIdx(lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__List_toArrayAux_match__1_splitter(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_filterM(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterMap___spec__2(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRev_x3f___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold(lean_object*, lean_object*, lean_object*); lean_object* l_Lean_addMacroScope(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_filterMapM___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_zipWith___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__2(lean_object*, lean_object*); static lean_object* l_Array_instHAppendArrayList___closed__1; LEAN_EXPORT lean_object* l_Array_instReprArray(lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe(lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Name_str___override(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapIdxM_map___at_Array_mapIdx___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___rarg___lambda__1(size_t, lean_object*, lean_object*, lean_object*, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_modify___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*, size_t, size_t); lean_object* l_Lean_Syntax_node2(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapIdxM_map___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_zipWithAux___at_Array_zip___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Array_findIdxM_x3f___rarg___closed__1; static lean_object* l_term_x23_x5b___x2c_x5d___closed__1; LEAN_EXPORT lean_object* l_Array_instInhabitedArray(lean_object*); LEAN_EXPORT lean_object* l_Array_findRevM_x3f___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_filter(lean_object*); lean_object* l_Lean_Syntax_getArg(lean_object*, lean_object*); lean_object* l___private_Init_Util_0__mkPanicMessageWithDecl(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_instForInArray(lean_object*, lean_object*, lean_object*); static lean_object* l_Array_findSome_x21___rarg___closed__2; LEAN_EXPORT lean_object* l_panic___at_Array_insertAt_x21___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMap___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_List_foldl___at_Array_instReprArray___spec__2___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findRevM_x3f(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__3(lean_object*, lean_object*, lean_object*, lean_object*, uint8_t); LEAN_EXPORT lean_object* l_Array_forRevM(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_eraseIdxAux(lean_object*); LEAN_EXPORT lean_object* l_Array_filterMap(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldr___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRev_x3f(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_back_x3f(lean_object*); LEAN_EXPORT lean_object* l_Array_indexOfAux___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Std_Format_joinSep___at_Array_instReprArray___spec__1___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_reverse_loop(lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__11; LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__2(size_t, lean_object*, lean_object*, lean_object*, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_insertAt(lean_object*); LEAN_EXPORT lean_object* l_Array_eraseIdx___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_partition(lean_object*); LEAN_EXPORT lean_object* l_Array_eraseIdxSzAux___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_eraseIdx___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forM(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_get_x3f(lean_object*); LEAN_EXPORT lean_object* l_Array_insertAt_loop(lean_object*); LEAN_EXPORT lean_object* l_Array_filterMapM___rarg___lambda__1(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSome_x3f(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_getEvenElems___rarg___boxed(lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_List_foldl___at_Array_appendList___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_append___rarg(lean_object*, lean_object*); static lean_object* l_Array_findSome_x21___rarg___closed__1; static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__14; LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__2(lean_object*); static lean_object* l_Array_insertAt_x21___rarg___closed__3; LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___rarg___lambda__1(size_t, lean_object*, lean_object*, lean_object*, size_t, uint8_t); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__10; LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_eraseIdx_x27___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_pop___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapIdxM_map___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_erase(lean_object*); LEAN_EXPORT lean_object* l_Array_mapIdxM_map___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_getEvenElems___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__16; static lean_object* l_term_x23_x5b___x2c_x5d___closed__2; static lean_object* l_term_x23_x5b___x2c_x5d___closed__13; LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_modify___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_toArrayLit(lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__11; LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forIn_loop___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_unzip___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_isEmpty___rarg___boxed(lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_find_x3f___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Array_insertAt_x21___rarg___closed__2; LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x3f___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__16; LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_split___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forM___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_filterMapM___at_Array_filterMap___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___rarg___lambda__1(size_t, lean_object*, lean_object*, lean_object*, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_any___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_filter___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_filterMap___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_getLit___boxed(lean_object*, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__8; LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_reverse_loop___rarg(lean_object*, lean_object*, lean_object*); lean_object* lean_string_length(lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); uint8_t lean_nat_dec_eq(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__2(lean_object*, size_t, lean_object*, lean_object*, lean_object*, lean_object*, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__1___rarg(lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_elem(lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filter___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_swap_x21___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT uint8_t l_Array_contains___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___rarg(lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___rarg___lambda__1(lean_object*, size_t, lean_object*, lean_object*, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_eraseIdx_x27(lean_object*); LEAN_EXPORT lean_object* l_Array_instBEqArray(lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); uint8_t lean_nat_dec_lt(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filter___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_allDiffAux___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x3f___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlM_loop___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__1(lean_object*, lean_object*, uint8_t); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Name_mkStr2(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findRev_x3f(lean_object*); LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___at_Array_map___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_zipWithAux___at_Array_zip___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_instEmptyCollectionArray(lean_object*); LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___at_Array_map___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_shrink___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__1(lean_object*, lean_object*, lean_object*, uint8_t); LEAN_EXPORT lean_object* l_Array_takeWhile_go___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_appendList___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_panic___at_Array_insertAt_x21___spec__1___rarg(lean_object*); LEAN_EXPORT lean_object* l_Array_findIdxM_x3f(lean_object*, lean_object*); lean_object* l_Lean_Syntax_node1(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_getMax_x3f___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_getEvenElems___spec__1___rarg(lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_singleton___rarg(lean_object*); LEAN_EXPORT lean_object* l_Array_swapAt___rarg(lean_object*, lean_object*, lean_object*); static lean_object* l_Array_instReprArray___rarg___closed__4; LEAN_EXPORT lean_object* l_Array_findIdx_x3f(lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__1(lean_object*, lean_object*, lean_object*); static lean_object* l_Array_swapAt_x21___rarg___closed__4; LEAN_EXPORT lean_object* l_Array_toListLitAux___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_append(lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f___rarg(lean_object*, lean_object*, lean_object*); lean_object* lean_panic_fn(lean_object*, lean_object*); static lean_object* l_Array_instToStringArray___rarg___closed__1; LEAN_EXPORT lean_object* l_Array_isEqvAux(lean_object*); LEAN_EXPORT lean_object* l_Array_shrink_loop___rarg(lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__9; LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_filterMapM___at_Array_filterMap___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeM_x3f(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__2___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_nat_sub(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x21___spec__1___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_insertAt_x21___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_shrink_loop(lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___lambda__1(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_isPrefixOfAux___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__17; LEAN_EXPORT lean_object* l_Array_getEvenElems___rarg(lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_allDiffAuxAux(lean_object*); LEAN_EXPORT uint8_t l_Array_allDiff___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Array_instReprArray___rarg___closed__1; LEAN_EXPORT lean_object* l_Array_back___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_List_foldl___at_Array_appendList___spec__1___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_zipWithAux___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_get_x3f___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_instAppendArray(lean_object*); LEAN_EXPORT lean_object* l_Array_zip(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_isPrefixOf___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_find_x3f___rarg___lambda__1___boxed(lean_object*); LEAN_EXPORT lean_object* l_Array_concatMap___rarg(lean_object*, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__17; LEAN_EXPORT lean_object* l_Array_back___rarg(lean_object*, lean_object*); static lean_object* l_Array_swapAt_x21___rarg___closed__1; LEAN_EXPORT lean_object* l_Array_eraseIdxAux___rarg(lean_object*, lean_object*); static lean_object* l_Array_instReprArray___rarg___closed__6; LEAN_EXPORT lean_object* l_Array_partition___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_any___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_isEqvAux___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); size_t lean_usize_sub(size_t, size_t); LEAN_EXPORT uint8_t l_Array_all___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT uint8_t l_Array_instBEqArray___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_takeWhile_go(lean_object*); LEAN_EXPORT lean_object* l_Array_findIdxM_x3f___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_modifyOp___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_map___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_isPrefixOfAux(lean_object*); size_t lean_usize_add(size_t, size_t); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_any___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter(lean_object*, lean_object*, lean_object*); extern lean_object* l_Id_instMonadId; LEAN_EXPORT lean_object* l_Array_instGetElemArrayUSizeLtNatInstLTNatToNatSize(lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_split___rarg(lean_object*, lean_object*); lean_object* lean_array_uget(lean_object*, size_t); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__6; LEAN_EXPORT uint8_t l_Array_anyMUnsafe_any___at_Array_all___spec__1___rarg(lean_object*, lean_object*, size_t, size_t); lean_object* l_Lean_Name_mkStr4(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findM_x3f___rarg(lean_object*, lean_object*, lean_object*); lean_object* l_List_redLength___rarg(lean_object*); LEAN_EXPORT lean_object* l_Array_swapAt___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRev_x3f___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_all___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__15; lean_object* lean_string_append(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_getLit___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_toListLitAux(lean_object*); LEAN_EXPORT lean_object* l_Array_insertAt___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop(lean_object*, lean_object*, lean_object*); lean_object* lean_array_get_size(lean_object*); LEAN_EXPORT lean_object* l_Array_shrink___rarg___boxed(lean_object*, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__3; LEAN_EXPORT lean_object* l_Array_indexOfAux___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Array_instReprArray___rarg___closed__7; LEAN_EXPORT lean_object* l_Array_zipWithAux___at_Array_zip___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_findM_x3f(lean_object*, lean_object*); uint8_t lean_nat_dec_le(lean_object*, lean_object*); static lean_object* l_Array_instReprArray___rarg___closed__5; LEAN_EXPORT lean_object* l_Array_getIdx_x3f___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_instReprArray___rarg(lean_object*, lean_object*, lean_object*); uint8_t lean_usize_dec_lt(size_t, size_t); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_unzip___spec__1___rarg(lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__3___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_nat_add(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapM_map___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__9; LEAN_EXPORT lean_object* l_Array_findIdx_x3f___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_swap___boxed(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_zipWith(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_instBEqArray___rarg___boxed(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_forIn_loop(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldrM_fold___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_allM___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Array_find_x3f___rarg___closed__1; LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_split___spec__1(lean_object*); LEAN_EXPORT lean_object* l_Array_indexOf_x3f(lean_object*); LEAN_EXPORT lean_object* l_Array_find_x3f___rarg___lambda__1(lean_object*); LEAN_EXPORT lean_object* l_Array_mapIdxM___rarg(lean_object*, lean_object*, lean_object*); lean_object* l_String_toSubstring_x27(lean_object*); LEAN_EXPORT lean_object* l_Array_takeWhile___rarg___boxed(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe(lean_object*, lean_object*, lean_object*); lean_object* lean_array_uset(lean_object*, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_filterMap___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_getEvenElems(lean_object*); lean_object* lean_array_get(lean_object*, lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__8; LEAN_EXPORT uint8_t l_Array_anyMUnsafe_any___at_Array_any___spec__1___rarg(lean_object*, lean_object*, size_t, size_t); LEAN_EXPORT lean_object* l_Array_mapIdxM_map___at_Array_mapIdx___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_allM(lean_object*, lean_object*); static lean_object* l_term_x23_x5b___x2c_x5d___closed__18; LEAN_EXPORT lean_object* l_Array_findSomeM_x3f___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_eraseIdxSzAux___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_instForInArray___rarg(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mapIdx___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_popWhile___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_term_x23_x5b___x2c_x5d; LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__1___rarg(lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_toArrayLit___rarg___boxed(lean_object*, lean_object*, lean_object*); static lean_object* l_Array_instReprArray___rarg___closed__10; lean_object* l_Nat_repr(lean_object*); LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__1(lean_object*, uint8_t); LEAN_EXPORT lean_object* l_Array_anyMUnsafe(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_instToStringArray(lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterMap___spec__2___rarg(lean_object*, lean_object*, size_t, size_t, lean_object*); LEAN_EXPORT lean_object* l_Array_instToStringArray___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_contains(lean_object*); LEAN_EXPORT lean_object* l_Array_eraseIdx(lean_object*); LEAN_EXPORT lean_object* l_Array_find_x3f___rarg(lean_object*, lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__7; LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_split(lean_object*); static lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__2; LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__2___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_List_toArrayAux___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_foldlMUnsafe___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Array_partition___rarg___closed__1; LEAN_EXPORT lean_object* l_Array_unzip___rarg___boxed(lean_object*); static lean_object* l_Array_getEvenElems___rarg___closed__1; LEAN_EXPORT lean_object* l_Array_eraseIdx_x27___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_insertAt___rarg(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_modifyMUnsafe___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT uint8_t l_Array_isEmpty___rarg(lean_object*); LEAN_EXPORT lean_object* l_Array_find_x3f(lean_object*); LEAN_EXPORT lean_object* l_Array_get_x3f___rarg(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Array_mkArray___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_mk_array(x_2, x_3); return x_4; } } static lean_object* _init_l_Array_instEmptyCollectionArray___closed__1() { _start: { lean_object* x_1; lean_object* x_2; x_1 = lean_unsigned_to_nat(0u); x_2 = lean_mk_empty_array_with_capacity(x_1); return x_2; } } LEAN_EXPORT lean_object* l_Array_instEmptyCollectionArray(lean_object* x_1) { _start: { lean_object* x_2; x_2 = l_Array_instEmptyCollectionArray___closed__1; return x_2; } } LEAN_EXPORT lean_object* l_Array_instInhabitedArray(lean_object* x_1) { _start: { lean_object* x_2; x_2 = l_Array_instEmptyCollectionArray___closed__1; return x_2; } } LEAN_EXPORT uint8_t l_Array_isEmpty___rarg(lean_object* x_1) { _start: { lean_object* x_2; lean_object* x_3; uint8_t x_4; x_2 = lean_array_get_size(x_1); x_3 = lean_unsigned_to_nat(0u); x_4 = lean_nat_dec_eq(x_2, x_3); lean_dec(x_2); return x_4; } } LEAN_EXPORT lean_object* l_Array_isEmpty(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_isEmpty___rarg___boxed), 1, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_isEmpty___rarg___boxed(lean_object* x_1) { _start: { uint8_t x_2; lean_object* x_3; x_2 = l_Array_isEmpty___rarg(x_1); lean_dec(x_1); x_3 = lean_box(x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_singleton___rarg(lean_object* x_1) { _start: { lean_object* x_2; lean_object* x_3; x_2 = lean_unsigned_to_nat(1u); x_3 = lean_mk_array(x_2, x_1); return x_3; } } LEAN_EXPORT lean_object* l_Array_singleton(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_singleton___rarg), 1, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_uget___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { size_t x_5; lean_object* x_6; x_5 = lean_unbox_usize(x_3); lean_dec(x_3); x_6 = lean_array_uget(x_2, x_5); lean_dec(x_2); return x_6; } } static lean_object* _init_l_Array_instGetElemArrayUSizeLtNatInstLTNatToNatSize___closed__1() { _start: { lean_object* x_1; x_1 = lean_alloc_closure((void*)(l_Array_uget___boxed), 4, 1); lean_closure_set(x_1, 0, lean_box(0)); return x_1; } } LEAN_EXPORT lean_object* l_Array_instGetElemArrayUSizeLtNatInstLTNatToNatSize(lean_object* x_1) { _start: { lean_object* x_2; x_2 = l_Array_instGetElemArrayUSizeLtNatInstLTNatToNatSize___closed__1; return x_2; } } LEAN_EXPORT lean_object* l_Array_back___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_3 = lean_array_get_size(x_2); x_4 = lean_unsigned_to_nat(1u); x_5 = lean_nat_sub(x_3, x_4); lean_dec(x_3); x_6 = lean_array_get(x_1, x_2, x_5); lean_dec(x_5); return x_6; } } LEAN_EXPORT lean_object* l_Array_back(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_back___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_back___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_back___rarg(x_1, x_2); lean_dec(x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_get_x3f___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; uint8_t x_4; x_3 = lean_array_get_size(x_1); x_4 = lean_nat_dec_lt(x_2, x_3); lean_dec(x_3); if (x_4 == 0) { lean_object* x_5; x_5 = lean_box(0); return x_5; } else { lean_object* x_6; lean_object* x_7; x_6 = lean_array_fget(x_1, x_2); x_7 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_7, 0, x_6); return x_7; } } } LEAN_EXPORT lean_object* l_Array_get_x3f(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_get_x3f___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_get_x3f___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_get_x3f___rarg(x_1, x_2); lean_dec(x_2); lean_dec(x_1); return x_3; } } LEAN_EXPORT lean_object* l_Array_back_x3f___rarg(lean_object* x_1) { _start: { lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; x_2 = lean_array_get_size(x_1); x_3 = lean_unsigned_to_nat(1u); x_4 = lean_nat_sub(x_2, x_3); lean_dec(x_2); x_5 = l_Array_get_x3f___rarg(x_1, x_4); lean_dec(x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_back_x3f(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_back_x3f___rarg___boxed), 1, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_back_x3f___rarg___boxed(lean_object* x_1) { _start: { lean_object* x_2; x_2 = l_Array_back_x3f___rarg(x_1); lean_dec(x_1); return x_2; } } LEAN_EXPORT lean_object* l_Array_getLit___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = lean_array_fget(x_1, x_2); return x_5; } } LEAN_EXPORT lean_object* l_Array_getLit(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_getLit___rarg___boxed), 4, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_getLit___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_getLit___rarg(x_1, x_2, x_3, x_4); lean_dec(x_2); lean_dec(x_1); return x_5; } } LEAN_EXPORT lean_object* l_Array_getLit___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_getLit(x_1, x_2); lean_dec(x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_uset___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; lean_object* x_7; x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = lean_array_uset(x_2, x_6, x_4); return x_7; } } LEAN_EXPORT lean_object* l_Array_swap___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = lean_array_fswap(x_2, x_3, x_4); lean_dec(x_4); lean_dec(x_3); return x_5; } } LEAN_EXPORT lean_object* l_Array_swap_x21___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = lean_array_swap(x_2, x_3, x_4); lean_dec(x_4); lean_dec(x_3); return x_5; } } LEAN_EXPORT lean_object* l_Array_swapAt___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; x_4 = lean_array_fget(x_1, x_2); x_5 = lean_array_fset(x_1, x_2, x_3); x_6 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_6, 0, x_4); lean_ctor_set(x_6, 1, x_5); return x_6; } } LEAN_EXPORT lean_object* l_Array_swapAt(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_swapAt___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_swapAt___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_swapAt___rarg(x_1, x_2, x_3); lean_dec(x_2); return x_4; } } LEAN_EXPORT lean_object* l_panic___at_Array_swapAt_x21___spec__1___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; lean_object* x_5; x_3 = l_Array_instEmptyCollectionArray___closed__1; x_4 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_4, 0, x_1); lean_ctor_set(x_4, 1, x_3); x_5 = lean_panic_fn(x_4, x_2); return x_5; } } LEAN_EXPORT lean_object* l_panic___at_Array_swapAt_x21___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_panic___at_Array_swapAt_x21___spec__1___rarg), 2, 0); return x_2; } } static lean_object* _init_l_Array_swapAt_x21___rarg___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("index ", 6); return x_1; } } static lean_object* _init_l_Array_swapAt_x21___rarg___closed__2() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes(" out of bounds", 14); return x_1; } } static lean_object* _init_l_Array_swapAt_x21___rarg___closed__3() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("Init.Data.Array.Basic", 21); return x_1; } } static lean_object* _init_l_Array_swapAt_x21___rarg___closed__4() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("Array.swapAt!", 13); return x_1; } } LEAN_EXPORT lean_object* l_Array_swapAt_x21___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; uint8_t x_5; x_4 = lean_array_get_size(x_1); x_5 = lean_nat_dec_lt(x_2, x_4); lean_dec(x_4); if (x_5 == 0) { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_dec(x_1); x_6 = l_Nat_repr(x_2); x_7 = l_Array_swapAt_x21___rarg___closed__1; x_8 = lean_string_append(x_7, x_6); lean_dec(x_6); x_9 = l_Array_swapAt_x21___rarg___closed__2; x_10 = lean_string_append(x_8, x_9); x_11 = l_Array_swapAt_x21___rarg___closed__3; x_12 = l_Array_swapAt_x21___rarg___closed__4; x_13 = lean_unsigned_to_nat(99u); x_14 = lean_unsigned_to_nat(4u); x_15 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_11, x_12, x_13, x_14, x_10); lean_dec(x_10); x_16 = l_panic___at_Array_swapAt_x21___spec__1___rarg(x_3, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; x_17 = lean_array_fget(x_1, x_2); x_18 = lean_array_fset(x_1, x_2, x_3); lean_dec(x_2); x_19 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_19, 0, x_17); lean_ctor_set(x_19, 1, x_18); return x_19; } } } LEAN_EXPORT lean_object* l_Array_swapAt_x21(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_swapAt_x21___rarg), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_pop___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_array_pop(x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_shrink_loop___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; uint8_t x_4; x_3 = lean_unsigned_to_nat(0u); x_4 = lean_nat_dec_eq(x_1, x_3); if (x_4 == 0) { lean_object* x_5; lean_object* x_6; lean_object* x_7; x_5 = lean_unsigned_to_nat(1u); x_6 = lean_nat_sub(x_1, x_5); lean_dec(x_1); x_7 = lean_array_pop(x_2); x_1 = x_6; x_2 = x_7; goto _start; } else { lean_dec(x_1); return x_2; } } } LEAN_EXPORT lean_object* l_Array_shrink_loop(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_shrink_loop___rarg), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_shrink___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; lean_object* x_5; x_3 = lean_array_get_size(x_1); x_4 = lean_nat_sub(x_3, x_2); lean_dec(x_3); x_5 = l_Array_shrink_loop___rarg(x_4, x_1); return x_5; } } LEAN_EXPORT lean_object* l_Array_shrink(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_shrink___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_shrink___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_shrink___rarg(x_1, x_2); lean_dec(x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_modifyMUnsafe___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; x_5 = lean_ctor_get(x_1, 0); lean_inc(x_5); lean_dec(x_1); x_6 = lean_ctor_get(x_5, 1); lean_inc(x_6); lean_dec(x_5); x_7 = lean_array_fset(x_2, x_3, x_4); x_8 = lean_apply_2(x_6, lean_box(0), x_7); return x_8; } } LEAN_EXPORT lean_object* l_Array_modifyMUnsafe___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; uint8_t x_6; x_5 = lean_array_get_size(x_2); x_6 = lean_nat_dec_lt(x_3, x_5); lean_dec(x_5); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_dec(x_4); lean_dec(x_3); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = lean_apply_2(x_8, lean_box(0), x_2); return x_9; } else { lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; x_10 = lean_array_fget(x_2, x_3); x_11 = lean_box(0); x_12 = lean_array_fset(x_2, x_3, x_11); x_13 = lean_ctor_get(x_1, 1); lean_inc(x_13); x_14 = lean_apply_1(x_4, x_10); x_15 = lean_alloc_closure((void*)(l_Array_modifyMUnsafe___rarg___lambda__1___boxed), 4, 3); lean_closure_set(x_15, 0, x_1); lean_closure_set(x_15, 1, x_12); lean_closure_set(x_15, 2, x_3); x_16 = lean_apply_4(x_13, lean_box(0), lean_box(0), x_14, x_15); return x_16; } } } LEAN_EXPORT lean_object* l_Array_modifyMUnsafe(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_modifyMUnsafe___rarg), 4, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_modifyMUnsafe___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_modifyMUnsafe___rarg___lambda__1(x_1, x_2, x_3, x_4); lean_dec(x_3); return x_5; } } LEAN_EXPORT lean_object* l_Array_modify___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; uint8_t x_5; x_4 = lean_array_get_size(x_1); x_5 = lean_nat_dec_lt(x_2, x_4); lean_dec(x_4); if (x_5 == 0) { lean_dec(x_3); return x_1; } else { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; x_6 = lean_array_fget(x_1, x_2); x_7 = lean_box(0); x_8 = lean_array_fset(x_1, x_2, x_7); x_9 = lean_apply_1(x_3, x_6); x_10 = lean_array_fset(x_8, x_2, x_9); return x_10; } } } LEAN_EXPORT lean_object* l_Array_modify(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_modify___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_modify___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_modify___rarg(x_1, x_2, x_3); lean_dec(x_2); return x_4; } } LEAN_EXPORT lean_object* l_Array_modifyOp___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; uint8_t x_5; x_4 = lean_array_get_size(x_1); x_5 = lean_nat_dec_lt(x_2, x_4); lean_dec(x_4); if (x_5 == 0) { lean_dec(x_3); return x_1; } else { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; x_6 = lean_array_fget(x_1, x_2); x_7 = lean_box(0); x_8 = lean_array_fset(x_1, x_2, x_7); x_9 = lean_apply_1(x_3, x_6); x_10 = lean_array_fset(x_8, x_2, x_9); return x_10; } } } LEAN_EXPORT lean_object* l_Array_modifyOp(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_modifyOp___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_modifyOp___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_modifyOp___rarg(x_1, x_2, x_3); lean_dec(x_2); return x_4; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___rarg___lambda__1(lean_object* x_1, size_t x_2, lean_object* x_3, lean_object* x_4, size_t x_5, lean_object* x_6) { _start: { if (lean_obj_tag(x_6) == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_dec(x_4); lean_dec(x_3); x_7 = lean_ctor_get(x_6, 0); lean_inc(x_7); lean_dec(x_6); x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = lean_apply_2(x_9, lean_box(0), x_7); return x_10; } else { lean_object* x_11; size_t x_12; size_t x_13; lean_object* x_14; x_11 = lean_ctor_get(x_6, 0); lean_inc(x_11); lean_dec(x_6); x_12 = 1; x_13 = lean_usize_add(x_2, x_12); x_14 = l_Array_forInUnsafe_loop___rarg(x_1, x_3, x_4, x_5, x_13, x_11); return x_14; } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_lt(x_5, x_4); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_dec(x_3); lean_dec(x_2); x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = lean_apply_2(x_9, lean_box(0), x_6); return x_10; } else { lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; x_11 = lean_array_uget(x_2, x_5); x_12 = lean_ctor_get(x_1, 1); lean_inc(x_12); lean_inc(x_3); x_13 = lean_apply_2(x_3, x_11, x_6); x_14 = lean_box_usize(x_5); x_15 = lean_box_usize(x_4); x_16 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___rarg___lambda__1___boxed), 6, 5); lean_closure_set(x_16, 0, x_1); lean_closure_set(x_16, 1, x_14); lean_closure_set(x_16, 2, x_2); lean_closure_set(x_16, 3, x_3); lean_closure_set(x_16, 4, x_15); x_17 = lean_apply_4(x_12, lean_box(0), lean_box(0), x_13, x_16); return x_17; } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___rarg___boxed), 6, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_2); lean_dec(x_2); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_forInUnsafe_loop___rarg___lambda__1(x_1, x_7, x_3, x_4, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_forInUnsafe_loop___rarg(x_1, x_2, x_3, x_7, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; size_t x_6; size_t x_7; lean_object* x_8; x_5 = lean_array_get_size(x_2); x_6 = lean_usize_of_nat(x_5); lean_dec(x_5); x_7 = 0; x_8 = l_Array_forInUnsafe_loop___rarg(x_1, x_2, x_4, x_6, x_7, x_3); return x_8; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_forInUnsafe___rarg), 4, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_forIn_loop___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { if (lean_obj_tag(x_5) == 0) { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_dec(x_3); lean_dec(x_2); x_6 = lean_ctor_get(x_5, 0); lean_inc(x_6); lean_dec(x_5); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = lean_apply_2(x_8, lean_box(0), x_6); return x_9; } else { lean_object* x_10; lean_object* x_11; x_10 = lean_ctor_get(x_5, 0); lean_inc(x_10); lean_dec(x_5); x_11 = l_Array_forIn_loop___rarg(x_1, x_2, x_3, x_4, lean_box(0), x_10); return x_11; } } } LEAN_EXPORT lean_object* l_Array_forIn_loop___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { lean_object* x_7; uint8_t x_8; x_7 = lean_unsigned_to_nat(0u); x_8 = lean_nat_dec_eq(x_4, x_7); if (x_8 == 0) { lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; x_9 = lean_unsigned_to_nat(1u); x_10 = lean_nat_sub(x_4, x_9); x_11 = lean_ctor_get(x_1, 1); lean_inc(x_11); x_12 = lean_array_get_size(x_2); x_13 = lean_nat_sub(x_12, x_9); lean_dec(x_12); x_14 = lean_nat_sub(x_13, x_10); lean_dec(x_13); x_15 = lean_array_fget(x_2, x_14); lean_dec(x_14); lean_inc(x_3); x_16 = lean_apply_2(x_3, x_15, x_6); x_17 = lean_alloc_closure((void*)(l_Array_forIn_loop___rarg___lambda__1___boxed), 5, 4); lean_closure_set(x_17, 0, x_1); lean_closure_set(x_17, 1, x_2); lean_closure_set(x_17, 2, x_3); lean_closure_set(x_17, 3, x_10); x_18 = lean_apply_4(x_11, lean_box(0), lean_box(0), x_16, x_17); return x_18; } else { lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_dec(x_3); lean_dec(x_2); x_19 = lean_ctor_get(x_1, 0); lean_inc(x_19); lean_dec(x_1); x_20 = lean_ctor_get(x_19, 1); lean_inc(x_20); lean_dec(x_19); x_21 = lean_apply_2(x_20, lean_box(0), x_6); return x_21; } } } LEAN_EXPORT lean_object* l_Array_forIn_loop(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_forIn_loop___rarg___boxed), 6, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_forIn_loop___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_forIn_loop___rarg___lambda__1(x_1, x_2, x_3, x_4, x_5); lean_dec(x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_forIn_loop___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { lean_object* x_7; x_7 = l_Array_forIn_loop___rarg(x_1, x_2, x_3, x_4, x_5, x_6); lean_dec(x_4); return x_7; } } LEAN_EXPORT lean_object* l_Array_instForInArray___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; size_t x_6; size_t x_7; lean_object* x_8; x_5 = lean_array_get_size(x_2); x_6 = lean_usize_of_nat(x_5); lean_dec(x_5); x_7 = 0; x_8 = l_Array_forInUnsafe_loop___rarg(x_1, x_2, x_4, x_6, x_7, x_3); return x_8; } } LEAN_EXPORT lean_object* l_Array_instForInArray(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_instForInArray___rarg), 4, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___rarg___lambda__1(size_t x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, size_t x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = 1; x_8 = lean_usize_add(x_1, x_7); x_9 = l_Array_foldlMUnsafe_fold___rarg(x_2, x_3, x_4, x_8, x_5, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_eq(x_4, x_5); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; x_8 = lean_ctor_get(x_1, 1); lean_inc(x_8); x_9 = lean_array_uget(x_3, x_4); lean_inc(x_2); x_10 = lean_apply_2(x_2, x_6, x_9); x_11 = lean_box_usize(x_4); x_12 = lean_box_usize(x_5); x_13 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___rarg___lambda__1___boxed), 6, 5); lean_closure_set(x_13, 0, x_11); lean_closure_set(x_13, 1, x_1); lean_closure_set(x_13, 2, x_2); lean_closure_set(x_13, 3, x_3); lean_closure_set(x_13, 4, x_12); x_14 = lean_apply_4(x_8, lean_box(0), lean_box(0), x_10, x_13); return x_14; } else { lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_dec(x_3); lean_dec(x_2); x_15 = lean_ctor_get(x_1, 0); lean_inc(x_15); lean_dec(x_1); x_16 = lean_ctor_get(x_15, 1); lean_inc(x_16); lean_dec(x_15); x_17 = lean_apply_2(x_16, lean_box(0), x_6); return x_17; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___rarg___boxed), 6, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_1); lean_dec(x_1); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldlMUnsafe_fold___rarg___lambda__1(x_7, x_2, x_3, x_4, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldlMUnsafe_fold___rarg(x_1, x_2, x_3, x_7, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_nat_dec_lt(x_5, x_6); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_dec(x_4); lean_dec(x_2); x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = lean_apply_2(x_9, lean_box(0), x_3); return x_10; } else { lean_object* x_11; uint8_t x_12; x_11 = lean_array_get_size(x_4); x_12 = lean_nat_dec_le(x_6, x_11); lean_dec(x_11); if (x_12 == 0) { lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_dec(x_4); lean_dec(x_2); x_13 = lean_ctor_get(x_1, 0); lean_inc(x_13); lean_dec(x_1); x_14 = lean_ctor_get(x_13, 1); lean_inc(x_14); lean_dec(x_13); x_15 = lean_apply_2(x_14, lean_box(0), x_3); return x_15; } else { size_t x_16; size_t x_17; lean_object* x_18; x_16 = lean_usize_of_nat(x_5); x_17 = lean_usize_of_nat(x_6); x_18 = l_Array_foldlMUnsafe_fold___rarg(x_1, x_2, x_4, x_16, x_17, x_3); return x_18; } } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe___rarg___boxed), 6, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { lean_object* x_7; x_7 = l_Array_foldlMUnsafe___rarg(x_1, x_2, x_3, x_4, x_5, x_6); lean_dec(x_6); lean_dec(x_5); return x_7; } } LEAN_EXPORT lean_object* l_Array_foldlM_loop___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; lean_object* x_9; lean_object* x_10; x_8 = lean_unsigned_to_nat(1u); x_9 = lean_nat_add(x_1, x_8); lean_dec(x_1); x_10 = l_Array_foldlM_loop___rarg(x_2, x_3, x_4, x_5, lean_box(0), x_6, x_9, x_7); return x_10; } } LEAN_EXPORT lean_object* l_Array_foldlM_loop___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { uint8_t x_9; x_9 = lean_nat_dec_lt(x_7, x_4); if (x_9 == 0) { lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_dec(x_7); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_10 = lean_ctor_get(x_1, 0); lean_inc(x_10); lean_dec(x_1); x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); x_12 = lean_apply_2(x_11, lean_box(0), x_8); return x_12; } else { lean_object* x_13; uint8_t x_14; x_13 = lean_unsigned_to_nat(0u); x_14 = lean_nat_dec_eq(x_6, x_13); if (x_14 == 0) { lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; x_15 = lean_unsigned_to_nat(1u); x_16 = lean_nat_sub(x_6, x_15); x_17 = lean_ctor_get(x_1, 1); lean_inc(x_17); x_18 = lean_array_fget(x_3, x_7); lean_inc(x_2); x_19 = lean_apply_2(x_2, x_8, x_18); x_20 = lean_alloc_closure((void*)(l_Array_foldlM_loop___rarg___lambda__1___boxed), 7, 6); lean_closure_set(x_20, 0, x_7); lean_closure_set(x_20, 1, x_1); lean_closure_set(x_20, 2, x_2); lean_closure_set(x_20, 3, x_3); lean_closure_set(x_20, 4, x_4); lean_closure_set(x_20, 5, x_16); x_21 = lean_apply_4(x_17, lean_box(0), lean_box(0), x_19, x_20); return x_21; } else { lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_dec(x_7); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_22 = lean_ctor_get(x_1, 0); lean_inc(x_22); lean_dec(x_1); x_23 = lean_ctor_get(x_22, 1); lean_inc(x_23); lean_dec(x_22); x_24 = lean_apply_2(x_23, lean_box(0), x_8); return x_24; } } } } LEAN_EXPORT lean_object* l_Array_foldlM_loop(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_foldlM_loop___rarg___boxed), 8, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_foldlM_loop___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; x_8 = l_Array_foldlM_loop___rarg___lambda__1(x_1, x_2, x_3, x_4, x_5, x_6, x_7); lean_dec(x_6); return x_8; } } LEAN_EXPORT lean_object* l_Array_foldlM_loop___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; x_9 = l_Array_foldlM_loop___rarg(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8); lean_dec(x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_eq(x_4, x_5); if (x_7 == 0) { lean_object* x_8; size_t x_9; size_t x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; x_8 = lean_ctor_get(x_1, 1); lean_inc(x_8); x_9 = 1; x_10 = lean_usize_sub(x_4, x_9); x_11 = lean_array_uget(x_3, x_10); lean_inc(x_2); x_12 = lean_apply_2(x_2, x_11, x_6); x_13 = lean_box_usize(x_10); x_14 = lean_box_usize(x_5); x_15 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe_fold___rarg___boxed), 6, 5); lean_closure_set(x_15, 0, x_1); lean_closure_set(x_15, 1, x_2); lean_closure_set(x_15, 2, x_3); lean_closure_set(x_15, 3, x_13); lean_closure_set(x_15, 4, x_14); x_16 = lean_apply_4(x_8, lean_box(0), lean_box(0), x_12, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_dec(x_3); lean_dec(x_2); x_17 = lean_ctor_get(x_1, 0); lean_inc(x_17); lean_dec(x_1); x_18 = lean_ctor_get(x_17, 1); lean_inc(x_18); lean_dec(x_17); x_19 = lean_apply_2(x_18, lean_box(0), x_6); return x_19; } } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe_fold___rarg___boxed), 6, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldrMUnsafe_fold___rarg(x_1, x_2, x_3, x_7, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { lean_object* x_7; uint8_t x_8; x_7 = lean_array_get_size(x_4); x_8 = lean_nat_dec_le(x_5, x_7); if (x_8 == 0) { uint8_t x_9; x_9 = lean_nat_dec_lt(x_6, x_7); if (x_9 == 0) { lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_dec(x_7); lean_dec(x_4); lean_dec(x_2); x_10 = lean_ctor_get(x_1, 0); lean_inc(x_10); lean_dec(x_1); x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); x_12 = lean_apply_2(x_11, lean_box(0), x_3); return x_12; } else { size_t x_13; size_t x_14; lean_object* x_15; x_13 = lean_usize_of_nat(x_7); lean_dec(x_7); x_14 = lean_usize_of_nat(x_6); x_15 = l_Array_foldrMUnsafe_fold___rarg(x_1, x_2, x_4, x_13, x_14, x_3); return x_15; } } else { uint8_t x_16; lean_dec(x_7); x_16 = lean_nat_dec_lt(x_6, x_5); if (x_16 == 0) { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_dec(x_4); lean_dec(x_2); x_17 = lean_ctor_get(x_1, 0); lean_inc(x_17); lean_dec(x_1); x_18 = lean_ctor_get(x_17, 1); lean_inc(x_18); lean_dec(x_17); x_19 = lean_apply_2(x_18, lean_box(0), x_3); return x_19; } else { size_t x_20; size_t x_21; lean_object* x_22; x_20 = lean_usize_of_nat(x_5); x_21 = lean_usize_of_nat(x_6); x_22 = l_Array_foldrMUnsafe_fold___rarg(x_1, x_2, x_4, x_20, x_21, x_3); return x_22; } } } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe___rarg___boxed), 6, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { lean_object* x_7; x_7 = l_Array_foldrMUnsafe___rarg(x_1, x_2, x_3, x_4, x_5, x_6); lean_dec(x_6); lean_dec(x_5); return x_7; } } LEAN_EXPORT lean_object* l_Array_foldrM_fold___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { uint8_t x_8; x_8 = lean_nat_dec_eq(x_5, x_4); if (x_8 == 0) { lean_object* x_9; uint8_t x_10; x_9 = lean_unsigned_to_nat(0u); x_10 = lean_nat_dec_eq(x_5, x_9); if (x_10 == 0) { lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; x_11 = lean_unsigned_to_nat(1u); x_12 = lean_nat_sub(x_5, x_11); x_13 = lean_ctor_get(x_1, 1); lean_inc(x_13); x_14 = lean_array_fget(x_3, x_12); lean_inc(x_2); x_15 = lean_apply_2(x_2, x_14, x_7); x_16 = lean_alloc_closure((void*)(l_Array_foldrM_fold___rarg___boxed), 7, 6); lean_closure_set(x_16, 0, x_1); lean_closure_set(x_16, 1, x_2); lean_closure_set(x_16, 2, x_3); lean_closure_set(x_16, 3, x_4); lean_closure_set(x_16, 4, x_12); lean_closure_set(x_16, 5, lean_box(0)); x_17 = lean_apply_4(x_13, lean_box(0), lean_box(0), x_15, x_16); return x_17; } else { lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_18 = lean_ctor_get(x_1, 0); lean_inc(x_18); lean_dec(x_1); x_19 = lean_ctor_get(x_18, 1); lean_inc(x_19); lean_dec(x_18); x_20 = lean_apply_2(x_19, lean_box(0), x_7); return x_20; } } else { lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_21 = lean_ctor_get(x_1, 0); lean_inc(x_21); lean_dec(x_1); x_22 = lean_ctor_get(x_21, 1); lean_inc(x_22); lean_dec(x_21); x_23 = lean_apply_2(x_22, lean_box(0), x_7); return x_23; } } } LEAN_EXPORT lean_object* l_Array_foldrM_fold(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_foldrM_fold___rarg___boxed), 7, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_foldrM_fold___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; x_8 = l_Array_foldrM_fold___rarg(x_1, x_2, x_3, x_4, x_5, x_6, x_7); lean_dec(x_5); return x_8; } } LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___rarg___lambda__1(size_t x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, size_t x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; lean_object* x_10; x_7 = 1; x_8 = lean_usize_add(x_1, x_7); x_9 = lean_array_uset(x_2, x_1, x_6); x_10 = l_Array_mapMUnsafe_map___rarg(x_3, x_4, x_5, x_8, x_9); return x_10; } } LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_lt(x_4, x_3); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_dec(x_2); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = lean_apply_2(x_8, lean_box(0), x_5); return x_9; } else { lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; x_10 = lean_array_uget(x_5, x_4); x_11 = lean_unsigned_to_nat(0u); x_12 = lean_array_uset(x_5, x_4, x_11); x_13 = lean_ctor_get(x_1, 1); lean_inc(x_13); lean_inc(x_2); x_14 = lean_apply_1(x_2, x_10); x_15 = lean_box_usize(x_4); x_16 = lean_box_usize(x_3); x_17 = lean_alloc_closure((void*)(l_Array_mapMUnsafe_map___rarg___lambda__1___boxed), 6, 5); lean_closure_set(x_17, 0, x_15); lean_closure_set(x_17, 1, x_12); lean_closure_set(x_17, 2, x_1); lean_closure_set(x_17, 3, x_2); lean_closure_set(x_17, 4, x_16); x_18 = lean_apply_4(x_13, lean_box(0), lean_box(0), x_14, x_17); return x_18; } } } LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_mapMUnsafe_map___rarg___boxed), 5, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_1); lean_dec(x_1); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_mapMUnsafe_map___rarg___lambda__1(x_7, x_2, x_3, x_4, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; lean_object* x_8; x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = l_Array_mapMUnsafe_map___rarg(x_1, x_2, x_6, x_7, x_5); return x_8; } } LEAN_EXPORT lean_object* l_Array_mapMUnsafe___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; size_t x_5; size_t x_6; lean_object* x_7; x_4 = lean_array_get_size(x_3); x_5 = lean_usize_of_nat(x_4); lean_dec(x_4); x_6 = 0; x_7 = l_Array_mapMUnsafe_map___rarg(x_1, x_2, x_5, x_6, x_3); return x_7; } } LEAN_EXPORT lean_object* l_Array_mapMUnsafe(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_mapMUnsafe___rarg), 3, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_mapM_map___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; x_7 = lean_unsigned_to_nat(1u); x_8 = lean_nat_add(x_1, x_7); lean_dec(x_1); x_9 = lean_array_push(x_2, x_6); x_10 = l_Array_mapM_map___rarg(x_3, x_4, x_5, x_8, x_9); return x_10; } } LEAN_EXPORT lean_object* l_Array_mapM_map___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_array_get_size(x_3); x_7 = lean_nat_dec_lt(x_4, x_6); lean_dec(x_6); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = lean_apply_2(x_9, lean_box(0), x_5); return x_10; } else { lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; x_11 = lean_ctor_get(x_1, 1); lean_inc(x_11); x_12 = lean_array_fget(x_3, x_4); lean_inc(x_2); x_13 = lean_apply_1(x_2, x_12); x_14 = lean_alloc_closure((void*)(l_Array_mapM_map___rarg___lambda__1), 6, 5); lean_closure_set(x_14, 0, x_4); lean_closure_set(x_14, 1, x_5); lean_closure_set(x_14, 2, x_1); lean_closure_set(x_14, 3, x_2); lean_closure_set(x_14, 4, x_3); x_15 = lean_apply_4(x_11, lean_box(0), lean_box(0), x_13, x_14); return x_15; } } } LEAN_EXPORT lean_object* l_Array_mapM_map(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_mapM_map___rarg), 5, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_mapIdxM_map___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; x_8 = lean_unsigned_to_nat(1u); x_9 = lean_nat_add(x_1, x_8); lean_dec(x_1); x_10 = lean_array_push(x_2, x_7); x_11 = l_Array_mapIdxM_map___rarg(x_3, x_4, x_5, x_6, x_9, lean_box(0), x_10); return x_11; } } LEAN_EXPORT lean_object* l_Array_mapIdxM_map___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; uint8_t x_9; x_8 = lean_unsigned_to_nat(0u); x_9 = lean_nat_dec_eq(x_4, x_8); if (x_9 == 0) { lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; x_10 = lean_unsigned_to_nat(1u); x_11 = lean_nat_sub(x_4, x_10); x_12 = lean_ctor_get(x_1, 1); lean_inc(x_12); x_13 = lean_array_fget(x_2, x_5); lean_inc(x_3); lean_inc(x_5); x_14 = lean_apply_2(x_3, x_5, x_13); x_15 = lean_alloc_closure((void*)(l_Array_mapIdxM_map___rarg___lambda__1___boxed), 7, 6); lean_closure_set(x_15, 0, x_5); lean_closure_set(x_15, 1, x_7); lean_closure_set(x_15, 2, x_1); lean_closure_set(x_15, 3, x_2); lean_closure_set(x_15, 4, x_3); lean_closure_set(x_15, 5, x_11); x_16 = lean_apply_4(x_12, lean_box(0), lean_box(0), x_14, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_dec(x_5); lean_dec(x_3); lean_dec(x_2); x_17 = lean_ctor_get(x_1, 0); lean_inc(x_17); lean_dec(x_1); x_18 = lean_ctor_get(x_17, 1); lean_inc(x_18); lean_dec(x_17); x_19 = lean_apply_2(x_18, lean_box(0), x_7); return x_19; } } } LEAN_EXPORT lean_object* l_Array_mapIdxM_map(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_mapIdxM_map___rarg___boxed), 7, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_mapIdxM_map___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; x_8 = l_Array_mapIdxM_map___rarg___lambda__1(x_1, x_2, x_3, x_4, x_5, x_6, x_7); lean_dec(x_6); return x_8; } } LEAN_EXPORT lean_object* l_Array_mapIdxM_map___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; x_8 = l_Array_mapIdxM_map___rarg(x_1, x_2, x_3, x_4, x_5, x_6, x_7); lean_dec(x_4); return x_8; } } LEAN_EXPORT lean_object* l_Array_mapIdxM___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; lean_object* x_7; x_4 = lean_array_get_size(x_2); x_5 = lean_mk_empty_array_with_capacity(x_4); x_6 = lean_unsigned_to_nat(0u); x_7 = l_Array_mapIdxM_map___rarg(x_1, x_2, x_3, x_4, x_6, lean_box(0), x_5); lean_dec(x_4); return x_7; } } LEAN_EXPORT lean_object* l_Array_mapIdxM(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_mapIdxM___rarg), 3, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; x_4 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_4, 0, x_1); x_5 = lean_apply_2(x_2, lean_box(0), x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__2(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { if (lean_obj_tag(x_4) == 0) { lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; x_5 = lean_ctor_get(x_1, 0); lean_inc(x_5); lean_dec(x_1); x_6 = lean_ctor_get(x_5, 1); lean_inc(x_6); lean_dec(x_5); x_7 = lean_box(0); lean_inc(x_6); x_8 = lean_apply_2(x_6, lean_box(0), x_7); x_9 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__1___boxed), 3, 2); lean_closure_set(x_9, 0, x_2); lean_closure_set(x_9, 1, x_6); x_10 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_8, x_9); return x_10; } else { uint8_t x_11; lean_dec(x_3); lean_dec(x_2); x_11 = !lean_is_exclusive(x_4); if (x_11 == 0) { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; x_12 = lean_ctor_get(x_1, 0); lean_inc(x_12); lean_dec(x_1); x_13 = lean_ctor_get(x_12, 1); lean_inc(x_13); lean_dec(x_12); x_14 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_14, 0, x_4); x_15 = lean_box(0); x_16 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_16, 0, x_14); lean_ctor_set(x_16, 1, x_15); x_17 = lean_alloc_ctor(0, 1, 0); lean_ctor_set(x_17, 0, x_16); x_18 = lean_apply_2(x_13, lean_box(0), x_17); return x_18; } else { lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_object* x_25; lean_object* x_26; lean_object* x_27; x_19 = lean_ctor_get(x_4, 0); lean_inc(x_19); lean_dec(x_4); x_20 = lean_ctor_get(x_1, 0); lean_inc(x_20); lean_dec(x_1); x_21 = lean_ctor_get(x_20, 1); lean_inc(x_21); lean_dec(x_20); x_22 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_22, 0, x_19); x_23 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_23, 0, x_22); x_24 = lean_box(0); x_25 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_25, 0, x_23); lean_ctor_set(x_25, 1, x_24); x_26 = lean_alloc_ctor(0, 1, 0); lean_ctor_set(x_26, 0, x_25); x_27 = lean_apply_2(x_21, lean_box(0), x_26); return x_27; } } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__3(lean_object* x_1, size_t x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, size_t x_7, lean_object* x_8) { _start: { if (lean_obj_tag(x_8) == 0) { lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); x_9 = lean_ctor_get(x_8, 0); lean_inc(x_9); lean_dec(x_8); x_10 = lean_ctor_get(x_1, 0); lean_inc(x_10); lean_dec(x_1); x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); x_12 = lean_apply_2(x_11, lean_box(0), x_9); return x_12; } else { lean_object* x_13; size_t x_14; size_t x_15; lean_object* x_16; x_13 = lean_ctor_get(x_8, 0); lean_inc(x_13); lean_dec(x_8); x_14 = 1; x_15 = lean_usize_add(x_2, x_14); x_16 = l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg(x_1, x_3, x_4, x_5, x_6, x_7, x_15, x_13); return x_16; } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, size_t x_6, size_t x_7, lean_object* x_8) { _start: { uint8_t x_9; x_9 = lean_usize_dec_lt(x_7, x_6); if (x_9 == 0) { lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_10 = lean_ctor_get(x_1, 0); lean_inc(x_10); lean_dec(x_1); x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); x_12 = lean_apply_2(x_11, lean_box(0), x_8); return x_12; } else { lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_dec(x_8); x_13 = lean_array_uget(x_5, x_7); x_14 = lean_ctor_get(x_1, 1); lean_inc(x_14); lean_inc(x_2); x_15 = lean_apply_1(x_2, x_13); lean_inc(x_3); lean_inc(x_4); lean_inc(x_1); x_16 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__2), 4, 3); lean_closure_set(x_16, 0, x_1); lean_closure_set(x_16, 1, x_4); lean_closure_set(x_16, 2, x_3); lean_inc(x_3); x_17 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_15, x_16); x_18 = lean_box_usize(x_7); x_19 = lean_box_usize(x_6); x_20 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__3___boxed), 8, 7); lean_closure_set(x_20, 0, x_1); lean_closure_set(x_20, 1, x_18); lean_closure_set(x_20, 2, x_2); lean_closure_set(x_20, 3, x_3); lean_closure_set(x_20, 4, x_4); lean_closure_set(x_20, 5, x_5); lean_closure_set(x_20, 6, x_19); x_21 = lean_apply_4(x_14, lean_box(0), lean_box(0), x_17, x_20); return x_21; } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___boxed), 8, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_findSomeM_x3f___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; x_4 = lean_ctor_get(x_1, 0); lean_inc(x_4); lean_dec(x_1); x_5 = lean_ctor_get(x_4, 1); lean_inc(x_5); lean_dec(x_4); x_6 = lean_apply_2(x_5, lean_box(0), x_2); return x_6; } } LEAN_EXPORT lean_object* l_Array_findSomeM_x3f___rarg___lambda__2(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = lean_ctor_get(x_4, 0); lean_inc(x_5); lean_dec(x_4); if (lean_obj_tag(x_5) == 0) { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_inc(x_1); x_6 = lean_alloc_closure((void*)(l_Array_findSomeM_x3f___rarg___lambda__1___boxed), 3, 2); lean_closure_set(x_6, 0, x_1); lean_closure_set(x_6, 1, x_2); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = lean_box(0); x_10 = lean_apply_2(x_8, lean_box(0), x_9); x_11 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_10, x_6); return x_11; } else { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_dec(x_3); lean_dec(x_2); x_12 = lean_ctor_get(x_5, 0); lean_inc(x_12); lean_dec(x_5); x_13 = lean_ctor_get(x_1, 0); lean_inc(x_13); lean_dec(x_1); x_14 = lean_ctor_get(x_13, 1); lean_inc(x_14); lean_dec(x_13); x_15 = lean_apply_2(x_14, lean_box(0), x_12); return x_15; } } } static lean_object* _init_l_Array_findSomeM_x3f___rarg___closed__1() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = lean_box(0); x_3 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_3, 0, x_1); lean_ctor_set(x_3, 1, x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_findSomeM_x3f___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; size_t x_7; size_t x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; x_4 = lean_ctor_get(x_1, 1); lean_inc(x_4); x_5 = lean_box(0); x_6 = lean_array_get_size(x_2); x_7 = lean_usize_of_nat(x_6); lean_dec(x_6); x_8 = 0; x_9 = l_Array_findSomeM_x3f___rarg___closed__1; lean_inc(x_4); lean_inc(x_1); x_10 = l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg(x_1, x_3, x_4, x_9, x_2, x_7, x_8, x_9); lean_inc(x_4); x_11 = lean_alloc_closure((void*)(l_Array_findSomeM_x3f___rarg___lambda__2), 4, 3); lean_closure_set(x_11, 0, x_1); lean_closure_set(x_11, 1, x_5); lean_closure_set(x_11, 2, x_4); x_12 = lean_apply_4(x_4, lean_box(0), lean_box(0), x_10, x_11); return x_12; } } LEAN_EXPORT lean_object* l_Array_findSomeM_x3f(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_findSomeM_x3f___rarg), 3, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__1(x_1, x_2, x_3); lean_dec(x_3); return x_4; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__3___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { size_t x_9; size_t x_10; lean_object* x_11; x_9 = lean_unbox_usize(x_2); lean_dec(x_2); x_10 = lean_unbox_usize(x_7); lean_dec(x_7); x_11 = l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__3(x_1, x_9, x_3, x_4, x_5, x_6, x_10, x_8); return x_11; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { size_t x_9; size_t x_10; lean_object* x_11; x_9 = lean_unbox_usize(x_6); lean_dec(x_6); x_10 = lean_unbox_usize(x_7); lean_dec(x_7); x_11 = l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg(x_1, x_2, x_3, x_4, x_5, x_9, x_10, x_8); return x_11; } } LEAN_EXPORT lean_object* l_Array_findSomeM_x3f___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_findSomeM_x3f___rarg___lambda__1(x_1, x_2, x_3); lean_dec(x_3); return x_4; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, uint8_t x_5) { _start: { if (x_5 == 0) { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_dec(x_4); x_6 = lean_ctor_get(x_1, 0); lean_inc(x_6); lean_dec(x_1); x_7 = lean_ctor_get(x_6, 1); lean_inc(x_7); lean_dec(x_6); x_8 = lean_box(0); lean_inc(x_7); x_9 = lean_apply_2(x_7, lean_box(0), x_8); x_10 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findSomeM_x3f___spec__1___rarg___lambda__1___boxed), 3, 2); lean_closure_set(x_10, 0, x_2); lean_closure_set(x_10, 1, x_7); x_11 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_9, x_10); return x_11; } else { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_dec(x_3); lean_dec(x_2); x_12 = lean_ctor_get(x_1, 0); lean_inc(x_12); lean_dec(x_1); x_13 = lean_ctor_get(x_12, 1); lean_inc(x_13); lean_dec(x_12); x_14 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_14, 0, x_4); x_15 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_15, 0, x_14); x_16 = lean_box(0); x_17 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_17, 0, x_15); lean_ctor_set(x_17, 1, x_16); x_18 = lean_alloc_ctor(0, 1, 0); lean_ctor_set(x_18, 0, x_17); x_19 = lean_apply_2(x_13, lean_box(0), x_18); return x_19; } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__2(lean_object* x_1, size_t x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, size_t x_7, lean_object* x_8) { _start: { if (lean_obj_tag(x_8) == 0) { lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); x_9 = lean_ctor_get(x_8, 0); lean_inc(x_9); lean_dec(x_8); x_10 = lean_ctor_get(x_1, 0); lean_inc(x_10); lean_dec(x_1); x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); x_12 = lean_apply_2(x_11, lean_box(0), x_9); return x_12; } else { lean_object* x_13; size_t x_14; size_t x_15; lean_object* x_16; x_13 = lean_ctor_get(x_8, 0); lean_inc(x_13); lean_dec(x_8); x_14 = 1; x_15 = lean_usize_add(x_2, x_14); x_16 = l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg(x_1, x_3, x_4, x_5, x_6, x_7, x_15, x_13); return x_16; } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, size_t x_6, size_t x_7, lean_object* x_8) { _start: { uint8_t x_9; x_9 = lean_usize_dec_lt(x_7, x_6); if (x_9 == 0) { lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_10 = lean_ctor_get(x_1, 0); lean_inc(x_10); lean_dec(x_1); x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); x_12 = lean_apply_2(x_11, lean_box(0), x_8); return x_12; } else { lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_dec(x_8); x_13 = lean_array_uget(x_5, x_7); x_14 = lean_ctor_get(x_1, 1); lean_inc(x_14); lean_inc(x_2); lean_inc(x_13); x_15 = lean_apply_1(x_2, x_13); lean_inc(x_3); lean_inc(x_4); lean_inc(x_1); x_16 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__1___boxed), 5, 4); lean_closure_set(x_16, 0, x_1); lean_closure_set(x_16, 1, x_4); lean_closure_set(x_16, 2, x_3); lean_closure_set(x_16, 3, x_13); lean_inc(x_3); x_17 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_15, x_16); x_18 = lean_box_usize(x_7); x_19 = lean_box_usize(x_6); x_20 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__2___boxed), 8, 7); lean_closure_set(x_20, 0, x_1); lean_closure_set(x_20, 1, x_18); lean_closure_set(x_20, 2, x_2); lean_closure_set(x_20, 3, x_3); lean_closure_set(x_20, 4, x_4); lean_closure_set(x_20, 5, x_5); lean_closure_set(x_20, 6, x_19); x_21 = lean_apply_4(x_14, lean_box(0), lean_box(0), x_17, x_20); return x_21; } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___boxed), 8, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_findM_x3f___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = lean_ctor_get(x_4, 0); lean_inc(x_5); lean_dec(x_4); if (lean_obj_tag(x_5) == 0) { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_inc(x_1); x_6 = lean_alloc_closure((void*)(l_Array_findSomeM_x3f___rarg___lambda__1___boxed), 3, 2); lean_closure_set(x_6, 0, x_1); lean_closure_set(x_6, 1, x_2); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = lean_box(0); x_10 = lean_apply_2(x_8, lean_box(0), x_9); x_11 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_10, x_6); return x_11; } else { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_dec(x_3); lean_dec(x_2); x_12 = lean_ctor_get(x_5, 0); lean_inc(x_12); lean_dec(x_5); x_13 = lean_ctor_get(x_1, 0); lean_inc(x_13); lean_dec(x_1); x_14 = lean_ctor_get(x_13, 1); lean_inc(x_14); lean_dec(x_13); x_15 = lean_apply_2(x_14, lean_box(0), x_12); return x_15; } } } LEAN_EXPORT lean_object* l_Array_findM_x3f___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; size_t x_7; size_t x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; x_4 = lean_ctor_get(x_1, 1); lean_inc(x_4); x_5 = lean_box(0); x_6 = lean_array_get_size(x_2); x_7 = lean_usize_of_nat(x_6); lean_dec(x_6); x_8 = 0; x_9 = l_Array_findSomeM_x3f___rarg___closed__1; lean_inc(x_4); lean_inc(x_1); x_10 = l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg(x_1, x_3, x_4, x_9, x_2, x_7, x_8, x_9); lean_inc(x_4); x_11 = lean_alloc_closure((void*)(l_Array_findM_x3f___rarg___lambda__1), 4, 3); lean_closure_set(x_11, 0, x_1); lean_closure_set(x_11, 1, x_5); lean_closure_set(x_11, 2, x_4); x_12 = lean_apply_4(x_4, lean_box(0), lean_box(0), x_10, x_11); return x_12; } } LEAN_EXPORT lean_object* l_Array_findM_x3f(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_findM_x3f___rarg), 3, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { uint8_t x_6; lean_object* x_7; x_6 = lean_unbox(x_5); lean_dec(x_5); x_7 = l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__1(x_1, x_2, x_3, x_4, x_6); return x_7; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__2___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { size_t x_9; size_t x_10; lean_object* x_11; x_9 = lean_unbox_usize(x_2); lean_dec(x_2); x_10 = lean_unbox_usize(x_7); lean_dec(x_7); x_11 = l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___lambda__2(x_1, x_9, x_3, x_4, x_5, x_6, x_10, x_8); return x_11; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { size_t x_9; size_t x_10; lean_object* x_11; x_9 = lean_unbox_usize(x_6); lean_dec(x_6); x_10 = lean_unbox_usize(x_7); lean_dec(x_7); x_11 = l_Array_forInUnsafe_loop___at_Array_findM_x3f___spec__1___rarg(x_1, x_2, x_3, x_4, x_5, x_9, x_10, x_8); return x_11; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; lean_object* x_6; lean_object* x_7; x_5 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_5, 0, x_1); lean_ctor_set(x_5, 1, x_2); x_6 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_6, 0, x_5); x_7 = lean_apply_2(x_3, lean_box(0), x_6); return x_7; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__2(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; x_6 = lean_unsigned_to_nat(1u); x_7 = lean_nat_add(x_4, x_6); x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = lean_box(0); lean_inc(x_9); x_11 = lean_apply_2(x_9, lean_box(0), x_10); x_12 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__1___boxed), 4, 3); lean_closure_set(x_12, 0, x_2); lean_closure_set(x_12, 1, x_7); lean_closure_set(x_12, 2, x_9); x_13 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_11, x_12); return x_13; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__3(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, uint8_t x_5) { _start: { if (x_5 == 0) { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; x_6 = lean_ctor_get(x_1, 0); lean_inc(x_6); x_7 = lean_ctor_get(x_6, 1); lean_inc(x_7); lean_dec(x_6); x_8 = lean_box(0); x_9 = lean_apply_2(x_7, lean_box(0), x_8); lean_inc(x_3); x_10 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__2___boxed), 5, 4); lean_closure_set(x_10, 0, x_1); lean_closure_set(x_10, 1, x_2); lean_closure_set(x_10, 2, x_3); lean_closure_set(x_10, 3, x_4); x_11 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_9, x_10); return x_11; } else { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_dec(x_3); lean_dec(x_2); x_12 = lean_ctor_get(x_1, 0); lean_inc(x_12); lean_dec(x_1); x_13 = lean_ctor_get(x_12, 1); lean_inc(x_13); lean_dec(x_12); lean_inc(x_4); x_14 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_14, 0, x_4); x_15 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_15, 0, x_14); x_16 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_16, 0, x_15); lean_ctor_set(x_16, 1, x_4); x_17 = lean_alloc_ctor(0, 1, 0); lean_ctor_set(x_17, 0, x_16); x_18 = lean_apply_2(x_13, lean_box(0), x_17); return x_18; } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__4(lean_object* x_1, size_t x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, size_t x_7, lean_object* x_8) { _start: { if (lean_obj_tag(x_8) == 0) { lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); x_9 = lean_ctor_get(x_8, 0); lean_inc(x_9); lean_dec(x_8); x_10 = lean_ctor_get(x_1, 0); lean_inc(x_10); lean_dec(x_1); x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); x_12 = lean_apply_2(x_11, lean_box(0), x_9); return x_12; } else { lean_object* x_13; size_t x_14; size_t x_15; lean_object* x_16; x_13 = lean_ctor_get(x_8, 0); lean_inc(x_13); lean_dec(x_8); x_14 = 1; x_15 = lean_usize_add(x_2, x_14); x_16 = l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg(x_1, x_3, x_4, x_5, x_6, x_7, x_15, x_13); return x_16; } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, size_t x_6, size_t x_7, lean_object* x_8) { _start: { uint8_t x_9; x_9 = lean_usize_dec_lt(x_7, x_6); if (x_9 == 0) { lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_10 = lean_ctor_get(x_1, 0); lean_inc(x_10); lean_dec(x_1); x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); x_12 = lean_apply_2(x_11, lean_box(0), x_8); return x_12; } else { lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_object* x_22; x_13 = lean_array_uget(x_5, x_7); x_14 = lean_ctor_get(x_1, 1); lean_inc(x_14); x_15 = lean_ctor_get(x_8, 1); lean_inc(x_15); lean_dec(x_8); lean_inc(x_2); x_16 = lean_apply_1(x_2, x_13); lean_inc(x_3); lean_inc(x_4); lean_inc(x_1); x_17 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__3___boxed), 5, 4); lean_closure_set(x_17, 0, x_1); lean_closure_set(x_17, 1, x_4); lean_closure_set(x_17, 2, x_3); lean_closure_set(x_17, 3, x_15); lean_inc(x_3); x_18 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_16, x_17); x_19 = lean_box_usize(x_7); x_20 = lean_box_usize(x_6); x_21 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__4___boxed), 8, 7); lean_closure_set(x_21, 0, x_1); lean_closure_set(x_21, 1, x_19); lean_closure_set(x_21, 2, x_2); lean_closure_set(x_21, 3, x_3); lean_closure_set(x_21, 4, x_4); lean_closure_set(x_21, 5, x_5); lean_closure_set(x_21, 6, x_20); x_22 = lean_apply_4(x_14, lean_box(0), lean_box(0), x_18, x_21); return x_22; } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___boxed), 8, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_findIdxM_x3f___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = lean_ctor_get(x_4, 0); lean_inc(x_5); lean_dec(x_4); if (lean_obj_tag(x_5) == 0) { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_inc(x_1); x_6 = lean_alloc_closure((void*)(l_Array_findSomeM_x3f___rarg___lambda__1___boxed), 3, 2); lean_closure_set(x_6, 0, x_1); lean_closure_set(x_6, 1, x_2); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = lean_box(0); x_10 = lean_apply_2(x_8, lean_box(0), x_9); x_11 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_10, x_6); return x_11; } else { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_dec(x_3); lean_dec(x_2); x_12 = lean_ctor_get(x_5, 0); lean_inc(x_12); lean_dec(x_5); x_13 = lean_ctor_get(x_1, 0); lean_inc(x_13); lean_dec(x_1); x_14 = lean_ctor_get(x_13, 1); lean_inc(x_14); lean_dec(x_13); x_15 = lean_apply_2(x_14, lean_box(0), x_12); return x_15; } } } static lean_object* _init_l_Array_findIdxM_x3f___rarg___closed__1() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = lean_unsigned_to_nat(0u); x_3 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_3, 0, x_1); lean_ctor_set(x_3, 1, x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_findIdxM_x3f___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; size_t x_7; size_t x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; x_4 = lean_ctor_get(x_1, 1); lean_inc(x_4); x_5 = lean_box(0); x_6 = lean_array_get_size(x_2); x_7 = lean_usize_of_nat(x_6); lean_dec(x_6); x_8 = 0; x_9 = l_Array_findIdxM_x3f___rarg___closed__1; lean_inc(x_4); lean_inc(x_1); x_10 = l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg(x_1, x_3, x_4, x_5, x_2, x_7, x_8, x_9); lean_inc(x_4); x_11 = lean_alloc_closure((void*)(l_Array_findIdxM_x3f___rarg___lambda__1), 4, 3); lean_closure_set(x_11, 0, x_1); lean_closure_set(x_11, 1, x_5); lean_closure_set(x_11, 2, x_4); x_12 = lean_apply_4(x_4, lean_box(0), lean_box(0), x_10, x_11); return x_12; } } LEAN_EXPORT lean_object* l_Array_findIdxM_x3f(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_findIdxM_x3f___rarg), 3, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__1(x_1, x_2, x_3, x_4); lean_dec(x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__2___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__2(x_1, x_2, x_3, x_4, x_5); lean_dec(x_5); lean_dec(x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__3___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { uint8_t x_6; lean_object* x_7; x_6 = lean_unbox(x_5); lean_dec(x_5); x_7 = l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__3(x_1, x_2, x_3, x_4, x_6); return x_7; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__4___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { size_t x_9; size_t x_10; lean_object* x_11; x_9 = lean_unbox_usize(x_2); lean_dec(x_2); x_10 = lean_unbox_usize(x_7); lean_dec(x_7); x_11 = l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___lambda__4(x_1, x_9, x_3, x_4, x_5, x_6, x_10, x_8); return x_11; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { size_t x_9; size_t x_10; lean_object* x_11; x_9 = lean_unbox_usize(x_6); lean_dec(x_6); x_10 = lean_unbox_usize(x_7); lean_dec(x_7); x_11 = l_Array_forInUnsafe_loop___at_Array_findIdxM_x3f___spec__1___rarg(x_1, x_2, x_3, x_4, x_5, x_9, x_10, x_8); return x_11; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___rarg___lambda__1(size_t x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, size_t x_5, uint8_t x_6) { _start: { if (x_6 == 0) { size_t x_7; size_t x_8; lean_object* x_9; x_7 = 1; x_8 = lean_usize_add(x_1, x_7); x_9 = l_Array_anyMUnsafe_any___rarg(x_2, x_3, x_4, x_8, x_5); return x_9; } else { lean_object* x_10; lean_object* x_11; uint8_t x_12; lean_object* x_13; lean_object* x_14; lean_dec(x_4); lean_dec(x_3); x_10 = lean_ctor_get(x_2, 0); lean_inc(x_10); lean_dec(x_2); x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); x_12 = 1; x_13 = lean_box(x_12); x_14 = lean_apply_2(x_11, lean_box(0), x_13); return x_14; } } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_eq(x_4, x_5); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; x_7 = lean_ctor_get(x_1, 1); lean_inc(x_7); x_8 = lean_array_uget(x_3, x_4); lean_inc(x_2); x_9 = lean_apply_1(x_2, x_8); x_10 = lean_box_usize(x_4); x_11 = lean_box_usize(x_5); x_12 = lean_alloc_closure((void*)(l_Array_anyMUnsafe_any___rarg___lambda__1___boxed), 6, 5); lean_closure_set(x_12, 0, x_10); lean_closure_set(x_12, 1, x_1); lean_closure_set(x_12, 2, x_2); lean_closure_set(x_12, 3, x_3); lean_closure_set(x_12, 4, x_11); x_13 = lean_apply_4(x_7, lean_box(0), lean_box(0), x_9, x_12); return x_13; } else { lean_object* x_14; lean_object* x_15; uint8_t x_16; lean_object* x_17; lean_object* x_18; lean_dec(x_3); lean_dec(x_2); x_14 = lean_ctor_get(x_1, 0); lean_inc(x_14); lean_dec(x_1); x_15 = lean_ctor_get(x_14, 1); lean_inc(x_15); lean_dec(x_14); x_16 = 0; x_17 = lean_box(x_16); x_18 = lean_apply_2(x_15, lean_box(0), x_17); return x_18; } } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_anyMUnsafe_any___rarg___boxed), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; uint8_t x_9; lean_object* x_10; x_7 = lean_unbox_usize(x_1); lean_dec(x_1); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = lean_unbox(x_6); lean_dec(x_6); x_10 = l_Array_anyMUnsafe_any___rarg___lambda__1(x_7, x_2, x_3, x_4, x_8, x_9); return x_10; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; lean_object* x_8; x_6 = lean_unbox_usize(x_4); lean_dec(x_4); x_7 = lean_unbox_usize(x_5); lean_dec(x_5); x_8 = l_Array_anyMUnsafe_any___rarg(x_1, x_2, x_3, x_6, x_7); return x_8; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_nat_dec_lt(x_4, x_5); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; uint8_t x_9; lean_object* x_10; lean_object* x_11; lean_dec(x_3); lean_dec(x_2); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = 0; x_10 = lean_box(x_9); x_11 = lean_apply_2(x_8, lean_box(0), x_10); return x_11; } else { lean_object* x_12; uint8_t x_13; x_12 = lean_array_get_size(x_3); x_13 = lean_nat_dec_le(x_5, x_12); lean_dec(x_12); if (x_13 == 0) { lean_object* x_14; lean_object* x_15; uint8_t x_16; lean_object* x_17; lean_object* x_18; lean_dec(x_3); lean_dec(x_2); x_14 = lean_ctor_get(x_1, 0); lean_inc(x_14); lean_dec(x_1); x_15 = lean_ctor_get(x_14, 1); lean_inc(x_15); lean_dec(x_14); x_16 = 0; x_17 = lean_box(x_16); x_18 = lean_apply_2(x_15, lean_box(0), x_17); return x_18; } else { size_t x_19; size_t x_20; lean_object* x_21; x_19 = lean_usize_of_nat(x_4); x_20 = lean_usize_of_nat(x_5); x_21 = l_Array_anyMUnsafe_any___rarg(x_1, x_2, x_3, x_19, x_20); return x_21; } } } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_anyMUnsafe___rarg___boxed), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_anyMUnsafe___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_5); lean_dec(x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_anyM_loop___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, uint8_t x_6) { _start: { if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; x_7 = lean_unsigned_to_nat(1u); x_8 = lean_nat_add(x_1, x_7); lean_dec(x_1); x_9 = l_Array_anyM_loop___rarg(x_2, x_3, x_4, x_5, lean_box(0), x_8); return x_9; } else { lean_object* x_10; lean_object* x_11; uint8_t x_12; lean_object* x_13; lean_object* x_14; lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_10 = lean_ctor_get(x_2, 0); lean_inc(x_10); lean_dec(x_2); x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); x_12 = 1; x_13 = lean_box(x_12); x_14 = lean_apply_2(x_11, lean_box(0), x_13); return x_14; } } } LEAN_EXPORT lean_object* l_Array_anyM_loop___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_nat_dec_lt(x_6, x_4); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; uint8_t x_10; lean_object* x_11; lean_object* x_12; lean_dec(x_6); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = 0; x_11 = lean_box(x_10); x_12 = lean_apply_2(x_9, lean_box(0), x_11); return x_12; } else { lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; x_13 = lean_ctor_get(x_1, 1); lean_inc(x_13); x_14 = lean_array_fget(x_3, x_6); lean_inc(x_2); x_15 = lean_apply_1(x_2, x_14); x_16 = lean_alloc_closure((void*)(l_Array_anyM_loop___rarg___lambda__1___boxed), 6, 5); lean_closure_set(x_16, 0, x_6); lean_closure_set(x_16, 1, x_1); lean_closure_set(x_16, 2, x_2); lean_closure_set(x_16, 3, x_3); lean_closure_set(x_16, 4, x_4); x_17 = lean_apply_4(x_13, lean_box(0), lean_box(0), x_15, x_16); return x_17; } } } LEAN_EXPORT lean_object* l_Array_anyM_loop(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_anyM_loop___rarg), 6, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_anyM_loop___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { uint8_t x_7; lean_object* x_8; x_7 = lean_unbox(x_6); lean_dec(x_6); x_8 = l_Array_anyM_loop___rarg___lambda__1(x_1, x_2, x_3, x_4, x_5, x_7); return x_8; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__1(lean_object* x_1, uint8_t x_2) { _start: { if (x_2 == 0) { lean_object* x_3; lean_object* x_4; uint8_t x_5; lean_object* x_6; lean_object* x_7; x_3 = lean_ctor_get(x_1, 0); lean_inc(x_3); lean_dec(x_1); x_4 = lean_ctor_get(x_3, 1); lean_inc(x_4); lean_dec(x_3); x_5 = 1; x_6 = lean_box(x_5); x_7 = lean_apply_2(x_4, lean_box(0), x_6); return x_7; } else { lean_object* x_8; lean_object* x_9; uint8_t x_10; lean_object* x_11; lean_object* x_12; x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = 0; x_11 = lean_box(x_10); x_12 = lean_apply_2(x_9, lean_box(0), x_11); return x_12; } } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__2(size_t x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, size_t x_6, uint8_t x_7) { _start: { if (x_7 == 0) { size_t x_8; size_t x_9; lean_object* x_10; x_8 = 1; x_9 = lean_usize_add(x_1, x_8); x_10 = l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg(x_2, x_3, x_4, x_5, x_9, x_6); return x_10; } else { lean_object* x_11; lean_object* x_12; uint8_t x_13; lean_object* x_14; lean_object* x_15; lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); x_11 = lean_ctor_get(x_2, 0); lean_inc(x_11); lean_dec(x_2); x_12 = lean_ctor_get(x_11, 1); lean_inc(x_12); lean_dec(x_11); x_13 = 1; x_14 = lean_box(x_13); x_15 = lean_apply_2(x_12, lean_box(0), x_14); return x_15; } } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, size_t x_5, size_t x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_eq(x_5, x_6); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; x_8 = lean_ctor_get(x_1, 1); lean_inc(x_8); x_9 = lean_array_uget(x_4, x_5); lean_inc(x_2); x_10 = lean_apply_1(x_2, x_9); lean_inc(x_1); x_11 = lean_alloc_closure((void*)(l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__1___boxed), 2, 1); lean_closure_set(x_11, 0, x_1); lean_inc(x_3); x_12 = lean_apply_4(x_3, lean_box(0), lean_box(0), x_10, x_11); x_13 = lean_box_usize(x_5); x_14 = lean_box_usize(x_6); x_15 = lean_alloc_closure((void*)(l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__2___boxed), 7, 6); lean_closure_set(x_15, 0, x_13); lean_closure_set(x_15, 1, x_1); lean_closure_set(x_15, 2, x_2); lean_closure_set(x_15, 3, x_3); lean_closure_set(x_15, 4, x_4); lean_closure_set(x_15, 5, x_14); x_16 = lean_apply_4(x_8, lean_box(0), lean_box(0), x_12, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; uint8_t x_19; lean_object* x_20; lean_object* x_21; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_17 = lean_ctor_get(x_1, 0); lean_inc(x_17); lean_dec(x_1); x_18 = lean_ctor_get(x_17, 1); lean_inc(x_18); lean_dec(x_17); x_19 = 0; x_20 = lean_box(x_19); x_21 = lean_apply_2(x_18, lean_box(0), x_20); return x_21; } } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___boxed), 6, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_allM___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; lean_object* x_8; x_6 = lean_ctor_get(x_1, 1); lean_inc(x_6); x_7 = lean_nat_dec_lt(x_4, x_5); lean_inc(x_1); x_8 = lean_alloc_closure((void*)(l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__1___boxed), 2, 1); lean_closure_set(x_8, 0, x_1); if (x_7 == 0) { lean_object* x_9; lean_object* x_10; uint8_t x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_dec(x_3); lean_dec(x_2); x_9 = lean_ctor_get(x_1, 0); lean_inc(x_9); lean_dec(x_1); x_10 = lean_ctor_get(x_9, 1); lean_inc(x_10); lean_dec(x_9); x_11 = 0; x_12 = lean_box(x_11); x_13 = lean_apply_2(x_10, lean_box(0), x_12); x_14 = lean_apply_4(x_6, lean_box(0), lean_box(0), x_13, x_8); return x_14; } else { lean_object* x_15; uint8_t x_16; x_15 = lean_array_get_size(x_3); x_16 = lean_nat_dec_le(x_5, x_15); lean_dec(x_15); if (x_16 == 0) { lean_object* x_17; lean_object* x_18; uint8_t x_19; lean_object* x_20; lean_object* x_21; lean_object* x_22; lean_dec(x_3); lean_dec(x_2); x_17 = lean_ctor_get(x_1, 0); lean_inc(x_17); lean_dec(x_1); x_18 = lean_ctor_get(x_17, 1); lean_inc(x_18); lean_dec(x_17); x_19 = 0; x_20 = lean_box(x_19); x_21 = lean_apply_2(x_18, lean_box(0), x_20); x_22 = lean_apply_4(x_6, lean_box(0), lean_box(0), x_21, x_8); return x_22; } else { size_t x_23; size_t x_24; lean_object* x_25; lean_object* x_26; x_23 = lean_usize_of_nat(x_4); x_24 = lean_usize_of_nat(x_5); lean_inc(x_6); x_25 = l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg(x_1, x_2, x_6, x_3, x_23, x_24); x_26 = lean_apply_4(x_6, lean_box(0), lean_box(0), x_25, x_8); return x_26; } } } } LEAN_EXPORT lean_object* l_Array_allM(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_allM___rarg___boxed), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2) { _start: { uint8_t x_3; lean_object* x_4; x_3 = lean_unbox(x_2); lean_dec(x_2); x_4 = l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__1(x_1, x_3); return x_4; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__2___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { size_t x_8; size_t x_9; uint8_t x_10; lean_object* x_11; x_8 = lean_unbox_usize(x_1); lean_dec(x_1); x_9 = lean_unbox_usize(x_6); lean_dec(x_6); x_10 = lean_unbox(x_7); lean_dec(x_7); x_11 = l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___lambda__2(x_8, x_2, x_3, x_4, x_5, x_9, x_10); return x_11; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_5); lean_dec(x_5); x_8 = lean_unbox_usize(x_6); lean_dec(x_6); x_9 = l_Array_anyMUnsafe_any___at_Array_allM___spec__1___rarg(x_1, x_2, x_3, x_4, x_7, x_8); return x_9; } } LEAN_EXPORT lean_object* l_Array_allM___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_allM___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_5); lean_dec(x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { if (lean_obj_tag(x_5) == 0) { lean_object* x_6; x_6 = l_Array_findSomeRevM_x3f_find___rarg(x_1, x_2, x_3, x_4, lean_box(0)); return x_6; } else { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_dec(x_3); lean_dec(x_2); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = lean_apply_2(x_8, lean_box(0), x_5); return x_9; } } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_unsigned_to_nat(0u); x_7 = lean_nat_dec_eq(x_4, x_6); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; x_8 = lean_unsigned_to_nat(1u); x_9 = lean_nat_sub(x_4, x_8); x_10 = lean_ctor_get(x_1, 1); lean_inc(x_10); x_11 = lean_array_fget(x_2, x_9); lean_inc(x_3); x_12 = lean_apply_1(x_3, x_11); x_13 = lean_alloc_closure((void*)(l_Array_findSomeRevM_x3f_find___rarg___lambda__1___boxed), 5, 4); lean_closure_set(x_13, 0, x_1); lean_closure_set(x_13, 1, x_2); lean_closure_set(x_13, 2, x_3); lean_closure_set(x_13, 3, x_9); x_14 = lean_apply_4(x_10, lean_box(0), lean_box(0), x_12, x_13); return x_14; } else { lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_dec(x_3); lean_dec(x_2); x_15 = lean_ctor_get(x_1, 0); lean_inc(x_15); lean_dec(x_1); x_16 = lean_ctor_get(x_15, 1); lean_inc(x_16); lean_dec(x_15); x_17 = lean_box(0); x_18 = lean_apply_2(x_16, lean_box(0), x_17); return x_18; } } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_findSomeRevM_x3f_find___rarg___boxed), 5, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_findSomeRevM_x3f_find___rarg___lambda__1(x_1, x_2, x_3, x_4, x_5); lean_dec(x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_findSomeRevM_x3f_find___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; x_4 = lean_array_get_size(x_2); x_5 = l_Array_findSomeRevM_x3f_find___rarg(x_1, x_2, x_3, x_4, lean_box(0)); lean_dec(x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_findSomeRevM_x3f___rarg), 3, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__1(lean_object* x_1, lean_object* x_2, uint8_t x_3) { _start: { if (x_3 == 0) { lean_object* x_4; lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_dec(x_2); x_4 = lean_ctor_get(x_1, 0); lean_inc(x_4); lean_dec(x_1); x_5 = lean_ctor_get(x_4, 1); lean_inc(x_5); lean_dec(x_4); x_6 = lean_box(0); x_7 = lean_apply_2(x_5, lean_box(0), x_6); return x_7; } else { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_10, 0, x_2); x_11 = lean_apply_2(x_9, lean_box(0), x_10); return x_11; } } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__2(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { if (lean_obj_tag(x_5) == 0) { lean_object* x_6; x_6 = l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg(x_1, x_2, x_3, x_4, lean_box(0)); return x_6; } else { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_dec(x_3); lean_dec(x_2); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = lean_apply_2(x_8, lean_box(0), x_5); return x_9; } } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_unsigned_to_nat(0u); x_7 = lean_nat_dec_eq(x_4, x_6); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; x_8 = lean_unsigned_to_nat(1u); x_9 = lean_nat_sub(x_4, x_8); x_10 = lean_ctor_get(x_1, 1); lean_inc(x_10); x_11 = lean_array_fget(x_3, x_9); lean_inc(x_2); lean_inc(x_11); x_12 = lean_apply_1(x_2, x_11); lean_inc(x_1); x_13 = lean_alloc_closure((void*)(l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__1___boxed), 3, 2); lean_closure_set(x_13, 0, x_1); lean_closure_set(x_13, 1, x_11); lean_inc(x_10); x_14 = lean_apply_4(x_10, lean_box(0), lean_box(0), x_12, x_13); x_15 = lean_alloc_closure((void*)(l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__2___boxed), 5, 4); lean_closure_set(x_15, 0, x_1); lean_closure_set(x_15, 1, x_2); lean_closure_set(x_15, 2, x_3); lean_closure_set(x_15, 3, x_9); x_16 = lean_apply_4(x_10, lean_box(0), lean_box(0), x_14, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_dec(x_3); lean_dec(x_2); x_17 = lean_ctor_get(x_1, 0); lean_inc(x_17); lean_dec(x_1); x_18 = lean_ctor_get(x_17, 1); lean_inc(x_18); lean_dec(x_17); x_19 = lean_box(0); x_20 = lean_apply_2(x_18, lean_box(0), x_19); return x_20; } } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___boxed), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_findRevM_x3f___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; x_4 = lean_array_get_size(x_2); x_5 = l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg(x_1, x_3, x_2, x_4, lean_box(0)); lean_dec(x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_findRevM_x3f(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_findRevM_x3f___rarg), 3, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { uint8_t x_4; lean_object* x_5; x_4 = lean_unbox(x_3); lean_dec(x_3); x_5 = l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__1(x_1, x_2, x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__2___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___lambda__2(x_1, x_2, x_3, x_4, x_5); lean_dec(x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_findSomeRevM_x3f_find___at_Array_findRevM_x3f___spec__1___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg___lambda__1(size_t x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, size_t x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = 1; x_8 = lean_usize_add(x_1, x_7); x_9 = l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg(x_2, x_3, x_4, x_8, x_5, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_eq(x_4, x_5); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_dec(x_6); x_8 = lean_ctor_get(x_1, 1); lean_inc(x_8); x_9 = lean_array_uget(x_3, x_4); lean_inc(x_2); x_10 = lean_apply_1(x_2, x_9); x_11 = lean_box_usize(x_4); x_12 = lean_box_usize(x_5); x_13 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg___lambda__1___boxed), 6, 5); lean_closure_set(x_13, 0, x_11); lean_closure_set(x_13, 1, x_1); lean_closure_set(x_13, 2, x_2); lean_closure_set(x_13, 3, x_3); lean_closure_set(x_13, 4, x_12); x_14 = lean_apply_4(x_8, lean_box(0), lean_box(0), x_10, x_13); return x_14; } else { lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_dec(x_3); lean_dec(x_2); x_15 = lean_ctor_get(x_1, 0); lean_inc(x_15); lean_dec(x_1); x_16 = lean_ctor_get(x_15, 1); lean_inc(x_16); lean_dec(x_15); x_17 = lean_apply_2(x_16, lean_box(0), x_6); return x_17; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg___boxed), 6, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_forM___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_nat_dec_lt(x_4, x_5); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = lean_box(0); x_10 = lean_apply_2(x_8, lean_box(0), x_9); return x_10; } else { lean_object* x_11; uint8_t x_12; x_11 = lean_array_get_size(x_3); x_12 = lean_nat_dec_le(x_5, x_11); lean_dec(x_11); if (x_12 == 0) { lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_13 = lean_ctor_get(x_1, 0); lean_inc(x_13); lean_dec(x_1); x_14 = lean_ctor_get(x_13, 1); lean_inc(x_14); lean_dec(x_13); x_15 = lean_box(0); x_16 = lean_apply_2(x_14, lean_box(0), x_15); return x_16; } else { size_t x_17; size_t x_18; lean_object* x_19; lean_object* x_20; x_17 = lean_usize_of_nat(x_4); lean_dec(x_4); x_18 = lean_usize_of_nat(x_5); lean_dec(x_5); x_19 = lean_box(0); x_20 = l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg(x_1, x_2, x_3, x_17, x_18, x_19); return x_20; } } } } LEAN_EXPORT lean_object* l_Array_forM(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_forM___rarg), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_1); lean_dec(x_1); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg___lambda__1(x_7, x_2, x_3, x_4, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldlMUnsafe_fold___at_Array_forM___spec__1___rarg(x_1, x_2, x_3, x_7, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_eq(x_4, x_5); if (x_7 == 0) { lean_object* x_8; size_t x_9; size_t x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_dec(x_6); x_8 = lean_ctor_get(x_1, 1); lean_inc(x_8); x_9 = 1; x_10 = lean_usize_sub(x_4, x_9); x_11 = lean_array_uget(x_3, x_10); lean_inc(x_2); x_12 = lean_apply_1(x_2, x_11); x_13 = lean_box_usize(x_10); x_14 = lean_box_usize(x_5); x_15 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__1___rarg___boxed), 6, 5); lean_closure_set(x_15, 0, x_1); lean_closure_set(x_15, 1, x_2); lean_closure_set(x_15, 2, x_3); lean_closure_set(x_15, 3, x_13); lean_closure_set(x_15, 4, x_14); x_16 = lean_apply_4(x_8, lean_box(0), lean_box(0), x_12, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_dec(x_3); lean_dec(x_2); x_17 = lean_ctor_get(x_1, 0); lean_inc(x_17); lean_dec(x_1); x_18 = lean_ctor_get(x_17, 1); lean_inc(x_18); lean_dec(x_17); x_19 = lean_apply_2(x_18, lean_box(0), x_6); return x_19; } } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__1___rarg___boxed), 6, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__2___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_eq(x_4, x_5); if (x_7 == 0) { lean_object* x_8; size_t x_9; size_t x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_dec(x_6); x_8 = lean_ctor_get(x_1, 1); lean_inc(x_8); x_9 = 1; x_10 = lean_usize_sub(x_4, x_9); x_11 = lean_array_uget(x_3, x_10); lean_inc(x_2); x_12 = lean_apply_1(x_2, x_11); x_13 = lean_box_usize(x_10); x_14 = lean_box_usize(x_5); x_15 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__2___rarg___boxed), 6, 5); lean_closure_set(x_15, 0, x_1); lean_closure_set(x_15, 1, x_2); lean_closure_set(x_15, 2, x_3); lean_closure_set(x_15, 3, x_13); lean_closure_set(x_15, 4, x_14); x_16 = lean_apply_4(x_8, lean_box(0), lean_box(0), x_12, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_dec(x_3); lean_dec(x_2); x_17 = lean_ctor_get(x_1, 0); lean_inc(x_17); lean_dec(x_1); x_18 = lean_ctor_get(x_17, 1); lean_inc(x_18); lean_dec(x_17); x_19 = lean_apply_2(x_18, lean_box(0), x_6); return x_19; } } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__2(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__2___rarg___boxed), 6, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_forRevM___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_array_get_size(x_3); x_7 = lean_nat_dec_le(x_4, x_6); if (x_7 == 0) { uint8_t x_8; lean_dec(x_4); x_8 = lean_nat_dec_lt(x_5, x_6); if (x_8 == 0) { lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); lean_dec(x_2); x_9 = lean_ctor_get(x_1, 0); lean_inc(x_9); lean_dec(x_1); x_10 = lean_ctor_get(x_9, 1); lean_inc(x_10); lean_dec(x_9); x_11 = lean_box(0); x_12 = lean_apply_2(x_10, lean_box(0), x_11); return x_12; } else { size_t x_13; size_t x_14; lean_object* x_15; lean_object* x_16; x_13 = lean_usize_of_nat(x_6); lean_dec(x_6); x_14 = lean_usize_of_nat(x_5); lean_dec(x_5); x_15 = lean_box(0); x_16 = l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__1___rarg(x_1, x_2, x_3, x_13, x_14, x_15); return x_16; } } else { uint8_t x_17; lean_dec(x_6); x_17 = lean_nat_dec_lt(x_5, x_4); if (x_17 == 0) { lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_18 = lean_ctor_get(x_1, 0); lean_inc(x_18); lean_dec(x_1); x_19 = lean_ctor_get(x_18, 1); lean_inc(x_19); lean_dec(x_18); x_20 = lean_box(0); x_21 = lean_apply_2(x_19, lean_box(0), x_20); return x_21; } else { size_t x_22; size_t x_23; lean_object* x_24; lean_object* x_25; x_22 = lean_usize_of_nat(x_4); lean_dec(x_4); x_23 = lean_usize_of_nat(x_5); lean_dec(x_5); x_24 = lean_box(0); x_25 = l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__2___rarg(x_1, x_2, x_3, x_22, x_23, x_24); return x_25; } } } } LEAN_EXPORT lean_object* l_Array_forRevM(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_forRevM___rarg), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__1___rarg(x_1, x_2, x_3, x_7, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__2___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldrMUnsafe_fold___at_Array_forRevM___spec__2___rarg(x_1, x_2, x_3, x_7, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_foldl___spec__1___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_eq(x_3, x_4); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; size_t x_9; size_t x_10; x_7 = lean_array_uget(x_2, x_3); lean_inc(x_1); x_8 = lean_apply_2(x_1, x_5, x_7); x_9 = 1; x_10 = lean_usize_add(x_3, x_9); x_3 = x_10; x_5 = x_8; goto _start; } else { lean_dec(x_1); return x_5; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_foldl___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_foldl___spec__1___rarg___boxed), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldl___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_nat_dec_lt(x_4, x_5); if (x_6 == 0) { lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); return x_2; } else { lean_object* x_7; uint8_t x_8; x_7 = lean_array_get_size(x_3); x_8 = lean_nat_dec_le(x_5, x_7); lean_dec(x_7); if (x_8 == 0) { lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); return x_2; } else { size_t x_9; size_t x_10; lean_object* x_11; x_9 = lean_usize_of_nat(x_4); lean_dec(x_4); x_10 = lean_usize_of_nat(x_5); lean_dec(x_5); x_11 = l_Array_foldlMUnsafe_fold___at_Array_foldl___spec__1___rarg(x_1, x_3, x_9, x_10, x_2); lean_dec(x_3); return x_11; } } } } LEAN_EXPORT lean_object* l_Array_foldl(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldl___rarg), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_foldl___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; lean_object* x_8; x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = l_Array_foldlMUnsafe_fold___at_Array_foldl___spec__1___rarg(x_1, x_2, x_6, x_7, x_5); lean_dec(x_2); return x_8; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__1___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_eq(x_3, x_4); if (x_6 == 0) { size_t x_7; size_t x_8; lean_object* x_9; lean_object* x_10; x_7 = 1; x_8 = lean_usize_sub(x_3, x_7); x_9 = lean_array_uget(x_2, x_8); lean_inc(x_1); x_10 = lean_apply_2(x_1, x_9, x_5); x_3 = x_8; x_5 = x_10; goto _start; } else { lean_dec(x_1); return x_5; } } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__1___rarg___boxed), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__2___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_eq(x_3, x_4); if (x_6 == 0) { size_t x_7; size_t x_8; lean_object* x_9; lean_object* x_10; x_7 = 1; x_8 = lean_usize_sub(x_3, x_7); x_9 = lean_array_uget(x_2, x_8); lean_inc(x_1); x_10 = lean_apply_2(x_1, x_9, x_5); x_3 = x_8; x_5 = x_10; goto _start; } else { lean_dec(x_1); return x_5; } } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__2(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__2___rarg___boxed), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldr___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_array_get_size(x_3); x_7 = lean_nat_dec_le(x_4, x_6); if (x_7 == 0) { uint8_t x_8; lean_dec(x_4); x_8 = lean_nat_dec_lt(x_5, x_6); if (x_8 == 0) { lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); lean_dec(x_1); return x_2; } else { size_t x_9; size_t x_10; lean_object* x_11; x_9 = lean_usize_of_nat(x_6); lean_dec(x_6); x_10 = lean_usize_of_nat(x_5); lean_dec(x_5); x_11 = l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__1___rarg(x_1, x_3, x_9, x_10, x_2); lean_dec(x_3); return x_11; } } else { uint8_t x_12; lean_dec(x_6); x_12 = lean_nat_dec_lt(x_5, x_4); if (x_12 == 0) { lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); return x_2; } else { size_t x_13; size_t x_14; lean_object* x_15; x_13 = lean_usize_of_nat(x_4); lean_dec(x_4); x_14 = lean_usize_of_nat(x_5); lean_dec(x_5); x_15 = l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__2___rarg(x_1, x_3, x_13, x_14, x_2); lean_dec(x_3); return x_15; } } } } LEAN_EXPORT lean_object* l_Array_foldr(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldr___rarg), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; lean_object* x_8; x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__1___rarg(x_1, x_2, x_6, x_7, x_5); lean_dec(x_2); return x_8; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__2___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; lean_object* x_8; x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = l_Array_foldrMUnsafe_fold___at_Array_foldr___spec__2___rarg(x_1, x_2, x_6, x_7, x_5); lean_dec(x_2); return x_8; } } LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___at_Array_map___spec__1___rarg(lean_object* x_1, size_t x_2, size_t x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_usize_dec_lt(x_3, x_2); if (x_5 == 0) { lean_dec(x_1); return x_4; } else { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; size_t x_10; size_t x_11; lean_object* x_12; x_6 = lean_array_uget(x_4, x_3); x_7 = lean_unsigned_to_nat(0u); x_8 = lean_array_uset(x_4, x_3, x_7); lean_inc(x_1); x_9 = lean_apply_1(x_1, x_6); x_10 = 1; x_11 = lean_usize_add(x_3, x_10); x_12 = lean_array_uset(x_8, x_3, x_9); x_3 = x_11; x_4 = x_12; goto _start; } } } LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___at_Array_map___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_mapMUnsafe_map___at_Array_map___spec__1___rarg___boxed), 4, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_map___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; size_t x_4; size_t x_5; lean_object* x_6; x_3 = lean_array_get_size(x_2); x_4 = lean_usize_of_nat(x_3); lean_dec(x_3); x_5 = 0; x_6 = l_Array_mapMUnsafe_map___at_Array_map___spec__1___rarg(x_1, x_4, x_5, x_2); return x_6; } } LEAN_EXPORT lean_object* l_Array_map(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_map___rarg), 2, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_mapMUnsafe_map___at_Array_map___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { size_t x_5; size_t x_6; lean_object* x_7; x_5 = lean_unbox_usize(x_2); lean_dec(x_2); x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = l_Array_mapMUnsafe_map___at_Array_map___spec__1___rarg(x_1, x_5, x_6, x_4); return x_7; } } LEAN_EXPORT lean_object* l_Array_mapIdxM_map___at_Array_mapIdx___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; uint8_t x_9; x_8 = lean_unsigned_to_nat(0u); x_9 = lean_nat_dec_eq(x_4, x_8); if (x_9 == 0) { lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; x_10 = lean_unsigned_to_nat(1u); x_11 = lean_nat_sub(x_4, x_10); lean_dec(x_4); x_12 = lean_array_fget(x_3, x_5); lean_inc(x_2); lean_inc(x_5); x_13 = lean_apply_2(x_2, x_5, x_12); x_14 = lean_nat_add(x_5, x_10); lean_dec(x_5); x_15 = lean_array_push(x_7, x_13); x_4 = x_11; x_5 = x_14; x_6 = lean_box(0); x_7 = x_15; goto _start; } else { lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); return x_7; } } } LEAN_EXPORT lean_object* l_Array_mapIdxM_map___at_Array_mapIdx___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_mapIdxM_map___at_Array_mapIdx___spec__1___rarg___boxed), 7, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_mapIdx___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_3 = lean_array_get_size(x_1); x_4 = lean_mk_empty_array_with_capacity(x_3); x_5 = lean_unsigned_to_nat(0u); x_6 = l_Array_mapIdxM_map___at_Array_mapIdx___spec__1___rarg(x_1, x_2, x_1, x_3, x_5, lean_box(0), x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_mapIdx(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_mapIdx___rarg___boxed), 2, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_mapIdxM_map___at_Array_mapIdx___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; x_8 = l_Array_mapIdxM_map___at_Array_mapIdx___spec__1___rarg(x_1, x_2, x_3, x_4, x_5, x_6, x_7); lean_dec(x_3); lean_dec(x_1); return x_8; } } LEAN_EXPORT lean_object* l_Array_mapIdx___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_mapIdx___rarg(x_1, x_2); lean_dec(x_1); return x_3; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_find_x3f___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_lt(x_5, x_4); if (x_7 == 0) { lean_dec(x_1); lean_inc(x_6); return x_6; } else { lean_object* x_8; lean_object* x_9; uint8_t x_10; x_8 = lean_array_uget(x_3, x_5); lean_inc(x_1); lean_inc(x_8); x_9 = lean_apply_1(x_1, x_8); x_10 = lean_unbox(x_9); lean_dec(x_9); if (x_10 == 0) { size_t x_11; size_t x_12; lean_dec(x_8); x_11 = 1; x_12 = lean_usize_add(x_5, x_11); { size_t _tmp_4 = x_12; lean_object* _tmp_5 = x_2; x_5 = _tmp_4; x_6 = _tmp_5; } goto _start; } else { lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_dec(x_1); x_14 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_14, 0, x_8); x_15 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_15, 0, x_14); x_16 = lean_box(0); x_17 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_17, 0, x_15); lean_ctor_set(x_17, 1, x_16); return x_17; } } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_find_x3f___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_find_x3f___spec__1___rarg___boxed), 6, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_find_x3f___rarg___lambda__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_box(0); return x_2; } } static lean_object* _init_l_Array_find_x3f___rarg___closed__1() { _start: { lean_object* x_1; x_1 = lean_alloc_closure((void*)(l_Array_find_x3f___rarg___lambda__1___boxed), 1, 0); return x_1; } } static lean_object* _init_l_Array_find_x3f___rarg___closed__2() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = l_Array_find_x3f___rarg___closed__1; x_2 = lean_box(0); x_3 = lean_apply_1(x_1, x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_find_x3f___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; size_t x_4; size_t x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; x_3 = lean_array_get_size(x_1); x_4 = lean_usize_of_nat(x_3); lean_dec(x_3); x_5 = 0; x_6 = l_Array_findSomeM_x3f___rarg___closed__1; x_7 = l_Array_forInUnsafe_loop___at_Array_find_x3f___spec__1___rarg(x_2, x_6, x_1, x_4, x_5, x_6); x_8 = lean_ctor_get(x_7, 0); lean_inc(x_8); lean_dec(x_7); if (lean_obj_tag(x_8) == 0) { lean_object* x_9; x_9 = l_Array_find_x3f___rarg___closed__2; return x_9; } else { lean_object* x_10; x_10 = lean_ctor_get(x_8, 0); lean_inc(x_10); lean_dec(x_8); return x_10; } } } LEAN_EXPORT lean_object* l_Array_find_x3f(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_find_x3f___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_find_x3f___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_forInUnsafe_loop___at_Array_find_x3f___spec__1___rarg(x_1, x_2, x_3, x_7, x_8, x_6); lean_dec(x_6); lean_dec(x_3); lean_dec(x_2); return x_9; } } LEAN_EXPORT lean_object* l_Array_find_x3f___rarg___lambda__1___boxed(lean_object* x_1) { _start: { lean_object* x_2; x_2 = l_Array_find_x3f___rarg___lambda__1(x_1); lean_dec(x_1); return x_2; } } LEAN_EXPORT lean_object* l_Array_find_x3f___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_find_x3f___rarg(x_1, x_2); lean_dec(x_1); return x_3; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x3f___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_lt(x_5, x_4); if (x_7 == 0) { lean_dec(x_1); lean_inc(x_6); return x_6; } else { lean_object* x_8; lean_object* x_9; x_8 = lean_array_uget(x_3, x_5); lean_inc(x_1); x_9 = lean_apply_1(x_1, x_8); if (lean_obj_tag(x_9) == 0) { size_t x_10; size_t x_11; x_10 = 1; x_11 = lean_usize_add(x_5, x_10); { size_t _tmp_4 = x_11; lean_object* _tmp_5 = x_2; x_5 = _tmp_4; x_6 = _tmp_5; } goto _start; } else { uint8_t x_13; lean_dec(x_1); x_13 = !lean_is_exclusive(x_9); if (x_13 == 0) { lean_object* x_14; lean_object* x_15; lean_object* x_16; x_14 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_14, 0, x_9); x_15 = lean_box(0); x_16 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_16, 0, x_14); lean_ctor_set(x_16, 1, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; x_17 = lean_ctor_get(x_9, 0); lean_inc(x_17); lean_dec(x_9); x_18 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_18, 0, x_17); x_19 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_19, 0, x_18); x_20 = lean_box(0); x_21 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_21, 0, x_19); lean_ctor_set(x_21, 1, x_20); return x_21; } } } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x3f___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findSome_x3f___spec__1___rarg___boxed), 6, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_findSome_x3f___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; size_t x_4; size_t x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; x_3 = lean_array_get_size(x_1); x_4 = lean_usize_of_nat(x_3); lean_dec(x_3); x_5 = 0; x_6 = l_Array_findSomeM_x3f___rarg___closed__1; x_7 = l_Array_forInUnsafe_loop___at_Array_findSome_x3f___spec__1___rarg(x_2, x_6, x_1, x_4, x_5, x_6); x_8 = lean_ctor_get(x_7, 0); lean_inc(x_8); lean_dec(x_7); if (lean_obj_tag(x_8) == 0) { lean_object* x_9; x_9 = lean_box(0); return x_9; } else { lean_object* x_10; x_10 = lean_ctor_get(x_8, 0); lean_inc(x_10); lean_dec(x_8); return x_10; } } } LEAN_EXPORT lean_object* l_Array_findSome_x3f(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_findSome_x3f___rarg___boxed), 2, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x3f___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_forInUnsafe_loop___at_Array_findSome_x3f___spec__1___rarg(x_1, x_2, x_3, x_7, x_8, x_6); lean_dec(x_6); lean_dec(x_3); lean_dec(x_2); return x_9; } } LEAN_EXPORT lean_object* l_Array_findSome_x3f___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_findSome_x3f___rarg(x_1, x_2); lean_dec(x_1); return x_3; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x21___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_lt(x_5, x_4); if (x_7 == 0) { lean_dec(x_1); lean_inc(x_6); return x_6; } else { lean_object* x_8; lean_object* x_9; x_8 = lean_array_uget(x_3, x_5); lean_inc(x_1); x_9 = lean_apply_1(x_1, x_8); if (lean_obj_tag(x_9) == 0) { size_t x_10; size_t x_11; x_10 = 1; x_11 = lean_usize_add(x_5, x_10); { size_t _tmp_4 = x_11; lean_object* _tmp_5 = x_2; x_5 = _tmp_4; x_6 = _tmp_5; } goto _start; } else { uint8_t x_13; lean_dec(x_1); x_13 = !lean_is_exclusive(x_9); if (x_13 == 0) { lean_object* x_14; lean_object* x_15; lean_object* x_16; x_14 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_14, 0, x_9); x_15 = lean_box(0); x_16 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_16, 0, x_14); lean_ctor_set(x_16, 1, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; x_17 = lean_ctor_get(x_9, 0); lean_inc(x_17); lean_dec(x_9); x_18 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_18, 0, x_17); x_19 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_19, 0, x_18); x_20 = lean_box(0); x_21 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_21, 0, x_19); lean_ctor_set(x_21, 1, x_20); return x_21; } } } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x21___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_findSome_x21___spec__1___rarg___boxed), 6, 0); return x_3; } } static lean_object* _init_l_Array_findSome_x21___rarg___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("Array.findSome!", 15); return x_1; } } static lean_object* _init_l_Array_findSome_x21___rarg___closed__2() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("failed to find element", 22); return x_1; } } static lean_object* _init_l_Array_findSome_x21___rarg___closed__3() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l_Array_swapAt_x21___rarg___closed__3; x_2 = l_Array_findSome_x21___rarg___closed__1; x_3 = lean_unsigned_to_nat(415u); x_4 = lean_unsigned_to_nat(14u); x_5 = l_Array_findSome_x21___rarg___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; } } LEAN_EXPORT lean_object* l_Array_findSome_x21___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; size_t x_5; size_t x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; x_4 = lean_array_get_size(x_2); x_5 = lean_usize_of_nat(x_4); lean_dec(x_4); x_6 = 0; x_7 = l_Array_findSomeM_x3f___rarg___closed__1; x_8 = l_Array_forInUnsafe_loop___at_Array_findSome_x21___spec__1___rarg(x_3, x_7, x_2, x_5, x_6, x_7); x_9 = lean_ctor_get(x_8, 0); lean_inc(x_9); lean_dec(x_8); if (lean_obj_tag(x_9) == 0) { lean_object* x_10; lean_object* x_11; x_10 = l_Array_findSome_x21___rarg___closed__3; x_11 = l_panic___rarg(x_1, x_10); return x_11; } else { lean_object* x_12; x_12 = lean_ctor_get(x_9, 0); lean_inc(x_12); lean_dec(x_9); if (lean_obj_tag(x_12) == 0) { lean_object* x_13; lean_object* x_14; x_13 = l_Array_findSome_x21___rarg___closed__3; x_14 = l_panic___rarg(x_1, x_13); return x_14; } else { lean_object* x_15; lean_dec(x_1); x_15 = lean_ctor_get(x_12, 0); lean_inc(x_15); lean_dec(x_12); return x_15; } } } } LEAN_EXPORT lean_object* l_Array_findSome_x21(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_findSome_x21___rarg___boxed), 3, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_findSome_x21___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_forInUnsafe_loop___at_Array_findSome_x21___spec__1___rarg(x_1, x_2, x_3, x_7, x_8, x_6); lean_dec(x_6); lean_dec(x_3); lean_dec(x_2); return x_9; } } LEAN_EXPORT lean_object* l_Array_findSome_x21___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_findSome_x21___rarg(x_1, x_2, x_3); lean_dec(x_2); return x_4; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findSomeRev_x3f___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; uint8_t x_6; x_5 = lean_unsigned_to_nat(0u); x_6 = lean_nat_dec_eq(x_3, x_5); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; x_7 = lean_unsigned_to_nat(1u); x_8 = lean_nat_sub(x_3, x_7); lean_dec(x_3); x_9 = lean_array_fget(x_2, x_8); lean_inc(x_1); x_10 = lean_apply_1(x_1, x_9); if (lean_obj_tag(x_10) == 0) { x_3 = x_8; x_4 = lean_box(0); goto _start; } else { lean_dec(x_8); lean_dec(x_1); return x_10; } } else { lean_object* x_12; lean_dec(x_3); lean_dec(x_1); x_12 = lean_box(0); return x_12; } } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findSomeRev_x3f___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_findSomeRevM_x3f_find___at_Array_findSomeRev_x3f___spec__1___rarg___boxed), 4, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_findSomeRev_x3f___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; x_3 = lean_array_get_size(x_1); x_4 = l_Array_findSomeRevM_x3f_find___at_Array_findSomeRev_x3f___spec__1___rarg(x_2, x_1, x_3, lean_box(0)); lean_dec(x_1); return x_4; } } LEAN_EXPORT lean_object* l_Array_findSomeRev_x3f(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_findSomeRev_x3f___rarg), 2, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findSomeRev_x3f___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_findSomeRevM_x3f_find___at_Array_findSomeRev_x3f___spec__1___rarg(x_1, x_2, x_3, x_4); lean_dec(x_2); return x_5; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRev_x3f___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; uint8_t x_6; x_5 = lean_unsigned_to_nat(0u); x_6 = lean_nat_dec_eq(x_3, x_5); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; uint8_t x_11; x_7 = lean_unsigned_to_nat(1u); x_8 = lean_nat_sub(x_3, x_7); lean_dec(x_3); x_9 = lean_array_fget(x_2, x_8); lean_inc(x_1); lean_inc(x_9); x_10 = lean_apply_1(x_1, x_9); x_11 = lean_unbox(x_10); lean_dec(x_10); if (x_11 == 0) { lean_dec(x_9); x_3 = x_8; x_4 = lean_box(0); goto _start; } else { lean_object* x_13; lean_dec(x_8); lean_dec(x_1); x_13 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_13, 0, x_9); return x_13; } } else { lean_object* x_14; lean_dec(x_3); lean_dec(x_1); x_14 = lean_box(0); return x_14; } } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRev_x3f___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_findSomeRevM_x3f_find___at_Array_findRev_x3f___spec__1___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_findRev_x3f___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; x_3 = lean_array_get_size(x_1); x_4 = l_Array_findSomeRevM_x3f_find___at_Array_findRev_x3f___spec__1___rarg(x_2, x_1, x_3, lean_box(0)); lean_dec(x_1); return x_4; } } LEAN_EXPORT lean_object* l_Array_findRev_x3f(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_findRev_x3f___rarg), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_findSomeRevM_x3f_find___at_Array_findRev_x3f___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_findSomeRevM_x3f_find___at_Array_findRev_x3f___spec__1___rarg(x_1, x_2, x_3, x_4); lean_dec(x_2); return x_5; } } LEAN_EXPORT lean_object* l_Array_findIdx_x3f_loop___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_array_get_size(x_1); x_7 = lean_nat_dec_lt(x_4, x_6); lean_dec(x_6); if (x_7 == 0) { lean_object* x_8; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_8 = lean_box(0); return x_8; } else { lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; uint8_t x_13; x_9 = lean_unsigned_to_nat(1u); x_10 = lean_nat_sub(x_3, x_9); lean_dec(x_3); x_11 = lean_array_fget(x_1, x_4); lean_inc(x_2); x_12 = lean_apply_1(x_2, x_11); x_13 = lean_unbox(x_12); lean_dec(x_12); if (x_13 == 0) { lean_object* x_14; x_14 = lean_nat_add(x_4, x_9); lean_dec(x_4); x_3 = x_10; x_4 = x_14; x_5 = lean_box(0); goto _start; } else { lean_object* x_16; lean_dec(x_10); lean_dec(x_2); x_16 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_16, 0, x_4); return x_16; } } } } LEAN_EXPORT lean_object* l_Array_findIdx_x3f_loop(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_findIdx_x3f_loop___rarg___boxed), 5, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_findIdx_x3f_loop___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_findIdx_x3f_loop___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_1); return x_6; } } LEAN_EXPORT lean_object* l_Array_findIdx_x3f___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; lean_object* x_5; x_3 = lean_array_get_size(x_1); x_4 = lean_unsigned_to_nat(0u); x_5 = l_Array_findIdx_x3f_loop___rarg(x_1, x_2, x_3, x_4, lean_box(0)); return x_5; } } LEAN_EXPORT lean_object* l_Array_findIdx_x3f(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_findIdx_x3f___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_findIdx_x3f___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_findIdx_x3f___rarg(x_1, x_2); lean_dec(x_1); return x_3; } } LEAN_EXPORT lean_object* l_Array_getIdx_x3f___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_apply_2(x_1, x_3, x_2); return x_4; } } LEAN_EXPORT lean_object* l_Array_getIdx_x3f___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; lean_object* x_7; x_4 = lean_alloc_closure((void*)(l_Array_getIdx_x3f___rarg___lambda__1), 3, 2); lean_closure_set(x_4, 0, x_1); lean_closure_set(x_4, 1, x_3); x_5 = lean_array_get_size(x_2); x_6 = lean_unsigned_to_nat(0u); x_7 = l_Array_findIdx_x3f_loop___rarg(x_2, x_4, x_5, x_6, lean_box(0)); return x_7; } } LEAN_EXPORT lean_object* l_Array_getIdx_x3f(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_getIdx_x3f___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_getIdx_x3f___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_getIdx_x3f___rarg(x_1, x_2, x_3); lean_dec(x_2); return x_4; } } LEAN_EXPORT uint8_t l_Array_anyMUnsafe_any___at_Array_any___spec__1___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4) { _start: { uint8_t x_5; x_5 = lean_usize_dec_eq(x_3, x_4); if (x_5 == 0) { lean_object* x_6; lean_object* x_7; uint8_t x_8; x_6 = lean_array_uget(x_2, x_3); lean_inc(x_1); x_7 = lean_apply_1(x_1, x_6); x_8 = lean_unbox(x_7); lean_dec(x_7); if (x_8 == 0) { size_t x_9; size_t x_10; x_9 = 1; x_10 = lean_usize_add(x_3, x_9); x_3 = x_10; goto _start; } else { uint8_t x_12; lean_dec(x_1); x_12 = 1; return x_12; } } else { uint8_t x_13; lean_dec(x_1); x_13 = 0; return x_13; } } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_any___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_anyMUnsafe_any___at_Array_any___spec__1___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT uint8_t l_Array_any___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_nat_dec_lt(x_3, x_4); if (x_5 == 0) { uint8_t x_6; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_6 = 0; return x_6; } else { lean_object* x_7; uint8_t x_8; x_7 = lean_array_get_size(x_1); x_8 = lean_nat_dec_le(x_4, x_7); lean_dec(x_7); if (x_8 == 0) { uint8_t x_9; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_9 = 0; return x_9; } else { size_t x_10; size_t x_11; uint8_t x_12; x_10 = lean_usize_of_nat(x_3); lean_dec(x_3); x_11 = lean_usize_of_nat(x_4); lean_dec(x_4); x_12 = l_Array_anyMUnsafe_any___at_Array_any___spec__1___rarg(x_2, x_1, x_10, x_11); lean_dec(x_1); return x_12; } } } } LEAN_EXPORT lean_object* l_Array_any(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_any___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_any___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { size_t x_5; size_t x_6; uint8_t x_7; lean_object* x_8; x_5 = lean_unbox_usize(x_3); lean_dec(x_3); x_6 = lean_unbox_usize(x_4); lean_dec(x_4); x_7 = l_Array_anyMUnsafe_any___at_Array_any___spec__1___rarg(x_1, x_2, x_5, x_6); lean_dec(x_2); x_8 = lean_box(x_7); return x_8; } } LEAN_EXPORT lean_object* l_Array_any___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { uint8_t x_5; lean_object* x_6; x_5 = l_Array_any___rarg(x_1, x_2, x_3, x_4); x_6 = lean_box(x_5); return x_6; } } LEAN_EXPORT uint8_t l_Array_anyMUnsafe_any___at_Array_all___spec__1___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4) { _start: { uint8_t x_5; x_5 = lean_usize_dec_eq(x_3, x_4); if (x_5 == 0) { lean_object* x_6; lean_object* x_7; uint8_t x_8; x_6 = lean_array_uget(x_2, x_3); lean_inc(x_1); x_7 = lean_apply_1(x_1, x_6); x_8 = lean_unbox(x_7); lean_dec(x_7); if (x_8 == 0) { uint8_t x_9; lean_dec(x_1); x_9 = 1; return x_9; } else { size_t x_10; size_t x_11; x_10 = 1; x_11 = lean_usize_add(x_3, x_10); x_3 = x_11; goto _start; } } else { uint8_t x_13; lean_dec(x_1); x_13 = 0; return x_13; } } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_all___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_anyMUnsafe_any___at_Array_all___spec__1___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT uint8_t l_Array_all___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_nat_dec_lt(x_3, x_4); if (x_5 == 0) { uint8_t x_6; lean_dec(x_2); x_6 = 1; return x_6; } else { lean_object* x_7; uint8_t x_8; x_7 = lean_array_get_size(x_1); x_8 = lean_nat_dec_le(x_4, x_7); lean_dec(x_7); if (x_8 == 0) { uint8_t x_9; lean_dec(x_2); x_9 = 1; return x_9; } else { size_t x_10; size_t x_11; uint8_t x_12; x_10 = lean_usize_of_nat(x_3); x_11 = lean_usize_of_nat(x_4); x_12 = l_Array_anyMUnsafe_any___at_Array_all___spec__1___rarg(x_2, x_1, x_10, x_11); if (x_12 == 0) { uint8_t x_13; x_13 = 1; return x_13; } else { uint8_t x_14; x_14 = 0; return x_14; } } } } } LEAN_EXPORT lean_object* l_Array_all(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_all___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_all___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { size_t x_5; size_t x_6; uint8_t x_7; lean_object* x_8; x_5 = lean_unbox_usize(x_3); lean_dec(x_3); x_6 = lean_unbox_usize(x_4); lean_dec(x_4); x_7 = l_Array_anyMUnsafe_any___at_Array_all___spec__1___rarg(x_1, x_2, x_5, x_6); lean_dec(x_2); x_8 = lean_box(x_7); return x_8; } } LEAN_EXPORT lean_object* l_Array_all___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { uint8_t x_5; lean_object* x_6; x_5 = l_Array_all___rarg(x_1, x_2, x_3, x_4); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_6 = lean_box(x_5); return x_6; } } LEAN_EXPORT uint8_t l_Array_anyMUnsafe_any___at_Array_contains___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_eq(x_4, x_5); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; uint8_t x_9; x_7 = lean_array_uget(x_3, x_4); lean_inc(x_1); lean_inc(x_2); x_8 = lean_apply_2(x_1, x_2, x_7); x_9 = lean_unbox(x_8); lean_dec(x_8); if (x_9 == 0) { size_t x_10; size_t x_11; x_10 = 1; x_11 = lean_usize_add(x_4, x_10); x_4 = x_11; goto _start; } else { uint8_t x_13; lean_dec(x_2); lean_dec(x_1); x_13 = 1; return x_13; } } else { uint8_t x_14; lean_dec(x_2); lean_dec(x_1); x_14 = 0; return x_14; } } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_contains___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_anyMUnsafe_any___at_Array_contains___spec__1___rarg___boxed), 5, 0); return x_2; } } LEAN_EXPORT uint8_t l_Array_contains___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; uint8_t x_6; x_4 = lean_array_get_size(x_2); x_5 = lean_unsigned_to_nat(0u); x_6 = lean_nat_dec_lt(x_5, x_4); if (x_6 == 0) { uint8_t x_7; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_7 = 0; return x_7; } else { uint8_t x_8; x_8 = lean_nat_dec_le(x_4, x_4); if (x_8 == 0) { uint8_t x_9; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_9 = 0; return x_9; } else { size_t x_10; size_t x_11; uint8_t x_12; x_10 = 0; x_11 = lean_usize_of_nat(x_4); lean_dec(x_4); x_12 = l_Array_anyMUnsafe_any___at_Array_contains___spec__1___rarg(x_1, x_3, x_2, x_10, x_11); lean_dec(x_2); return x_12; } } } } LEAN_EXPORT lean_object* l_Array_contains(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_contains___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_anyMUnsafe_any___at_Array_contains___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; uint8_t x_8; lean_object* x_9; x_6 = lean_unbox_usize(x_4); lean_dec(x_4); x_7 = lean_unbox_usize(x_5); lean_dec(x_5); x_8 = l_Array_anyMUnsafe_any___at_Array_contains___spec__1___rarg(x_1, x_2, x_3, x_6, x_7); lean_dec(x_3); x_9 = lean_box(x_8); return x_9; } } LEAN_EXPORT lean_object* l_Array_contains___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { uint8_t x_4; lean_object* x_5; x_4 = l_Array_contains___rarg(x_1, x_2, x_3); x_5 = lean_box(x_4); return x_5; } } LEAN_EXPORT uint8_t l_Array_elem___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { uint8_t x_4; x_4 = l_Array_contains___rarg(x_1, x_3, x_2); return x_4; } } LEAN_EXPORT lean_object* l_Array_elem(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_elem___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_elem___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { uint8_t x_4; lean_object* x_5; x_4 = l_Array_elem___rarg(x_1, x_2, x_3); x_5 = lean_box(x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_getEvenElems___spec__1___rarg(lean_object* x_1, size_t x_2, size_t x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_usize_dec_eq(x_2, x_3); if (x_5 == 0) { lean_object* x_6; size_t x_7; size_t x_8; lean_object* x_9; uint8_t x_10; x_6 = lean_array_uget(x_1, x_2); x_7 = 1; x_8 = lean_usize_add(x_2, x_7); x_9 = lean_ctor_get(x_4, 0); lean_inc(x_9); x_10 = lean_unbox(x_9); lean_dec(x_9); if (x_10 == 0) { uint8_t x_11; lean_dec(x_6); x_11 = !lean_is_exclusive(x_4); if (x_11 == 0) { lean_object* x_12; uint8_t x_13; lean_object* x_14; x_12 = lean_ctor_get(x_4, 0); lean_dec(x_12); x_13 = 1; x_14 = lean_box(x_13); lean_ctor_set(x_4, 0, x_14); x_2 = x_8; goto _start; } else { lean_object* x_16; uint8_t x_17; lean_object* x_18; lean_object* x_19; x_16 = lean_ctor_get(x_4, 1); lean_inc(x_16); lean_dec(x_4); x_17 = 1; x_18 = lean_box(x_17); x_19 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_19, 0, x_18); lean_ctor_set(x_19, 1, x_16); x_2 = x_8; x_4 = x_19; goto _start; } } else { uint8_t x_21; x_21 = !lean_is_exclusive(x_4); if (x_21 == 0) { lean_object* x_22; lean_object* x_23; lean_object* x_24; uint8_t x_25; lean_object* x_26; x_22 = lean_ctor_get(x_4, 1); x_23 = lean_ctor_get(x_4, 0); lean_dec(x_23); x_24 = lean_array_push(x_22, x_6); x_25 = 0; x_26 = lean_box(x_25); lean_ctor_set(x_4, 1, x_24); lean_ctor_set(x_4, 0, x_26); x_2 = x_8; goto _start; } else { lean_object* x_28; lean_object* x_29; uint8_t x_30; lean_object* x_31; lean_object* x_32; x_28 = lean_ctor_get(x_4, 1); lean_inc(x_28); lean_dec(x_4); x_29 = lean_array_push(x_28, x_6); x_30 = 0; x_31 = lean_box(x_30); x_32 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_32, 0, x_31); lean_ctor_set(x_32, 1, x_29); x_2 = x_8; x_4 = x_32; goto _start; } } } else { return x_4; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_getEvenElems___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_getEvenElems___spec__1___rarg___boxed), 4, 0); return x_2; } } static lean_object* _init_l_Array_getEvenElems___rarg___closed__1() { _start: { uint8_t x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; x_1 = 1; x_2 = l_Array_instEmptyCollectionArray___closed__1; x_3 = lean_box(x_1); x_4 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_4, 0, x_3); lean_ctor_set(x_4, 1, x_2); return x_4; } } LEAN_EXPORT lean_object* l_Array_getEvenElems___rarg(lean_object* x_1) { _start: { lean_object* x_2; lean_object* x_3; uint8_t x_4; x_2 = lean_array_get_size(x_1); x_3 = lean_unsigned_to_nat(0u); x_4 = lean_nat_dec_lt(x_3, x_2); if (x_4 == 0) { lean_object* x_5; lean_dec(x_2); x_5 = l_Array_instEmptyCollectionArray___closed__1; return x_5; } else { uint8_t x_6; x_6 = lean_nat_dec_le(x_2, x_2); if (x_6 == 0) { lean_object* x_7; lean_dec(x_2); x_7 = l_Array_instEmptyCollectionArray___closed__1; return x_7; } else { size_t x_8; size_t x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; x_8 = 0; x_9 = lean_usize_of_nat(x_2); lean_dec(x_2); x_10 = l_Array_getEvenElems___rarg___closed__1; x_11 = l_Array_foldlMUnsafe_fold___at_Array_getEvenElems___spec__1___rarg(x_1, x_8, x_9, x_10); x_12 = lean_ctor_get(x_11, 1); lean_inc(x_12); lean_dec(x_11); return x_12; } } } } LEAN_EXPORT lean_object* l_Array_getEvenElems(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_getEvenElems___rarg___boxed), 1, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_getEvenElems___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { size_t x_5; size_t x_6; lean_object* x_7; x_5 = lean_unbox_usize(x_2); lean_dec(x_2); x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = l_Array_foldlMUnsafe_fold___at_Array_getEvenElems___spec__1___rarg(x_1, x_5, x_6, x_4); lean_dec(x_1); return x_7; } } LEAN_EXPORT lean_object* l_Array_getEvenElems___rarg___boxed(lean_object* x_1) { _start: { lean_object* x_2; x_2 = l_Array_getEvenElems___rarg(x_1); lean_dec(x_1); return x_2; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__1___rarg(lean_object* x_1, size_t x_2, size_t x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_usize_dec_eq(x_2, x_3); if (x_5 == 0) { size_t x_6; size_t x_7; lean_object* x_8; lean_object* x_9; x_6 = 1; x_7 = lean_usize_sub(x_2, x_6); x_8 = lean_array_uget(x_1, x_7); x_9 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_9, 0, x_8); lean_ctor_set(x_9, 1, x_4); x_2 = x_7; x_4 = x_9; goto _start; } else { return x_4; } } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe_fold___at_Array_toList___spec__1___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__2___rarg(lean_object* x_1, size_t x_2, size_t x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_usize_dec_eq(x_2, x_3); if (x_5 == 0) { size_t x_6; size_t x_7; lean_object* x_8; lean_object* x_9; x_6 = 1; x_7 = lean_usize_sub(x_2, x_6); x_8 = lean_array_uget(x_1, x_7); x_9 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_9, 0, x_8); lean_ctor_set(x_9, 1, x_4); x_2 = x_7; x_4 = x_9; goto _start; } else { return x_4; } } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__2(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_foldrMUnsafe_fold___at_Array_toList___spec__2___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* lean_array_to_list(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; uint8_t x_5; x_3 = lean_box(0); x_4 = lean_array_get_size(x_2); x_5 = lean_nat_dec_le(x_4, x_4); if (x_5 == 0) { lean_object* x_6; uint8_t x_7; x_6 = lean_unsigned_to_nat(0u); x_7 = lean_nat_dec_lt(x_6, x_4); if (x_7 == 0) { lean_dec(x_4); lean_dec(x_2); return x_3; } else { size_t x_8; size_t x_9; lean_object* x_10; x_8 = lean_usize_of_nat(x_4); lean_dec(x_4); x_9 = 0; x_10 = l_Array_foldrMUnsafe_fold___at_Array_toList___spec__1___rarg(x_2, x_8, x_9, x_3); lean_dec(x_2); return x_10; } } else { lean_object* x_11; uint8_t x_12; x_11 = lean_unsigned_to_nat(0u); x_12 = lean_nat_dec_lt(x_11, x_4); if (x_12 == 0) { lean_dec(x_4); lean_dec(x_2); return x_3; } else { size_t x_13; size_t x_14; lean_object* x_15; x_13 = lean_usize_of_nat(x_4); lean_dec(x_4); x_14 = 0; x_15 = l_Array_foldrMUnsafe_fold___at_Array_toList___spec__2___rarg(x_2, x_13, x_14, x_3); lean_dec(x_2); return x_15; } } } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { size_t x_5; size_t x_6; lean_object* x_7; x_5 = lean_unbox_usize(x_2); lean_dec(x_2); x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = l_Array_foldrMUnsafe_fold___at_Array_toList___spec__1___rarg(x_1, x_5, x_6, x_4); lean_dec(x_1); return x_7; } } LEAN_EXPORT lean_object* l_Array_foldrMUnsafe_fold___at_Array_toList___spec__2___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { size_t x_5; size_t x_6; lean_object* x_7; x_5 = lean_unbox_usize(x_2); lean_dec(x_2); x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = l_Array_foldrMUnsafe_fold___at_Array_toList___spec__2___rarg(x_1, x_5, x_6, x_4); lean_dec(x_1); return x_7; } } LEAN_EXPORT lean_object* l_List_foldl___at_Array_instReprArray___spec__2___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { if (lean_obj_tag(x_4) == 0) { lean_dec(x_2); lean_dec(x_1); return x_3; } else { lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; x_5 = lean_ctor_get(x_4, 0); lean_inc(x_5); x_6 = lean_ctor_get(x_4, 1); lean_inc(x_6); lean_dec(x_4); lean_inc(x_2); x_7 = lean_alloc_ctor(5, 2, 0); lean_ctor_set(x_7, 0, x_3); lean_ctor_set(x_7, 1, x_2); x_8 = lean_unsigned_to_nat(0u); lean_inc(x_1); x_9 = lean_apply_2(x_1, x_5, x_8); x_10 = lean_alloc_ctor(5, 2, 0); lean_ctor_set(x_10, 0, x_7); lean_ctor_set(x_10, 1, x_9); x_3 = x_10; x_4 = x_6; goto _start; } } } LEAN_EXPORT lean_object* l_List_foldl___at_Array_instReprArray___spec__2(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_List_foldl___at_Array_instReprArray___spec__2___rarg), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Std_Format_joinSep___at_Array_instReprArray___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { if (lean_obj_tag(x_2) == 0) { lean_object* x_4; lean_dec(x_3); lean_dec(x_1); x_4 = lean_box(0); return x_4; } else { lean_object* x_5; x_5 = lean_ctor_get(x_2, 1); lean_inc(x_5); if (lean_obj_tag(x_5) == 0) { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_dec(x_3); x_6 = lean_ctor_get(x_2, 0); lean_inc(x_6); lean_dec(x_2); x_7 = lean_unsigned_to_nat(0u); x_8 = lean_apply_2(x_1, x_6, x_7); return x_8; } else { lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; x_9 = lean_ctor_get(x_2, 0); lean_inc(x_9); lean_dec(x_2); x_10 = lean_unsigned_to_nat(0u); lean_inc(x_1); x_11 = lean_apply_2(x_1, x_9, x_10); x_12 = l_List_foldl___at_Array_instReprArray___spec__2___rarg(x_1, x_3, x_11, x_5); return x_12; } } } } LEAN_EXPORT lean_object* l_Std_Format_joinSep___at_Array_instReprArray___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Std_Format_joinSep___at_Array_instReprArray___spec__1___rarg), 3, 0); return x_2; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes(",", 1); return x_1; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__2() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Array_instReprArray___rarg___closed__1; x_2 = lean_alloc_ctor(3, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__3() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = l_Array_instReprArray___rarg___closed__2; x_2 = lean_box(1); x_3 = lean_alloc_ctor(5, 2, 0); lean_ctor_set(x_3, 0, x_1); lean_ctor_set(x_3, 1, x_2); return x_3; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__4() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("#[", 2); return x_1; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__5() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Array_instReprArray___rarg___closed__4; x_2 = lean_string_length(x_1); return x_2; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__6() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Array_instReprArray___rarg___closed__5; x_2 = lean_nat_to_int(x_1); return x_2; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__7() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Array_instReprArray___rarg___closed__4; x_2 = lean_alloc_ctor(3, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__8() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("]", 1); return x_1; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__9() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Array_instReprArray___rarg___closed__8; x_2 = lean_alloc_ctor(3, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__10() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("#[]", 3); return x_1; } } static lean_object* _init_l_Array_instReprArray___rarg___closed__11() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Array_instReprArray___rarg___closed__10; x_2 = lean_alloc_ctor(3, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } LEAN_EXPORT lean_object* l_Array_instReprArray___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; uint8_t x_6; x_4 = lean_array_get_size(x_2); x_5 = lean_unsigned_to_nat(0u); x_6 = lean_nat_dec_eq(x_4, x_5); lean_dec(x_4); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; uint8_t x_16; lean_object* x_17; x_7 = lean_array_to_list(lean_box(0), x_2); x_8 = l_Array_instReprArray___rarg___closed__3; x_9 = l_Std_Format_joinSep___at_Array_instReprArray___spec__1___rarg(x_1, x_7, x_8); x_10 = l_Array_instReprArray___rarg___closed__7; x_11 = lean_alloc_ctor(5, 2, 0); lean_ctor_set(x_11, 0, x_10); lean_ctor_set(x_11, 1, x_9); x_12 = l_Array_instReprArray___rarg___closed__9; x_13 = lean_alloc_ctor(5, 2, 0); lean_ctor_set(x_13, 0, x_11); lean_ctor_set(x_13, 1, x_12); x_14 = l_Array_instReprArray___rarg___closed__6; x_15 = lean_alloc_ctor(4, 2, 0); lean_ctor_set(x_15, 0, x_14); lean_ctor_set(x_15, 1, x_13); x_16 = 1; x_17 = lean_alloc_ctor(6, 1, 1); lean_ctor_set(x_17, 0, x_15); lean_ctor_set_uint8(x_17, sizeof(void*)*1, x_16); return x_17; } else { lean_object* x_18; lean_dec(x_2); lean_dec(x_1); x_18 = l_Array_instReprArray___rarg___closed__11; return x_18; } } } LEAN_EXPORT lean_object* l_Array_instReprArray(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_instReprArray___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_instReprArray___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_instReprArray___rarg(x_1, x_2, x_3); lean_dec(x_3); return x_4; } } static lean_object* _init_l_Array_instToStringArray___rarg___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("#", 1); return x_1; } } LEAN_EXPORT lean_object* l_Array_instToStringArray___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_3 = lean_array_to_list(lean_box(0), x_2); x_4 = l_List_toString___rarg(x_1, x_3); x_5 = l_Array_instToStringArray___rarg___closed__1; x_6 = lean_string_append(x_5, x_4); lean_dec(x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_instToStringArray(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_instToStringArray___rarg), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_append___spec__1___rarg(lean_object* x_1, size_t x_2, size_t x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_usize_dec_eq(x_2, x_3); if (x_5 == 0) { lean_object* x_6; lean_object* x_7; size_t x_8; size_t x_9; x_6 = lean_array_uget(x_1, x_2); x_7 = lean_array_push(x_4, x_6); x_8 = 1; x_9 = lean_usize_add(x_2, x_8); x_2 = x_9; x_4 = x_7; goto _start; } else { return x_4; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_append___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_append___spec__1___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_append___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; uint8_t x_5; x_3 = lean_array_get_size(x_2); x_4 = lean_unsigned_to_nat(0u); x_5 = lean_nat_dec_lt(x_4, x_3); if (x_5 == 0) { lean_dec(x_3); lean_dec(x_2); return x_1; } else { uint8_t x_6; x_6 = lean_nat_dec_le(x_3, x_3); if (x_6 == 0) { lean_dec(x_3); lean_dec(x_2); return x_1; } else { size_t x_7; size_t x_8; lean_object* x_9; x_7 = 0; x_8 = lean_usize_of_nat(x_3); lean_dec(x_3); x_9 = l_Array_foldlMUnsafe_fold___at_Array_append___spec__1___rarg(x_2, x_7, x_8, x_1); lean_dec(x_2); return x_9; } } } } LEAN_EXPORT lean_object* l_Array_append(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_append___rarg), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_append___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { size_t x_5; size_t x_6; lean_object* x_7; x_5 = lean_unbox_usize(x_2); lean_dec(x_2); x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = l_Array_foldlMUnsafe_fold___at_Array_append___spec__1___rarg(x_1, x_5, x_6, x_4); lean_dec(x_1); return x_7; } } static lean_object* _init_l_Array_instAppendArray___closed__1() { _start: { lean_object* x_1; x_1 = lean_alloc_closure((void*)(l_Array_append___rarg), 2, 0); return x_1; } } LEAN_EXPORT lean_object* l_Array_instAppendArray(lean_object* x_1) { _start: { lean_object* x_2; x_2 = l_Array_instAppendArray___closed__1; return x_2; } } LEAN_EXPORT lean_object* l_List_foldl___at_Array_appendList___spec__1___rarg(lean_object* x_1, lean_object* x_2) { _start: { if (lean_obj_tag(x_2) == 0) { return x_1; } else { lean_object* x_3; lean_object* x_4; lean_object* x_5; x_3 = lean_ctor_get(x_2, 0); lean_inc(x_3); x_4 = lean_ctor_get(x_2, 1); lean_inc(x_4); lean_dec(x_2); x_5 = lean_array_push(x_1, x_3); x_1 = x_5; x_2 = x_4; goto _start; } } } LEAN_EXPORT lean_object* l_List_foldl___at_Array_appendList___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_List_foldl___at_Array_appendList___spec__1___rarg), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_appendList___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_List_foldl___at_Array_appendList___spec__1___rarg(x_1, x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_appendList(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_appendList___rarg), 2, 0); return x_2; } } static lean_object* _init_l_Array_instHAppendArrayList___closed__1() { _start: { lean_object* x_1; x_1 = lean_alloc_closure((void*)(l_Array_appendList___rarg), 2, 0); return x_1; } } LEAN_EXPORT lean_object* l_Array_instHAppendArrayList(lean_object* x_1) { _start: { lean_object* x_2; x_2 = l_Array_instHAppendArrayList___closed__1; return x_2; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; lean_object* x_7; x_4 = lean_ctor_get(x_1, 0); lean_inc(x_4); lean_dec(x_1); x_5 = lean_ctor_get(x_4, 1); lean_inc(x_5); lean_dec(x_4); x_6 = l_Array_append___rarg(x_2, x_3); x_7 = lean_apply_2(x_5, lean_box(0), x_6); return x_7; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___lambda__2(size_t x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, size_t x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = 1; x_8 = lean_usize_add(x_1, x_7); x_9 = l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg(x_2, x_3, x_4, x_8, x_5, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_eq(x_4, x_5); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; x_8 = lean_ctor_get(x_1, 1); lean_inc(x_8); x_9 = lean_array_uget(x_3, x_4); lean_inc(x_2); x_10 = lean_apply_1(x_2, x_9); lean_inc(x_1); x_11 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___lambda__1), 3, 2); lean_closure_set(x_11, 0, x_1); lean_closure_set(x_11, 1, x_6); lean_inc(x_8); x_12 = lean_apply_4(x_8, lean_box(0), lean_box(0), x_10, x_11); x_13 = lean_box_usize(x_4); x_14 = lean_box_usize(x_5); x_15 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___lambda__2___boxed), 6, 5); lean_closure_set(x_15, 0, x_13); lean_closure_set(x_15, 1, x_1); lean_closure_set(x_15, 2, x_2); lean_closure_set(x_15, 3, x_3); lean_closure_set(x_15, 4, x_14); x_16 = lean_apply_4(x_8, lean_box(0), lean_box(0), x_12, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_dec(x_3); lean_dec(x_2); x_17 = lean_ctor_get(x_1, 0); lean_inc(x_17); lean_dec(x_1); x_18 = lean_ctor_get(x_17, 1); lean_inc(x_18); lean_dec(x_17); x_19 = lean_apply_2(x_18, lean_box(0), x_6); return x_19; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___boxed), 6, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_concatMapM___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; uint8_t x_6; x_4 = lean_array_get_size(x_3); x_5 = lean_unsigned_to_nat(0u); x_6 = lean_nat_dec_lt(x_5, x_4); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = l_Array_instEmptyCollectionArray___closed__1; x_10 = lean_apply_2(x_8, lean_box(0), x_9); return x_10; } else { uint8_t x_11; x_11 = lean_nat_dec_le(x_4, x_4); if (x_11 == 0) { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_12 = lean_ctor_get(x_1, 0); lean_inc(x_12); lean_dec(x_1); x_13 = lean_ctor_get(x_12, 1); lean_inc(x_13); lean_dec(x_12); x_14 = l_Array_instEmptyCollectionArray___closed__1; x_15 = lean_apply_2(x_13, lean_box(0), x_14); return x_15; } else { size_t x_16; size_t x_17; lean_object* x_18; lean_object* x_19; x_16 = 0; x_17 = lean_usize_of_nat(x_4); lean_dec(x_4); x_18 = l_Array_instEmptyCollectionArray___closed__1; x_19 = l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg(x_1, x_2, x_3, x_16, x_17, x_18); return x_19; } } } } LEAN_EXPORT lean_object* l_Array_concatMapM(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_concatMapM___rarg), 3, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___lambda__2___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_1); lean_dec(x_1); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___lambda__2(x_7, x_2, x_3, x_4, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldlMUnsafe_fold___at_Array_concatMapM___spec__1___rarg(x_1, x_2, x_3, x_7, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMap___spec__1___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_eq(x_3, x_4); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; size_t x_10; size_t x_11; x_7 = lean_array_uget(x_2, x_3); lean_inc(x_1); x_8 = lean_apply_1(x_1, x_7); x_9 = l_Array_append___rarg(x_5, x_8); x_10 = 1; x_11 = lean_usize_add(x_3, x_10); x_3 = x_11; x_5 = x_9; goto _start; } else { lean_dec(x_1); return x_5; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMap___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_concatMap___spec__1___rarg___boxed), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_concatMap___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; uint8_t x_5; x_3 = lean_array_get_size(x_2); x_4 = lean_unsigned_to_nat(0u); x_5 = lean_nat_dec_lt(x_4, x_3); if (x_5 == 0) { lean_object* x_6; lean_dec(x_3); lean_dec(x_1); x_6 = l_Array_instEmptyCollectionArray___closed__1; return x_6; } else { uint8_t x_7; x_7 = lean_nat_dec_le(x_3, x_3); if (x_7 == 0) { lean_object* x_8; lean_dec(x_3); lean_dec(x_1); x_8 = l_Array_instEmptyCollectionArray___closed__1; return x_8; } else { size_t x_9; size_t x_10; lean_object* x_11; lean_object* x_12; x_9 = 0; x_10 = lean_usize_of_nat(x_3); lean_dec(x_3); x_11 = l_Array_instEmptyCollectionArray___closed__1; x_12 = l_Array_foldlMUnsafe_fold___at_Array_concatMap___spec__1___rarg(x_1, x_2, x_9, x_10, x_11); return x_12; } } } } LEAN_EXPORT lean_object* l_Array_concatMap(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_concatMap___rarg___boxed), 2, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_concatMap___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; lean_object* x_8; x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = l_Array_foldlMUnsafe_fold___at_Array_concatMap___spec__1___rarg(x_1, x_2, x_6, x_7, x_5); lean_dec(x_2); return x_8; } } LEAN_EXPORT lean_object* l_Array_concatMap___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_concatMap___rarg(x_1, x_2); lean_dec(x_2); return x_3; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("term#[_,]", 9); return x_1; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__2() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l_term_x23_x5b___x2c_x5d___closed__1; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__3() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("andthen", 7); return x_1; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__4() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l_term_x23_x5b___x2c_x5d___closed__3; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__5() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Array_instReprArray___rarg___closed__4; x_2 = lean_alloc_ctor(5, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__6() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("withoutPosition", 15); return x_1; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__7() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l_term_x23_x5b___x2c_x5d___closed__6; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__8() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("term", 4); return x_1; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__9() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l_term_x23_x5b___x2c_x5d___closed__8; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__10() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = l_term_x23_x5b___x2c_x5d___closed__9; x_2 = lean_unsigned_to_nat(0u); x_3 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_3, 0, x_1); lean_ctor_set(x_3, 1, x_2); return x_3; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__11() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes(", ", 2); return x_1; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__12() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_term_x23_x5b___x2c_x5d___closed__11; x_2 = lean_alloc_ctor(5, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__13() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; uint8_t x_4; lean_object* x_5; x_1 = l_term_x23_x5b___x2c_x5d___closed__10; x_2 = l_term_x23_x5b___x2c_x5d___closed__11; x_3 = l_term_x23_x5b___x2c_x5d___closed__12; x_4 = 0; x_5 = lean_alloc_ctor(10, 3, 1); lean_ctor_set(x_5, 0, x_1); lean_ctor_set(x_5, 1, x_2); lean_ctor_set(x_5, 2, x_3); lean_ctor_set_uint8(x_5, sizeof(void*)*3, x_4); return x_5; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__14() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = l_term_x23_x5b___x2c_x5d___closed__7; x_2 = l_term_x23_x5b___x2c_x5d___closed__13; x_3 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_3, 0, x_1); lean_ctor_set(x_3, 1, x_2); return x_3; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__15() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; x_1 = l_term_x23_x5b___x2c_x5d___closed__4; x_2 = l_term_x23_x5b___x2c_x5d___closed__5; x_3 = l_term_x23_x5b___x2c_x5d___closed__14; x_4 = lean_alloc_ctor(2, 3, 0); lean_ctor_set(x_4, 0, x_1); lean_ctor_set(x_4, 1, x_2); lean_ctor_set(x_4, 2, x_3); return x_4; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__16() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Array_instReprArray___rarg___closed__8; x_2 = lean_alloc_ctor(5, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__17() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; x_1 = l_term_x23_x5b___x2c_x5d___closed__4; x_2 = l_term_x23_x5b___x2c_x5d___closed__15; x_3 = l_term_x23_x5b___x2c_x5d___closed__16; x_4 = lean_alloc_ctor(2, 3, 0); lean_ctor_set(x_4, 0, x_1); lean_ctor_set(x_4, 1, x_2); lean_ctor_set(x_4, 2, x_3); return x_4; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d___closed__18() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; x_1 = l_term_x23_x5b___x2c_x5d___closed__2; x_2 = lean_unsigned_to_nat(1024u); x_3 = l_term_x23_x5b___x2c_x5d___closed__17; x_4 = lean_alloc_ctor(3, 3, 0); lean_ctor_set(x_4, 0, x_1); lean_ctor_set(x_4, 1, x_2); lean_ctor_set(x_4, 2, x_3); return x_4; } } static lean_object* _init_l_term_x23_x5b___x2c_x5d() { _start: { lean_object* x_1; x_1 = l_term_x23_x5b___x2c_x5d___closed__18; return x_1; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("Lean", 4); return x_1; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__2() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("Parser", 6); return x_1; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__3() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("Term", 4); return x_1; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__4() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("app", 3); return x_1; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__5() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; x_1 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__1; x_2 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__2; x_3 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__3; x_4 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__4; x_5 = l_Lean_Name_mkStr4(x_1, x_2, x_3, x_4); return x_5; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__6() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("List.toArray", 12); return x_1; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__7() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__6; x_2 = l_String_toSubstring_x27(x_1); return x_2; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__8() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("List", 4); return x_1; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__9() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("toArray", 7); return x_1; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__10() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__8; x_2 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__9; x_3 = l_Lean_Name_mkStr2(x_1, x_2); return x_3; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__11() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__10; x_3 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_3, 0, x_2); lean_ctor_set(x_3, 1, x_1); return x_3; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__12() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__10; x_2 = lean_alloc_ctor(0, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__13() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__12; x_3 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_3, 0, x_2); lean_ctor_set(x_3, 1, x_1); return x_3; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__14() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__11; x_2 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__13; x_3 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_3, 0, x_1); lean_ctor_set(x_3, 1, x_2); return x_3; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__15() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("null", 4); return x_1; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__16() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__15; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__17() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("term[_]", 7); return x_1; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__18() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__17; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } static lean_object* _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__19() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("[", 1); return x_1; } } LEAN_EXPORT lean_object* l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; uint8_t x_5; x_4 = l_term_x23_x5b___x2c_x5d___closed__2; lean_inc(x_1); x_5 = l_Lean_Syntax_isOfKind(x_1, x_4); if (x_5 == 0) { lean_object* x_6; lean_object* x_7; lean_dec(x_2); lean_dec(x_1); x_6 = lean_box(1); x_7 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_7, 0, x_6); lean_ctor_set(x_7, 1, x_3); return x_7; } else { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; uint8_t x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_object* x_25; lean_object* x_26; lean_object* x_27; lean_object* x_28; lean_object* x_29; lean_object* x_30; lean_object* x_31; lean_object* x_32; lean_object* x_33; lean_object* x_34; x_8 = lean_unsigned_to_nat(1u); x_9 = l_Lean_Syntax_getArg(x_1, x_8); lean_dec(x_1); x_10 = l_Lean_Syntax_getArgs(x_9); lean_dec(x_9); x_11 = lean_ctor_get(x_2, 5); lean_inc(x_11); x_12 = 0; x_13 = l_Lean_SourceInfo_fromRef(x_11, x_12); x_14 = lean_ctor_get(x_2, 2); lean_inc(x_14); x_15 = lean_ctor_get(x_2, 1); lean_inc(x_15); lean_dec(x_2); x_16 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__10; x_17 = l_Lean_addMacroScope(x_15, x_16, x_14); x_18 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__7; x_19 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__14; lean_inc(x_13); x_20 = lean_alloc_ctor(3, 4, 0); lean_ctor_set(x_20, 0, x_13); lean_ctor_set(x_20, 1, x_18); lean_ctor_set(x_20, 2, x_17); lean_ctor_set(x_20, 3, x_19); x_21 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__19; lean_inc(x_13); x_22 = lean_alloc_ctor(2, 2, 0); lean_ctor_set(x_22, 0, x_13); lean_ctor_set(x_22, 1, x_21); x_23 = l_Array_instEmptyCollectionArray___closed__1; x_24 = l_Array_append___rarg(x_23, x_10); x_25 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__16; lean_inc(x_13); x_26 = lean_alloc_ctor(1, 3, 0); lean_ctor_set(x_26, 0, x_13); lean_ctor_set(x_26, 1, x_25); lean_ctor_set(x_26, 2, x_24); x_27 = l_Array_instReprArray___rarg___closed__8; lean_inc(x_13); x_28 = lean_alloc_ctor(2, 2, 0); lean_ctor_set(x_28, 0, x_13); lean_ctor_set(x_28, 1, x_27); x_29 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__18; lean_inc(x_13); x_30 = l_Lean_Syntax_node3(x_13, x_29, x_22, x_26, x_28); lean_inc(x_13); x_31 = l_Lean_Syntax_node1(x_13, x_25, x_30); x_32 = l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__5; x_33 = l_Lean_Syntax_node2(x_13, x_32, x_20, x_31); x_34 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_34, 0, x_33); lean_ctor_set(x_34, 1, x_3); return x_34; } } } LEAN_EXPORT uint8_t l_Array_isEqvAux___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_array_get_size(x_1); x_7 = lean_nat_dec_lt(x_5, x_6); lean_dec(x_6); if (x_7 == 0) { uint8_t x_8; lean_dec(x_5); lean_dec(x_4); x_8 = 1; return x_8; } else { lean_object* x_9; lean_object* x_10; lean_object* x_11; uint8_t x_12; x_9 = lean_array_fget(x_1, x_5); x_10 = lean_array_fget(x_2, x_5); lean_inc(x_4); x_11 = lean_apply_2(x_4, x_9, x_10); x_12 = lean_unbox(x_11); lean_dec(x_11); if (x_12 == 0) { uint8_t x_13; lean_dec(x_5); lean_dec(x_4); x_13 = 0; return x_13; } else { lean_object* x_14; lean_object* x_15; x_14 = lean_unsigned_to_nat(1u); x_15 = lean_nat_add(x_5, x_14); lean_dec(x_5); x_3 = lean_box(0); x_5 = x_15; goto _start; } } } } LEAN_EXPORT lean_object* l_Array_isEqvAux(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_isEqvAux___rarg___boxed), 5, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_isEqvAux___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { uint8_t x_6; lean_object* x_7; x_6 = l_Array_isEqvAux___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_2); lean_dec(x_1); x_7 = lean_box(x_6); return x_7; } } LEAN_EXPORT uint8_t l_Array_isEqv___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; uint8_t x_6; x_4 = lean_array_get_size(x_1); x_5 = lean_array_get_size(x_2); x_6 = lean_nat_dec_eq(x_4, x_5); lean_dec(x_5); lean_dec(x_4); if (x_6 == 0) { uint8_t x_7; lean_dec(x_3); x_7 = 0; return x_7; } else { lean_object* x_8; uint8_t x_9; x_8 = lean_unsigned_to_nat(0u); x_9 = l_Array_isEqvAux___rarg(x_1, x_2, lean_box(0), x_3, x_8); return x_9; } } } LEAN_EXPORT lean_object* l_Array_isEqv(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_isEqv___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_isEqv___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { uint8_t x_4; lean_object* x_5; x_4 = l_Array_isEqv___rarg(x_1, x_2, x_3); lean_dec(x_2); lean_dec(x_1); x_5 = lean_box(x_4); return x_5; } } LEAN_EXPORT uint8_t l_Array_instBEqArray___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; uint8_t x_6; x_4 = lean_array_get_size(x_2); x_5 = lean_array_get_size(x_3); x_6 = lean_nat_dec_eq(x_4, x_5); lean_dec(x_5); lean_dec(x_4); if (x_6 == 0) { uint8_t x_7; lean_dec(x_1); x_7 = 0; return x_7; } else { lean_object* x_8; uint8_t x_9; x_8 = lean_unsigned_to_nat(0u); x_9 = l_Array_isEqvAux___rarg(x_2, x_3, lean_box(0), x_1, x_8); return x_9; } } } LEAN_EXPORT lean_object* l_Array_instBEqArray(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_instBEqArray___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_instBEqArray___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { uint8_t x_4; lean_object* x_5; x_4 = l_Array_instBEqArray___rarg(x_1, x_2, x_3); lean_dec(x_3); lean_dec(x_2); x_5 = lean_box(x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filter___spec__1___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_eq(x_3, x_4); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; uint8_t x_9; size_t x_10; size_t x_11; x_7 = lean_array_uget(x_2, x_3); lean_inc(x_1); lean_inc(x_7); x_8 = lean_apply_1(x_1, x_7); x_9 = lean_unbox(x_8); lean_dec(x_8); x_10 = 1; x_11 = lean_usize_add(x_3, x_10); if (x_9 == 0) { lean_dec(x_7); x_3 = x_11; goto _start; } else { lean_object* x_13; x_13 = lean_array_push(x_5, x_7); x_3 = x_11; x_5 = x_13; goto _start; } } else { lean_dec(x_1); return x_5; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filter___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_filter___spec__1___rarg___boxed), 5, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_filter___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_nat_dec_lt(x_3, x_4); if (x_5 == 0) { lean_object* x_6; lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_6 = l_Array_instEmptyCollectionArray___closed__1; return x_6; } else { lean_object* x_7; uint8_t x_8; x_7 = lean_array_get_size(x_2); x_8 = lean_nat_dec_le(x_4, x_7); lean_dec(x_7); if (x_8 == 0) { lean_object* x_9; lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_9 = l_Array_instEmptyCollectionArray___closed__1; return x_9; } else { size_t x_10; size_t x_11; lean_object* x_12; lean_object* x_13; x_10 = lean_usize_of_nat(x_3); lean_dec(x_3); x_11 = lean_usize_of_nat(x_4); lean_dec(x_4); x_12 = l_Array_instEmptyCollectionArray___closed__1; x_13 = l_Array_foldlMUnsafe_fold___at_Array_filter___spec__1___rarg(x_1, x_2, x_10, x_11, x_12); return x_13; } } } } LEAN_EXPORT lean_object* l_Array_filter(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_filter___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filter___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; lean_object* x_8; x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = l_Array_foldlMUnsafe_fold___at_Array_filter___spec__1___rarg(x_1, x_2, x_6, x_7, x_5); lean_dec(x_2); return x_8; } } LEAN_EXPORT lean_object* l_Array_filter___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_filter___rarg(x_1, x_2, x_3, x_4); lean_dec(x_2); return x_5; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, uint8_t x_4) { _start: { if (x_4 == 0) { lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_dec(x_3); x_5 = lean_ctor_get(x_1, 0); lean_inc(x_5); lean_dec(x_1); x_6 = lean_ctor_get(x_5, 1); lean_inc(x_6); lean_dec(x_5); x_7 = lean_apply_2(x_6, lean_box(0), x_2); return x_7; } else { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = lean_array_push(x_2, x_3); x_11 = lean_apply_2(x_9, lean_box(0), x_10); return x_11; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__2(size_t x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, size_t x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = 1; x_8 = lean_usize_add(x_1, x_7); x_9 = l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg(x_2, x_3, x_4, x_8, x_5, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, size_t x_4, size_t x_5, lean_object* x_6) { _start: { uint8_t x_7; x_7 = lean_usize_dec_eq(x_4, x_5); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; x_8 = lean_ctor_get(x_1, 1); lean_inc(x_8); x_9 = lean_array_uget(x_3, x_4); lean_inc(x_2); lean_inc(x_9); x_10 = lean_apply_1(x_2, x_9); lean_inc(x_1); x_11 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__1___boxed), 4, 3); lean_closure_set(x_11, 0, x_1); lean_closure_set(x_11, 1, x_6); lean_closure_set(x_11, 2, x_9); lean_inc(x_8); x_12 = lean_apply_4(x_8, lean_box(0), lean_box(0), x_10, x_11); x_13 = lean_box_usize(x_4); x_14 = lean_box_usize(x_5); x_15 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__2___boxed), 6, 5); lean_closure_set(x_15, 0, x_13); lean_closure_set(x_15, 1, x_1); lean_closure_set(x_15, 2, x_2); lean_closure_set(x_15, 3, x_3); lean_closure_set(x_15, 4, x_14); x_16 = lean_apply_4(x_8, lean_box(0), lean_box(0), x_12, x_15); return x_16; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_dec(x_3); lean_dec(x_2); x_17 = lean_ctor_get(x_1, 0); lean_inc(x_17); lean_dec(x_1); x_18 = lean_ctor_get(x_17, 1); lean_inc(x_18); lean_dec(x_17); x_19 = lean_apply_2(x_18, lean_box(0), x_6); return x_19; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___boxed), 6, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_filterM___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_nat_dec_lt(x_4, x_5); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_7 = lean_ctor_get(x_1, 0); lean_inc(x_7); lean_dec(x_1); x_8 = lean_ctor_get(x_7, 1); lean_inc(x_8); lean_dec(x_7); x_9 = l_Array_instEmptyCollectionArray___closed__1; x_10 = lean_apply_2(x_8, lean_box(0), x_9); return x_10; } else { lean_object* x_11; uint8_t x_12; x_11 = lean_array_get_size(x_3); x_12 = lean_nat_dec_le(x_5, x_11); lean_dec(x_11); if (x_12 == 0) { lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); x_13 = lean_ctor_get(x_1, 0); lean_inc(x_13); lean_dec(x_1); x_14 = lean_ctor_get(x_13, 1); lean_inc(x_14); lean_dec(x_13); x_15 = l_Array_instEmptyCollectionArray___closed__1; x_16 = lean_apply_2(x_14, lean_box(0), x_15); return x_16; } else { size_t x_17; size_t x_18; lean_object* x_19; lean_object* x_20; x_17 = lean_usize_of_nat(x_4); lean_dec(x_4); x_18 = lean_usize_of_nat(x_5); lean_dec(x_5); x_19 = l_Array_instEmptyCollectionArray___closed__1; x_20 = l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg(x_1, x_2, x_3, x_17, x_18, x_19); return x_20; } } } } LEAN_EXPORT lean_object* l_Array_filterM(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_filterM___rarg), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { uint8_t x_5; lean_object* x_6; x_5 = lean_unbox(x_4); lean_dec(x_4); x_6 = l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__1(x_1, x_2, x_3, x_5); return x_6; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__2___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_1); lean_dec(x_1); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___lambda__2(x_7, x_2, x_3, x_4, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { size_t x_7; size_t x_8; lean_object* x_9; x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = lean_unbox_usize(x_5); lean_dec(x_5); x_9 = l_Array_foldlMUnsafe_fold___at_Array_filterM___spec__1___rarg(x_1, x_2, x_3, x_7, x_8, x_6); return x_9; } } LEAN_EXPORT lean_object* l_Array_filterMapM___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { if (lean_obj_tag(x_3) == 0) { lean_object* x_4; lean_object* x_5; lean_object* x_6; x_4 = lean_ctor_get(x_1, 0); lean_inc(x_4); lean_dec(x_1); x_5 = lean_ctor_get(x_4, 1); lean_inc(x_5); lean_dec(x_4); x_6 = lean_apply_2(x_5, lean_box(0), x_2); return x_6; } else { lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; x_7 = lean_ctor_get(x_3, 0); lean_inc(x_7); lean_dec(x_3); x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = lean_array_push(x_2, x_7); x_11 = lean_apply_2(x_9, lean_box(0), x_10); return x_11; } } } LEAN_EXPORT lean_object* l_Array_filterMapM___rarg___lambda__2(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; x_5 = lean_ctor_get(x_1, 1); lean_inc(x_5); x_6 = lean_apply_1(x_2, x_4); x_7 = lean_alloc_closure((void*)(l_Array_filterMapM___rarg___lambda__1), 3, 2); lean_closure_set(x_7, 0, x_1); lean_closure_set(x_7, 1, x_3); x_8 = lean_apply_4(x_5, lean_box(0), lean_box(0), x_6, x_7); return x_8; } } LEAN_EXPORT lean_object* l_Array_filterMapM___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; lean_inc(x_1); x_6 = lean_alloc_closure((void*)(l_Array_filterMapM___rarg___lambda__2), 4, 2); lean_closure_set(x_6, 0, x_1); lean_closure_set(x_6, 1, x_2); x_7 = lean_nat_dec_lt(x_4, x_5); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_dec(x_6); lean_dec(x_3); x_8 = lean_ctor_get(x_1, 0); lean_inc(x_8); lean_dec(x_1); x_9 = lean_ctor_get(x_8, 1); lean_inc(x_9); lean_dec(x_8); x_10 = l_Array_instEmptyCollectionArray___closed__1; x_11 = lean_apply_2(x_9, lean_box(0), x_10); return x_11; } else { lean_object* x_12; uint8_t x_13; x_12 = lean_array_get_size(x_3); x_13 = lean_nat_dec_le(x_5, x_12); lean_dec(x_12); if (x_13 == 0) { lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_dec(x_6); lean_dec(x_3); x_14 = lean_ctor_get(x_1, 0); lean_inc(x_14); lean_dec(x_1); x_15 = lean_ctor_get(x_14, 1); lean_inc(x_15); lean_dec(x_14); x_16 = l_Array_instEmptyCollectionArray___closed__1; x_17 = lean_apply_2(x_15, lean_box(0), x_16); return x_17; } else { size_t x_18; size_t x_19; lean_object* x_20; lean_object* x_21; x_18 = lean_usize_of_nat(x_4); x_19 = lean_usize_of_nat(x_5); x_20 = l_Array_instEmptyCollectionArray___closed__1; x_21 = l_Array_foldlMUnsafe_fold___rarg(x_1, x_6, x_3, x_18, x_19, x_20); return x_21; } } } } LEAN_EXPORT lean_object* l_Array_filterMapM(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_filterMapM___rarg___boxed), 5, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_filterMapM___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_filterMapM___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_5); lean_dec(x_4); return x_6; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterMap___spec__2___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_eq(x_3, x_4); if (x_6 == 0) { lean_object* x_7; lean_object* x_8; size_t x_9; size_t x_10; x_7 = lean_array_uget(x_2, x_3); lean_inc(x_1); x_8 = lean_apply_1(x_1, x_7); x_9 = 1; x_10 = lean_usize_add(x_3, x_9); if (lean_obj_tag(x_8) == 0) { x_3 = x_10; goto _start; } else { lean_object* x_12; lean_object* x_13; x_12 = lean_ctor_get(x_8, 0); lean_inc(x_12); lean_dec(x_8); x_13 = lean_array_push(x_5, x_12); x_3 = x_10; x_5 = x_13; goto _start; } } else { lean_dec(x_1); return x_5; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterMap___spec__2(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_filterMap___spec__2___rarg___boxed), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_filterMapM___at_Array_filterMap___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_nat_dec_lt(x_3, x_4); if (x_5 == 0) { lean_object* x_6; lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_6 = l_Array_instEmptyCollectionArray___closed__1; return x_6; } else { lean_object* x_7; uint8_t x_8; x_7 = lean_array_get_size(x_2); x_8 = lean_nat_dec_le(x_4, x_7); lean_dec(x_7); if (x_8 == 0) { lean_object* x_9; lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_9 = l_Array_instEmptyCollectionArray___closed__1; return x_9; } else { size_t x_10; size_t x_11; lean_object* x_12; lean_object* x_13; x_10 = lean_usize_of_nat(x_3); lean_dec(x_3); x_11 = lean_usize_of_nat(x_4); lean_dec(x_4); x_12 = l_Array_instEmptyCollectionArray___closed__1; x_13 = l_Array_foldlMUnsafe_fold___at_Array_filterMap___spec__2___rarg(x_1, x_2, x_10, x_11, x_12); return x_13; } } } } LEAN_EXPORT lean_object* l_Array_filterMapM___at_Array_filterMap___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_filterMapM___at_Array_filterMap___spec__1___rarg___boxed), 4, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_filterMap___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_filterMapM___at_Array_filterMap___spec__1___rarg(x_1, x_2, x_3, x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_filterMap(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_filterMap___rarg___boxed), 4, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_filterMap___spec__2___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; lean_object* x_8; x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = l_Array_foldlMUnsafe_fold___at_Array_filterMap___spec__2___rarg(x_1, x_2, x_6, x_7, x_5); lean_dec(x_2); return x_8; } } LEAN_EXPORT lean_object* l_Array_filterMapM___at_Array_filterMap___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_filterMapM___at_Array_filterMap___spec__1___rarg(x_1, x_2, x_3, x_4); lean_dec(x_2); return x_5; } } LEAN_EXPORT lean_object* l_Array_filterMap___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_filterMap___rarg(x_1, x_2, x_3, x_4); lean_dec(x_2); return x_5; } } LEAN_EXPORT lean_object* l_Array_getMax_x3f___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; uint8_t x_5; lean_inc(x_3); lean_inc(x_2); x_4 = lean_apply_2(x_1, x_2, x_3); x_5 = lean_unbox(x_4); lean_dec(x_4); if (x_5 == 0) { lean_dec(x_3); return x_2; } else { lean_dec(x_2); return x_3; } } } LEAN_EXPORT lean_object* l_Array_getMax_x3f___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; uint8_t x_5; x_3 = lean_array_get_size(x_1); x_4 = lean_unsigned_to_nat(0u); x_5 = lean_nat_dec_lt(x_4, x_3); if (x_5 == 0) { lean_object* x_6; lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_6 = lean_box(0); return x_6; } else { lean_object* x_7; lean_object* x_8; lean_object* x_9; uint8_t x_10; x_7 = lean_array_fget(x_1, x_4); x_8 = lean_alloc_closure((void*)(l_Array_getMax_x3f___rarg___lambda__1), 3, 1); lean_closure_set(x_8, 0, x_2); x_9 = lean_unsigned_to_nat(1u); x_10 = lean_nat_dec_lt(x_9, x_3); if (x_10 == 0) { lean_object* x_11; lean_dec(x_8); lean_dec(x_3); lean_dec(x_1); x_11 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_11, 0, x_7); return x_11; } else { uint8_t x_12; x_12 = lean_nat_dec_le(x_3, x_3); if (x_12 == 0) { lean_object* x_13; lean_dec(x_8); lean_dec(x_3); lean_dec(x_1); x_13 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_13, 0, x_7); return x_13; } else { size_t x_14; size_t x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; x_14 = 1; x_15 = lean_usize_of_nat(x_3); lean_dec(x_3); x_16 = l_Id_instMonadId; x_17 = l_Array_foldlMUnsafe_fold___rarg(x_16, x_8, x_1, x_14, x_15, x_7); x_18 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_18, 0, x_17); return x_18; } } } } } LEAN_EXPORT lean_object* l_Array_getMax_x3f(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_getMax_x3f___rarg), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_partition___spec__1___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_lt(x_4, x_3); if (x_6 == 0) { lean_dec(x_1); return x_5; } else { lean_object* x_7; uint8_t x_8; x_7 = lean_array_uget(x_2, x_4); x_8 = !lean_is_exclusive(x_5); if (x_8 == 0) { lean_object* x_9; lean_object* x_10; lean_object* x_11; uint8_t x_12; x_9 = lean_ctor_get(x_5, 0); x_10 = lean_ctor_get(x_5, 1); lean_inc(x_1); lean_inc(x_7); x_11 = lean_apply_1(x_1, x_7); x_12 = lean_unbox(x_11); lean_dec(x_11); if (x_12 == 0) { lean_object* x_13; size_t x_14; size_t x_15; x_13 = lean_array_push(x_10, x_7); lean_ctor_set(x_5, 1, x_13); x_14 = 1; x_15 = lean_usize_add(x_4, x_14); x_4 = x_15; goto _start; } else { lean_object* x_17; size_t x_18; size_t x_19; x_17 = lean_array_push(x_9, x_7); lean_ctor_set(x_5, 0, x_17); x_18 = 1; x_19 = lean_usize_add(x_4, x_18); x_4 = x_19; goto _start; } } else { lean_object* x_21; lean_object* x_22; lean_object* x_23; uint8_t x_24; x_21 = lean_ctor_get(x_5, 0); x_22 = lean_ctor_get(x_5, 1); lean_inc(x_22); lean_inc(x_21); lean_dec(x_5); lean_inc(x_1); lean_inc(x_7); x_23 = lean_apply_1(x_1, x_7); x_24 = lean_unbox(x_23); lean_dec(x_23); if (x_24 == 0) { lean_object* x_25; lean_object* x_26; size_t x_27; size_t x_28; x_25 = lean_array_push(x_22, x_7); x_26 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_26, 0, x_21); lean_ctor_set(x_26, 1, x_25); x_27 = 1; x_28 = lean_usize_add(x_4, x_27); x_4 = x_28; x_5 = x_26; goto _start; } else { lean_object* x_30; lean_object* x_31; size_t x_32; size_t x_33; x_30 = lean_array_push(x_21, x_7); x_31 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_31, 0, x_30); lean_ctor_set(x_31, 1, x_22); x_32 = 1; x_33 = lean_usize_add(x_4, x_32); x_4 = x_33; x_5 = x_31; goto _start; } } } } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_partition___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_forInUnsafe_loop___at_Array_partition___spec__1___rarg___boxed), 5, 0); return x_2; } } static lean_object* _init_l_Array_partition___rarg___closed__1() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Array_instEmptyCollectionArray___closed__1; x_2 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_2, 0, x_1); lean_ctor_set(x_2, 1, x_1); return x_2; } } LEAN_EXPORT lean_object* l_Array_partition___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; size_t x_4; size_t x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; lean_object* x_10; x_3 = lean_array_get_size(x_2); x_4 = lean_usize_of_nat(x_3); lean_dec(x_3); x_5 = 0; x_6 = l_Array_partition___rarg___closed__1; x_7 = l_Array_forInUnsafe_loop___at_Array_partition___spec__1___rarg(x_1, x_2, x_4, x_5, x_6); x_8 = lean_ctor_get(x_7, 0); lean_inc(x_8); x_9 = lean_ctor_get(x_7, 1); lean_inc(x_9); lean_dec(x_7); x_10 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_10, 0, x_8); lean_ctor_set(x_10, 1, x_9); return x_10; } } LEAN_EXPORT lean_object* l_Array_partition(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_partition___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_forInUnsafe_loop___at_Array_partition___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; lean_object* x_8; x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = l_Array_forInUnsafe_loop___at_Array_partition___spec__1___rarg(x_1, x_2, x_6, x_7, x_5); lean_dec(x_2); return x_8; } } LEAN_EXPORT lean_object* l_Array_partition___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_partition___rarg(x_1, x_2); lean_dec(x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_indexOfAux___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; uint8_t x_6; x_5 = lean_array_get_size(x_2); x_6 = lean_nat_dec_lt(x_4, x_5); lean_dec(x_5); if (x_6 == 0) { lean_object* x_7; lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_7 = lean_box(0); return x_7; } else { lean_object* x_8; lean_object* x_9; uint8_t x_10; x_8 = lean_array_fget(x_2, x_4); lean_inc(x_1); lean_inc(x_3); x_9 = lean_apply_2(x_1, x_8, x_3); x_10 = lean_unbox(x_9); lean_dec(x_9); if (x_10 == 0) { lean_object* x_11; lean_object* x_12; x_11 = lean_unsigned_to_nat(1u); x_12 = lean_nat_add(x_4, x_11); lean_dec(x_4); x_4 = x_12; goto _start; } else { lean_object* x_14; lean_dec(x_3); lean_dec(x_1); x_14 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_14, 0, x_4); return x_14; } } } } LEAN_EXPORT lean_object* l_Array_indexOfAux(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_indexOfAux___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_indexOfAux___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_indexOfAux___rarg(x_1, x_2, x_3, x_4); lean_dec(x_2); return x_5; } } LEAN_EXPORT lean_object* l_Array_indexOf_x3f___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; x_4 = lean_unsigned_to_nat(0u); x_5 = l_Array_indexOfAux___rarg(x_1, x_2, x_3, x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_indexOf_x3f(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_indexOf_x3f___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_indexOf_x3f___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_indexOf_x3f___rarg(x_1, x_2, x_3); lean_dec(x_2); return x_4; } } LEAN_EXPORT lean_object* l_Array_reverse_loop___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { uint8_t x_4; x_4 = lean_nat_dec_lt(x_2, x_3); if (x_4 == 0) { lean_dec(x_3); lean_dec(x_2); return x_1; } else { lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; x_5 = lean_array_fswap(x_1, x_2, x_3); x_6 = lean_unsigned_to_nat(1u); x_7 = lean_nat_add(x_2, x_6); lean_dec(x_2); x_8 = lean_nat_sub(x_3, x_6); lean_dec(x_3); x_1 = x_5; x_2 = x_7; x_3 = x_8; goto _start; } } } LEAN_EXPORT lean_object* l_Array_reverse_loop(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_reverse_loop___rarg), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_reverse___rarg(lean_object* x_1) { _start: { lean_object* x_2; lean_object* x_3; uint8_t x_4; x_2 = lean_array_get_size(x_1); x_3 = lean_unsigned_to_nat(1u); x_4 = lean_nat_dec_le(x_2, x_3); if (x_4 == 0) { lean_object* x_5; lean_object* x_6; lean_object* x_7; x_5 = lean_nat_sub(x_2, x_3); lean_dec(x_2); x_6 = lean_unsigned_to_nat(0u); x_7 = l_Array_reverse_loop___rarg(x_1, x_6, x_5); return x_7; } else { lean_dec(x_2); return x_1; } } } LEAN_EXPORT lean_object* l_Array_reverse(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_reverse___rarg), 1, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_popWhile___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; uint8_t x_5; x_3 = lean_array_get_size(x_2); x_4 = lean_unsigned_to_nat(0u); x_5 = lean_nat_dec_lt(x_4, x_3); if (x_5 == 0) { lean_dec(x_3); lean_dec(x_1); return x_2; } else { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; uint8_t x_10; x_6 = lean_unsigned_to_nat(1u); x_7 = lean_nat_sub(x_3, x_6); lean_dec(x_3); x_8 = lean_array_fget(x_2, x_7); lean_dec(x_7); lean_inc(x_1); x_9 = lean_apply_1(x_1, x_8); x_10 = lean_unbox(x_9); lean_dec(x_9); if (x_10 == 0) { lean_dec(x_1); return x_2; } else { lean_object* x_11; x_11 = lean_array_pop(x_2); x_2 = x_11; goto _start; } } } } LEAN_EXPORT lean_object* l_Array_popWhile(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_popWhile___rarg), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_takeWhile_go___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; uint8_t x_6; x_5 = lean_array_get_size(x_2); x_6 = lean_nat_dec_lt(x_3, x_5); lean_dec(x_5); if (x_6 == 0) { lean_dec(x_3); lean_dec(x_1); return x_4; } else { lean_object* x_7; lean_object* x_8; uint8_t x_9; x_7 = lean_array_fget(x_2, x_3); lean_inc(x_1); lean_inc(x_7); x_8 = lean_apply_1(x_1, x_7); x_9 = lean_unbox(x_8); lean_dec(x_8); if (x_9 == 0) { lean_dec(x_7); lean_dec(x_3); lean_dec(x_1); return x_4; } else { lean_object* x_10; lean_object* x_11; lean_object* x_12; x_10 = lean_unsigned_to_nat(1u); x_11 = lean_nat_add(x_3, x_10); lean_dec(x_3); x_12 = lean_array_push(x_4, x_7); x_3 = x_11; x_4 = x_12; goto _start; } } } } LEAN_EXPORT lean_object* l_Array_takeWhile_go(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_takeWhile_go___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_takeWhile_go___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_takeWhile_go___rarg(x_1, x_2, x_3, x_4); lean_dec(x_2); return x_5; } } LEAN_EXPORT lean_object* l_Array_takeWhile___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; lean_object* x_5; x_3 = lean_unsigned_to_nat(0u); x_4 = l_Array_instEmptyCollectionArray___closed__1; x_5 = l_Array_takeWhile_go___rarg(x_1, x_2, x_3, x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_takeWhile(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_takeWhile___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_takeWhile___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_takeWhile___rarg(x_1, x_2); lean_dec(x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_eraseIdxAux___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; uint8_t x_4; x_3 = lean_array_get_size(x_2); x_4 = lean_nat_dec_lt(x_1, x_3); lean_dec(x_3); if (x_4 == 0) { lean_object* x_5; lean_dec(x_1); x_5 = lean_array_pop(x_2); return x_5; } else { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9; x_6 = lean_unsigned_to_nat(1u); x_7 = lean_nat_sub(x_1, x_6); x_8 = lean_array_fswap(x_2, x_1, x_7); lean_dec(x_7); x_9 = lean_nat_add(x_1, x_6); lean_dec(x_1); x_1 = x_9; x_2 = x_8; goto _start; } } } LEAN_EXPORT lean_object* l_Array_eraseIdxAux(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_eraseIdxAux___rarg), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_feraseIdx___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; lean_object* x_5; x_3 = lean_unsigned_to_nat(1u); x_4 = lean_nat_add(x_2, x_3); x_5 = l_Array_eraseIdxAux___rarg(x_4, x_1); return x_5; } } LEAN_EXPORT lean_object* l_Array_feraseIdx(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_feraseIdx___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_feraseIdx___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_feraseIdx___rarg(x_1, x_2); lean_dec(x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_eraseIdx___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; uint8_t x_4; x_3 = lean_array_get_size(x_1); x_4 = lean_nat_dec_lt(x_2, x_3); lean_dec(x_3); if (x_4 == 0) { return x_1; } else { lean_object* x_5; lean_object* x_6; lean_object* x_7; x_5 = lean_unsigned_to_nat(1u); x_6 = lean_nat_add(x_2, x_5); x_7 = l_Array_eraseIdxAux___rarg(x_6, x_1); return x_7; } } } LEAN_EXPORT lean_object* l_Array_eraseIdx(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_eraseIdx___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_eraseIdx___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_eraseIdx___rarg(x_1, x_2); lean_dec(x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_eraseIdxSzAux___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; uint8_t x_6; x_5 = lean_array_get_size(x_3); x_6 = lean_nat_dec_lt(x_2, x_5); lean_dec(x_5); if (x_6 == 0) { lean_object* x_7; lean_dec(x_2); x_7 = lean_array_pop(x_3); return x_7; } else { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; x_8 = lean_unsigned_to_nat(1u); x_9 = lean_nat_sub(x_2, x_8); x_10 = lean_nat_add(x_2, x_8); x_11 = lean_array_fswap(x_3, x_2, x_9); lean_dec(x_9); lean_dec(x_2); x_2 = x_10; x_3 = x_11; x_4 = lean_box(0); goto _start; } } } LEAN_EXPORT lean_object* l_Array_eraseIdxSzAux(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_eraseIdxSzAux___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_eraseIdxSzAux___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_eraseIdxSzAux___rarg(x_1, x_2, x_3, x_4); lean_dec(x_1); return x_5; } } LEAN_EXPORT lean_object* l_Array_eraseIdx_x27___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; lean_object* x_5; x_3 = lean_unsigned_to_nat(1u); x_4 = lean_nat_add(x_2, x_3); lean_inc(x_1); x_5 = l_Array_eraseIdxSzAux___rarg(x_1, x_4, x_1, lean_box(0)); lean_dec(x_1); return x_5; } } LEAN_EXPORT lean_object* l_Array_eraseIdx_x27(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_eraseIdx_x27___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_eraseIdx_x27___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_eraseIdx_x27___rarg(x_1, x_2); lean_dec(x_2); return x_3; } } LEAN_EXPORT lean_object* l_Array_erase___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; x_4 = lean_unsigned_to_nat(0u); x_5 = l_Array_indexOfAux___rarg(x_1, x_2, x_3, x_4); if (lean_obj_tag(x_5) == 0) { return x_2; } else { lean_object* x_6; lean_object* x_7; x_6 = lean_ctor_get(x_5, 0); lean_inc(x_6); lean_dec(x_5); x_7 = l_Array_feraseIdx___rarg(x_2, x_6); lean_dec(x_6); return x_7; } } } LEAN_EXPORT lean_object* l_Array_erase(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_erase___rarg), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_insertAt_loop___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_nat_dec_lt(x_2, x_4); if (x_5 == 0) { lean_dec(x_4); return x_3; } else { lean_object* x_6; lean_object* x_7; lean_object* x_8; x_6 = lean_unsigned_to_nat(1u); x_7 = lean_nat_sub(x_4, x_6); x_8 = lean_array_fswap(x_3, x_7, x_4); lean_dec(x_4); x_3 = x_8; x_4 = x_7; goto _start; } } } LEAN_EXPORT lean_object* l_Array_insertAt_loop(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_insertAt_loop___rarg___boxed), 4, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_insertAt_loop___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_insertAt_loop___rarg(x_1, x_2, x_3, x_4); lean_dec(x_2); lean_dec(x_1); return x_5; } } LEAN_EXPORT lean_object* l_Array_insertAt___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; x_4 = lean_array_get_size(x_1); lean_inc(x_1); x_5 = lean_array_push(x_1, x_3); x_6 = l_Array_insertAt_loop___rarg(x_1, x_2, x_5, x_4); lean_dec(x_1); return x_6; } } LEAN_EXPORT lean_object* l_Array_insertAt(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_insertAt___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_insertAt___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_insertAt___rarg(x_1, x_2, x_3); lean_dec(x_2); return x_4; } } LEAN_EXPORT lean_object* l_panic___at_Array_insertAt_x21___spec__1___rarg(lean_object* x_1) { _start: { lean_object* x_2; lean_object* x_3; x_2 = l_Array_instEmptyCollectionArray___closed__1; x_3 = lean_panic_fn(x_2, x_1); return x_3; } } LEAN_EXPORT lean_object* l_panic___at_Array_insertAt_x21___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_panic___at_Array_insertAt_x21___spec__1___rarg), 1, 0); return x_2; } } static lean_object* _init_l_Array_insertAt_x21___rarg___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("Array.insertAt!", 15); return x_1; } } static lean_object* _init_l_Array_insertAt_x21___rarg___closed__2() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("invalid index", 13); return x_1; } } static lean_object* _init_l_Array_insertAt_x21___rarg___closed__3() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_1 = l_Array_swapAt_x21___rarg___closed__3; x_2 = l_Array_insertAt_x21___rarg___closed__1; x_3 = lean_unsigned_to_nat(734u); x_4 = lean_unsigned_to_nat(7u); x_5 = l_Array_insertAt_x21___rarg___closed__2; x_6 = l___private_Init_Util_0__mkPanicMessageWithDecl(x_1, x_2, x_3, x_4, x_5); return x_6; } } LEAN_EXPORT lean_object* l_Array_insertAt_x21___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; uint8_t x_5; x_4 = lean_array_get_size(x_1); x_5 = lean_nat_dec_le(x_2, x_4); if (x_5 == 0) { lean_object* x_6; lean_object* x_7; lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_6 = l_Array_insertAt_x21___rarg___closed__3; x_7 = l_panic___at_Array_insertAt_x21___spec__1___rarg(x_6); return x_7; } else { lean_object* x_8; lean_object* x_9; lean_inc(x_1); x_8 = lean_array_push(x_1, x_3); x_9 = l_Array_insertAt_loop___rarg(x_1, x_2, x_8, x_4); lean_dec(x_1); return x_9; } } } LEAN_EXPORT lean_object* l_Array_insertAt_x21(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_insertAt_x21___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_insertAt_x21___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_insertAt_x21___rarg(x_1, x_2, x_3); lean_dec(x_2); return x_4; } } LEAN_EXPORT lean_object* l_Array_toListLitAux___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { lean_object* x_7; uint8_t x_8; x_7 = lean_unsigned_to_nat(0u); x_8 = lean_nat_dec_eq(x_4, x_7); if (x_8 == 0) { lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; x_9 = lean_unsigned_to_nat(1u); x_10 = lean_nat_sub(x_4, x_9); lean_dec(x_4); x_11 = lean_array_fget(x_1, x_10); x_12 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_12, 0, x_11); lean_ctor_set(x_12, 1, x_6); x_3 = lean_box(0); x_4 = x_10; x_5 = lean_box(0); x_6 = x_12; goto _start; } else { lean_dec(x_4); return x_6; } } } LEAN_EXPORT lean_object* l_Array_toListLitAux(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_toListLitAux___rarg___boxed), 6, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_toListLitAux___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { lean_object* x_7; x_7 = l_Array_toListLitAux___rarg(x_1, x_2, x_3, x_4, x_5, x_6); lean_dec(x_2); lean_dec(x_1); return x_7; } } LEAN_EXPORT lean_object* l_Array_toArrayLit___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; x_4 = lean_box(0); lean_inc(x_2); x_5 = l_Array_toListLitAux___rarg(x_1, x_2, lean_box(0), x_2, lean_box(0), x_4); lean_dec(x_2); x_6 = l_List_redLength___rarg(x_5); x_7 = lean_mk_empty_array_with_capacity(x_6); lean_dec(x_6); x_8 = l_List_toArrayAux___rarg(x_5, x_7); return x_8; } } LEAN_EXPORT lean_object* l_Array_toArrayLit(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_toArrayLit___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_toArrayLit___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_toArrayLit___rarg(x_1, x_2, x_3); lean_dec(x_1); return x_4; } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__List_toArrayAux_match__1_splitter___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { if (lean_obj_tag(x_1) == 0) { lean_object* x_5; lean_dec(x_4); x_5 = lean_apply_1(x_3, x_2); return x_5; } else { lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_dec(x_3); x_6 = lean_ctor_get(x_1, 0); lean_inc(x_6); x_7 = lean_ctor_get(x_1, 1); lean_inc(x_7); lean_dec(x_1); x_8 = lean_apply_3(x_4, x_6, x_7, x_2); return x_8; } } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__List_toArrayAux_match__1_splitter(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l___private_Init_Data_Array_Basic_0__List_toArrayAux_match__1_splitter___rarg), 4, 0); return x_3; } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_unsigned_to_nat(0u); x_7 = lean_nat_dec_eq(x_1, x_6); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_dec(x_4); x_8 = lean_unsigned_to_nat(1u); x_9 = lean_nat_sub(x_1, x_8); x_10 = lean_apply_3(x_5, x_9, lean_box(0), x_3); return x_10; } else { lean_object* x_11; lean_dec(x_5); x_11 = lean_apply_2(x_4, lean_box(0), x_3); return x_11; } } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter___rarg___boxed), 5, 0); return x_4; } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_1); return x_6; } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l___private_Init_Data_Array_Basic_0__Array_toListLitAux_match__1_splitter(x_1, x_2, x_3); lean_dec(x_2); return x_4; } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__List_drop_match__1_splitter___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_unsigned_to_nat(0u); x_7 = lean_nat_dec_eq(x_1, x_6); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_dec(x_3); x_8 = lean_unsigned_to_nat(1u); x_9 = lean_nat_sub(x_1, x_8); if (lean_obj_tag(x_2) == 0) { lean_object* x_10; lean_dec(x_5); x_10 = lean_apply_1(x_4, x_9); return x_10; } else { lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_dec(x_4); x_11 = lean_ctor_get(x_2, 0); lean_inc(x_11); x_12 = lean_ctor_get(x_2, 1); lean_inc(x_12); lean_dec(x_2); x_13 = lean_apply_3(x_5, x_9, x_11, x_12); return x_13; } } else { lean_object* x_14; lean_dec(x_5); lean_dec(x_4); x_14 = lean_apply_1(x_3, x_2); return x_14; } } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__List_drop_match__1_splitter(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l___private_Init_Data_Array_Basic_0__List_drop_match__1_splitter___rarg___boxed), 5, 0); return x_3; } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__List_drop_match__1_splitter___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l___private_Init_Data_Array_Basic_0__List_drop_match__1_splitter___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_1); return x_6; } } LEAN_EXPORT uint8_t l_Array_isPrefixOfAux___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_array_get_size(x_2); x_7 = lean_nat_dec_lt(x_5, x_6); lean_dec(x_6); if (x_7 == 0) { uint8_t x_8; lean_dec(x_5); lean_dec(x_1); x_8 = 1; return x_8; } else { lean_object* x_9; lean_object* x_10; lean_object* x_11; uint8_t x_12; x_9 = lean_array_fget(x_2, x_5); x_10 = lean_array_fget(x_3, x_5); lean_inc(x_1); x_11 = lean_apply_2(x_1, x_9, x_10); x_12 = lean_unbox(x_11); lean_dec(x_11); if (x_12 == 0) { uint8_t x_13; lean_dec(x_5); lean_dec(x_1); x_13 = 0; return x_13; } else { lean_object* x_14; lean_object* x_15; x_14 = lean_unsigned_to_nat(1u); x_15 = lean_nat_add(x_5, x_14); lean_dec(x_5); x_4 = lean_box(0); x_5 = x_15; goto _start; } } } } LEAN_EXPORT lean_object* l_Array_isPrefixOfAux(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_isPrefixOfAux___rarg___boxed), 5, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_isPrefixOfAux___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { uint8_t x_6; lean_object* x_7; x_6 = l_Array_isPrefixOfAux___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_3); lean_dec(x_2); x_7 = lean_box(x_6); return x_7; } } LEAN_EXPORT uint8_t l_Array_isPrefixOf___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; uint8_t x_6; x_4 = lean_array_get_size(x_2); x_5 = lean_array_get_size(x_3); x_6 = lean_nat_dec_le(x_4, x_5); lean_dec(x_5); lean_dec(x_4); if (x_6 == 0) { uint8_t x_7; lean_dec(x_1); x_7 = 0; return x_7; } else { lean_object* x_8; uint8_t x_9; x_8 = lean_unsigned_to_nat(0u); x_9 = l_Array_isPrefixOfAux___rarg(x_1, x_2, x_3, lean_box(0), x_8); return x_9; } } } LEAN_EXPORT lean_object* l_Array_isPrefixOf(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_isPrefixOf___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_isPrefixOf___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { uint8_t x_4; lean_object* x_5; x_4 = l_Array_isPrefixOf___rarg(x_1, x_2, x_3); lean_dec(x_3); lean_dec(x_2); x_5 = lean_box(x_4); return x_5; } } LEAN_EXPORT uint8_t l___private_Init_Data_Array_Basic_0__Array_allDiffAuxAux___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_unsigned_to_nat(0u); x_7 = lean_nat_dec_eq(x_4, x_6); if (x_7 == 0) { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; uint8_t x_12; x_8 = lean_unsigned_to_nat(1u); x_9 = lean_nat_sub(x_4, x_8); lean_dec(x_4); x_10 = lean_array_fget(x_2, x_9); lean_inc(x_1); lean_inc(x_3); x_11 = lean_apply_2(x_1, x_3, x_10); x_12 = lean_unbox(x_11); lean_dec(x_11); if (x_12 == 0) { x_4 = x_9; x_5 = lean_box(0); goto _start; } else { uint8_t x_14; lean_dec(x_9); lean_dec(x_3); lean_dec(x_1); x_14 = 0; return x_14; } } else { uint8_t x_15; lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_15 = 1; return x_15; } } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_allDiffAuxAux(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l___private_Init_Data_Array_Basic_0__Array_allDiffAuxAux___rarg___boxed), 5, 0); return x_2; } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_allDiffAuxAux___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { uint8_t x_6; lean_object* x_7; x_6 = l___private_Init_Data_Array_Basic_0__Array_allDiffAuxAux___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_2); x_7 = lean_box(x_6); return x_7; } } LEAN_EXPORT uint8_t l___private_Init_Data_Array_Basic_0__Array_allDiffAux___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; uint8_t x_5; x_4 = lean_array_get_size(x_2); x_5 = lean_nat_dec_lt(x_3, x_4); lean_dec(x_4); if (x_5 == 0) { uint8_t x_6; lean_dec(x_3); lean_dec(x_1); x_6 = 1; return x_6; } else { lean_object* x_7; uint8_t x_8; x_7 = lean_array_fget(x_2, x_3); lean_inc(x_3); lean_inc(x_1); x_8 = l___private_Init_Data_Array_Basic_0__Array_allDiffAuxAux___rarg(x_1, x_2, x_7, x_3, lean_box(0)); if (x_8 == 0) { uint8_t x_9; lean_dec(x_3); lean_dec(x_1); x_9 = 0; return x_9; } else { lean_object* x_10; lean_object* x_11; x_10 = lean_unsigned_to_nat(1u); x_11 = lean_nat_add(x_3, x_10); lean_dec(x_3); x_3 = x_11; goto _start; } } } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_allDiffAux(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l___private_Init_Data_Array_Basic_0__Array_allDiffAux___rarg___boxed), 3, 0); return x_2; } } LEAN_EXPORT lean_object* l___private_Init_Data_Array_Basic_0__Array_allDiffAux___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { uint8_t x_4; lean_object* x_5; x_4 = l___private_Init_Data_Array_Basic_0__Array_allDiffAux___rarg(x_1, x_2, x_3); lean_dec(x_2); x_5 = lean_box(x_4); return x_5; } } LEAN_EXPORT uint8_t l_Array_allDiff___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; uint8_t x_4; x_3 = lean_unsigned_to_nat(0u); x_4 = l___private_Init_Data_Array_Basic_0__Array_allDiffAux___rarg(x_1, x_2, x_3); return x_4; } } LEAN_EXPORT lean_object* l_Array_allDiff(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_allDiff___rarg___boxed), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_allDiff___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { uint8_t x_3; lean_object* x_4; x_3 = l_Array_allDiff___rarg(x_1, x_2); lean_dec(x_2); x_4 = lean_box(x_3); return x_4; } } LEAN_EXPORT lean_object* l_Array_zipWithAux___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; uint8_t x_7; x_6 = lean_array_get_size(x_2); x_7 = lean_nat_dec_lt(x_4, x_6); lean_dec(x_6); if (x_7 == 0) { lean_dec(x_4); lean_dec(x_1); return x_5; } else { lean_object* x_8; lean_object* x_9; uint8_t x_10; x_8 = lean_array_fget(x_2, x_4); x_9 = lean_array_get_size(x_3); x_10 = lean_nat_dec_lt(x_4, x_9); lean_dec(x_9); if (x_10 == 0) { lean_dec(x_8); lean_dec(x_4); lean_dec(x_1); return x_5; } else { lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; x_11 = lean_array_fget(x_3, x_4); x_12 = lean_unsigned_to_nat(1u); x_13 = lean_nat_add(x_4, x_12); lean_dec(x_4); lean_inc(x_1); x_14 = lean_apply_2(x_1, x_8, x_11); x_15 = lean_array_push(x_5, x_14); x_4 = x_13; x_5 = x_15; goto _start; } } } } LEAN_EXPORT lean_object* l_Array_zipWithAux(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_zipWithAux___rarg___boxed), 5, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_zipWithAux___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { lean_object* x_6; x_6 = l_Array_zipWithAux___rarg(x_1, x_2, x_3, x_4, x_5); lean_dec(x_3); lean_dec(x_2); return x_6; } } LEAN_EXPORT lean_object* l_Array_zipWith___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; x_4 = lean_unsigned_to_nat(0u); x_5 = l_Array_instEmptyCollectionArray___closed__1; x_6 = l_Array_zipWithAux___rarg(x_3, x_1, x_2, x_4, x_5); return x_6; } } LEAN_EXPORT lean_object* l_Array_zipWith(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = lean_alloc_closure((void*)(l_Array_zipWith___rarg___boxed), 3, 0); return x_4; } } LEAN_EXPORT lean_object* l_Array_zipWith___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; x_4 = l_Array_zipWith___rarg(x_1, x_2, x_3); lean_dec(x_2); lean_dec(x_1); return x_4; } } LEAN_EXPORT lean_object* l_Array_zipWithAux___at_Array_zip___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; uint8_t x_6; x_5 = lean_array_get_size(x_1); x_6 = lean_nat_dec_lt(x_3, x_5); lean_dec(x_5); if (x_6 == 0) { lean_dec(x_3); return x_4; } else { lean_object* x_7; lean_object* x_8; uint8_t x_9; x_7 = lean_array_fget(x_1, x_3); x_8 = lean_array_get_size(x_2); x_9 = lean_nat_dec_lt(x_3, x_8); lean_dec(x_8); if (x_9 == 0) { lean_dec(x_7); lean_dec(x_3); return x_4; } else { lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; x_10 = lean_array_fget(x_2, x_3); x_11 = lean_unsigned_to_nat(1u); x_12 = lean_nat_add(x_3, x_11); lean_dec(x_3); x_13 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_13, 0, x_7); lean_ctor_set(x_13, 1, x_10); x_14 = lean_array_push(x_4, x_13); x_3 = x_12; x_4 = x_14; goto _start; } } } } LEAN_EXPORT lean_object* l_Array_zipWithAux___at_Array_zip___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_zipWithAux___at_Array_zip___spec__1___rarg___boxed), 4, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_zip___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; lean_object* x_5; x_3 = lean_unsigned_to_nat(0u); x_4 = l_Array_instEmptyCollectionArray___closed__1; x_5 = l_Array_zipWithAux___at_Array_zip___spec__1___rarg(x_1, x_2, x_3, x_4); return x_5; } } LEAN_EXPORT lean_object* l_Array_zip(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_zip___rarg___boxed), 2, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_zipWithAux___at_Array_zip___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { lean_object* x_5; x_5 = l_Array_zipWithAux___at_Array_zip___spec__1___rarg(x_1, x_2, x_3, x_4); lean_dec(x_2); lean_dec(x_1); return x_5; } } LEAN_EXPORT lean_object* l_Array_zip___rarg___boxed(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = l_Array_zip___rarg(x_1, x_2); lean_dec(x_2); lean_dec(x_1); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_unzip___spec__1___rarg(lean_object* x_1, size_t x_2, size_t x_3, lean_object* x_4) { _start: { uint8_t x_5; x_5 = lean_usize_dec_eq(x_2, x_3); if (x_5 == 0) { lean_object* x_6; size_t x_7; size_t x_8; lean_object* x_9; lean_object* x_10; uint8_t x_11; x_6 = lean_array_uget(x_1, x_2); x_7 = 1; x_8 = lean_usize_add(x_2, x_7); x_9 = lean_ctor_get(x_4, 0); lean_inc(x_9); x_10 = lean_ctor_get(x_4, 1); lean_inc(x_10); lean_dec(x_4); x_11 = !lean_is_exclusive(x_6); if (x_11 == 0) { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; x_12 = lean_ctor_get(x_6, 0); x_13 = lean_ctor_get(x_6, 1); x_14 = lean_array_push(x_9, x_12); x_15 = lean_array_push(x_10, x_13); lean_ctor_set(x_6, 1, x_15); lean_ctor_set(x_6, 0, x_14); x_2 = x_8; x_4 = x_6; goto _start; } else { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; x_17 = lean_ctor_get(x_6, 0); x_18 = lean_ctor_get(x_6, 1); lean_inc(x_18); lean_inc(x_17); lean_dec(x_6); x_19 = lean_array_push(x_9, x_17); x_20 = lean_array_push(x_10, x_18); x_21 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_21, 0, x_19); lean_ctor_set(x_21, 1, x_20); x_2 = x_8; x_4 = x_21; goto _start; } } else { return x_4; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_unzip___spec__1(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_unzip___spec__1___rarg___boxed), 4, 0); return x_3; } } static lean_object* _init_l_Array_unzip___rarg___closed__1() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Array_instEmptyCollectionArray___closed__1; x_2 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_2, 0, x_1); lean_ctor_set(x_2, 1, x_1); return x_2; } } LEAN_EXPORT lean_object* l_Array_unzip___rarg(lean_object* x_1) { _start: { lean_object* x_2; lean_object* x_3; uint8_t x_4; x_2 = lean_array_get_size(x_1); x_3 = lean_unsigned_to_nat(0u); x_4 = lean_nat_dec_lt(x_3, x_2); if (x_4 == 0) { lean_object* x_5; lean_dec(x_2); x_5 = l_Array_unzip___rarg___closed__1; return x_5; } else { uint8_t x_6; x_6 = lean_nat_dec_le(x_2, x_2); if (x_6 == 0) { lean_object* x_7; lean_dec(x_2); x_7 = l_Array_unzip___rarg___closed__1; return x_7; } else { size_t x_8; size_t x_9; lean_object* x_10; lean_object* x_11; x_8 = 0; x_9 = lean_usize_of_nat(x_2); lean_dec(x_2); x_10 = l_Array_unzip___rarg___closed__1; x_11 = l_Array_foldlMUnsafe_fold___at_Array_unzip___spec__1___rarg(x_1, x_8, x_9, x_10); return x_11; } } } } LEAN_EXPORT lean_object* l_Array_unzip(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; x_3 = lean_alloc_closure((void*)(l_Array_unzip___rarg___boxed), 1, 0); return x_3; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_unzip___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) { _start: { size_t x_5; size_t x_6; lean_object* x_7; x_5 = lean_unbox_usize(x_2); lean_dec(x_2); x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = l_Array_foldlMUnsafe_fold___at_Array_unzip___spec__1___rarg(x_1, x_5, x_6, x_4); lean_dec(x_1); return x_7; } } LEAN_EXPORT lean_object* l_Array_unzip___rarg___boxed(lean_object* x_1) { _start: { lean_object* x_2; x_2 = l_Array_unzip___rarg(x_1); lean_dec(x_1); return x_2; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_split___spec__1___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4, lean_object* x_5) { _start: { uint8_t x_6; x_6 = lean_usize_dec_eq(x_3, x_4); if (x_6 == 0) { lean_object* x_7; size_t x_8; size_t x_9; uint8_t x_10; x_7 = lean_array_uget(x_2, x_3); x_8 = 1; x_9 = lean_usize_add(x_3, x_8); x_10 = !lean_is_exclusive(x_5); if (x_10 == 0) { lean_object* x_11; lean_object* x_12; lean_object* x_13; uint8_t x_14; x_11 = lean_ctor_get(x_5, 0); x_12 = lean_ctor_get(x_5, 1); lean_inc(x_1); lean_inc(x_7); x_13 = lean_apply_1(x_1, x_7); x_14 = lean_unbox(x_13); lean_dec(x_13); if (x_14 == 0) { lean_object* x_15; x_15 = lean_array_push(x_12, x_7); lean_ctor_set(x_5, 1, x_15); x_3 = x_9; goto _start; } else { lean_object* x_17; x_17 = lean_array_push(x_11, x_7); lean_ctor_set(x_5, 0, x_17); x_3 = x_9; goto _start; } } else { lean_object* x_19; lean_object* x_20; lean_object* x_21; uint8_t x_22; x_19 = lean_ctor_get(x_5, 0); x_20 = lean_ctor_get(x_5, 1); lean_inc(x_20); lean_inc(x_19); lean_dec(x_5); lean_inc(x_1); lean_inc(x_7); x_21 = lean_apply_1(x_1, x_7); x_22 = lean_unbox(x_21); lean_dec(x_21); if (x_22 == 0) { lean_object* x_23; lean_object* x_24; x_23 = lean_array_push(x_20, x_7); x_24 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_24, 0, x_19); lean_ctor_set(x_24, 1, x_23); x_3 = x_9; x_5 = x_24; goto _start; } else { lean_object* x_26; lean_object* x_27; x_26 = lean_array_push(x_19, x_7); x_27 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_27, 0, x_26); lean_ctor_set(x_27, 1, x_20); x_3 = x_9; x_5 = x_27; goto _start; } } } else { lean_dec(x_1); return x_5; } } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_split___spec__1(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Array_split___spec__1___rarg___boxed), 5, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_split___rarg(lean_object* x_1, lean_object* x_2) { _start: { lean_object* x_3; lean_object* x_4; uint8_t x_5; x_3 = lean_array_get_size(x_1); x_4 = lean_unsigned_to_nat(0u); x_5 = lean_nat_dec_lt(x_4, x_3); if (x_5 == 0) { lean_object* x_6; lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_6 = l_Array_unzip___rarg___closed__1; return x_6; } else { uint8_t x_7; x_7 = lean_nat_dec_le(x_3, x_3); if (x_7 == 0) { lean_object* x_8; lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_8 = l_Array_unzip___rarg___closed__1; return x_8; } else { size_t x_9; size_t x_10; lean_object* x_11; lean_object* x_12; x_9 = 0; x_10 = lean_usize_of_nat(x_3); lean_dec(x_3); x_11 = l_Array_unzip___rarg___closed__1; x_12 = l_Array_foldlMUnsafe_fold___at_Array_split___spec__1___rarg(x_2, x_1, x_9, x_10, x_11); lean_dec(x_1); return x_12; } } } } LEAN_EXPORT lean_object* l_Array_split(lean_object* x_1) { _start: { lean_object* x_2; x_2 = lean_alloc_closure((void*)(l_Array_split___rarg), 2, 0); return x_2; } } LEAN_EXPORT lean_object* l_Array_foldlMUnsafe_fold___at_Array_split___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) { _start: { size_t x_6; size_t x_7; lean_object* x_8; x_6 = lean_unbox_usize(x_3); lean_dec(x_3); x_7 = lean_unbox_usize(x_4); lean_dec(x_4); x_8 = l_Array_foldlMUnsafe_fold___at_Array_split___spec__1___rarg(x_1, x_2, x_6, x_7, x_5); lean_dec(x_2); return x_8; } } lean_object* initialize_Init_WFTactics(uint8_t builtin, lean_object*); lean_object* initialize_Init_Data_Nat_Basic(uint8_t builtin, lean_object*); lean_object* initialize_Init_Data_Fin_Basic(uint8_t builtin, lean_object*); lean_object* initialize_Init_Data_UInt_Basic(uint8_t builtin, lean_object*); lean_object* initialize_Init_Data_Repr(uint8_t builtin, lean_object*); lean_object* initialize_Init_Data_ToString_Basic(uint8_t builtin, lean_object*); lean_object* initialize_Init_Util(uint8_t builtin, lean_object*); static bool _G_initialized = false; LEAN_EXPORT lean_object* initialize_Init_Data_Array_Basic(uint8_t builtin, lean_object* w) { lean_object * res; if (_G_initialized) return lean_io_result_mk_ok(lean_box(0)); _G_initialized = true; res = initialize_Init_WFTactics(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Init_Data_Nat_Basic(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Init_Data_Fin_Basic(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Init_Data_UInt_Basic(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Init_Data_Repr(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Init_Data_ToString_Basic(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Init_Util(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); l_Array_instEmptyCollectionArray___closed__1 = _init_l_Array_instEmptyCollectionArray___closed__1(); lean_mark_persistent(l_Array_instEmptyCollectionArray___closed__1); l_Array_instGetElemArrayUSizeLtNatInstLTNatToNatSize___closed__1 = _init_l_Array_instGetElemArrayUSizeLtNatInstLTNatToNatSize___closed__1(); lean_mark_persistent(l_Array_instGetElemArrayUSizeLtNatInstLTNatToNatSize___closed__1); l_Array_swapAt_x21___rarg___closed__1 = _init_l_Array_swapAt_x21___rarg___closed__1(); lean_mark_persistent(l_Array_swapAt_x21___rarg___closed__1); l_Array_swapAt_x21___rarg___closed__2 = _init_l_Array_swapAt_x21___rarg___closed__2(); lean_mark_persistent(l_Array_swapAt_x21___rarg___closed__2); l_Array_swapAt_x21___rarg___closed__3 = _init_l_Array_swapAt_x21___rarg___closed__3(); lean_mark_persistent(l_Array_swapAt_x21___rarg___closed__3); l_Array_swapAt_x21___rarg___closed__4 = _init_l_Array_swapAt_x21___rarg___closed__4(); lean_mark_persistent(l_Array_swapAt_x21___rarg___closed__4); l_Array_findSomeM_x3f___rarg___closed__1 = _init_l_Array_findSomeM_x3f___rarg___closed__1(); lean_mark_persistent(l_Array_findSomeM_x3f___rarg___closed__1); l_Array_findIdxM_x3f___rarg___closed__1 = _init_l_Array_findIdxM_x3f___rarg___closed__1(); lean_mark_persistent(l_Array_findIdxM_x3f___rarg___closed__1); l_Array_find_x3f___rarg___closed__1 = _init_l_Array_find_x3f___rarg___closed__1(); lean_mark_persistent(l_Array_find_x3f___rarg___closed__1); l_Array_find_x3f___rarg___closed__2 = _init_l_Array_find_x3f___rarg___closed__2(); lean_mark_persistent(l_Array_find_x3f___rarg___closed__2); l_Array_findSome_x21___rarg___closed__1 = _init_l_Array_findSome_x21___rarg___closed__1(); lean_mark_persistent(l_Array_findSome_x21___rarg___closed__1); l_Array_findSome_x21___rarg___closed__2 = _init_l_Array_findSome_x21___rarg___closed__2(); lean_mark_persistent(l_Array_findSome_x21___rarg___closed__2); l_Array_findSome_x21___rarg___closed__3 = _init_l_Array_findSome_x21___rarg___closed__3(); lean_mark_persistent(l_Array_findSome_x21___rarg___closed__3); l_Array_getEvenElems___rarg___closed__1 = _init_l_Array_getEvenElems___rarg___closed__1(); lean_mark_persistent(l_Array_getEvenElems___rarg___closed__1); l_Array_instReprArray___rarg___closed__1 = _init_l_Array_instReprArray___rarg___closed__1(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__1); l_Array_instReprArray___rarg___closed__2 = _init_l_Array_instReprArray___rarg___closed__2(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__2); l_Array_instReprArray___rarg___closed__3 = _init_l_Array_instReprArray___rarg___closed__3(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__3); l_Array_instReprArray___rarg___closed__4 = _init_l_Array_instReprArray___rarg___closed__4(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__4); l_Array_instReprArray___rarg___closed__5 = _init_l_Array_instReprArray___rarg___closed__5(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__5); l_Array_instReprArray___rarg___closed__6 = _init_l_Array_instReprArray___rarg___closed__6(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__6); l_Array_instReprArray___rarg___closed__7 = _init_l_Array_instReprArray___rarg___closed__7(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__7); l_Array_instReprArray___rarg___closed__8 = _init_l_Array_instReprArray___rarg___closed__8(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__8); l_Array_instReprArray___rarg___closed__9 = _init_l_Array_instReprArray___rarg___closed__9(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__9); l_Array_instReprArray___rarg___closed__10 = _init_l_Array_instReprArray___rarg___closed__10(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__10); l_Array_instReprArray___rarg___closed__11 = _init_l_Array_instReprArray___rarg___closed__11(); lean_mark_persistent(l_Array_instReprArray___rarg___closed__11); l_Array_instToStringArray___rarg___closed__1 = _init_l_Array_instToStringArray___rarg___closed__1(); lean_mark_persistent(l_Array_instToStringArray___rarg___closed__1); l_Array_instAppendArray___closed__1 = _init_l_Array_instAppendArray___closed__1(); lean_mark_persistent(l_Array_instAppendArray___closed__1); l_Array_instHAppendArrayList___closed__1 = _init_l_Array_instHAppendArrayList___closed__1(); lean_mark_persistent(l_Array_instHAppendArrayList___closed__1); l_term_x23_x5b___x2c_x5d___closed__1 = _init_l_term_x23_x5b___x2c_x5d___closed__1(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__1); l_term_x23_x5b___x2c_x5d___closed__2 = _init_l_term_x23_x5b___x2c_x5d___closed__2(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__2); l_term_x23_x5b___x2c_x5d___closed__3 = _init_l_term_x23_x5b___x2c_x5d___closed__3(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__3); l_term_x23_x5b___x2c_x5d___closed__4 = _init_l_term_x23_x5b___x2c_x5d___closed__4(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__4); l_term_x23_x5b___x2c_x5d___closed__5 = _init_l_term_x23_x5b___x2c_x5d___closed__5(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__5); l_term_x23_x5b___x2c_x5d___closed__6 = _init_l_term_x23_x5b___x2c_x5d___closed__6(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__6); l_term_x23_x5b___x2c_x5d___closed__7 = _init_l_term_x23_x5b___x2c_x5d___closed__7(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__7); l_term_x23_x5b___x2c_x5d___closed__8 = _init_l_term_x23_x5b___x2c_x5d___closed__8(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__8); l_term_x23_x5b___x2c_x5d___closed__9 = _init_l_term_x23_x5b___x2c_x5d___closed__9(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__9); l_term_x23_x5b___x2c_x5d___closed__10 = _init_l_term_x23_x5b___x2c_x5d___closed__10(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__10); l_term_x23_x5b___x2c_x5d___closed__11 = _init_l_term_x23_x5b___x2c_x5d___closed__11(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__11); l_term_x23_x5b___x2c_x5d___closed__12 = _init_l_term_x23_x5b___x2c_x5d___closed__12(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__12); l_term_x23_x5b___x2c_x5d___closed__13 = _init_l_term_x23_x5b___x2c_x5d___closed__13(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__13); l_term_x23_x5b___x2c_x5d___closed__14 = _init_l_term_x23_x5b___x2c_x5d___closed__14(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__14); l_term_x23_x5b___x2c_x5d___closed__15 = _init_l_term_x23_x5b___x2c_x5d___closed__15(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__15); l_term_x23_x5b___x2c_x5d___closed__16 = _init_l_term_x23_x5b___x2c_x5d___closed__16(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__16); l_term_x23_x5b___x2c_x5d___closed__17 = _init_l_term_x23_x5b___x2c_x5d___closed__17(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__17); l_term_x23_x5b___x2c_x5d___closed__18 = _init_l_term_x23_x5b___x2c_x5d___closed__18(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d___closed__18); l_term_x23_x5b___x2c_x5d = _init_l_term_x23_x5b___x2c_x5d(); lean_mark_persistent(l_term_x23_x5b___x2c_x5d); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__1 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__1(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__1); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__2 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__2(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__2); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__3 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__3(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__3); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__4 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__4(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__4); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__5 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__5(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__5); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__6 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__6(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__6); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__7 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__7(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__7); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__8 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__8(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__8); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__9 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__9(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__9); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__10 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__10(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__10); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__11 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__11(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__11); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__12 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__12(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__12); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__13 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__13(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__13); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__14 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__14(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__14); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__15 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__15(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__15); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__16 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__16(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__16); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__17 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__17(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__17); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__18 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__18(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__18); l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__19 = _init_l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__19(); lean_mark_persistent(l___aux__Init__Data__Array__Basic______macroRules__term_x23_x5b___x2c_x5d__1___closed__19); l_Array_partition___rarg___closed__1 = _init_l_Array_partition___rarg___closed__1(); lean_mark_persistent(l_Array_partition___rarg___closed__1); l_Array_insertAt_x21___rarg___closed__1 = _init_l_Array_insertAt_x21___rarg___closed__1(); lean_mark_persistent(l_Array_insertAt_x21___rarg___closed__1); l_Array_insertAt_x21___rarg___closed__2 = _init_l_Array_insertAt_x21___rarg___closed__2(); lean_mark_persistent(l_Array_insertAt_x21___rarg___closed__2); l_Array_insertAt_x21___rarg___closed__3 = _init_l_Array_insertAt_x21___rarg___closed__3(); lean_mark_persistent(l_Array_insertAt_x21___rarg___closed__3); l_Array_unzip___rarg___closed__1 = _init_l_Array_unzip___rarg___closed__1(); lean_mark_persistent(l_Array_unzip___rarg___closed__1); return lean_io_result_mk_ok(lean_box(0)); } #ifdef __cplusplus } #endif
0cfaf73992b3bebd949cea9ecdc2fdd33644990e
b36f34b6a24d019d624d1cc74f5b29062eef2ba4
/frameworks/3rd/luaopenssl/compat.c
e5d7b212d55a95be1263bf9c5fd5c761f91dd2ab
[ "OpenSSL", "MIT", "LicenseRef-scancode-openssl" ]
permissive
zhongfq/cocos-lua
f49c1639f2c9a2a7678f9ed67e58114986ac882f
c2cf0f36ac0f0c91fb3456b555cacd8e8587be46
refs/heads/main
2023-08-17T17:13:05.705639
2023-08-17T06:06:36
2023-08-17T06:06:36
192,316,318
165
63
MIT
2023-08-14T23:59:30
2019-06-17T09:27:37
C
UTF-8
C
false
false
10,982
c
compat.c
#include <lua.h> #include <lualib.h> #include <lauxlib.h> #include "openssl.h" #include "private.h" #if OPENSSL_VERSION_NUMBER < 0x10100000L int BIO_up_ref(BIO *b) { CRYPTO_add(&b->references, 1, CRYPTO_LOCK_BIO); return 1; } int X509_up_ref(X509 *x) { CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); return 1; } int X509_STORE_up_ref(X509_STORE *s) { CRYPTO_add(&s->references, 1, CRYPTO_LOCK_X509_STORE); return 1; } int EVP_PKEY_up_ref(EVP_PKEY *pkey) { CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); return 1; } int SSL_up_ref(SSL *ssl) { CRYPTO_add(&ssl->references, 1, CRYPTO_LOCK_SSL); return 1; } int SSL_SESSION_up_ref(SSL_SESSION *sess) { CRYPTO_add(&sess->references, 1, CRYPTO_LOCK_SSL_SESSION); return 1; } #endif #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) #if !defined(LIBRESSL_VERSION_NUMBER) int RSA_bits(const RSA *r) { return (BN_num_bits(r->n)); } void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) { *pr = sig->r; *ps = sig->s; } int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) { if (r == NULL || s == NULL) return 0; BN_free(sig->r); BN_free(sig->s); sig->r = r; sig->s = s; return 1; } void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) { if (n != NULL) *n = r->n; if (e != NULL) *e = r->e; if (d != NULL) *d = r->d; } void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) { if (p != NULL) *p = r->p; if (q != NULL) *q = r->q; } void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, const BIGNUM **iqmp) { if (dmp1 != NULL) *dmp1 = r->dmp1; if (dmq1 != NULL) *dmq1 = r->dmq1; if (iqmp != NULL) *iqmp = r->iqmp; } HMAC_CTX *HMAC_CTX_new(void) { HMAC_CTX *ctx = OPENSSL_malloc(sizeof(HMAC_CTX)); if (ctx != NULL) { HMAC_CTX_init(ctx); } return ctx; } void HMAC_CTX_free(HMAC_CTX *ctx) { if (ctx != NULL) { HMAC_CTX_cleanup(ctx); OPENSSL_free(ctx); } } #endif #ifndef OPENSSL_NO_DSA int DSA_bits(const DSA *dsa) { return BN_num_bits(dsa->p); } #if !defined(LIBRESSL_VERSION_NUMBER) DSA *EVP_PKEY_get0_DSA(EVP_PKEY *pkey) { if (pkey->type != EVP_PKEY_DSA) { return NULL; } return pkey->pkey.dsa; } void DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) { if (p != NULL) *p = d->p; if (q != NULL) *q = d->q; if (g != NULL) *g = d->g; } int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g) { /* If the fields p, q and g in d are NULL, the corresponding input * parameters MUST be non-NULL. */ if ((d->p == NULL && p == NULL) || (d->q == NULL && q == NULL) || (d->g == NULL && g == NULL)) return 0; if (p != NULL) { BN_free(d->p); d->p = p; } if (q != NULL) { BN_free(d->q); d->q = q; } if (g != NULL) { BN_free(d->g); d->g = g; } return 1; } void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, const BIGNUM **priv_key) { if (pub_key != NULL) *pub_key = d->pub_key; if (priv_key != NULL) *priv_key = d->priv_key; } int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key) { /* If the field pub_key in d is NULL, the corresponding input * parameters MUST be non-NULL. The priv_key field may * be left NULL. */ if (d->pub_key == NULL && pub_key == NULL) return 0; if (pub_key != NULL) { BN_free(d->pub_key); d->pub_key = pub_key; } if (priv_key != NULL) { BN_free(d->priv_key); d->priv_key = priv_key; } return 1; } #endif #endif #ifndef OPENSSL_NO_EC #if !defined(LIBRESSL_VERSION_NUMBER) EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) { if (pkey->type != EVP_PKEY_EC) { return NULL; } return pkey->pkey.ec; } #endif #endif #ifndef OPENSSL_NO_DH #if !defined(LIBRESSL_VERSION_NUMBER) DH *EVP_PKEY_get0_DH(EVP_PKEY *pkey) { if (pkey->type != EVP_PKEY_DH) { return NULL; } return pkey->pkey.dh; } int DH_bits(const DH *dh) { return BN_num_bits(dh->p); } void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key) { if (pub_key != NULL) *pub_key = dh->pub_key; if (priv_key != NULL) *priv_key = dh->priv_key; } int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) { /* If the field pub_key in dh is NULL, the corresponding input * parameters MUST be non-NULL. The priv_key field may * be left NULL. */ if (dh->pub_key == NULL && pub_key == NULL) return 0; if (pub_key != NULL) { BN_free(dh->pub_key); dh->pub_key = pub_key; } if (priv_key != NULL) { BN_free(dh->priv_key); dh->priv_key = priv_key; } return 1; } void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) { if (p != NULL) *p = dh->p; if (q != NULL) *q = dh->q; if (g != NULL) *g = dh->g; } int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) { /* If the fields p and g in d are NULL, the corresponding input * parameters MUST be non-NULL. q may remain NULL. */ if ((dh->p == NULL && p == NULL) || (dh->g == NULL && g == NULL)) return 0; if (p != NULL) { BN_free(dh->p); dh->p = p; } if (q != NULL) { BN_free(dh->q); dh->q = q; } if (g != NULL) { BN_free(dh->g); dh->g = g; } if (q != NULL) { dh->length = BN_num_bits(q); } return 1; } #endif #endif #ifndef OPENSSL_NO_RSA #if !defined(LIBRESSL_VERSION_NUMBER) RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey) { if (pkey->type != EVP_PKEY_RSA) { return NULL; } return pkey->pkey.rsa; } int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) { /* If the fields n and e in r are NULL, the corresponding input * parameters MUST be non-NULL for n and e. d may be * left NULL (in case only the public key is used). */ if ((r->n == NULL && n == NULL) || (r->e == NULL && e == NULL)) return 0; if (n != NULL) { BN_free(r->n); r->n = n; } if (e != NULL) { BN_free(r->e); r->e = e; } if (d != NULL) { BN_free(r->d); r->d = d; } return 1; } int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) { /* If the fields p and q in r are NULL, the corresponding input * parameters MUST be non-NULL. */ if ((r->p == NULL && p == NULL) || (r->q == NULL && q == NULL)) return 0; if (p != NULL) { BN_free(r->p); r->p = p; } if (q != NULL) { BN_free(r->q); r->q = q; } return 1; } int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) { /* If the fields dmp1, dmq1 and iqmp in r are NULL, the corresponding input * parameters MUST be non-NULL. */ if ((r->dmp1 == NULL && dmp1 == NULL) || (r->dmq1 == NULL && dmq1 == NULL) || (r->iqmp == NULL && iqmp == NULL)) return 0; if (dmp1 != NULL) { BN_free(r->dmp1); r->dmp1 = dmp1; } if (dmq1 != NULL) { BN_free(r->dmq1); r->dmq1 = dmq1; } if (iqmp != NULL) { BN_free(r->iqmp); r->iqmp = iqmp; } return 1; } #endif #endif #if !defined(LIBRESSL_VERSION_NUMBER) EVP_MD_CTX *EVP_MD_CTX_new(void) { return OPENSSL_malloc(sizeof(EVP_MD_CTX)); } int EVP_MD_CTX_reset(EVP_MD_CTX *ctx) { return EVP_MD_CTX_cleanup(ctx); } void EVP_MD_CTX_free(EVP_MD_CTX *ctx) { EVP_MD_CTX_cleanup(ctx); OPENSSL_free(ctx); } void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig, const X509_ALGOR **palg) { if (psig != NULL) *psig = req->signature; if (palg != NULL) *palg = req->sig_alg; } #endif X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req) { return req->req_info->pubkey; } int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp) { req->req_info->enc.modified = 1; return i2d_X509_REQ_INFO(req->req_info, pp); } #if !defined(LIBRESSL_VERSION_NUMBER) const ASN1_INTEGER *X509_get0_serialNumber(const X509 *a) { return a->cert_info->serialNumber; } const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x) { return x->cert_info->extensions; } const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x) { return x->revocationDate; } const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x) { return x->serialNumber; } const STACK_OF(X509_EXTENSION) *X509_REVOKED_get0_extensions(const X509_REVOKED *r) { return r->extensions; } const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl) { return crl->crl->extensions; } void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig, const X509_ALGOR **palg) { if (psig != NULL) *psig = crl->signature; if (palg != NULL) *palg = crl->sig_alg; } const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl) { return crl->crl->lastUpdate; } const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl) { return crl->crl->nextUpdate; } #endif const ASN1_INTEGER *TS_STATUS_INFO_get0_status(const TS_STATUS_INFO *a) { return a->status; } const STACK_OF(ASN1_UTF8STRING) *TS_STATUS_INFO_get0_text(const TS_STATUS_INFO *a) { return a->text; } const ASN1_BIT_STRING *TS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *a) { return a->failure_info; } #if OPENSSL_VERSION_NUMBER < 0x10002000L || defined(LIBRESSL_VERSION_NUMBER) int i2d_re_X509_tbs(X509 *x, unsigned char **pp) { x->cert_info->enc.modified = 1; return i2d_X509_CINF(x->cert_info, pp); } #if !defined(LIBRESSL_VERSION_NUMBER) void X509_get0_signature(CONSTIFY_X509_get0 ASN1_BIT_STRING **psig, CONSTIFY_X509_get0 X509_ALGOR **palg, const X509 *x) { if (psig) *psig = x->signature; if (palg) *palg = x->sig_alg; } int X509_get_signature_nid(const X509 *x) { return OBJ_obj2nid(x->sig_alg->algorithm); } #endif #endif /* < 1.0.2 */ int TS_VERIFY_CTX_add_flags(TS_VERIFY_CTX *ctx, int f) { ctx->flags |= f; return ctx->flags; } int TS_VERIFY_CTX_set_flags(TS_VERIFY_CTX *ctx, int f) { ctx->flags = f; return ctx->flags; } BIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b) { ctx->data = b; return ctx->data; } X509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s) { ctx->store = s; return ctx->store; } STACK_OF(X509) *TS_VERIFY_CTS_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) *certs) { ctx->certs = certs; return ctx->certs; } unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx, unsigned char *hexstr, long len) { ctx->imprint = hexstr; ctx->imprint_len = len; return ctx->imprint; } #if !defined(LIBRESSL_VERSION_NUMBER) const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x) { return x->data; } #endif #endif /* < 1.1.0 */
67ca5744eea0db6871ff5d2d59ad5cdf144ecaba
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/imx6sx/iMX6_Platform_SDK/sdk/drivers/audio/src/imx_audmux.c
a4e9d1fb2f38438f7ef82edc8f93bda9aeb052d9
[ "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
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
5,889
c
imx_audmux.c
/* * Copyright (c) 2010-2012, Freescale Semiconductor, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, this list * of conditions and the following disclaimer. * * o 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. * * o Neither the name of Freescale Semiconductor, Inc. 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. */ /*! * @file imx-audmux.c * @brief Driver for AUDMUX. * * @ingroup diag_audio */ #include <stdio.h> #include "sdk.h" #include "audio/imx_audmux.h" #include "imx_audmux_priv.h" #include "registers/regsaudmux.h" /*! * Dump the registers of audmux * * @return always 0 */ static uint32_t audmux_dump(void) { uint32_t idx; printf("=======================AUDMUX dump===================\n"); for (idx = AUDMUX_PORT_INDEX_MIN; idx <= AUDMUX_PORT_INDEX_MAX; idx++) { printf("PTCR%d: 0x%x\n", idx, HW_AUDMUX_PTCR_RD(idx)); printf("PDCR%d: 0x%x\n", idx, HW_AUDMUX_PDCR_RD(idx)); } return 0; } uint32_t audmux_port_set(uint32_t port, uint32_t ptcr, uint32_t pdcr) { if ((port < AUDMUX_PORT_INDEX_MIN) || (port > AUDMUX_PORT_INDEX_MAX)) { return -1; } HW_AUDMUX_PTCR_WR(port, ptcr); HW_AUDMUX_PDCR_WR(port, pdcr); return 0; } uint32_t audmux_route(uint32_t intPort, uint32_t extPort, uint32_t is_master) { if ((intPort < AUDMUX_PORT_INDEX_MIN) || (intPort > AUDMUX_PORT_INDEX_MAX) || (extPort < AUDMUX_PORT_INDEX_MIN) || (extPort > AUDMUX_PORT_INDEX_MAX)) { return -1; } // Configure the Audio MUX internal port to connect with the SSI based // upon who is acting as the bus master. // // But regardless of who is the master, we also configure the internal // port for synchronous 4-wire operation in normal mode (which is what // we actually need to support the SSI and PMIC for either network or I2S // modes). // // Note that we only configure the transmit framesync and bitclock here // because we are using synchronous mode and the receiver clock // settings will be determined by the transmitter settings. if (AUDMUX_SSI_MASTER == is_master) { // All clock signals for the internal port are input signals for // SSI master mode. HW_AUDMUX_PTCR_WR(intPort, BF_AUDMUX_PTCR1_RFS_DIR(AUDMUX_PTCR_TFSDIR_INPUT) | BF_AUDMUX_PTCR1_TCLKDIR(AUDMUX_PTCR_TCLKDIR_INPUT) | BF_AUDMUX_PTCR1_SYN(AUDMUX_PTCR_SYN_SYNC)); } else { // All clock signals for the internal port are all output signals for // slave mode. The source of the clock signals is the external // port that is connected to the PMIC. HW_AUDMUX_PTCR_WR(intPort, BF_AUDMUX_PTCR1_TFS_DIR(AUDMUX_PTCR_TFSDIR_OUTPUT) | BF_AUDMUX_PTCR1_TFSEL(extPort - 1) | BF_AUDMUX_PTCR1_TCLKDIR(AUDMUX_PTCR_TCLKDIR_OUTPUT) | BF_AUDMUX_PTCR1_TCSEL(extPort - 1) | BF_AUDMUX_PTCR1_SYN(AUDMUX_PTCR_SYN_SYNC)); } HW_AUDMUX_PDCR_WR(intPort, BF_AUDMUX_PDCR1_RXDSEL(extPort - 1) | BF_AUDMUX_PDCR1_TXRXEN(AUDMUX_PDCR_TXRXEN_NO_SWAP) | BF_AUDMUX_PDCR1_MODE(AUDMUX_PDCR_MODE_NORMAL)); // Configure the Audio MUX external port to connect with the PMIC based // upon who is acting as the bus master. // // But regardless of who is the master, we also configure the external // port for synchronous 4-wire operation in normal mode (which is what // we actually need to support the SSI and PMIC in either network or I2S // mode). if (AUDMUX_SSI_MASTER == is_master) { // All clock signals for the external port are output signals for // SSI master mode. The source of the clock signals is the internal // port that is connected to the SSI. HW_AUDMUX_PTCR_WR(extPort, BF_AUDMUX_PTCR1_TFS_DIR(AUDMUX_PTCR_TFSDIR_OUTPUT) | BF_AUDMUX_PTCR1_TFSEL(intPort - 1) | BF_AUDMUX_PTCR1_TCLKDIR(AUDMUX_PTCR_TCLKDIR_OUTPUT) | BF_AUDMUX_PTCR1_TCSEL(intPort - 1) | BF_AUDMUX_PTCR1_SYN(AUDMUX_PTCR_SYN_SYNC)); } else { // All clock signals for the external port are input signals for // PMIC master mode. HW_AUDMUX_PTCR_WR(extPort, BF_AUDMUX_PTCR1_TFS_DIR(AUDMUX_PTCR_TFSDIR_INPUT) | BF_AUDMUX_PTCR1_TCLKDIR(AUDMUX_PTCR_TCLKDIR_INPUT) | BF_AUDMUX_PTCR1_SYN(AUDMUX_PTCR_SYN_SYNC)); } HW_AUDMUX_PDCR_WR(extPort, BF_AUDMUX_PDCR1_RXDSEL(intPort - 1) | BF_AUDMUX_PDCR1_TXRXEN(AUDMUX_PDCR_TXRXEN_NO_SWAP) | BF_AUDMUX_PDCR1_MODE(AUDMUX_PDCR_MODE_NORMAL)); return 0; }
7e71dd35a23b1165ab37d0edb9b0638563b61580
9e0c8c8d8bafa73d133e41f201badc756c92978a
/include/3rd_party/acpi/actypes.h
0ec14a36ada94f09af92b29cf159be6e20f19410
[ "BSD-2-Clause", "MIT", "CC0-1.0", "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause-Views" ]
permissive
vvaltchev/tilck
ccf8d9933be1269b85388e5b21645b831ecf5412
e9c27da4dd15f5f8a927b11f31484aec3f1429f0
refs/heads/master
2023-08-16T00:07:42.593483
2023-07-04T21:00:31
2023-07-19T23:25:42
53,845,595
2,142
115
BSD-2-Clause
2023-09-03T05:36:46
2016-03-14T10:02:41
C
UTF-8
C
false
false
55,208
h
actypes.h
/****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2020, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * ***************************************************************************** * * Alternatively, you may choose to be licensed under the terms of the * following license: * * 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, * without modification. * 2. Redistributions in binary form must reproduce at minimum a disclaimer * substantially similar to the "NO WARRANTY" disclaimer below * ("Disclaimer") and any redistribution must be conditioned upon * including a substantially similar Disclaimer requirement for further * binary redistribution. * 3. Neither the names of the above-listed copyright holders nor the names * of any contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Alternatively, you may choose to be licensed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * *****************************************************************************/ #ifndef __ACTYPES_H__ #define __ACTYPES_H__ /* acpisrc:StructDefs -- for acpisrc conversion */ /* * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent * header and must be either 32 or 64. 16-bit ACPICA is no longer * supported, as of 12/2006. */ #ifndef ACPI_MACHINE_WIDTH #error ACPI_MACHINE_WIDTH not defined #endif /* * Data type ranges * Note: These macros are designed to be compiler independent as well as * working around problems that some 32-bit compilers have with 64-bit * constants. */ #define ACPI_UINT8_MAX (UINT8) (~((UINT8) 0)) /* 0xFF */ #define ACPI_UINT16_MAX (UINT16)(~((UINT16) 0)) /* 0xFFFF */ #define ACPI_UINT32_MAX (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF */ #define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */ #define ACPI_ASCII_MAX 0x7F /* * Architecture-specific ACPICA Subsystem Data Types * * The goal of these types is to provide source code portability across * 16-bit, 32-bit, and 64-bit targets. * * 1) The following types are of fixed size for all targets (16/32/64): * * BOOLEAN Logical boolean * * UINT8 8-bit (1 byte) unsigned value * UINT16 16-bit (2 byte) unsigned value * UINT32 32-bit (4 byte) unsigned value * UINT64 64-bit (8 byte) unsigned value * * INT16 16-bit (2 byte) signed value * INT32 32-bit (4 byte) signed value * INT64 64-bit (8 byte) signed value * * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the * compiler-dependent header(s) and were introduced because there is no * common 64-bit integer type across the various compilation models, as * shown in the table below. * * Datatype LP64 ILP64 LLP64 ILP32 LP32 16bit * char 8 8 8 8 8 8 * short 16 16 16 16 16 16 * _int32 32 * int 32 64 32 32 16 16 * long 64 64 32 32 32 32 * long long 64 64 * pointer 64 64 64 32 32 32 * * Note: ILP64 and LP32 are currently not supported. * * * 2) These types represent the native word size of the target mode of the * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are * usually used for memory allocation, efficient loop counters, and array * indexes. The types are similar to the size_t type in the C library and * are required because there is no C type that consistently represents the * native data width. ACPI_SIZE is needed because there is no guarantee * that a kernel-level C library is present. * * ACPI_SIZE 16/32/64-bit unsigned value * ACPI_NATIVE_INT 16/32/64-bit signed value */ /******************************************************************************* * * Common types for all compilers, all targets * ******************************************************************************/ #ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned char BOOLEAN; typedef unsigned char UINT8; typedef unsigned short UINT16; typedef short INT16; typedef COMPILER_DEPENDENT_UINT64 UINT64; typedef COMPILER_DEPENDENT_INT64 INT64; #endif /* ACPI_USE_SYSTEM_INTTYPES */ /* * Value returned by AcpiOsGetThreadId. There is no standard "thread_id" * across operating systems or even the various UNIX systems. Since ACPICA * only needs the thread ID as a unique thread identifier, we use a UINT64 * as the only common data type - it will accommodate any type of pointer or * any type of integer. It is up to the host-dependent OSL to cast the * native thread ID type to a UINT64 (in AcpiOsGetThreadId). */ #define ACPI_THREAD_ID UINT64 /******************************************************************************* * * Types specific to 64-bit targets * ******************************************************************************/ #if ACPI_MACHINE_WIDTH == 64 #ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned int UINT32; typedef int INT32; #endif /* ACPI_USE_SYSTEM_INTTYPES */ typedef INT64 ACPI_NATIVE_INT; typedef UINT64 ACPI_SIZE; typedef UINT64 ACPI_IO_ADDRESS; typedef UINT64 ACPI_PHYSICAL_ADDRESS; #define ACPI_MAX_PTR ACPI_UINT64_MAX #define ACPI_SIZE_MAX ACPI_UINT64_MAX #define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ #define ACPI_USE_NATIVE_MATH64 /* Has native 64-bit integer support */ /* * In the case of the Itanium Processor Family (IPF), the hardware does not * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED * flag to indicate that special precautions must be taken to avoid alignment * faults. (IA64 or ia64 is currently used by existing compilers to indicate * IPF.) * * Note: EM64T and other X86-64 processors support misaligned transfers, * so there is no need to define this flag. */ #if defined (__IA64__) || defined (__ia64__) #define ACPI_MISALIGNMENT_NOT_SUPPORTED #endif /******************************************************************************* * * Types specific to 32-bit targets * ******************************************************************************/ #elif ACPI_MACHINE_WIDTH == 32 #ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned int UINT32; typedef int INT32; #endif /* ACPI_USE_SYSTEM_INTTYPES */ typedef INT32 ACPI_NATIVE_INT; typedef UINT32 ACPI_SIZE; #ifdef ACPI_32BIT_PHYSICAL_ADDRESS /* * OSPMs can define this to shrink the size of the structures for 32-bit * none PAE environment. ASL compiler may always define this to generate * 32-bit OSPM compliant tables. */ typedef UINT32 ACPI_IO_ADDRESS; typedef UINT32 ACPI_PHYSICAL_ADDRESS; #else /* ACPI_32BIT_PHYSICAL_ADDRESS */ /* * It is reported that, after some calculations, the physical addresses can * wrap over the 32-bit boundary on 32-bit PAE environment. * https://bugzilla.kernel.org/show_bug.cgi?id=87971 */ typedef UINT64 ACPI_IO_ADDRESS; typedef UINT64 ACPI_PHYSICAL_ADDRESS; #endif /* ACPI_32BIT_PHYSICAL_ADDRESS */ #define ACPI_MAX_PTR ACPI_UINT32_MAX #define ACPI_SIZE_MAX ACPI_UINT32_MAX #else /* ACPI_MACHINE_WIDTH must be either 64 or 32 */ #error unknown ACPI_MACHINE_WIDTH #endif /******************************************************************************* * * OS-dependent types * * If the defaults below are not appropriate for the host system, they can * be defined in the OS-specific header, and this will take precedence. * ******************************************************************************/ /* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */ #ifndef ACPI_CPU_FLAGS #define ACPI_CPU_FLAGS ACPI_SIZE #endif /* Object returned from AcpiOsCreateCache */ #ifndef ACPI_CACHE_T #ifdef ACPI_USE_LOCAL_CACHE #define ACPI_CACHE_T ACPI_MEMORY_LIST #else #define ACPI_CACHE_T void * #endif #endif /* * Synchronization objects - Mutexes, Semaphores, and SpinLocks */ #if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE) /* * These macros are used if the host OS does not support a mutex object. * Map the OSL Mutex interfaces to binary semaphores. */ #define ACPI_MUTEX ACPI_SEMAPHORE #define AcpiOsCreateMutex(OutHandle) AcpiOsCreateSemaphore (1, 1, OutHandle) #define AcpiOsDeleteMutex(Handle) (void) AcpiOsDeleteSemaphore (Handle) #define AcpiOsAcquireMutex(Handle,Time) AcpiOsWaitSemaphore (Handle, 1, Time) #define AcpiOsReleaseMutex(Handle) (void) AcpiOsSignalSemaphore (Handle, 1) #endif /* Configurable types for synchronization objects */ #ifndef ACPI_SPINLOCK #define ACPI_SPINLOCK void * #endif #ifndef ACPI_SEMAPHORE #define ACPI_SEMAPHORE void * #endif #ifndef ACPI_MUTEX #define ACPI_MUTEX void * #endif /******************************************************************************* * * Compiler-dependent types * * If the defaults below are not appropriate for the host compiler, they can * be defined in the compiler-specific header, and this will take precedence. * ******************************************************************************/ /* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ #ifndef ACPI_UINTPTR_T #define ACPI_UINTPTR_T void * #endif /* * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because * some compilers can catch printf format string problems */ #ifndef ACPI_PRINTF_LIKE #define ACPI_PRINTF_LIKE(c) #endif /* * Some compilers complain about unused variables. Sometimes we don't want * to use all the variables (for example, _AcpiModuleName). This allows us * to tell the compiler in a per-variable manner that a variable * is unused */ #ifndef ACPI_UNUSED_VAR #define ACPI_UNUSED_VAR #endif /* * All ACPICA external functions that are available to the rest of the * kernel are tagged with these macros which can be defined as appropriate * for the host. * * Notes: * ACPI_EXPORT_SYMBOL_INIT is used for initialization and termination * interfaces that may need special processing. * ACPI_EXPORT_SYMBOL is used for all other public external functions. */ #ifndef ACPI_EXPORT_SYMBOL_INIT #define ACPI_EXPORT_SYMBOL_INIT(Symbol) #endif #ifndef ACPI_EXPORT_SYMBOL #define ACPI_EXPORT_SYMBOL(Symbol) #endif /* * Compiler/Clibrary-dependent debug initialization. Used for ACPICA * utilities only. */ #ifndef ACPI_DEBUG_INITIALIZE #define ACPI_DEBUG_INITIALIZE() #endif /******************************************************************************* * * Configuration * ******************************************************************************/ #ifdef ACPI_NO_MEM_ALLOCATIONS #define ACPI_ALLOCATE(a) NULL #define ACPI_ALLOCATE_ZEROED(a) NULL #define ACPI_FREE(a) #define ACPI_MEM_TRACKING(a) #else /* ACPI_NO_MEM_ALLOCATIONS */ #ifdef ACPI_DBG_TRACK_ALLOCATIONS /* * Memory allocation tracking (used by AcpiExec to detect memory leaks) */ #define ACPI_MEM_PARAMETERS _COMPONENT, _AcpiModuleName, __LINE__ #define ACPI_ALLOCATE(a) AcpiUtAllocateAndTrack ((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) #define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroedAndTrack ((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) #define ACPI_FREE(a) AcpiUtFreeAndTrack (a, ACPI_MEM_PARAMETERS) #define ACPI_MEM_TRACKING(a) a #else /* * Normal memory allocation directly via the OS services layer */ #define ACPI_ALLOCATE(a) AcpiOsAllocate ((ACPI_SIZE) (a)) #define ACPI_ALLOCATE_ZEROED(a) AcpiOsAllocateZeroed ((ACPI_SIZE) (a)) #define ACPI_FREE(a) AcpiOsFree (a) #define ACPI_MEM_TRACKING(a) #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ #endif /* ACPI_NO_MEM_ALLOCATIONS */ /****************************************************************************** * * ACPI Specification constants (Do not change unless the specification * changes) * *****************************************************************************/ /* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */ #define ACPI_MAX_GPE_BLOCKS 2 /* Default ACPI register widths */ #define ACPI_GPE_REGISTER_WIDTH 8 #define ACPI_PM1_REGISTER_WIDTH 16 #define ACPI_PM2_REGISTER_WIDTH 8 #define ACPI_PM_TIMER_WIDTH 32 #define ACPI_RESET_REGISTER_WIDTH 8 /* Names within the namespace are 4 bytes long */ #define ACPI_NAMESEG_SIZE 4 /* Fixed by ACPI spec */ #define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ #define ACPI_PATH_SEPARATOR '.' /* Sizes for ACPI table headers */ #define ACPI_OEM_ID_SIZE 6 #define ACPI_OEM_TABLE_ID_SIZE 8 /* ACPI/PNP hardware IDs */ #define PCI_ROOT_HID_STRING "PNP0A03" #define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" /* PM Timer ticks per second (HZ) */ #define ACPI_PM_TIMER_FREQUENCY 3579545 /******************************************************************************* * * Independent types * ******************************************************************************/ /* Logical defines and NULL */ #ifdef FALSE #undef FALSE #endif #define FALSE (1 == 0) #ifdef TRUE #undef TRUE #endif #define TRUE (1 == 1) #ifndef NULL #define NULL (void *) 0 #endif /* * Miscellaneous types */ typedef UINT32 ACPI_STATUS; /* All ACPI Exceptions */ typedef UINT32 ACPI_NAME; /* 4-byte ACPI name */ typedef char * ACPI_STRING; /* Null terminated ASCII string */ typedef void * ACPI_HANDLE; /* Actually a ptr to a NS Node */ /* Time constants for timer calculations */ #define ACPI_MSEC_PER_SEC 1000L #define ACPI_USEC_PER_MSEC 1000L #define ACPI_USEC_PER_SEC 1000000L #define ACPI_100NSEC_PER_USEC 10L #define ACPI_100NSEC_PER_MSEC 10000L #define ACPI_100NSEC_PER_SEC 10000000L #define ACPI_NSEC_PER_USEC 1000L #define ACPI_NSEC_PER_MSEC 1000000L #define ACPI_NSEC_PER_SEC 1000000000L #define ACPI_TIME_AFTER(a, b) ((INT64)((b) - (a)) < 0) /* Owner IDs are used to track namespace nodes for selective deletion */ typedef UINT16 ACPI_OWNER_ID; #define ACPI_OWNER_ID_MAX 0xFFF /* 4095 possible owner IDs */ #define ACPI_INTEGER_BIT_SIZE 64 #define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ #define ACPI_MAX64_DECIMAL_DIGITS 20 #define ACPI_MAX32_DECIMAL_DIGITS 10 #define ACPI_MAX16_DECIMAL_DIGITS 5 #define ACPI_MAX8_DECIMAL_DIGITS 3 /* * Constants with special meanings */ #define ACPI_ROOT_OBJECT ((ACPI_HANDLE) ACPI_TO_POINTER (ACPI_MAX_PTR)) #define ACPI_WAIT_FOREVER 0xFFFF /* UINT16, as per ACPI spec */ #define ACPI_DO_NOT_WAIT 0 /* * Obsolete: Acpi integer width. In ACPI version 1 (1996), integers are * 32 bits. In ACPI version 2 (2000) and later, integers are max 64 bits. * Note that this pertains to the ACPI integer type only, not to other * integers used in the implementation of the ACPICA subsystem. * * 01/2010: This type is obsolete and has been removed from the entire ACPICA * code base. It remains here for compatibility with device drivers that use * the type. However, it will be removed in the future. */ typedef UINT64 ACPI_INTEGER; #define ACPI_INTEGER_MAX ACPI_UINT64_MAX /******************************************************************************* * * Commonly used macros * ******************************************************************************/ /* Data manipulation */ #define ACPI_LOBYTE(Integer) ((UINT8) (UINT16)(Integer)) #define ACPI_HIBYTE(Integer) ((UINT8) (((UINT16)(Integer)) >> 8)) #define ACPI_LOWORD(Integer) ((UINT16) (UINT32)(Integer)) #define ACPI_HIWORD(Integer) ((UINT16)(((UINT32)(Integer)) >> 16)) #define ACPI_LODWORD(Integer64) ((UINT32) (UINT64)(Integer64)) #define ACPI_HIDWORD(Integer64) ((UINT32)(((UINT64)(Integer64)) >> 32)) #define ACPI_SET_BIT(target,bit) ((target) |= (bit)) #define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) #define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) #define ACPI_MAX(a,b) (((a)>(b))?(a):(b)) /* Size calculation */ #define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) /* Pointer manipulation */ #define ACPI_CAST_PTR(t, p) ((t *) (ACPI_UINTPTR_T) (p)) #define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (ACPI_UINTPTR_T) (p)) #define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) + (ACPI_SIZE)(b))) #define ACPI_SUB_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) - (ACPI_SIZE)(b))) #define ACPI_PTR_DIFF(a, b) ((ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b)))) /* Pointer/Integer type conversions */ #define ACPI_TO_POINTER(i) ACPI_CAST_PTR (void, (ACPI_SIZE) (i)) #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) 0) #define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) #define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) /* Optimizations for 4-character (32-bit) ACPI_NAME manipulation */ #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED #define ACPI_COMPARE_NAMESEG(a,b) (*ACPI_CAST_PTR (UINT32, (a)) == *ACPI_CAST_PTR (UINT32, (b))) #define ACPI_COPY_NAMESEG(dest,src) (*ACPI_CAST_PTR (UINT32, (dest)) = *ACPI_CAST_PTR (UINT32, (src))) #else #define ACPI_COMPARE_NAMESEG(a,b) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAMESEG_SIZE)) #define ACPI_COPY_NAMESEG(dest,src) (strncpy (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAMESEG_SIZE)) #endif /* Support for the special RSDP signature (8 characters) */ #define ACPI_VALIDATE_RSDP_SIG(a) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, 8)) #define ACPI_MAKE_RSDP_SIG(dest) (memcpy (ACPI_CAST_PTR (char, (dest)), ACPI_SIG_RSDP, 8)) /* Support for OEMx signature (x can be any character) */ #define ACPI_IS_OEM_SIG(a) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_OEM_NAME, 3) &&\ strnlen (a, ACPI_NAMESEG_SIZE) == ACPI_NAMESEG_SIZE) /* * Algorithm to obtain access bit or byte width. * Can be used with AccessSize field of ACPI_GENERIC_ADDRESS and * ACPI_RESOURCE_GENERIC_REGISTER. */ #define ACPI_ACCESS_BIT_WIDTH(AccessSize) (1 << ((AccessSize) + 2)) #define ACPI_ACCESS_BYTE_WIDTH(AccessSize) (1 << ((AccessSize) - 1)) /******************************************************************************* * * Miscellaneous constants * ******************************************************************************/ /* * Initialization sequence options */ #define ACPI_FULL_INITIALIZATION 0x0000 #define ACPI_NO_FACS_INIT 0x0001 #define ACPI_NO_ACPI_ENABLE 0x0002 #define ACPI_NO_HARDWARE_INIT 0x0004 #define ACPI_NO_EVENT_INIT 0x0008 #define ACPI_NO_HANDLER_INIT 0x0010 #define ACPI_NO_OBJECT_INIT 0x0020 #define ACPI_NO_DEVICE_INIT 0x0040 #define ACPI_NO_ADDRESS_SPACE_INIT 0x0080 /* * Initialization state */ #define ACPI_SUBSYSTEM_INITIALIZE 0x01 #define ACPI_INITIALIZED_OK 0x02 /* * Power state values */ #define ACPI_STATE_UNKNOWN (UINT8) 0xFF #define ACPI_STATE_S0 (UINT8) 0 #define ACPI_STATE_S1 (UINT8) 1 #define ACPI_STATE_S2 (UINT8) 2 #define ACPI_STATE_S3 (UINT8) 3 #define ACPI_STATE_S4 (UINT8) 4 #define ACPI_STATE_S5 (UINT8) 5 #define ACPI_S_STATES_MAX ACPI_STATE_S5 #define ACPI_S_STATE_COUNT 6 #define ACPI_STATE_D0 (UINT8) 0 #define ACPI_STATE_D1 (UINT8) 1 #define ACPI_STATE_D2 (UINT8) 2 #define ACPI_STATE_D3 (UINT8) 3 #define ACPI_D_STATES_MAX ACPI_STATE_D3 #define ACPI_D_STATE_COUNT 4 #define ACPI_STATE_C0 (UINT8) 0 #define ACPI_STATE_C1 (UINT8) 1 #define ACPI_STATE_C2 (UINT8) 2 #define ACPI_STATE_C3 (UINT8) 3 #define ACPI_C_STATES_MAX ACPI_STATE_C3 #define ACPI_C_STATE_COUNT 4 /* * Sleep type invalid value */ #define ACPI_SLEEP_TYPE_MAX 0x7 #define ACPI_SLEEP_TYPE_INVALID 0xFF /* * Standard notify values */ #define ACPI_NOTIFY_BUS_CHECK (UINT8) 0x00 #define ACPI_NOTIFY_DEVICE_CHECK (UINT8) 0x01 #define ACPI_NOTIFY_DEVICE_WAKE (UINT8) 0x02 #define ACPI_NOTIFY_EJECT_REQUEST (UINT8) 0x03 #define ACPI_NOTIFY_DEVICE_CHECK_LIGHT (UINT8) 0x04 #define ACPI_NOTIFY_FREQUENCY_MISMATCH (UINT8) 0x05 #define ACPI_NOTIFY_BUS_MODE_MISMATCH (UINT8) 0x06 #define ACPI_NOTIFY_POWER_FAULT (UINT8) 0x07 #define ACPI_NOTIFY_CAPABILITIES_CHECK (UINT8) 0x08 #define ACPI_NOTIFY_DEVICE_PLD_CHECK (UINT8) 0x09 #define ACPI_NOTIFY_RESERVED (UINT8) 0x0A #define ACPI_NOTIFY_LOCALITY_UPDATE (UINT8) 0x0B #define ACPI_NOTIFY_SHUTDOWN_REQUEST (UINT8) 0x0C #define ACPI_NOTIFY_AFFINITY_UPDATE (UINT8) 0x0D #define ACPI_NOTIFY_MEMORY_UPDATE (UINT8) 0x0E #define ACPI_NOTIFY_DISCONNECT_RECOVER (UINT8) 0x0F #define ACPI_GENERIC_NOTIFY_MAX 0x0F #define ACPI_SPECIFIC_NOTIFY_MAX 0x84 /* * Types associated with ACPI names and objects. The first group of * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore, * only add to the first group if the spec changes. * * NOTE: Types must be kept in sync with the global AcpiNsProperties * and AcpiNsTypeNames arrays. */ typedef UINT32 ACPI_OBJECT_TYPE; #define ACPI_TYPE_ANY 0x00 #define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */ #define ACPI_TYPE_STRING 0x02 #define ACPI_TYPE_BUFFER 0x03 #define ACPI_TYPE_PACKAGE 0x04 /* ByteConst, multiple DataTerm/Constant/SuperName */ #define ACPI_TYPE_FIELD_UNIT 0x05 #define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */ #define ACPI_TYPE_EVENT 0x07 #define ACPI_TYPE_METHOD 0x08 /* Name, ByteConst, multiple Code */ #define ACPI_TYPE_MUTEX 0x09 #define ACPI_TYPE_REGION 0x0A #define ACPI_TYPE_POWER 0x0B /* Name,ByteConst,WordConst,multi Node */ #define ACPI_TYPE_PROCESSOR 0x0C /* Name,ByteConst,DWordConst,ByteConst,multi NmO */ #define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */ #define ACPI_TYPE_BUFFER_FIELD 0x0E #define ACPI_TYPE_DDB_HANDLE 0x0F #define ACPI_TYPE_DEBUG_OBJECT 0x10 #define ACPI_TYPE_EXTERNAL_MAX 0x10 #define ACPI_NUM_TYPES (ACPI_TYPE_EXTERNAL_MAX + 1) /* * These are object types that do not map directly to the ACPI * ObjectType() operator. They are used for various internal purposes * only. If new predefined ACPI_TYPEs are added (via the ACPI * specification), these internal types must move upwards. (There * is code that depends on these values being contiguous with the * external types above.) */ #define ACPI_TYPE_LOCAL_REGION_FIELD 0x11 #define ACPI_TYPE_LOCAL_BANK_FIELD 0x12 #define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13 #define ACPI_TYPE_LOCAL_REFERENCE 0x14 /* Arg#, Local#, Name, Debug, RefOf, Index */ #define ACPI_TYPE_LOCAL_ALIAS 0x15 #define ACPI_TYPE_LOCAL_METHOD_ALIAS 0x16 #define ACPI_TYPE_LOCAL_NOTIFY 0x17 #define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18 #define ACPI_TYPE_LOCAL_RESOURCE 0x19 #define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x1A #define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple ObjectList Nodes */ #define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */ #define ACPI_TOTAL_TYPES (ACPI_TYPE_NS_NODE_MAX + 1) /* * These are special object types that never appear in * a Namespace node, only in an object of ACPI_OPERAND_OBJECT */ #define ACPI_TYPE_LOCAL_EXTRA 0x1C #define ACPI_TYPE_LOCAL_DATA 0x1D #define ACPI_TYPE_LOCAL_MAX 0x1D /* All types above here are invalid */ #define ACPI_TYPE_INVALID 0x1E #define ACPI_TYPE_NOT_FOUND 0xFF #define ACPI_NUM_NS_TYPES (ACPI_TYPE_INVALID + 1) /* * All I/O */ #define ACPI_READ 0 #define ACPI_WRITE 1 #define ACPI_IO_MASK 1 /* * Event Types: Fixed & General Purpose */ typedef UINT32 ACPI_EVENT_TYPE; /* * Fixed events */ #define ACPI_EVENT_PMTIMER 0 #define ACPI_EVENT_GLOBAL 1 #define ACPI_EVENT_POWER_BUTTON 2 #define ACPI_EVENT_SLEEP_BUTTON 3 #define ACPI_EVENT_RTC 4 #define ACPI_EVENT_MAX 4 #define ACPI_NUM_FIXED_EVENTS ACPI_EVENT_MAX + 1 /* * Event Status - Per event * ------------- * The encoding of ACPI_EVENT_STATUS is illustrated below. * Note that a set bit (1) indicates the property is TRUE * (e.g. if bit 0 is set then the event is enabled). * +-------------+-+-+-+-+-+-+ * | Bits 31:6 |5|4|3|2|1|0| * +-------------+-+-+-+-+-+-+ * | | | | | | | * | | | | | | +- Enabled? * | | | | | +--- Enabled for wake? * | | | | +----- Status bit set? * | | | +------- Enable bit set? * | | +--------- Has a handler? * | +----------- Masked? * +----------------- <Reserved> */ typedef UINT32 ACPI_EVENT_STATUS; #define ACPI_EVENT_FLAG_DISABLED (ACPI_EVENT_STATUS) 0x00 #define ACPI_EVENT_FLAG_ENABLED (ACPI_EVENT_STATUS) 0x01 #define ACPI_EVENT_FLAG_WAKE_ENABLED (ACPI_EVENT_STATUS) 0x02 #define ACPI_EVENT_FLAG_STATUS_SET (ACPI_EVENT_STATUS) 0x04 #define ACPI_EVENT_FLAG_ENABLE_SET (ACPI_EVENT_STATUS) 0x08 #define ACPI_EVENT_FLAG_HAS_HANDLER (ACPI_EVENT_STATUS) 0x10 #define ACPI_EVENT_FLAG_MASKED (ACPI_EVENT_STATUS) 0x20 #define ACPI_EVENT_FLAG_SET ACPI_EVENT_FLAG_STATUS_SET /* Actions for AcpiSetGpe, AcpiGpeWakeup, AcpiHwLowSetGpe */ #define ACPI_GPE_ENABLE 0 #define ACPI_GPE_DISABLE 1 #define ACPI_GPE_CONDITIONAL_ENABLE 2 /* * GPE info flags - Per GPE * +---+-+-+-+---+ * |7:6|5|4|3|2:0| * +---+-+-+-+---+ * | | | | | * | | | | +-- Type of dispatch:to method, handler, notify, or none * | | | +----- Interrupt type: edge or level triggered * | | +------- Is a Wake GPE * | +--------- Has been enabled automatically at init time * +------------ <Reserved> */ #define ACPI_GPE_DISPATCH_NONE (UINT8) 0x00 #define ACPI_GPE_DISPATCH_METHOD (UINT8) 0x01 #define ACPI_GPE_DISPATCH_HANDLER (UINT8) 0x02 #define ACPI_GPE_DISPATCH_NOTIFY (UINT8) 0x03 #define ACPI_GPE_DISPATCH_RAW_HANDLER (UINT8) 0x04 #define ACPI_GPE_DISPATCH_MASK (UINT8) 0x07 #define ACPI_GPE_DISPATCH_TYPE(flags) ((UINT8) ((flags) & ACPI_GPE_DISPATCH_MASK)) #define ACPI_GPE_LEVEL_TRIGGERED (UINT8) 0x08 #define ACPI_GPE_EDGE_TRIGGERED (UINT8) 0x00 #define ACPI_GPE_XRUPT_TYPE_MASK (UINT8) 0x08 #define ACPI_GPE_CAN_WAKE (UINT8) 0x10 #define ACPI_GPE_AUTO_ENABLED (UINT8) 0x20 #define ACPI_GPE_INITIALIZED (UINT8) 0x40 /* * Flags for GPE and Lock interfaces */ #define ACPI_NOT_ISR 0x1 #define ACPI_ISR 0x0 /* Notify types */ #define ACPI_SYSTEM_NOTIFY 0x1 #define ACPI_DEVICE_NOTIFY 0x2 #define ACPI_ALL_NOTIFY (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY) #define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3 #define ACPI_NUM_NOTIFY_TYPES 2 #define ACPI_MAX_SYS_NOTIFY 0x7F #define ACPI_MAX_DEVICE_SPECIFIC_NOTIFY 0xBF #define ACPI_SYSTEM_HANDLER_LIST 0 /* Used as index, must be SYSTEM_NOTIFY -1 */ #define ACPI_DEVICE_HANDLER_LIST 1 /* Used as index, must be DEVICE_NOTIFY -1 */ /* Address Space (Operation Region) Types */ typedef UINT8 ACPI_ADR_SPACE_TYPE; #define ACPI_ADR_SPACE_SYSTEM_MEMORY (ACPI_ADR_SPACE_TYPE) 0 #define ACPI_ADR_SPACE_SYSTEM_IO (ACPI_ADR_SPACE_TYPE) 1 #define ACPI_ADR_SPACE_PCI_CONFIG (ACPI_ADR_SPACE_TYPE) 2 #define ACPI_ADR_SPACE_EC (ACPI_ADR_SPACE_TYPE) 3 #define ACPI_ADR_SPACE_SMBUS (ACPI_ADR_SPACE_TYPE) 4 #define ACPI_ADR_SPACE_CMOS (ACPI_ADR_SPACE_TYPE) 5 #define ACPI_ADR_SPACE_PCI_BAR_TARGET (ACPI_ADR_SPACE_TYPE) 6 #define ACPI_ADR_SPACE_IPMI (ACPI_ADR_SPACE_TYPE) 7 #define ACPI_ADR_SPACE_GPIO (ACPI_ADR_SPACE_TYPE) 8 #define ACPI_ADR_SPACE_GSBUS (ACPI_ADR_SPACE_TYPE) 9 #define ACPI_ADR_SPACE_PLATFORM_COMM (ACPI_ADR_SPACE_TYPE) 10 #define ACPI_ADR_SPACE_PLATFORM_RT (ACPI_ADR_SPACE_TYPE) 11 #define ACPI_NUM_PREDEFINED_REGIONS 12 /* * Special Address Spaces * * Note: A Data Table region is a special type of operation region * that has its own AML opcode. However, internally, the AML * interpreter simply creates an operation region with an an address * space type of ACPI_ADR_SPACE_DATA_TABLE. */ #define ACPI_ADR_SPACE_DATA_TABLE (ACPI_ADR_SPACE_TYPE) 0x7E /* Internal to ACPICA only */ #define ACPI_ADR_SPACE_FIXED_HARDWARE (ACPI_ADR_SPACE_TYPE) 0x7F /* Values for _REG connection code */ #define ACPI_REG_DISCONNECT 0 #define ACPI_REG_CONNECT 1 /* * BitRegister IDs * * These values are intended to be used by the hardware interfaces * and are mapped to individual bitfields defined within the ACPI * registers. See the AcpiGbl_BitRegisterInfo global table in utglobal.c * for this mapping. */ /* PM1 Status register */ #define ACPI_BITREG_TIMER_STATUS 0x00 #define ACPI_BITREG_BUS_MASTER_STATUS 0x01 #define ACPI_BITREG_GLOBAL_LOCK_STATUS 0x02 #define ACPI_BITREG_POWER_BUTTON_STATUS 0x03 #define ACPI_BITREG_SLEEP_BUTTON_STATUS 0x04 #define ACPI_BITREG_RT_CLOCK_STATUS 0x05 #define ACPI_BITREG_WAKE_STATUS 0x06 #define ACPI_BITREG_PCIEXP_WAKE_STATUS 0x07 /* PM1 Enable register */ #define ACPI_BITREG_TIMER_ENABLE 0x08 #define ACPI_BITREG_GLOBAL_LOCK_ENABLE 0x09 #define ACPI_BITREG_POWER_BUTTON_ENABLE 0x0A #define ACPI_BITREG_SLEEP_BUTTON_ENABLE 0x0B #define ACPI_BITREG_RT_CLOCK_ENABLE 0x0C #define ACPI_BITREG_PCIEXP_WAKE_DISABLE 0x0D /* PM1 Control register */ #define ACPI_BITREG_SCI_ENABLE 0x0E #define ACPI_BITREG_BUS_MASTER_RLD 0x0F #define ACPI_BITREG_GLOBAL_LOCK_RELEASE 0x10 #define ACPI_BITREG_SLEEP_TYPE 0x11 #define ACPI_BITREG_SLEEP_ENABLE 0x12 /* PM2 Control register */ #define ACPI_BITREG_ARB_DISABLE 0x13 #define ACPI_BITREG_MAX 0x13 #define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1 /* Status register values. A 1 clears a status bit. 0 = no effect */ #define ACPI_CLEAR_STATUS 1 /* Enable and Control register values */ #define ACPI_ENABLE_EVENT 1 #define ACPI_DISABLE_EVENT 0 /* Sleep function dispatch */ typedef ACPI_STATUS (*ACPI_SLEEP_FUNCTION) ( UINT8 SleepState); typedef struct acpi_sleep_functions { ACPI_SLEEP_FUNCTION LegacyFunction; ACPI_SLEEP_FUNCTION ExtendedFunction; } ACPI_SLEEP_FUNCTIONS; /* * External ACPI object definition */ /* * Note: Type == ACPI_TYPE_ANY (0) is used to indicate a NULL package * element or an unresolved named reference. */ typedef union acpi_object { ACPI_OBJECT_TYPE Type; /* See definition of AcpiNsType for values */ struct { ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_INTEGER */ UINT64 Value; /* The actual number */ } Integer; struct { ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_STRING */ UINT32 Length; /* # of bytes in string, excluding trailing null */ char *Pointer; /* points to the string value */ } String; struct { ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_BUFFER */ UINT32 Length; /* # of bytes in buffer */ UINT8 *Pointer; /* points to the buffer */ } Buffer; struct { ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_PACKAGE */ UINT32 Count; /* # of elements in package */ union acpi_object *Elements; /* Pointer to an array of ACPI_OBJECTs */ } Package; struct { ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_LOCAL_REFERENCE */ ACPI_OBJECT_TYPE ActualType; /* Type associated with the Handle */ ACPI_HANDLE Handle; /* object reference */ } Reference; struct { ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_PROCESSOR */ UINT32 ProcId; ACPI_IO_ADDRESS PblkAddress; UINT32 PblkLength; } Processor; struct { ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_POWER */ UINT32 SystemLevel; UINT32 ResourceOrder; } PowerResource; } ACPI_OBJECT; /* * List of objects, used as a parameter list for control method evaluation */ typedef struct acpi_object_list { UINT32 Count; ACPI_OBJECT *Pointer; } ACPI_OBJECT_LIST; /* * Miscellaneous common Data Structures used by the interfaces */ #define ACPI_NO_BUFFER 0 #ifdef ACPI_NO_MEM_ALLOCATIONS #define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (0) #define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (0) #else /* ACPI_NO_MEM_ALLOCATIONS */ #define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (-1) /* Let ACPICA allocate buffer */ #define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (-2) /* For internal use only (enables tracking) */ #endif /* ACPI_NO_MEM_ALLOCATIONS */ typedef struct acpi_buffer { ACPI_SIZE Length; /* Length in bytes of the buffer */ void *Pointer; /* pointer to buffer */ } ACPI_BUFFER; /* * NameType for AcpiGetName */ #define ACPI_FULL_PATHNAME 0 #define ACPI_SINGLE_NAME 1 #define ACPI_FULL_PATHNAME_NO_TRAILING 2 #define ACPI_NAME_TYPE_MAX 2 /* * Predefined Namespace items */ typedef struct acpi_predefined_names { const char *Name; UINT8 Type; char *Val; } ACPI_PREDEFINED_NAMES; /* * Structure and flags for AcpiGetSystemInfo */ #define ACPI_SYS_MODE_UNKNOWN 0x0000 #define ACPI_SYS_MODE_ACPI 0x0001 #define ACPI_SYS_MODE_LEGACY 0x0002 #define ACPI_SYS_MODES_MASK 0x0003 /* * System info returned by AcpiGetSystemInfo() */ typedef struct acpi_system_info { UINT32 AcpiCaVersion; UINT32 Flags; UINT32 TimerResolution; UINT32 Reserved1; UINT32 Reserved2; UINT32 DebugLevel; UINT32 DebugLayer; } ACPI_SYSTEM_INFO; /* * System statistics returned by AcpiGetStatistics() */ typedef struct acpi_statistics { UINT32 SciCount; UINT32 GpeCount; UINT32 FixedEventCount[ACPI_NUM_FIXED_EVENTS]; UINT32 MethodCount; } ACPI_STATISTICS; /* * Types specific to the OS service interfaces */ typedef UINT32 (ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) ( void *Context); typedef void (ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) ( void *Context); /* * Various handlers and callback procedures */ typedef UINT32 (*ACPI_SCI_HANDLER) ( void *Context); typedef void (*ACPI_GBL_EVENT_HANDLER) ( UINT32 EventType, ACPI_HANDLE Device, UINT32 EventNumber, void *Context); #define ACPI_EVENT_TYPE_GPE 0 #define ACPI_EVENT_TYPE_FIXED 1 typedef UINT32 (*ACPI_EVENT_HANDLER) ( void *Context); typedef UINT32 (*ACPI_GPE_HANDLER) ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, void *Context); typedef void (*ACPI_NOTIFY_HANDLER) ( ACPI_HANDLE Device, UINT32 Value, void *Context); typedef void (*ACPI_OBJECT_HANDLER) ( ACPI_HANDLE Object, void *Data); typedef ACPI_STATUS (*ACPI_INIT_HANDLER) ( ACPI_HANDLE Object, UINT32 Function); #define ACPI_INIT_DEVICE_INI 1 typedef ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) ( ACPI_STATUS AmlStatus, ACPI_NAME Name, UINT16 Opcode, UINT32 AmlOffset, void *Context); /* Table Event handler (Load, LoadTable, etc.) and types */ typedef ACPI_STATUS (*ACPI_TABLE_HANDLER) ( UINT32 Event, void *Table, void *Context); /* Table Event Types */ #define ACPI_TABLE_EVENT_LOAD 0x0 #define ACPI_TABLE_EVENT_UNLOAD 0x1 #define ACPI_TABLE_EVENT_INSTALL 0x2 #define ACPI_TABLE_EVENT_UNINSTALL 0x3 #define ACPI_NUM_TABLE_EVENTS 4 /* Address Spaces (For Operation Regions) */ typedef ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext); #define ACPI_DEFAULT_HANDLER NULL /* Special Context data for GenericSerialBus/GeneralPurposeIo (ACPI 5.0) */ typedef struct acpi_connection_info { UINT8 *Connection; UINT16 Length; UINT8 AccessLength; } ACPI_CONNECTION_INFO; typedef ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) ( ACPI_HANDLE RegionHandle, UINT32 Function, void *HandlerContext, void **RegionContext); #define ACPI_REGION_ACTIVATE 0 #define ACPI_REGION_DEACTIVATE 1 typedef ACPI_STATUS (*ACPI_WALK_CALLBACK) ( ACPI_HANDLE Object, UINT32 NestingLevel, void *Context, void **ReturnValue); typedef UINT32 (*ACPI_INTERFACE_HANDLER) ( ACPI_STRING InterfaceName, UINT32 Supported); /* Interrupt handler return values */ #define ACPI_INTERRUPT_NOT_HANDLED 0x00 #define ACPI_INTERRUPT_HANDLED 0x01 /* GPE handler return values */ #define ACPI_REENABLE_GPE 0x80 /* Length of 32-bit EISAID values when converted back to a string */ #define ACPI_EISAID_STRING_SIZE 8 /* Includes null terminator */ /* Length of UUID (string) values */ #define ACPI_UUID_LENGTH 16 /* Length of 3-byte PCI class code values when converted back to a string */ #define ACPI_PCICLS_STRING_SIZE 7 /* Includes null terminator */ /* Structures used for device/processor HID, UID, CID */ typedef struct acpi_pnp_device_id { UINT32 Length; /* Length of string + null */ char *String; } ACPI_PNP_DEVICE_ID; typedef struct acpi_pnp_device_id_list { UINT32 Count; /* Number of IDs in Ids array */ UINT32 ListSize; /* Size of list, including ID strings */ ACPI_PNP_DEVICE_ID Ids[]; /* ID array */ } ACPI_PNP_DEVICE_ID_LIST; /* * Structure returned from AcpiGetObjectInfo. * Optimized for both 32-bit and 64-bit builds. */ typedef struct acpi_device_info { UINT32 InfoSize; /* Size of info, including ID strings */ UINT32 Name; /* ACPI object Name */ ACPI_OBJECT_TYPE Type; /* ACPI object Type */ UINT8 ParamCount; /* If a method, required parameter count */ UINT16 Valid; /* Indicates which optional fields are valid */ UINT8 Flags; /* Miscellaneous info */ UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ UINT8 LowestDstates[5]; /* _SxW values: 0xFF indicates not valid */ UINT64 Address; /* _ADR value */ ACPI_PNP_DEVICE_ID HardwareId; /* _HID value */ ACPI_PNP_DEVICE_ID UniqueId; /* _UID value */ ACPI_PNP_DEVICE_ID ClassCode; /* _CLS value */ ACPI_PNP_DEVICE_ID_LIST CompatibleIdList; /* _CID list <must be last> */ } ACPI_DEVICE_INFO; /* Values for Flags field above (AcpiGetObjectInfo) */ #define ACPI_PCI_ROOT_BRIDGE 0x01 /* Flags for Valid field above (AcpiGetObjectInfo) */ #define ACPI_VALID_ADR 0x0002 #define ACPI_VALID_HID 0x0004 #define ACPI_VALID_UID 0x0008 #define ACPI_VALID_CID 0x0020 #define ACPI_VALID_CLS 0x0040 #define ACPI_VALID_SXDS 0x0100 #define ACPI_VALID_SXWS 0x0200 /* Flags for _STA method */ #define ACPI_STA_DEVICE_PRESENT 0x01 #define ACPI_STA_DEVICE_ENABLED 0x02 #define ACPI_STA_DEVICE_UI 0x04 #define ACPI_STA_DEVICE_FUNCTIONING 0x08 #define ACPI_STA_DEVICE_OK 0x08 /* Synonym */ #define ACPI_STA_BATTERY_PRESENT 0x10 /* Context structs for address space handlers */ typedef struct acpi_pci_id { UINT16 Segment; UINT16 Bus; UINT16 Device; UINT16 Function; } ACPI_PCI_ID; typedef struct acpi_mem_space_context { UINT32 Length; ACPI_PHYSICAL_ADDRESS Address; ACPI_PHYSICAL_ADDRESS MappedPhysicalAddress; UINT8 *MappedLogicalAddress; ACPI_SIZE MappedLength; } ACPI_MEM_SPACE_CONTEXT; /* * ACPI_MEMORY_LIST is used only if the ACPICA local cache is enabled */ typedef struct acpi_memory_list { const char *ListName; void *ListHead; UINT16 ObjectSize; UINT16 MaxDepth; UINT16 CurrentDepth; #ifdef ACPI_DBG_TRACK_ALLOCATIONS /* Statistics for debug memory tracking only */ UINT32 TotalAllocated; UINT32 TotalFreed; UINT32 MaxOccupied; UINT32 TotalSize; UINT32 CurrentTotalSize; UINT32 Requests; UINT32 Hits; #endif } ACPI_MEMORY_LIST; /* Definitions of trace event types */ typedef enum { ACPI_TRACE_AML_METHOD, ACPI_TRACE_AML_OPCODE, ACPI_TRACE_AML_REGION } ACPI_TRACE_EVENT_TYPE; /* Definitions of _OSI support */ #define ACPI_VENDOR_STRINGS 0x01 #define ACPI_FEATURE_STRINGS 0x02 #define ACPI_ENABLE_INTERFACES 0x00 #define ACPI_DISABLE_INTERFACES 0x04 #define ACPI_DISABLE_ALL_VENDOR_STRINGS (ACPI_DISABLE_INTERFACES | ACPI_VENDOR_STRINGS) #define ACPI_DISABLE_ALL_FEATURE_STRINGS (ACPI_DISABLE_INTERFACES | ACPI_FEATURE_STRINGS) #define ACPI_DISABLE_ALL_STRINGS (ACPI_DISABLE_INTERFACES | ACPI_VENDOR_STRINGS | ACPI_FEATURE_STRINGS) #define ACPI_ENABLE_ALL_VENDOR_STRINGS (ACPI_ENABLE_INTERFACES | ACPI_VENDOR_STRINGS) #define ACPI_ENABLE_ALL_FEATURE_STRINGS (ACPI_ENABLE_INTERFACES | ACPI_FEATURE_STRINGS) #define ACPI_ENABLE_ALL_STRINGS (ACPI_ENABLE_INTERFACES | ACPI_VENDOR_STRINGS | ACPI_FEATURE_STRINGS) #define ACPI_OSI_WIN_2000 0x01 #define ACPI_OSI_WIN_XP 0x02 #define ACPI_OSI_WIN_XP_SP1 0x03 #define ACPI_OSI_WINSRV_2003 0x04 #define ACPI_OSI_WIN_XP_SP2 0x05 #define ACPI_OSI_WINSRV_2003_SP1 0x06 #define ACPI_OSI_WIN_VISTA 0x07 #define ACPI_OSI_WINSRV_2008 0x08 #define ACPI_OSI_WIN_VISTA_SP1 0x09 #define ACPI_OSI_WIN_VISTA_SP2 0x0A #define ACPI_OSI_WIN_7 0x0B #define ACPI_OSI_WIN_8 0x0C #define ACPI_OSI_WIN_8_1 0x0D #define ACPI_OSI_WIN_10 0x0E #define ACPI_OSI_WIN_10_RS1 0x0F #define ACPI_OSI_WIN_10_RS2 0x10 #define ACPI_OSI_WIN_10_RS3 0x11 #define ACPI_OSI_WIN_10_RS4 0x12 #define ACPI_OSI_WIN_10_RS5 0x13 #define ACPI_OSI_WIN_10_19H1 0x14 /* Definitions of getopt */ #define ACPI_OPT_END -1 #endif /* __ACTYPES_H__ */
a3b46865dda5b6adb34779019e35c8a419924536
aa3befea459382dc5c01c925653d54f435b3fb0f
/arch/arm/src/nrf53/nrf53_i2c.c
b000187f105c9e56582b753b4417dfe10fb81590
[ "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
23,092
c
nrf53_i2c.c
/**************************************************************************** * arch/arm/src/nrf53/nrf53_i2c.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 <assert.h> #include <errno.h> #include <debug.h> #include <nuttx/irq.h> #include <nuttx/arch.h> #include <nuttx/mutex.h> #include <nuttx/kmalloc.h> #include <arch/board/board.h> #include "arm_internal.h" #include "nrf53_gpio.h" #include "nrf53_i2c.h" #include "hardware/nrf53_twi.h" #include "hardware/nrf53_utils.h" /**************************************************************************** * Private Types ****************************************************************************/ /* I2C Device Private Data */ struct nrf53_i2c_priv_s { const struct i2c_ops_s *ops; /* Standard I2C operations */ uint32_t base; /* TWI base address */ uint32_t scl_pin; /* SCL pin configuration */ uint32_t sda_pin; /* SDA pin configuration */ int refs; /* Reference count */ int status; /* I2C transfer status */ #ifndef CONFIG_I2C_POLLED uint32_t irq; /* TWI interrupt */ #endif uint8_t msgc; /* Message count */ struct i2c_msg_s *msgv; /* Message list */ uint8_t *ptr; /* Current message buffer */ #ifdef CONFIG_NRF53_I2C_MASTER_COPY_BUF_SIZE /* Static buffer used for continued messages */ uint8_t copy_buf[CONFIG_NRF53_I2C_MASTER_COPY_BUF_SIZE]; #endif uint32_t freq; /* Current I2C frequency */ int dcnt; /* Current message length */ uint16_t flags; /* Current message flags */ uint16_t addr; /* Current I2C address */ mutex_t lock; /* Mutual exclusion mutex */ #ifndef CONFIG_I2C_POLLED sem_t sem_isr; /* Interrupt wait semaphore */ #endif }; /**************************************************************************** * Private Function Prototypes ****************************************************************************/ static inline void nrf53_i2c_putreg(struct nrf53_i2c_priv_s *priv, uint32_t offset, uint32_t value); static inline uint32_t nrf53_i2c_getreg(struct nrf53_i2c_priv_s *priv, uint32_t offset); static int nrf53_i2c_transfer(struct i2c_master_s *dev, struct i2c_msg_s *msgs, int count); #ifdef CONFIG_I2C_RESET static int nrf53_i2c_reset(struct i2c_master_s *dev); #endif #ifndef CONFIG_I2C_POLLED static int nrf53_i2c_isr(int irq, void *context, void *arg); #endif static int nrf53_i2c_deinit(struct nrf53_i2c_priv_s *priv); static int nrf53_i2c_init(struct nrf53_i2c_priv_s *priv); /**************************************************************************** * Private Data ****************************************************************************/ /* I2C operations */ static const struct i2c_ops_s g_nrf53_i2c_ops = { .transfer = nrf53_i2c_transfer #ifdef CONFIG_I2C_RESET , .reset = nrf53_i2c_reset #endif }; /* I2C0 (TWI0) device */ #ifdef CONFIG_NRF53_I2C0_MASTER static struct nrf53_i2c_priv_s g_nrf53_i2c0_priv = { .ops = &g_nrf53_i2c_ops, .base = NRF53_TWIM0_BASE, .scl_pin = BOARD_I2C0_SCL_PIN, .sda_pin = BOARD_I2C0_SDA_PIN, .refs = 0, .lock = NXMUTEX_INITIALIZER, #ifndef CONFIG_I2C_POLLED .sem_isr = SEM_INITIALIZER(0), .irq = NRF53_IRQ_SERIAL0, #endif .msgc = 0, .msgv = NULL, .ptr = NULL, .freq = 0, .dcnt = 0, .flags = 0, .addr = 0, }; #endif /* I2C1 (TWI1) device */ #ifdef CONFIG_NRF53_I2C1_MASTER static struct nrf53_i2c_priv_s g_nrf53_i2c1_priv = { .ops = &g_nrf53_i2c_ops, .base = NRF53_TWIM1_BASE, .scl_pin = BOARD_I2C1_SCL_PIN, .sda_pin = BOARD_I2C1_SDA_PIN, .refs = 0, .lock = NXMUTEX_INITIALIZER, #ifndef CONFIG_I2C_POLLED .sem_isr = SEM_INITIALIZER(0), .irq = NRF53_IRQ_SERIAL1, #endif .msgc = 0, .msgv = NULL, .ptr = NULL, .freq = 0, .dcnt = 0, .flags = 0, .addr = 0, }; #endif /* I2C2 (TWI3) device */ #ifdef CONFIG_NRF53_I2C2_MASTER static struct nrf53_i2c_priv_s g_nrf53_i2c2_priv = { .ops = &g_nrf53_i2c_ops, .base = NRF53_TWIM2_BASE, .scl_pin = BOARD_I2C2_SCL_PIN, .sda_pin = BOARD_I2C2_SDA_PIN, .refs = 0, .lock = NXMUTEX_INITIALIZER, #ifndef CONFIG_I2C_POLLED .sem_isr = SEM_INITIALIZER(0), .irq = NRF53_IRQ_SERIAL2, #endif .msgc = 0, .msgv = NULL, .ptr = NULL, .freq = 0, .dcnt = 0, .flags = 0, .addr = 0, }; #endif /* I2C3 (TWI3) device */ #ifdef CONFIG_NRF53_I2C3_MASTER static struct nrf53_i2c_priv_s g_nrf53_i2c3_priv = { .ops = &g_nrf53_i2c_ops, .base = NRF53_TWIM2_BASE, .scl_pin = BOARD_I2C3_SCL_PIN, .sda_pin = BOARD_I2C3_SDA_PIN, .refs = 0, .lock = NXMUTEX_INITIALIZER, #ifndef CONFIG_I2C_POLLED .sem_isr = SEM_INITIALIZER(0), .irq = NRF53_IRQ_SERIAL3, #endif .msgc = 0, .msgv = NULL, .ptr = NULL, .freq = 0, .dcnt = 0, .flags = 0, .addr = 0, }; #endif /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** * Name: nrf53_i2c_putreg * * Description: * Put a 32-bit register value by offset * ****************************************************************************/ static inline void nrf53_i2c_putreg(struct nrf53_i2c_priv_s *priv, uint32_t offset, uint32_t value) { putreg32(value, priv->base + offset); } /**************************************************************************** * Name: nrf53_i2c_getreg * * Description: * Get a 32-bit register value by offset * ****************************************************************************/ static inline uint32_t nrf53_i2c_getreg(struct nrf53_i2c_priv_s *priv, uint32_t offset) { return getreg32(priv->base + offset); } /**************************************************************************** * Name: nrf53_i2c_transfer * * Description: * Generic I2C transfer function * ****************************************************************************/ static int nrf53_i2c_transfer(struct i2c_master_s *dev, struct i2c_msg_s *msgs, int count) { struct nrf53_i2c_priv_s *priv = (struct nrf53_i2c_priv_s *)dev; uint32_t regval = 0; int ret = OK; #ifndef CONFIG_NRF53_I2C_MASTER_DISABLE_NOSTART uint8_t *pack_buf = NULL; #endif ret = nxmutex_lock(&priv->lock); if (ret < 0) { return ret; } /* Reset ptr and dcnt */ priv->dcnt = 0; priv->ptr = NULL; priv->msgv = msgs; priv->msgc = count; /* Reset I2C transfer status */ priv->status = OK; i2cinfo("I2C TRANSFER count=%d\n", count); /* Do we need change I2C bus frequency ? */ if (priv->msgv->frequency != priv->freq) { /* Get TWI frequency */ switch (priv->msgv->frequency) { case 100000: { regval = TWIM_FREQUENCY_100KBPS; break; } case 250000: { regval = TWIM_FREQUENCY_250KBPS; break; } case 400000: { regval = TWIM_FREQUENCY_400KBPS; break; } default: { ret = -EINVAL; goto errout; } } /* Write TWI frequency */ nrf53_i2c_putreg(priv, NRF53_TWIM_FREQUENCY_OFFSET, regval); /* Save the new I2C frequency */ priv->freq = priv->msgv->frequency; } /* I2C transfer */ do { /* Get current message data */ priv->ptr = priv->msgv->buffer; priv->dcnt = priv->msgv->length; priv->flags = priv->msgv->flags; priv->addr = priv->msgv->addr; i2cinfo("ptr=%p dcnt=%d flags=%d addr=%d\n", priv->ptr, priv->dcnt, priv->flags, priv->addr); /* Write TWI address */ regval = priv->addr; nrf53_i2c_putreg(priv, NRF53_TWIM_ADDRESS_OFFSET, regval); if ((priv->flags & I2C_M_READ) == 0) { #ifndef CONFIG_NRF53_I2C_MASTER_DISABLE_NOSTART /* Check if we need to combine messages */ if (priv->msgc > 1) { if (priv->msgv[1].flags & I2C_M_NOSTART) { /* More than 2 messages not supported */ DEBUGASSERT(priv->msgc < 3); /* Combine buffers */ if ((priv->msgv[0].length + priv->msgv[1].length) <= CONFIG_NRF53_I2C_MASTER_COPY_BUF_SIZE) { pack_buf = priv->copy_buf; } else { pack_buf = kmm_malloc(priv->msgv[0].length + priv->msgv[1].length); if (pack_buf == NULL) { return -ENOMEM; } } /* Combine messages */ memcpy(pack_buf, priv->msgv[0].buffer, priv->msgv[0].length); memcpy(pack_buf + priv->msgv[0].length, priv->msgv[1].buffer, priv->msgv[1].length); /* Use new buffer to transmit data */ priv->ptr = pack_buf; priv->dcnt = priv->msgv[0].length + priv->msgv[1].length; /* Next message */ priv->msgc -= 1; priv->msgv += 1; } } #else if (priv->msgc > 1) { if (priv->msgv[1].flags & I2C_M_NOSTART) { /* Not supported */ DEBUGPANIC(); } } #endif /* Write TXD data pointer */ regval = (uint32_t)priv->ptr; DEBUGASSERT(nrf53_easydma_valid(regval)); nrf53_i2c_putreg(priv, NRF53_TWIM_TXDPTR_OFFSET, regval); /* Write number of bytes in TXD buffer */ regval = priv->dcnt; nrf53_i2c_putreg(priv, NRF53_TWIM_TXDMAXCNT_OFFSET, regval); /* Start TX sequence */ nrf53_i2c_putreg(priv, NRF53_TWIM_TASKS_STARTTX_OFFSET, 1); /* Wait for last TX event */ #ifdef CONFIG_I2C_POLLED while (nrf53_i2c_getreg(priv, NRF53_TWIM_EVENTS_LASTTX_OFFSET) != 1); while (1) { regval = nrf53_i2c_getreg(priv, NRF53_TWIM_ERRORSRC_OFFSET) & 0x7; if (regval != 0) { i2cerr("Error SRC: 0x%08" PRIx32 "\n", regval); ret = -1; nrf53_i2c_putreg(priv, NRF53_TWIM_ERRORSRC_OFFSET, 0x7); goto errout; } if (nrf53_i2c_getreg(priv, NRF53_TWIM_EVENTS_LASTTX_OFFSET) == 1) { break; } } /* Clear event */ nrf53_i2c_putreg(priv, NRF53_TWIM_EVENTS_LASTTX_OFFSET, 0); #else nxsem_wait(&priv->sem_isr); if (priv->status < 0) { ret = priv->status; goto errout; } #endif } else { /* Write RXD data pointer */ regval = (uint32_t)priv->ptr; DEBUGASSERT(nrf53_easydma_valid(regval)); nrf53_i2c_putreg(priv, NRF53_TWIM_RXDPTR_OFFSET, regval); /* Write number of bytes in RXD buffer */ regval = priv->dcnt; nrf53_i2c_putreg(priv, NRF53_TWIM_RXDMAXCNT_OFFSET, regval); /* Start RX sequence */ nrf53_i2c_putreg(priv, NRF53_TWIM_TASKS_STARTRX_OFFSET, 1); /* Wait for last RX done */ #ifdef CONFIG_I2C_POLLED while (1) { regval = nrf53_i2c_getreg(priv, NRF53_TWIM_ERRORSRC_OFFSET) & 0x7; if (regval != 0) { i2cerr("Error SRC: 0x%08" PRIx32 "\n", regval); ret = -1; nrf53_i2c_putreg(priv, NRF53_TWIM_ERRORSRC_OFFSET, 0x7); goto errout; } if (nrf53_i2c_getreg(priv, NRF53_TWIM_EVENTS_LASTRX_OFFSET) == 1) { break; } } /* Clear event */ nrf53_i2c_putreg(priv, NRF53_TWIM_EVENTS_LASTRX_OFFSET, 0); #else nxsem_wait(&priv->sem_isr); if (priv->status < 0) { ret = priv->status; goto errout; } #endif } /* Next message */ priv->msgc -= 1; priv->msgv += 1; } while (priv->msgc > 0); /* TWIM stop */ nrf53_i2c_putreg(priv, NRF53_TWIM_TASKS_STOP_OFFSET, 1); /* Wait for stop event */ #ifdef CONFIG_I2C_POLLED while (1) { regval = nrf53_i2c_getreg(priv, NRF53_TWIM_ERRORSRC_OFFSET) & 0x7; if (regval != 0) { i2cerr("Error SRC: 0x%08" PRIx32 "\n", regval); ret = -1; nrf53_i2c_putreg(priv, NRF53_TWIM_ERRORSRC_OFFSET, 0x7); goto errout; } if (nrf53_i2c_getreg(priv, NRF53_TWIM_EVENTS_STOPPED_OFFSET) == 1) { break; } } /* Clear event */ nrf53_i2c_putreg(priv, NRF53_TWIM_EVENTS_STOPPED_OFFSET, 0); #else nxsem_wait(&priv->sem_isr); if (priv->status < 0) { ret = priv->status; goto errout; } #endif errout: #ifndef CONFIG_NRF53_I2C_MASTER_DISABLE_NOSTART if (pack_buf != NULL && pack_buf != priv->copy_buf) { kmm_free(pack_buf); } #endif nxmutex_unlock(&priv->lock); return ret; } /**************************************************************************** * Name: nrf53_i2c_reset * * Description: * Perform an I2C bus reset in an attempt to break loose stuck I2C devices. * * Input Parameters: * dev - Device-specific state data * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ #ifdef CONFIG_I2C_RESET static int nrf53_i2c_reset(struct i2c_master_s *dev) { #error not implemented } #endif /**************************************************************************** * Name: nrf53_i2c_isr * * Description: * Common I2C interrupt service routine * ****************************************************************************/ #ifndef CONFIG_I2C_POLLED static int nrf53_i2c_isr(int irq, void *context, void *arg) { struct nrf53_i2c_priv_s *priv = (struct nrf53_i2c_priv_s *)arg; uint32_t regval = 0; /* Reset I2C status */ priv->status = OK; if ((priv->flags & I2C_M_READ) == 0) { if (nrf53_i2c_getreg(priv, NRF53_TWIM_EVENTS_LASTTX_OFFSET) == 1) { i2cinfo("I2C LASTTX\n"); /* TX done */ nxsem_post(&priv->sem_isr); /* Clear event */ nrf53_i2c_putreg(priv, NRF53_TWIM_EVENTS_LASTTX_OFFSET, 0); return OK; } } else { if (nrf53_i2c_getreg(priv, NRF53_TWIM_EVENTS_LASTRX_OFFSET) == 1) { i2cinfo("I2C LASTRX\n"); /* RX done */ nxsem_post(&priv->sem_isr); /* Clear event */ nrf53_i2c_putreg(priv, NRF53_TWIM_EVENTS_LASTRX_OFFSET, 0); return OK; } } if (nrf53_i2c_getreg(priv, NRF53_TWIM_EVENTS_STOPPED_OFFSET) == 1) { i2cinfo("I2C STOPPED\n"); /* STOPPED event */ nxsem_post(&priv->sem_isr); /* Clear event */ nrf53_i2c_putreg(priv, NRF53_TWIM_EVENTS_STOPPED_OFFSET, 0); } if (nrf53_i2c_getreg(priv, NRF53_TWIM_EVENTS_ERROR_OFFSET) == 1) { regval = nrf53_i2c_getreg(priv, NRF53_TWIM_ERRORSRC_OFFSET) & 0x7; i2cerr("Error SRC: 0x%08" PRIx32 "\n", regval); /* Set ERROR status */ if (regval & TWIM_ERRORSRC_OVERRUN) { /* Overrun error */ priv->status = -EIO; } else { /* NACK */ priv->status = -ENXIO; } /* ERROR event */ nxsem_post(&priv->sem_isr); /* Clear event */ nrf53_i2c_putreg(priv, NRF53_TWIM_EVENTS_ERROR_OFFSET, 0); nrf53_i2c_putreg(priv, NRF53_TWIM_ERRORSRC_OFFSET, 0x7); } return OK; } #endif /**************************************************************************** * Name: nrf53_i2c_init * * Description: * Setup the I2C hardware, ready for operation with defaults * ****************************************************************************/ static int nrf53_i2c_init(struct nrf53_i2c_priv_s *priv) { uint32_t regval = 0; int pin = 0; int port = 0; /* Disable TWI interface */ nrf53_i2c_putreg(priv, NRF53_TWIM_ENABLE_OFFSET, TWIM_ENABLE_DIS); /* Configure SCL and SDA pins */ nrf53_gpio_config(priv->scl_pin); nrf53_gpio_config(priv->sda_pin); /* Select SCL pin */ pin = GPIO_PIN_DECODE(priv->scl_pin); port = GPIO_PORT_DECODE(priv->scl_pin); regval = (pin << TWIM_PSELSCL_PIN_SHIFT); regval |= (port << TWIM_PSELSCL_PORT_SHIFT); nrf53_i2c_putreg(priv, NRF53_TWIM_PSELSCL_OFFSET, regval); /* Select SDA pin */ pin = GPIO_PIN_DECODE(priv->sda_pin); port = GPIO_PORT_DECODE(priv->sda_pin); regval = (pin << TWIM_PSELSDA_PIN_SHIFT); regval |= (port << TWIM_PSELSDA_PORT_SHIFT); nrf53_i2c_putreg(priv, NRF53_TWIM_PSELSDA_OFFSET, regval); /* Enable TWI interface */ nrf53_i2c_putreg(priv, NRF53_TWIM_ENABLE_OFFSET, TWIM_ENABLE_EN); #ifndef CONFIG_I2C_POLLED /* Enable I2C interrupts */ regval = (TWIM_INT_LASTRX | TWIM_INT_LASTTX | TWIM_INT_STOPPED | TWIM_INT_ERROR); nrf53_i2c_putreg(priv, NRF53_TWIM_INTEN_OFFSET, regval); /* Attach error and event interrupts to the ISRs */ irq_attach(priv->irq, nrf53_i2c_isr, priv); up_enable_irq(priv->irq); #endif return OK; } /**************************************************************************** * Name: nrf53_i2c_deinit * * Description: * Shutdown the I2C hardware * ****************************************************************************/ static int nrf53_i2c_deinit(struct nrf53_i2c_priv_s *priv) { /* Disable TWI interface */ nrf53_i2c_putreg(priv, NRF53_TWIM_ENABLE_OFFSET, TWIM_ENABLE_DIS); /* Unconfigure GPIO pins */ nrf53_gpio_unconfig(priv->scl_pin); nrf53_gpio_unconfig(priv->sda_pin); /* Deatach TWI from GPIO */ nrf53_i2c_putreg(priv, NRF53_TWIM_PSELSCL_OFFSET, TWIM_PSELSCL_RESET); nrf53_i2c_putreg(priv, NRF53_TWIM_PSELSDA_OFFSET, TWIM_PSELSDA_RESET); /* Disable and detach interrupts */ #ifndef CONFIG_I2C_POLLED up_disable_irq(priv->irq); irq_detach(priv->irq); #endif return OK; } /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: nrf53_i2cbus_initialize * * Description: * Initialize one I2C bus * ****************************************************************************/ struct i2c_master_s *nrf53_i2cbus_initialize(int port) { struct nrf53_i2c_priv_s *priv = NULL; i2cinfo("I2C INITIALIZE port=%d\n", port); /* Get interface */ switch (port) { #ifdef CONFIG_NRF53_I2C0_MASTER case 0: { priv = (struct nrf53_i2c_priv_s *)&g_nrf53_i2c0_priv; break; } #endif #ifdef CONFIG_NRF53_I2C1_MASTER case 1: { priv = (struct nrf53_i2c_priv_s *)&g_nrf53_i2c1_priv; break; } #endif #ifdef CONFIG_NRF53_I2C2_MASTER case 2: { priv = (struct nrf53_i2c_priv_s *)&g_nrf53_i2c2_priv; break; } #endif #ifdef CONFIG_NRF53_I2C3_MASTER case 3: { priv = (struct nrf53_i2c_priv_s *)&g_nrf53_i2c3_priv; break; } #endif default: { return NULL; } } /* Initialize private data for the first time, increment reference count, * power-up hardware and configure GPIOs. */ nxmutex_lock(&priv->lock); if (priv->refs++ == 0) { /* Initialize I2C */ nrf53_i2c_init(priv); } nxmutex_unlock(&priv->lock); return (struct i2c_master_s *)priv; } /**************************************************************************** * Name: nrf53_i2cbus_uninitialize * * Description: * Uninitialize an I2C bus * ****************************************************************************/ int nrf53_i2cbus_uninitialize(struct i2c_master_s *dev) { struct nrf53_i2c_priv_s *priv = (struct nrf53_i2c_priv_s *)dev; DEBUGASSERT(dev); /* Decrement reference count and check for underflow */ if (priv->refs == 0) { return ERROR; } nxmutex_lock(&priv->lock); if (--priv->refs) { nxmutex_unlock(&priv->lock); return OK; } /* Disable power and other HW resource (GPIO's) */ nrf53_i2c_deinit(priv); nxmutex_unlock(&priv->lock); return OK; }
4d3f7bb584417a4cc45ec4725bf0c181a9cf05fc
f61a792b07b5d8150f35b646a4af44bfee8086dd
/dbvm/vmm/vmeventhandler_amd.h
1a397ede190eb02e4b2519179e8a3726cfe1e40d
[]
no_license
cheat-engine/cheat-engine
9ba690f25cf53a4c375ca11bd0ae19123731a775
6a0c8253a9b596f0aa216574e7a9bf4a390e409a
refs/heads/master
2023-08-31T05:49:43.507423
2023-08-30T14:15:24
2023-08-30T14:15:24
34,163,206
12,899
2,821
null
2023-09-04T02:15:43
2015-04-18T11:21:57
Pascal
UTF-8
C
false
false
4,990
h
vmeventhandler_amd.h
/* * vmeventhandler_amd.h * * Created on: May 22, 2013 * Author: eric */ #ifndef VMEVENTHANDLER_AMD_H_ #define VMEVENTHANDLER_AMD_H_ #include "vmmhelper.h" //define Exit codes: #define VMEXIT_CR0_READ 0x00 #define VMEXIT_CR1_READ 0x01 #define VMEXIT_CR2_READ 0x02 #define VMEXIT_CR3_READ 0x03 #define VMEXIT_CR4_READ 0x04 #define VMEXIT_CR5_READ 0x05 #define VMEXIT_CR6_READ 0x06 #define VMEXIT_CR7_READ 0x07 #define VMEXIT_CR8_READ 0x08 #define VMEXIT_CR9_READ 0x09 #define VMEXIT_CR10_READ 0x0a #define VMEXIT_CR11_READ 0x0b #define VMEXIT_CR12_READ 0x0c #define VMEXIT_CR13_READ 0x0d #define VMEXIT_CR14_READ 0x0e #define VMEXIT_CR15_READ 0x0f #define VMEXIT_CR0_WRITE 0x10 #define VMEXIT_CR1_WRITE 0x11 #define VMEXIT_CR2_WRITE 0x12 #define VMEXIT_CR3_WRITE 0x13 #define VMEXIT_CR4_WRITE 0x14 #define VMEXIT_CR5_WRITE 0x15 #define VMEXIT_CR6_WRITE 0x16 #define VMEXIT_CR7_WRITE 0x17 #define VMEXIT_CR8_WRITE 0x18 #define VMEXIT_CR9_WRITE 0x19 #define VMEXIT_CR10_WRITE 0x1a #define VMEXIT_CR11_WRITE 0x1b #define VMEXIT_CR12_WRITE 0x1c #define VMEXIT_CR13_WRITE 0x1d #define VMEXIT_CR14_WRITE 0x1e #define VMEXIT_CR15_WRITE 0x1f #define VMEXIT_DR0_READ 0x20 #define VMEXIT_DR1_READ 0x21 #define VMEXIT_DR2_READ 0x22 #define VMEXIT_DR3_READ 0x23 #define VMEXIT_DR4_READ 0x24 #define VMEXIT_DR5_READ 0x25 #define VMEXIT_DR6_READ 0x26 #define VMEXIT_DR7_READ 0x27 #define VMEXIT_DR8_READ 0x28 #define VMEXIT_DR9_READ 0x29 #define VMEXIT_DR10_READ 0x2a #define VMEXIT_DR11_READ 0x2b #define VMEXIT_DR12_READ 0x2c #define VMEXIT_DR13_READ 0x2d #define VMEXIT_DR14_READ 0x2e #define VMEXIT_DR15_READ 0x2f #define VMEXIT_DR0_WRITE 0x30 #define VMEXIT_DR1_WRITE 0x31 #define VMEXIT_DR2_WRITE 0x32 #define VMEXIT_DR3_WRITE 0x33 #define VMEXIT_DR4_WRITE 0x34 #define VMEXIT_DR5_WRITE 0x35 #define VMEXIT_DR6_WRITE 0x36 #define VMEXIT_DR7_WRITE 0x37 #define VMEXIT_DR8_WRITE 0x38 #define VMEXIT_DR9_WRITE 0x39 #define VMEXIT_DR10_WRITE 0x3a #define VMEXIT_DR11_WRITE 0x3b #define VMEXIT_DR12_WRITE 0x3c #define VMEXIT_DR13_WRITE 0x3d #define VMEXIT_DR14_WRITE 0x3e #define VMEXIT_DR15_WRITE 0x3f #define VMEXIT_EXCP0 0x40 #define VMEXIT_EXCP1 0x41 #define VMEXIT_EXCP2 0x42 #define VMEXIT_EXCP3 0x43 #define VMEXIT_EXCP4 0x44 #define VMEXIT_EXCP5 0x45 #define VMEXIT_EXCP6 0x46 #define VMEXIT_EXCP7 0x47 #define VMEXIT_EXCP8 0x48 #define VMEXIT_EXCP9 0x49 #define VMEXIT_EXCP10 0x4a #define VMEXIT_EXCP11 0x4b #define VMEXIT_EXCP12 0x4c #define VMEXIT_EXCP13 0x4d #define VMEXIT_EXCP14 0x4e #define VMEXIT_EXCP15 0x4f #define VMEXIT_EXCP16 0x50 #define VMEXIT_EXCP17 0x51 #define VMEXIT_EXCP18 0x52 #define VMEXIT_EXCP19 0x53 #define VMEXIT_EXCP20 0x54 #define VMEXIT_EXCP21 0x55 #define VMEXIT_EXCP22 0x56 #define VMEXIT_EXCP23 0x57 #define VMEXIT_EXCP24 0x58 #define VMEXIT_EXCP25 0x59 #define VMEXIT_EXCP26 0x5a #define VMEXIT_EXCP27 0x5b #define VMEXIT_EXCP28 0x5c #define VMEXIT_EXCP29 0x5d #define VMEXIT_EXCP30 0x5e #define VMEXIT_EXCP31 0x5f #define VMEXIT_INTR 0x60 #define VMEXIT_NMI 0x61 #define VMEXIT_SMI 0x62 #define VMEXIT_INIT 0x63 #define VMEXIT_VINTR 0x64 #define VMEXIT_CR0_SEL_WRITE 0x65 #define VMEXIT_IDTR_READ 0x66 #define VMEXIT_GDTR_READ 0x67 #define VMEXIT_LDTR_READ 0x68 #define VMEXIT_TR_READ 0x69 #define VMEXIT_IDTR_WRITE 0x6a #define VMEXIT_GDTR_WRITE 0x6b #define VMEXIT_LDTR_WRITE 0x6c #define VMEXIT_TR_WRITE 0x6d #define VMEXIT_RDTSC 0x6e #define VMEXIT_RDPMC 0x6f #define VMEXIT_PUSHF 0x70 #define VMEXIT_POPF 0x71 #define VMEXIT_CPUID 0x72 #define VMEXIT_RSM 0x73 #define VMEXIT_IRET 0x74 #define VMEXIT_SWINT 0x75 #define VMEXIT_INVD 0x76 #define VMEXIT_PAUSE 0x77 #define VMEXIT_HLT 0x78 #define VMEXIT_INVLPG 0x79 #define VMEXIT_INVLPGA 0x7a #define VMEXIT_IOIO 0x7b #define VMEXIT_MSR 0x7c #define VMEXIT_TASK_SWITCH 0x7d #define VMEXIT_FERR_FREEZE 0x7e #define VMEXIT_SHUTDOWN 0x7f #define VMEXIT_VMRUN 0x80 #define VMEXIT_VMMCALL 0x81 #define VMEXIT_VMLOAD 0x82 #define VMEXIT_VMSAVE 0x83 #define VMEXIT_STGI 0x84 #define VMEXIT_CLGI 0x85 #define VMEXIT_SKINIT 0x86 #define VMEXIT_RDTSCP 0x87 #define VMEXIT_ICEBP 0x88 #define VMEXIT_WBINVD 0x89 #define VMEXIT_MONITOR 0x8a #define VMEXIT_MWAIT 0x8b #define VMEXIT_MWAIT_CONDITIONAL 0x8c #define VMEXIT_XSETBV 0x8d #define VMEXIT_NPF 0x400 //nested paging pagefault. (Note for future: Look up possible (ab)use for stealthedit) #define AVIC_INCOMPLETE_IPI 0x401 #define AVIC_NOACCEL 0x402 #define VMEXIT_INVALID -1 int handleVMEvent_amd(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *fxsave); #endif /* VMEVENTHANDLER_AMD_H_ */
98cb379cf6a9b12084d0cd7dff918bf83df872ac
f367e4b66a1ee42e85830b31df88f63723c36a47
/lib/monkey/mk_core/mk_thread_channel.c
a31949d7b6afb42c830c8cdc935c5a501be3ff60
[ "Apache-2.0" ]
permissive
fluent/fluent-bit
06873e441162b92941024e9a7e9e8fc934150bf7
1a41f49dc2f3ae31a780caa9ffd6137b1d703065
refs/heads/master
2023-09-05T13:44:55.347372
2023-09-05T10:14:33
2023-09-05T10:14:33
29,933,948
4,907
1,565
Apache-2.0
2023-09-14T10:17:02
2015-01-27T20:41:52
C
UTF-8
C
false
false
4,162
c
mk_thread_channel.c
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Monkey HTTP Server (Duda I/O) * ----------------------------- * Copyright 2017 Eduardo Silva <eduardo@monkey.io> * Copyright 2014, Zeying Xie <swpdtz at gmail dot 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. */ #include <stdlib.h> #include <assert.h> #include <mk_core/mk_memory.h> #include <mk_core/mk_thread.h> #include <mk_core/mk_thread_channel.h> struct mk_thread_channel_elem { void *data; struct mk_list _head; }; struct mk_thread_channel_elem *mk_thread_channel_elem_create(void *data) { struct mk_thread_channel_elem *elem; elem = mk_mem_alloc(sizeof(*elem)); if (!elem) { return NULL; } elem->data = data; return elem; } static void mk_thread_channel_elem_free(struct mk_thread_channel_elem *elem) { assert(elem); mk_list_del(&elem->_head); mk_mem_free(elem); } /* * @METHOD_NAME: chan_create * @METHOD_DESC: create a channel(pipe) for dthread communication. * @METHOD_PROTO: mk_thread_channel_t *chan_create(int size) * @METHOD_PARAM: size the buffered size of the channel. * @METHOD_RETURN: returns a new channel. */ struct mk_thread_channel *mk_thread_channel_create(int size) { struct mk_thread_channel *chan; chan = mk_mem_alloc(sizeof(*chan)); if (!chan) { return NULL; } chan->size = size + 1; chan->used = 0; mk_list_init(&chan->bufs); chan->sender = -1; chan->receiver = -1; chan->ended = 0; chan->done = 0; return chan; } /* * @METHOD_NAME: chan_free * @METHOD_DESC: release a given channel. * @METHOD_PROTO: void chan_free(mk_thread_channel_t *chan) * @METHOD_PARAM: chan the target channel to be released. * @METHOD_RETURN: this method do not return any value. */ void mk_thread_channel_free(struct mk_thread_channel *chan) { assert(chan); if (chan->receiver != -1) { mk_list_del(&chan->_head); } mk_mem_free(chan); } /* * @METHOD_NAME: chan_send * @METHOD_DESC: add a new element to the given channel. * @METHOD_PROTO: int chan_send(mk_thread_channel_t *chan, void *data) * @METHOD_PARAM: chan the target channel to send. * @METHOD_PARAM: data the new element to be sent to channel. * @METHOD_RETURN: return THREAD_CHANNEL_BROKEN if the other side of the pipe * is closed, otherwise return THREAD_CHANNEL_OK. */ int mk_thread_channel_send(struct mk_thread_channel *chan, void *data) { struct mk_thread_channel_elem *elem; assert(chan); if (chan->receiver == -1) { return MK_THREAD_CHANNEL_BROKEN; } if (chan->used == chan->size) { // channel is full mk_thread_resume(chan->receiver); } elem = mk_thread_channel_elem_create(data); mk_list_add(&elem->_head, &chan->bufs); chan->used++; return MK_THREAD_CHANNEL_OK; } /* * @METHOD_NAME: chan_recv * @METHOD_DESC: remove an element from a given channel. * @METHOD_PROTO: void *chan_recv(mk_thread_channel_t *chan) * @METHOD_PARAM: chan the target channel to receive. * @METHOD_RETURN: the front element of the channel. */ void *mk_thread_channel_recv(struct mk_thread_channel *chan) { void *data; struct mk_thread_channel_elem *elem; assert(chan); assert(!chan->done); if (chan->used == 0) { /* channel is empty */ mk_thread_resume(chan->sender); } elem = mk_list_entry_first(&chan->bufs, struct mk_thread_channel_elem, _head); data = elem->data; mk_thread_channel_elem_free(elem); chan->used--; if (chan->used == 0 && chan->ended) { chan->done = 1; } return data; }
f6c884d5e1381db1382014d95902547afaff9815
de21f9075f55640514c29ef0f1fe3f0690845764
/regression/cbmc/typedef-return-type3/main.c
e246757c6924668d4fe7a3fb2fcdddfd24806526
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-4-Clause" ]
permissive
diffblue/cbmc
975a074ac445febb3b5715f8792beb545522dc18
decd2839c2f51a54b2ad0f3e89fdc1b4bf78cd16
refs/heads/develop
2023-08-31T05:52:05.342195
2023-08-30T13:31:51
2023-08-30T13:31:51
51,877,056
589
309
NOASSERTION
2023-09-14T18:49:17
2016-02-16T23:03:52
C++
UTF-8
C
false
false
86
c
main.c
typedef int MYINT; typedef MYINT CHAINEDINT; MYINT fun() { } CHAINEDINT fun2() { }
812e0f0f8cf34ffb4378e50bcba9e73e00453b3f
21c92afbd7fd022a206fb31294c523aebb770104
/SuiteSparse/CHOLMOD/Supernodal/t_cholmod_super_numeric.c
dba6f482aee165c9885bfe1c196bfa31ade9510f
[ "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "GPL-2.0-or-later", "GPL-3.0-only", "LGPL-2.1-or-later", "LGPL-2.0-or-later", "GPL-1.0-or-later", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "LicenseRef-scancode-generic-cla", "GPL-2.0-only" ]
permissive
jlblancoc/suitesparse-metis-for-windows
70e6bcab2b525afb41758d61f823efa0618f67cf
5ee2eb4bc7bfd6d27af2f7fb027b1545cfc0fa3f
refs/heads/master
2023-08-30T21:15:39.624300
2023-03-09T10:16:48
2023-03-09T10:16:48
16,236,582
423
251
BSD-3-Clause
2023-03-09T10:18:08
2014-01-25T18:06:21
C
UTF-8
C
false
false
42,486
c
t_cholmod_super_numeric.c
/* ========================================================================== */ /* === Supernodal/t_cholmod_super_numeric =================================== */ /* ========================================================================== */ /* ----------------------------------------------------------------------------- * CHOLMOD/Supernodal Module. Copyright (C) 2005-2012, Timothy A. Davis * http://www.suitesparse.com * -------------------------------------------------------------------------- */ /* Template routine for cholmod_super_numeric. All xtypes supported, except * that a zomplex A and F result in a complex L (there is no supernodal * zomplex L). */ /* ========================================================================== */ /* === complex arithmetic =================================================== */ /* ========================================================================== */ #include "cholmod_template.h" #undef L_ENTRY #undef L_CLEAR #undef L_ASSIGN #undef L_MULTADD #undef L_ASSEMBLE #undef L_ASSEMBLESUB #ifdef REAL /* -------------------------------------------------------------------------- */ /* A, F, and L are all real */ /* -------------------------------------------------------------------------- */ #define L_ENTRY 1 #define L_CLEAR(Lx,p) Lx [p] = 0 #define L_ASSIGN(Lx,q, Ax,Az,p) Lx [q] = Ax [p] #define L_MULTADD(Lx,q, Ax,Az,p, f) Lx [q] += Ax [p] * f [0] #define L_ASSEMBLE(Lx,q,b) Lx [q] += b [0] #define L_ASSEMBLESUB(Lx,q,C,p) Lx [q] -= C [p] #else /* -------------------------------------------------------------------------- */ /* A and F are complex or zomplex, L and C are complex */ /* -------------------------------------------------------------------------- */ #define L_ENTRY 2 #define L_CLEAR(Lx,p) Lx [2*(p)] = 0 ; Lx [2*(p)+1] = 0 #define L_ASSEMBLE(Lx,q,b) Lx [2*(q)] += b [0] ; #define L_ASSEMBLESUB(Lx,q,C,p) \ Lx [2*(q) ] -= C [2*(p) ] ; \ Lx [2*(q)+1] -= C [2*(p)+1] ; #ifdef COMPLEX /* -------------------------------------------------------------------------- */ /* A, F, L, and C are all complex */ /* -------------------------------------------------------------------------- */ #define L_ASSIGN(Lx,q, Ax,Az,p) \ Lx [2*(q) ] = Ax [2*(p) ] ; \ Lx [2*(q)+1] = Ax [2*(p)+1] #define L_MULTADD(Lx,q, Ax,Az,p, f) \ Lx [2*(q) ] += Ax [2*(p) ] * f [0] - Ax [2*(p)+1] * f [1] ; \ Lx [2*(q)+1] += Ax [2*(p)+1] * f [0] + Ax [2*(p) ] * f [1] #else /* -------------------------------------------------------------------------- */ /* A and F are zomplex, L and C is complex */ /* -------------------------------------------------------------------------- */ #define L_ASSIGN(Lx,q, Ax,Az,p) \ Lx [2*(q) ] = Ax [p] ; \ Lx [2*(q)+1] = Az [p] ; #define L_MULTADD(Lx,q, Ax,Az,p, f) \ Lx [2*(q) ] += Ax [p] * f [0] - Az [p] * f [1] ; \ Lx [2*(q)+1] += Az [p] * f [0] + Ax [p] * f [1] #endif #endif /* ========================================================================== */ /* === t_cholmod_super_numeric ============================================== */ /* ========================================================================== */ /* This function returns FALSE only if integer overflow occurs in the BLAS. * It returns TRUE otherwise whether or not the matrix is positive definite. */ static int TEMPLATE (cholmod_super_numeric) ( /* ---- input ---- */ cholmod_sparse *A, /* matrix to factorize */ cholmod_sparse *F, /* F = A' or A(:,f)' */ double beta [2], /* beta*I is added to diagonal of matrix to factorize */ /* ---- in/out --- */ cholmod_factor *L, /* factorization */ /* -- workspace -- */ cholmod_dense *Cwork, /* size (L->maxcsize)-by-1 */ /* --------------- */ cholmod_common *Common ) { double one [2], zero [2], tstart ; double *Lx, *Ax, *Fx, *Az, *Fz, *C ; Int *Super, *Head, *Ls, *Lpi, *Lpx, *Map, *SuperMap, *RelativeMap, *Next, *Lpos, *Fp, *Fi, *Fnz, *Ap, *Ai, *Anz, *Iwork, *Next_save, *Lpos_save, *Previous; Int nsuper, n, j, i, k, s, p, pend, k1, k2, nscol, psi, psx, psend, nsrow, pj, d, kd1, kd2, info, ndcol, ndrow, pdi, pdx, pdend, pdi1, pdi2, pdx1, ndrow1, ndrow2, px, dancestor, sparent, dnext, nsrow2, ndrow3, pk, pf, pfend, stype, Apacked, Fpacked, q, imap, repeat_supernode, nscol2, ss, tail, nscol_new = 0; /* ---------------------------------------------------------------------- */ /* declarations for the GPU */ /* ---------------------------------------------------------------------- */ /* these variables are not used if the GPU module is not installed */ #ifdef GPU_BLAS Int ndescendants, mapCreatedOnGpu, supernodeUsedGPU, idescendant, dlarge, dsmall, skips ; int iHostBuff, iDevBuff, useGPU, GPUavailable ; cholmod_gpu_pointers *gpu_p, gpu_pointer_struct ; gpu_p = &gpu_pointer_struct ; #endif /* ---------------------------------------------------------------------- */ /* guard against integer overflow in the BLAS */ /* ---------------------------------------------------------------------- */ /* If integer overflow occurs in the BLAS, Common->status is set to * CHOLMOD_TOO_LARGE, and the contents of Lx are undefined. */ Common->blas_ok = TRUE ; /* ---------------------------------------------------------------------- */ /* get inputs */ /* ---------------------------------------------------------------------- */ nsuper = L->nsuper ; n = L->n ; C = Cwork->x ; /* workspace of size L->maxcsize */ one [0] = 1.0 ; /* ALPHA for *syrk, *herk, *gemm, and *trsm */ one [1] = 0. ; zero [0] = 0. ; /* BETA for *syrk, *herk, and *gemm */ zero [1] = 0. ; /* Iwork must be of size 2n + 5*nsuper, allocated in the caller, * cholmod_super_numeric. The memory cannot be allocated here because the * cholmod_super_numeric initializes SuperMap, and cholmod_allocate_work * does not preserve existing workspace if the space needs to be increase * in size. */ /* allocate integer workspace */ Iwork = Common->Iwork ; SuperMap = Iwork ; /* size n (i/i/l) */ RelativeMap = Iwork + n ; /* size n (i/i/l) */ Next = Iwork + 2*((size_t) n) ; /* size nsuper*/ Lpos = Iwork + 2*((size_t) n) + nsuper ; /* size nsuper*/ Next_save = Iwork + 2*((size_t) n) + 2*((size_t) nsuper) ;/* size nsuper*/ Lpos_save = Iwork + 2*((size_t) n) + 3*((size_t) nsuper) ;/* size nsuper*/ Previous = Iwork + 2*((size_t) n) + 4*((size_t) nsuper) ;/* size nsuper*/ Map = Common->Flag ; /* size n, use Flag as workspace for Map array */ Head = Common->Head ; /* size n+1, only Head [0..nsuper-1] used */ Ls = L->s ; Lpi = L->pi ; Lpx = L->px ; Super = L->super ; Lx = L->x ; #ifdef GPU_BLAS /* local copy of useGPU */ if ( (Common->useGPU == 1) && L->useGPU) { /* Initialize the GPU. If not found, don't use it. */ useGPU = TEMPLATE2 (CHOLMOD (gpu_init)) (C, L, Common, nsuper, n, Lpi[nsuper]-Lpi[0], gpu_p) ; } else { useGPU = 0; } /* fprintf (stderr, "local useGPU %d\n", useGPU) ; */ #endif #ifndef NTIMER /* clear GPU / CPU statistics */ Common->CHOLMOD_CPU_GEMM_CALLS = 0 ; Common->CHOLMOD_CPU_SYRK_CALLS = 0 ; Common->CHOLMOD_CPU_TRSM_CALLS = 0 ; Common->CHOLMOD_CPU_POTRF_CALLS = 0 ; Common->CHOLMOD_GPU_GEMM_CALLS = 0 ; Common->CHOLMOD_GPU_SYRK_CALLS = 0 ; Common->CHOLMOD_GPU_TRSM_CALLS = 0 ; Common->CHOLMOD_GPU_POTRF_CALLS = 0 ; Common->CHOLMOD_CPU_GEMM_TIME = 0 ; Common->CHOLMOD_CPU_SYRK_TIME = 0 ; Common->CHOLMOD_CPU_TRSM_TIME = 0 ; Common->CHOLMOD_CPU_POTRF_TIME = 0 ; Common->CHOLMOD_GPU_GEMM_TIME = 0 ; Common->CHOLMOD_GPU_SYRK_TIME = 0 ; Common->CHOLMOD_GPU_TRSM_TIME = 0 ; Common->CHOLMOD_GPU_POTRF_TIME = 0 ; Common->CHOLMOD_ASSEMBLE_TIME = 0 ; Common->CHOLMOD_ASSEMBLE_TIME2 = 0 ; #endif stype = A->stype ; if (stype != 0) { /* F not accessed */ Fp = NULL ; Fi = NULL ; Fx = NULL ; Fz = NULL ; Fnz = NULL ; Fpacked = TRUE ; } else { Fp = F->p ; Fi = F->i ; Fx = F->x ; Fz = F->z ; Fnz = F->nz ; Fpacked = F->packed ; } Ap = A->p ; Ai = A->i ; Ax = A->x ; Az = A->z ; Anz = A->nz ; Apacked = A->packed ; /* clear the Map so that changes in the pattern of A can be detected */ #pragma omp parallel for num_threads(CHOLMOD_OMP_NUM_THREADS) \ if ( n > 128 ) schedule (static) for (i = 0 ; i < n ; i++) { Map [i] = EMPTY ; } /* If the matrix is not positive definite, the supernode s containing the * first zero or negative diagonal entry of L is repeated (but factorized * only up to just before the problematic diagonal entry). The purpose is * to provide MATLAB with [R,p]=chol(A); columns 1 to p-1 of L=R' are * required, where L(p,p) is the problematic diagonal entry. The * repeat_supernode flag tells us whether this is the repeated supernode. * Once supernode s is repeated, the factorization is terminated. */ repeat_supernode = FALSE ; #ifdef GPU_BLAS if ( useGPU ) { /* Case of GPU, zero all supernodes at one time for better performance*/ TEMPLATE2 (CHOLMOD (gpu_clear_memory))(Lx, L->xsize, CHOLMOD_OMP_NUM_THREADS); } #endif /* ---------------------------------------------------------------------- */ /* supernodal numerical factorization */ /* ---------------------------------------------------------------------- */ for (s = 0 ; s < nsuper ; s++) { /* ------------------------------------------------------------------ */ /* get the size of supernode s */ /* ------------------------------------------------------------------ */ k1 = Super [s] ; /* s contains columns k1 to k2-1 of L */ k2 = Super [s+1] ; nscol = k2 - k1 ; /* # of columns in all of s */ psi = Lpi [s] ; /* pointer to first row of s in Ls */ psx = Lpx [s] ; /* pointer to first row of s in Lx */ psend = Lpi [s+1] ; /* pointer just past last row of s in Ls */ nsrow = psend - psi ; /* # of rows in all of s */ PRINT1 (("====================================================\n" "S "ID" k1 "ID" k2 "ID" nsrow "ID" nscol "ID" psi "ID" psend " ""ID" psx "ID"\n", s, k1, k2, nsrow, nscol, psi, psend, psx)) ; /* ------------------------------------------------------------------ */ /* zero the supernode s */ /* ------------------------------------------------------------------ */ ASSERT ((size_t) (psx + nsrow*nscol) <= L->xsize) ; pend = psx + nsrow * nscol ; /* s is nsrow-by-nscol */ #ifdef GPU_BLAS if ( !useGPU ) #endif { /* Case of no GPU, zero individual supernodes */ #pragma omp parallel for num_threads(CHOLMOD_OMP_NUM_THREADS) \ schedule (static) if ( pend - psx > 1024 ) for (p = psx ; p < pend ; p++) { L_CLEAR (Lx,p); } } /* ------------------------------------------------------------------ */ /* construct the scattered Map for supernode s */ /* ------------------------------------------------------------------ */ /* If row i is the kth row in s, then Map [i] = k. Similarly, if * column j is the kth column in s, then Map [j] = k. */ #pragma omp parallel for num_threads(CHOLMOD_OMP_NUM_THREADS) \ if ( nsrow > 128 ) for (k = 0 ; k < nsrow ; k++) { PRINT1 ((" "ID" map "ID"\n", Ls [psi+k], k)) ; Map [Ls [psi + k]] = k ; } /* ------------------------------------------------------------------ */ /* when using GPU, reorder supernodes by levels.*/ /* (all supernodes in a level are independent) */ /* ------------------------------------------------------------------ */ #ifdef GPU_BLAS if ( useGPU ) { TEMPLATE2 (CHOLMOD (gpu_reorder_descendants)) ( Common, Super, &s, Lpi, Lpos, Head, Next, Previous, &ndescendants, &tail, &mapCreatedOnGpu, gpu_p ) ; } #endif /* ------------------------------------------------------------------ */ /* copy matrix into supernode s (lower triangular part only) */ /* ------------------------------------------------------------------ */ pk = psx ; #pragma omp parallel for private ( p, pend, pfend, pf, i, j, imap, q ) \ num_threads(CHOLMOD_OMP_NUM_THREADS) if ( k2-k1 > 64 ) for (k = k1 ; k < k2 ; k++) { if (stype != 0) { /* copy the kth column of A into the supernode */ p = Ap [k] ; pend = (Apacked) ? (Ap [k+1]) : (p + Anz [k]) ; for ( ; p < pend ; p++) { /* row i of L is located in row Map [i] of s */ i = Ai [p] ; if (i >= k) { /* This test is here simply to avoid a segfault. If * the test is false, the numeric factorization of A * is undefined. It does not detect all invalid * entries, only some of them (when debugging is * enabled, and Map is cleared after each step, then * all entries not in the pattern of L are detected). */ imap = Map [i] ; if (imap >= 0 && imap < nsrow) { /* Lx [Map [i] + pk] = Ax [p] ; */ L_ASSIGN (Lx,(imap+(psx+(k-k1)*nsrow)), Ax,Az,p) ; } } } } else { double fjk[2]; /* copy the kth column of A*F into the supernode */ pf = Fp [k] ; pfend = (Fpacked) ? (Fp [k+1]) : (p + Fnz [k]) ; for ( ; pf < pfend ; pf++) { j = Fi [pf] ; /* fjk = Fx [pf] ; */ L_ASSIGN (fjk,0, Fx,Fz,pf) ; p = Ap [j] ; pend = (Apacked) ? (Ap [j+1]) : (p + Anz [j]) ; for ( ; p < pend ; p++) { i = Ai [p] ; if (i >= k) { /* See the discussion of imap above. */ imap = Map [i] ; if (imap >= 0 && imap < nsrow) { /* Lx [Map [i] + pk] += Ax [p] * fjk ; */ L_MULTADD (Lx,(imap+(psx+(k-k1)*nsrow)), Ax,Az,p, fjk) ; } } } } } } /* add beta to the diagonal of the supernode, if nonzero */ if (beta [0] != 0.0) { /* note that only the real part of beta is used */ pk = psx ; for (k = k1 ; k < k2 ; k++) { /* Lx [pk] += beta [0] ; */ L_ASSEMBLE (Lx,pk, beta) ; pk += nsrow + 1 ; /* advance to the next diagonal entry */ } } PRINT1 (("Supernode with just A: repeat: "ID"\n", repeat_supernode)) ; DEBUG (CHOLMOD(dump_super) (s, Super, Lpi, Ls, Lpx, Lx, L_ENTRY, Common)) ; PRINT1 (("\n\n")) ; /* ------------------------------------------------------------------ */ /* save/restore the list of supernodes */ /* ------------------------------------------------------------------ */ if (!repeat_supernode) { /* Save the list of pending descendants in case s is not positive * definite. Also save Lpos for each descendant d, so that we can * find which part of d is used to update s. */ for (d = Head [s] ; d != EMPTY ; d = Next [d]) { Lpos_save [d] = Lpos [d] ; Next_save [d] = Next [d] ; } } else { for (d = Head [s] ; d != EMPTY ; d = Next [d]) { Lpos [d] = Lpos_save [d] ; Next [d] = Next_save [d] ; } } /* ------------------------------------------------------------------ */ /* update supernode s with each pending descendant d */ /* ------------------------------------------------------------------ */ #ifndef NDEBUG for (d = Head [s] ; d != EMPTY ; d = Next [d]) { PRINT1 (("\nWill update "ID" with Child: "ID"\n", s, d)) ; DEBUG (CHOLMOD(dump_super) (d, Super, Lpi, Ls, Lpx, Lx, L_ENTRY, Common)) ; } PRINT1 (("\nNow factorizing supernode "ID":\n", s)) ; #endif #ifdef GPU_BLAS /* initialize the buffer counter */ if ( useGPU ) { Common->ibuffer = 0; supernodeUsedGPU = 0; idescendant = 0; d = Head[s]; dnext = d; dlarge = Next[d]; dsmall = tail; GPUavailable = 1; skips = 0; } else { dnext = Head[s]; } #else /* GPU module not installed */ dnext = Head[s]; #endif while #ifdef GPU_BLAS ( (!useGPU && (dnext != EMPTY)) || (useGPU && (idescendant < ndescendants))) #else ( dnext != EMPTY ) #endif { #ifdef GPU_BLAS if ( useGPU ) { /* Conditionally select the next descendant supernode to * assemble. * + first, select the largest descendant * + subsequently, if gpu host buffers are available, select * the largest remaining descendant for assembly on the GPU * + otherwise select the smallest remaining descendant for * assembly on the CPU * * The objective is to keep the GPU busy assembling the largest * descendants, and simultaneously keep the CPU busy assembling * the smallest descendants. * * As this is called for every descendent supernode, moving * this code to t_cholmod_gpu incurs substantial overhead - * ~20 GF/s on audikw_1 - so it is being left here. */ iHostBuff = (Common->ibuffer) % CHOLMOD_HOST_SUPERNODE_BUFFERS; cudaError_t cuErr; if ( idescendant > 0 ) { if ( GPUavailable == -1 || skips > 0) { d = dsmall; dsmall = Previous[dsmall]; skips--; } else { cuErr = cudaEventQuery ( Common->updateCBuffersFree[iHostBuff] ); if ( cuErr == cudaSuccess ) { /* buffers are available, so assemble a large * descendant (anticipating that this will be * assembled on the GPU) */ d = dlarge; dlarge = Next[dlarge]; GPUavailable = 1; skips = 0; } else { /* buffers are not available, so the GPU is busy, * so assemble a small descendant (anticipating * that it will be assembled on the host) */ d = dsmall; dsmall = Previous[dsmall]; GPUavailable = 0; /* if the GPUs are busy, then do this many * supernodes on the CPU before querying GPUs * again. */ skips = CHOLMOD_GPU_SKIP; } } } idescendant++; } else { d = dnext; } #else /* GPU module not installed at compile time */ d = dnext ; #endif /* -------------------------------------------------------------- */ /* get the size of supernode d */ /* -------------------------------------------------------------- */ kd1 = Super [d] ; /* d contains cols kd1 to kd2-1 of L */ kd2 = Super [d+1] ; ndcol = kd2 - kd1 ; /* # of columns in all of d */ pdi = Lpi [d] ; /* pointer to first row of d in Ls */ pdx = Lpx [d] ; /* pointer to first row of d in Lx */ pdend = Lpi [d+1] ; /* pointer just past last row of d in Ls */ ndrow = pdend - pdi ; /* # rows in all of d */ PRINT1 (("Child: ")) ; DEBUG (CHOLMOD(dump_super) (d, Super, Lpi, Ls, Lpx, Lx, L_ENTRY, Common)) ; /* -------------------------------------------------------------- */ /* find the range of rows of d that affect rows k1 to k2-1 of s */ /* -------------------------------------------------------------- */ p = Lpos [d] ; /* offset of 1st row of d affecting s */ pdi1 = pdi + p ; /* ptr to 1st row of d affecting s in Ls */ pdx1 = pdx + p ; /* ptr to 1st row of d affecting s in Lx */ /* there must be at least one row remaining in d to update s */ ASSERT (pdi1 < pdend) ; PRINT1 (("Lpos[d] "ID" pdi1 "ID" Ls[pdi1] "ID"\n", Lpos[d], pdi1, Ls [pdi1])) ; ASSERT (Ls [pdi1] >= k1 && Ls [pdi1] < k2) ; for (pdi2 = pdi1 ; pdi2 < pdend && Ls [pdi2] < k2 ; pdi2++) ; ndrow1 = pdi2 - pdi1 ; /* # rows in first part of d */ ndrow2 = pdend - pdi1 ; /* # rows in remaining d */ /* rows Ls [pdi1 ... pdi2-1] are in the range k1 to k2-1. Since d * affects s, this set cannot be empty. */ ASSERT (pdi1 < pdi2 && pdi2 <= pdend) ; PRINT1 (("ndrow1 "ID" ndrow2 "ID"\n", ndrow1, ndrow2)) ; DEBUG (for (p = pdi1 ; p < pdi2 ; p++) PRINT1 (("Ls["ID"] "ID"\n", p, Ls[p]))) ; /* -------------------------------------------------------------- */ /* construct the update matrix C for this supernode d */ /* -------------------------------------------------------------- */ /* C = L (k1:n-1, kd1:kd2-1) * L (k1:k2-1, kd1:kd2-1)', except * that k1:n-1 refers to all of the rows in L, but many of the * rows are all zero. Supernode d holds columns kd1 to kd2-1 of L. * Nonzero rows in the range k1:k2-1 are in the list * Ls [pdi1 ... pdi2-1], of size ndrow1. Nonzero rows in the range * k2:n-1 are in the list Ls [pdi2 ... pdend], of size ndrow2. Let * L1 = L (Ls [pdi1 ... pdi2-1], kd1:kd2-1), and let * L2 = L (Ls [pdi2 ... pdend], kd1:kd2-1). C is ndrow2-by-ndrow1. * Let C1 be the first ndrow1 rows of C and let C2 be the last * ndrow2-ndrow1 rows of C. Only the lower triangular part of C1 * needs to be computed since C1 is symmetric. */ /* maxcsize is the largest size of C for all pairs (d,s) */ ASSERT (ndrow2 * ndrow1 <= ((Int) L->maxcsize)) ; /* compute leading ndrow1-by-ndrow1 lower triangular block of C, * C1 = L1*L1' */ ndrow3 = ndrow2 - ndrow1 ; /* number of rows of C2 */ ASSERT (ndrow3 >= 0) ; #ifdef GPU_BLAS if ( useGPU ) { /* set up GPU to assemble new supernode */ if ( GPUavailable == 1) { if ( ndrow2 * L_ENTRY >= CHOLMOD_ND_ROW_LIMIT && ndcol * L_ENTRY >= CHOLMOD_ND_COL_LIMIT ) { if ( ! mapCreatedOnGpu ) { TEMPLATE2 ( CHOLMOD (gpu_initialize_supernode)) ( Common, nscol, nsrow, psi, gpu_p ); mapCreatedOnGpu = 1; } } else { /* we've reached the limit of GPU-eligible descendants * flag to stop stop performing cudaEventQueries */ GPUavailable = -1; } } } #endif #ifdef GPU_BLAS if ( !useGPU || GPUavailable!=1 || !TEMPLATE2 (CHOLMOD (gpu_updateC)) (ndrow1, ndrow2, ndrow, ndcol, nsrow, pdx1, pdi1, Lx, C, Common, gpu_p)) #endif { /* GPU not installed, or not used */ #ifndef NTIMER Common->CHOLMOD_CPU_SYRK_CALLS++ ; tstart = SuiteSparse_time () ; #endif #ifdef REAL BLAS_dsyrk ("L", "N", ndrow1, ndcol, /* N, K: L1 is ndrow1-by-ndcol*/ one, /* ALPHA: 1 */ Lx + L_ENTRY*pdx1, ndrow, /* A, LDA: L1, ndrow */ zero, /* BETA: 0 */ C, ndrow2) ; /* C, LDC: C1 */ #else BLAS_zherk ("L", "N", ndrow1, ndcol, /* N, K: L1 is ndrow1-by-ndcol*/ one, /* ALPHA: 1 */ Lx + L_ENTRY*pdx1, ndrow, /* A, LDA: L1, ndrow */ zero, /* BETA: 0 */ C, ndrow2) ; /* C, LDC: C1 */ #endif #ifndef NTIMER Common->CHOLMOD_CPU_SYRK_TIME += SuiteSparse_time () - tstart ; #endif /* compute remaining (ndrow2-ndrow1)-by-ndrow1 block of C, * C2 = L2*L1' */ if (ndrow3 > 0) { #ifndef NTIMER Common->CHOLMOD_CPU_GEMM_CALLS++ ; tstart = SuiteSparse_time () ; #endif #ifdef REAL BLAS_dgemm ("N", "C", ndrow3, ndrow1, ndcol, /* M, N, K */ one, /* ALPHA: 1 */ Lx + L_ENTRY*(pdx1 + ndrow1), /* A, LDA: L2 */ ndrow, /* ndrow */ Lx + L_ENTRY*pdx1, /* B, LDB: L1 */ ndrow, /* ndrow */ zero, /* BETA: 0 */ C + L_ENTRY*ndrow1, /* C, LDC: C2 */ ndrow2) ; #else BLAS_zgemm ("N", "C", ndrow3, ndrow1, ndcol, /* M, N, K */ one, /* ALPHA: 1 */ Lx + L_ENTRY*(pdx1 + ndrow1), /* A, LDA: L2 */ ndrow, /* ndrow */ Lx + L_ENTRY*pdx1, /* B, LDB: L1, ndrow */ ndrow, zero, /* BETA: 0 */ C + L_ENTRY*ndrow1, /* C, LDC: C2 */ ndrow2) ; #endif #ifndef NTIMER Common->CHOLMOD_CPU_GEMM_TIME += SuiteSparse_time () - tstart ; #endif } /* ---------------------------------------------------------- */ /* construct relative map to assemble d into s */ /* ---------------------------------------------------------- */ DEBUG (CHOLMOD(dump_real) ("C", C, ndrow2, ndrow1, TRUE, L_ENTRY, Common)) ; #pragma omp parallel for num_threads(CHOLMOD_OMP_NUM_THREADS) \ if ( ndrow2 > 64 ) for (i = 0 ; i < ndrow2 ; i++) { RelativeMap [i] = Map [Ls [pdi1 + i]] ; ASSERT (RelativeMap [i] >= 0 && RelativeMap [i] < nsrow) ; } /* ---------------------------------------------------------- */ /* assemble C into supernode s using the relative map */ /* ---------------------------------------------------------- */ #pragma omp parallel for private ( j, i, px, q ) \ num_threads(CHOLMOD_OMP_NUM_THREADS) if (ndrow1 > 64 ) for (j = 0 ; j < ndrow1 ; j++) /* cols k1:k2-1 */ { ASSERT (RelativeMap [j] == Map [Ls [pdi1 + j]]) ; ASSERT (RelativeMap [j] >= 0 && RelativeMap [j] < nscol) ; px = psx + RelativeMap [j] * nsrow ; for (i = j ; i < ndrow2 ; i++) /* rows k1:n-1 */ { ASSERT (RelativeMap [i] == Map [Ls [pdi1 + i]]) ; ASSERT (RelativeMap [i] >= j && RelativeMap[i] < nsrow); /* Lx [px + RelativeMap [i]] -= C [i + pj] ; */ q = px + RelativeMap [i] ; L_ASSEMBLESUB (Lx,q, C, i+ndrow2*j) ; } } } #ifdef GPU_BLAS else { supernodeUsedGPU = 1; /* GPU was used for this supernode*/ Common->ibuffer++; /* gpu_updateC is asynchronous, so use * the next host buffer for the next * supernode */ Common->ibuffer = Common->ibuffer% (CHOLMOD_HOST_SUPERNODE_BUFFERS*CHOLMOD_DEVICE_STREAMS); } #endif /* -------------------------------------------------------------- */ /* prepare this supernode d for its next ancestor */ /* -------------------------------------------------------------- */ dnext = Next [d] ; if (!repeat_supernode) { /* If node s is being repeated, Head [dancestor] has already * been cleared (set to EMPTY). It must remain EMPTY. The * dancestor will not be factorized since the factorization * terminates at node s. */ Lpos [d] = pdi2 - pdi ; if (Lpos [d] < ndrow) { dancestor = SuperMap [Ls [pdi2]] ; ASSERT (dancestor > s && dancestor < nsuper) ; /* place d in the link list of its next ancestor */ Next [d] = Head [dancestor] ; Head [dancestor] = d ; } } } /* end of descendant supernode loop */ #ifdef GPU_BLAS if ( useGPU ) { iHostBuff = (Common->ibuffer)%CHOLMOD_HOST_SUPERNODE_BUFFERS; iDevBuff = (Common->ibuffer)%CHOLMOD_DEVICE_STREAMS; /* combine updates assembled on the GPU with updates * assembled on the CPU */ TEMPLATE2 ( CHOLMOD (gpu_final_assembly )) ( Common, Lx, psx, nscol, nsrow, supernodeUsedGPU, &iHostBuff, &iDevBuff, gpu_p ); } #endif PRINT1 (("\nSupernode with contributions A: repeat: "ID"\n", repeat_supernode)) ; DEBUG (CHOLMOD(dump_super) (s, Super, Lpi, Ls, Lpx, Lx, L_ENTRY, Common)) ; PRINT1 (("\n\n")) ; /* ------------------------------------------------------------------ */ /* factorize diagonal block of supernode s in LL' */ /* ------------------------------------------------------------------ */ /* The current supernode s is ready to factorize. It has been updated * by all descendant supernodes. Let S = the current supernode, which * holds rows k1:n-1 and columns k1:k2-1 of the updated matrix. It * splits into two parts: the square diagonal block S1, and the * rectangular part S2. Here, S1 is factorized into L1*L1' and * overwritten by L1. * * If supernode s is being repeated, only factorize it up to but not * including the column containing the problematic entry. */ nscol2 = (repeat_supernode) ? (nscol_new) : (nscol) ; #ifdef GPU_BLAS if ( !useGPU || !supernodeUsedGPU || !TEMPLATE2 (CHOLMOD (gpu_lower_potrf))(nscol2, nsrow, psx, Lx, &info, Common, gpu_p)) #endif { /* Note that the GPU will not be used for the triangular solve */ #ifdef GPU_BLAS supernodeUsedGPU = 0; #endif #ifndef NTIMER Common->CHOLMOD_CPU_POTRF_CALLS++ ; tstart = SuiteSparse_time () ; #endif #ifdef REAL LAPACK_dpotrf ("L", nscol2, /* N: nscol2 */ Lx + L_ENTRY*psx, nsrow, /* A, LDA: S1, nsrow */ info) ; /* INFO */ #else LAPACK_zpotrf ("L", nscol2, /* N: nscol2 */ Lx + L_ENTRY*psx, nsrow, /* A, LDA: S1, nsrow */ info) ; /* INFO */ #endif #ifndef NTIMER Common->CHOLMOD_CPU_POTRF_TIME += SuiteSparse_time ()- tstart ; #endif } /* ------------------------------------------------------------------ */ /* check if the matrix is not positive definite */ /* ------------------------------------------------------------------ */ if (repeat_supernode) { /* the leading part has been refactorized; it must have succeeded */ info = 0 ; /* zero out the rest of this supernode */ p = psx + nsrow * nscol_new ; pend = psx + nsrow * nscol ; /* s is nsrow-by-nscol */ for ( ; p < pend ; p++) { /* Lx [p] = 0 ; */ L_CLEAR (Lx,p) ; } } /* info is set to one in LAPACK_*potrf if blas_ok is FALSE. It is * set to zero in dpotrf/zpotrf if the factorization was successful. */ if (CHECK_BLAS_INT && !Common->blas_ok) { ERROR (CHOLMOD_TOO_LARGE, "problem too large for the BLAS") ; } if (info != 0) { /* Matrix is not positive definite. dpotrf/zpotrf do NOT report an * error if the diagonal of L has NaN's, only if it has a zero. */ if (Common->status == CHOLMOD_OK) { ERROR (CHOLMOD_NOT_POSDEF, "matrix not positive definite") ; } /* L->minor is the column of L that contains a zero or negative * diagonal term. */ L->minor = k1 + info - 1 ; /* clear the link lists of all subsequent supernodes */ for (ss = s+1 ; ss < nsuper ; ss++) { Head [ss] = EMPTY ; } /* zero this supernode, and all remaining supernodes */ pend = L->xsize ; for (p = psx ; p < pend ; p++) { /* Lx [p] = 0. ; */ L_CLEAR (Lx,p) ; } /* If L is indefinite, it still contains useful information. * Supernodes 0 to s-1 are valid, similar to MATLAB [R,p]=chol(A), * where the 1-based p is identical to the 0-based L->minor. Since * L->minor is in the current supernode s, it and any columns to the * left of it in supernode s are also all zero. This differs from * [R,p]=chol(A), which contains nonzero rows 1 to p-1. Fix this * by setting repeat_supernode to TRUE, and repeating supernode s. * * If Common->quick_return_if_not_posdef is true, then the entire * supernode s is not factorized; it is left as all zero. */ if (info == 1 || Common->quick_return_if_not_posdef) { /* If the first column of supernode s contains a zero or * negative diagonal entry, then it is already properly set to * zero. Also, info will be 1 if integer overflow occured in * the BLAS. */ Head [s] = EMPTY ; #ifdef GPU_BLAS if ( useGPU ) { CHOLMOD (gpu_end) (Common) ; } #endif return (Common->status >= CHOLMOD_OK) ; } else { /* Repeat supernode s, but only factorize it up to but not * including the column containing the problematic diagonal * entry. */ repeat_supernode = TRUE ; s-- ; nscol_new = info - 1 ; continue ; } } /* ------------------------------------------------------------------ */ /* compute the subdiagonal block and prepare supernode for its parent */ /* ------------------------------------------------------------------ */ nsrow2 = nsrow - nscol2 ; if (nsrow2 > 0) { /* The current supernode is columns k1 to k2-1 of L. Let L1 be the * diagonal block (factorized by dpotrf/zpotrf above; rows/cols * k1:k2-1), and L2 be rows k2:n-1 and columns k1:k2-1 of L. The * triangular system to solve is L2*L1' = S2, where S2 is * overwritten with L2. More precisely, L2 = S2 / L1' in MATLAB * notation. */ #ifdef GPU_BLAS if ( !useGPU || !supernodeUsedGPU || !TEMPLATE2 (CHOLMOD(gpu_triangular_solve)) (nsrow2, nscol2, nsrow, psx, Lx, Common, gpu_p)) #endif { #ifndef NTIMER Common->CHOLMOD_CPU_TRSM_CALLS++ ; tstart = SuiteSparse_time () ; #endif #ifdef REAL BLAS_dtrsm ("R", "L", "C", "N", nsrow2, nscol2, /* M, N */ one, /* ALPHA: 1 */ Lx + L_ENTRY*psx, nsrow, /* A, LDA: L1, nsrow */ Lx + L_ENTRY*(psx + nscol2), /* B, LDB, L2, nsrow */ nsrow) ; #else BLAS_ztrsm ("R", "L", "C", "N", nsrow2, nscol2, /* M, N */ one, /* ALPHA: 1 */ Lx + L_ENTRY*psx, nsrow, /* A, LDA: L1, nsrow */ Lx + L_ENTRY*(psx + nscol2), /* B, LDB, L2, nsrow */ nsrow) ; #endif #ifndef NTIMER Common->CHOLMOD_CPU_TRSM_TIME += SuiteSparse_time () - tstart ; #endif } if (CHECK_BLAS_INT && !Common->blas_ok) { ERROR (CHOLMOD_TOO_LARGE, "problem too large for the BLAS") ; } if (!repeat_supernode) { /* Lpos [s] is offset of first row of s affecting its parent */ Lpos [s] = nscol ; sparent = SuperMap [Ls [psi + nscol]] ; ASSERT (sparent != EMPTY) ; ASSERT (Ls [psi + nscol] >= Super [sparent]) ; ASSERT (Ls [psi + nscol] < Super [sparent+1]) ; ASSERT (SuperMap [Ls [psi + nscol]] == sparent) ; ASSERT (sparent > s && sparent < nsuper) ; /* place s in link list of its parent */ Next [s] = Head [sparent] ; Head [sparent] = s ; } } else { #ifdef GPU_BLAS TEMPLATE2 ( CHOLMOD (gpu_copy_supernode) ) ( Common, Lx, psx, nscol, nscol2, nsrow, supernodeUsedGPU, iHostBuff, gpu_p); #endif } Head [s] = EMPTY ; /* link list for supernode s no longer needed */ /* clear the Map (debugging only, to detect changes in pattern of A) */ DEBUG (for (k = 0 ; k < nsrow ; k++) Map [Ls [psi + k]] = EMPTY) ; DEBUG (CHOLMOD(dump_super) (s, Super, Lpi, Ls, Lpx, Lx, L_ENTRY, Common)) ; if (repeat_supernode) { /* matrix is not positive definite; finished clean-up for supernode * containing negative diagonal */ #ifdef GPU_BLAS if ( useGPU ) { CHOLMOD (gpu_end) (Common) ; } #endif return (Common->status >= CHOLMOD_OK) ; } } /* success; matrix is positive definite */ L->minor = n ; #ifdef GPU_BLAS if ( useGPU ) { CHOLMOD (gpu_end) (Common) ; } #endif return (Common->status >= CHOLMOD_OK) ; } #undef PATTERN #undef REAL #undef COMPLEX #undef ZOMPLEX
987ca02ba72b13e5b17979effc6cc178712c5af6
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/chrome/browser/vr/vr_base_export.h
cf5ae11b599a7d19fff23545942d5192c847209f
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C
false
false
774
h
vr_base_export.h
// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_VR_VR_BASE_EXPORT_H_ #define CHROME_BROWSER_VR_VR_BASE_EXPORT_H_ #if defined(COMPONENT_BUILD) #if defined(WIN32) #if defined(VR_BASE_IMPLEMENTATION) #define VR_BASE_EXPORT __declspec(dllexport) #else #define VR_BASE_EXPORT __declspec(dllimport) #endif // defined(VR_BASE_IMPLEMENTATION) #else // defined(WIN32) #if defined(VR_BASE_IMPLEMENTATION) #define VR_BASE_EXPORT __attribute__((visibility("default"))) #else #define VR_BASE_EXPORT #endif // defined(VR_BASE_IMPLEMENTATION) #endif #else // defined(COMPONENT_BUILD) #define VR_BASE_EXPORT #endif #endif // CHROME_BROWSER_VR_VR_BASE_EXPORT_H_
f4d03b853d93650684c138ae1efbbdb89267316f
095e5e86c931af6553996b0a128c07d94b38cbca
/hpy/devel/include/hpy/autogen_hpyslot.h
0fcf6608a25f027d7ebf2dcc45fb094d16ede203
[ "MIT" ]
permissive
hpyproject/hpy
1dc9e5e855fa006b1728703c5925addbb43cf792
8310a762d78e3412464b1869959a77da013e6307
refs/heads/master
2023-09-03T21:18:17.273371
2023-07-24T07:26:14
2023-07-24T07:26:14
196,559,763
681
41
MIT
2023-07-24T07:26:16
2019-07-12T10:27:56
Python
UTF-8
C
false
false
5,321
h
autogen_hpyslot.h
/* DO NOT EDIT THIS FILE! This file is automatically generated by hpy.tools.autogen.hpyslot.autogen_hpyslot_h See also hpy.tools.autogen and hpy/tools/public_api.h Run this to regenerate: make autogen */ typedef enum { HPy_bf_getbuffer = 1, HPy_bf_releasebuffer = 2, HPy_mp_ass_subscript = 3, HPy_mp_length = 4, HPy_mp_subscript = 5, HPy_nb_absolute = 6, HPy_nb_add = 7, HPy_nb_and = 8, HPy_nb_bool = 9, HPy_nb_divmod = 10, HPy_nb_float = 11, HPy_nb_floor_divide = 12, HPy_nb_index = 13, HPy_nb_inplace_add = 14, HPy_nb_inplace_and = 15, HPy_nb_inplace_floor_divide = 16, HPy_nb_inplace_lshift = 17, HPy_nb_inplace_multiply = 18, HPy_nb_inplace_or = 19, HPy_nb_inplace_power = 20, HPy_nb_inplace_remainder = 21, HPy_nb_inplace_rshift = 22, HPy_nb_inplace_subtract = 23, HPy_nb_inplace_true_divide = 24, HPy_nb_inplace_xor = 25, HPy_nb_int = 26, HPy_nb_invert = 27, HPy_nb_lshift = 28, HPy_nb_multiply = 29, HPy_nb_negative = 30, HPy_nb_or = 31, HPy_nb_positive = 32, HPy_nb_power = 33, HPy_nb_remainder = 34, HPy_nb_rshift = 35, HPy_nb_subtract = 36, HPy_nb_true_divide = 37, HPy_nb_xor = 38, HPy_sq_ass_item = 39, HPy_sq_concat = 40, HPy_sq_contains = 41, HPy_sq_inplace_concat = 42, HPy_sq_inplace_repeat = 43, HPy_sq_item = 44, HPy_sq_length = 45, HPy_sq_repeat = 46, HPy_tp_call = 50, HPy_tp_hash = 59, HPy_tp_init = 60, HPy_tp_new = 65, HPy_tp_repr = 66, HPy_tp_richcompare = 67, HPy_tp_str = 70, HPy_tp_traverse = 71, HPy_nb_matrix_multiply = 75, HPy_nb_inplace_matrix_multiply = 76, HPy_tp_finalize = 80, HPy_tp_destroy = 1000, HPy_mod_create = 2000, HPy_mod_exec = 2001, } HPySlot_Slot; #define _HPySlot_SIG__HPy_bf_getbuffer HPyFunc_GETBUFFERPROC #define _HPySlot_SIG__HPy_bf_releasebuffer HPyFunc_RELEASEBUFFERPROC #define _HPySlot_SIG__HPy_mp_ass_subscript HPyFunc_OBJOBJARGPROC #define _HPySlot_SIG__HPy_mp_length HPyFunc_LENFUNC #define _HPySlot_SIG__HPy_mp_subscript HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_absolute HPyFunc_UNARYFUNC #define _HPySlot_SIG__HPy_nb_add HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_and HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_bool HPyFunc_INQUIRY #define _HPySlot_SIG__HPy_nb_divmod HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_float HPyFunc_UNARYFUNC #define _HPySlot_SIG__HPy_nb_floor_divide HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_index HPyFunc_UNARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_add HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_and HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_floor_divide HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_lshift HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_multiply HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_or HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_power HPyFunc_TERNARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_remainder HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_rshift HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_subtract HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_true_divide HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_xor HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_int HPyFunc_UNARYFUNC #define _HPySlot_SIG__HPy_nb_invert HPyFunc_UNARYFUNC #define _HPySlot_SIG__HPy_nb_lshift HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_multiply HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_negative HPyFunc_UNARYFUNC #define _HPySlot_SIG__HPy_nb_or HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_positive HPyFunc_UNARYFUNC #define _HPySlot_SIG__HPy_nb_power HPyFunc_TERNARYFUNC #define _HPySlot_SIG__HPy_nb_remainder HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_rshift HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_subtract HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_true_divide HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_xor HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_sq_ass_item HPyFunc_SSIZEOBJARGPROC #define _HPySlot_SIG__HPy_sq_concat HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_sq_contains HPyFunc_OBJOBJPROC #define _HPySlot_SIG__HPy_sq_inplace_concat HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_sq_inplace_repeat HPyFunc_SSIZEARGFUNC #define _HPySlot_SIG__HPy_sq_item HPyFunc_SSIZEARGFUNC #define _HPySlot_SIG__HPy_sq_length HPyFunc_LENFUNC #define _HPySlot_SIG__HPy_sq_repeat HPyFunc_SSIZEARGFUNC #define _HPySlot_SIG__HPy_tp_call HPyFunc_KEYWORDS #define _HPySlot_SIG__HPy_tp_hash HPyFunc_HASHFUNC #define _HPySlot_SIG__HPy_tp_init HPyFunc_INITPROC #define _HPySlot_SIG__HPy_tp_new HPyFunc_NEWFUNC #define _HPySlot_SIG__HPy_tp_repr HPyFunc_REPRFUNC #define _HPySlot_SIG__HPy_tp_richcompare HPyFunc_RICHCMPFUNC #define _HPySlot_SIG__HPy_tp_str HPyFunc_REPRFUNC #define _HPySlot_SIG__HPy_tp_traverse HPyFunc_TRAVERSEPROC #define _HPySlot_SIG__HPy_nb_matrix_multiply HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_nb_inplace_matrix_multiply HPyFunc_BINARYFUNC #define _HPySlot_SIG__HPy_tp_finalize HPyFunc_DESTRUCTOR #define _HPySlot_SIG__HPy_tp_destroy HPyFunc_DESTROYFUNC #define _HPySlot_SIG__HPy_mod_create HPyFunc_MOD_CREATE #define _HPySlot_SIG__HPy_mod_exec HPyFunc_INQUIRY
b5c5ef59cb1d706ae49df55ffba2767691f190bf
5afa01fb706bc29154491c441ec801585622e38c
/verification/cbmc/proofs/aws_linked_list_front/aws_linked_list_front_harness.c
ff45b27cbd05393274401243657e844a3dd5166d
[ "Apache-2.0", "BSD-3-Clause", "GPL-2.0-only" ]
permissive
awslabs/aws-c-common
5af461d3b3586a569a1809c7b8f32091eec1a151
4dcc41cf4d1f868dcdd622c65c09bda972f75ad2
refs/heads/main
2023-08-29T14:07:10.856557
2023-08-25T07:40:54
2023-08-25T07:40:54
117,142,517
249
159
Apache-2.0
2023-09-12T19:02:25
2018-01-11T19:17:12
C
UTF-8
C
false
false
960
c
aws_linked_list_front_harness.c
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/common/linked_list.h> #include <proof_helpers/make_common_data_structures.h> void aws_linked_list_front_harness() { /* data structure */ struct aws_linked_list list; ensure_linked_list_is_allocated(&list, MAX_LINKED_LIST_ITEM_ALLOCATION); /* Keep the old last node of the linked list */ struct aws_linked_list_node *old_first = list.head.next; /* Assume the preconditions. The function requires that list != NULL */ __CPROVER_assume(!aws_linked_list_empty(&list)); /* perform operation under verification */ struct aws_linked_list_node *front = aws_linked_list_front(&list); /* assertions */ assert(aws_linked_list_is_valid(&list)); assert(aws_linked_list_node_prev_is_valid(front)); assert(aws_linked_list_node_next_is_valid(front)); assert(front == old_first); }
ec9bf01ccf4ab9682dfa18a355df589f16bcf9a4
f8a89dcc018d39eda52f17bd51544837dc4f6ce1
/src/libleo/leointerrupt.c
195ffd1fa6b30bdb1ca32ac88362be9c87be847a
[]
no_license
pret/pokestadium
cae99d565ba30a36285ed6a94aefaac992c66540
8a192a307d4d0dfa704fc5069c79744995a2fa58
refs/heads/master
2023-08-15T17:27:07.235493
2023-08-15T14:17:38
2023-08-15T14:17:38
26,101,139
113
35
null
2023-09-04T02:08:44
2014-11-03T02:45:35
C
UTF-8
C
false
false
6,804
c
leointerrupt.c
#include <ultra64.h> #include "ultra64/internal.h" #include "libleo/internal.h" #include "PR/os_system.h" extern OSThread* __osRunQueue; extern OSThread *__osPopThread(OSThread **); extern void __osEnqueueThread(OSThread **, OSThread *); extern OSIntMask __osGlobalIntMask; void __osLeoAbnormalResume(void); void __osLeoResume(void); extern s32 osEPiRawStartDma(OSPiHandle *, s32, u32, void *, u32); s32 __osLeoInterrupt(void) { u32 stat = 0; volatile u32 pi_stat; u32 bm_stat; __OSTranxInfo* info = &__osDiskHandle->transferInfo; __OSBlockInfo* blockInfo = &info->block[info->blockNum]; pi_stat = HW_REG(PI_STATUS_REG, u32); if (pi_stat & PI_STATUS_DMA_BUSY) { __osGlobalIntMask &= ~0x800; blockInfo->errStatus = 0x1D; __osLeoResume(); return 1; } pi_stat = HW_REG(PI_STATUS_REG, u32); while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { pi_stat = HW_REG(PI_STATUS_REG, u32); } stat = HW_REG(0x5000508, u32); if (stat & 0x2000000) { pi_stat = HW_REG(PI_STATUS_REG, u32); while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { pi_stat = HW_REG(PI_STATUS_REG, u32); } HW_REG(0x5000510, u32) = info->bmCtlShadow | 0x1000000; blockInfo->errStatus = 0; return 0; } if (info->cmdType == 2) { return 1; } if (stat & 0x8000000) { pi_stat = HW_REG(PI_STATUS_REG, u32); while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { pi_stat = HW_REG(PI_STATUS_REG, u32); } stat = HW_REG(0x5000508, u32); blockInfo->errStatus = 0x16; __osLeoResume(); HW_REG(PI_STATUS_REG, u32) = 2; __osGlobalIntMask |= 0x100401; return 1; } if (info->cmdType == 1) { if (!(stat & 0x40000000)) { if ((info->sectorNum + 1) != (info->transferMode * 0x55)) { blockInfo->errStatus = 0x18; __osLeoAbnormalResume(); return 1; } HW_REG(PI_STATUS_REG, u32) = 2; __osGlobalIntMask |= 0x100401; blockInfo->errStatus = 0; __osLeoResume(); return 1; } else { blockInfo->dramAddr = (u8*)(blockInfo->dramAddr) + blockInfo->sectorSize; info->sectorNum++; osEPiRawStartDma(__osDiskHandle, 1, 0x5000400, blockInfo->dramAddr, blockInfo->sectorSize); return 1; } } else if (info->cmdType == 0) { if (info->transferMode == 3) { if (((s32)blockInfo->C1ErrNum + 0x11) < info->sectorNum) { blockInfo->errStatus = 0; __osLeoAbnormalResume(); return 1; } if ((stat & 0x40000000) == 0) { blockInfo->errStatus = 0x17; __osLeoAbnormalResume(); return 1; } } else { blockInfo->dramAddr = (u8*)(blockInfo->dramAddr) + blockInfo->sectorSize; } bm_stat = HW_REG(0x5000510, u32); if (((bm_stat & 0x200000) && (bm_stat & 0x400000)) || (bm_stat & 0x2000000)) { if (blockInfo->C1ErrNum >= 4) { if ((info->transferMode != 3) || (info->sectorNum >= 0x53)) { blockInfo->errStatus = 0x17; __osLeoAbnormalResume(); return 1; } } else { int errNum = blockInfo->C1ErrNum; blockInfo->C1ErrSector[errNum] = info->sectorNum + 1; } blockInfo->C1ErrNum++; } if (stat & 0x10000000) { if (info->sectorNum != 0x57) { blockInfo->errStatus = 0x18; __osLeoAbnormalResume(); return 1; } if ((info->transferMode == 2) && (info->blockNum == 0)) { info->blockNum = 1; info->sectorNum = -1; info->block[1].dramAddr = (u8*)(info->block[1].dramAddr) - info->block[1].sectorSize; blockInfo->errStatus = 0x16; } else { HW_REG(PI_STATUS_REG, u32) = 2; __osGlobalIntMask |= 0x100401; info->cmdType = 2; blockInfo->errStatus = 0; } osEPiRawStartDma(__osDiskHandle, 0, 0x5000000U, blockInfo->C2Addr, blockInfo->sectorSize * 4); return 1; } if ((info->sectorNum == -1) && (info->transferMode == 2) && (info->blockNum == 1)) { __OSBlockInfo* bptr = info->block; if (bptr->C1ErrNum == 0) { if (((u32*)bptr->C2Addr)[0] | ((u32*)bptr->C2Addr)[1] | ((u32*)bptr->C2Addr)[2] | ((u32*)bptr->C2Addr)[3]) { bptr->errStatus = 0x17; __osLeoAbnormalResume(); return 1; } } bptr->errStatus = 0; __osLeoResume(); } info->sectorNum++; if (stat & 0x40000000) { if (info->sectorNum >= 0x55) { blockInfo->errStatus = 0x18; __osLeoAbnormalResume(); return 1; } osEPiRawStartDma(__osDiskHandle, 0, 0x5000400, blockInfo->dramAddr, blockInfo->sectorSize); blockInfo->errStatus = 0; return 1; } else if (info->sectorNum < 0x55) { blockInfo->errStatus = 0x18; __osLeoAbnormalResume(); return 1; } return 1; } else { blockInfo->errStatus = 4; __osLeoAbnormalResume(); return 1; } } void __osLeoAbnormalResume(void) { __OSTranxInfo* info; u32 pi_stat; info = &__osDiskHandle->transferInfo; pi_stat = HW_REG(PI_STATUS_REG, u32); while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { pi_stat = HW_REG(PI_STATUS_REG, u32); } HW_REG(0x5000510, u32) = info->bmCtlShadow | 0x10000000; pi_stat = HW_REG(PI_STATUS_REG, u32); while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { pi_stat = HW_REG(PI_STATUS_REG, u32); } HW_REG(0x5000510, u32) = info->bmCtlShadow; __osLeoResume(); HW_REG(PI_STATUS_REG, u32) = 2; __osGlobalIntMask |= 0x100401; } void __osLeoResume(void) { __OSEventState* es; OSMesgQueue* mq; s32 last; es = &__osEventStateTab[8]; mq = es->queue; if ((mq == 0) || (mq->validCount >= mq->msgCount)) { return; } last = (mq->first + mq->validCount) % mq->msgCount; mq->msg[last] = es->msg; mq->validCount++; if (mq->mtqueue->next != NULL) { __osEnqueueThread(&__osRunQueue, __osPopThread(&mq->mtqueue)); } }
6a04484bbc9adada0971ee03392d21403c406078
83372fce92c9088ee5c1e1c13bc67385a3b02a36
/samples/lynx/tgidemo.c
e92a078dc6541df0187903ffc61582c7c7731cea
[ "Zlib" ]
permissive
cc65/cc65
2cd1b20b61ddd0691cd4601b4da37a9200a50afb
16e90187e8e80c6e2fcfcc04f068ac865d2290e5
refs/heads/master
2023-09-03T17:16:46.027934
2023-09-02T22:30:44
2023-09-02T22:30:44
8,932,489
2,103
526
Zlib
2023-09-13T06:19:01
2013-03-21T15:56:48
C
UTF-8
C
false
false
3,934
c
tgidemo.c
/* Tgidemo modified for the Atari Lynx. ** ** Press any of the Lynx's option buttons to go to the next screen. */ #include <cc65.h> #include <conio.h> #include <tgi.h> #include <time.h> #define COLOR_BACK TGI_COLOR_BLACK #define COLOR_FORE TGI_COLOR_WHITE /*****************************************************************************/ /* Data */ /*****************************************************************************/ /* Driver stuff */ static unsigned MaxX; static unsigned MaxY; static unsigned AspectRatio; /*****************************************************************************/ /* Code */ /*****************************************************************************/ /* The Lynx draws too fast. This function delays ** the drawing so that we can watch it. */ static void wait (unsigned char ticks) { clock_t T = clock () + ticks; while (clock () < T) {} } static void DoCircles (void) { unsigned char I; unsigned char Color = COLOR_BACK; const unsigned X = MaxX / 2; const unsigned Y = MaxY / 2; const unsigned Limit = (X < Y) ? Y : X; tgi_setcolor (COLOR_FORE); tgi_clear (); tgi_line (0, 0, MaxX, MaxY); tgi_line (0, MaxY, MaxX, 0); while (!kbhit ()) { Color = (Color == COLOR_FORE) ? COLOR_BACK : COLOR_FORE; tgi_setcolor (Color); for (I = 10; I <= Limit; I += 10) { tgi_ellipse (X, Y, I, tgi_imulround (I, AspectRatio)); wait (9); } } cgetc (); } static void DoCheckerboard (void) { unsigned X, Y; unsigned char Color = COLOR_BACK; tgi_clear (); while (1) { for (Y = 0; Y <= MaxY - 2; Y += 10) { for (X = 0; X <= MaxX; X += 10) { Color = (Color == COLOR_FORE) ? COLOR_BACK : COLOR_FORE; tgi_setcolor (Color); tgi_bar (X, Y, X+9, Y+9); if (kbhit ()) { cgetc (); return; } wait (1); } Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE; } Color = Color == COLOR_FORE ? COLOR_BACK : COLOR_FORE; } } static void DoDiagram (void) { int XOrigin, YOrigin; int Amp; int X, Y; unsigned I; tgi_setcolor (COLOR_FORE); tgi_clear (); /* Determine zero and amplitude */ YOrigin = MaxY / 2; XOrigin = 10; Amp = (MaxY - 19) / 2; /* Y axis */ tgi_line (XOrigin, 10, XOrigin, MaxY-10); tgi_line (XOrigin-2, 12, XOrigin, 10); tgi_lineto (XOrigin+2, 12); /* X axis */ tgi_line (XOrigin, YOrigin, MaxX-10, YOrigin); tgi_line (MaxX-12, YOrigin-2, MaxX-10, YOrigin); tgi_lineto (MaxX-12, YOrigin+2); /* Sine */ tgi_gotoxy (XOrigin, YOrigin); for (I = 0; I <= 360; ++I) { /* Calculate the next points */ X = (int)(((long)(MaxX - 19) * I) / 360); Y = (int)(((long)Amp * -_sin (I)) / 256); /* Draw the line */ tgi_lineto (XOrigin + X, YOrigin + Y); } cgetc (); } static void DoLines (void) { unsigned X; const unsigned Min = (MaxX < MaxY) ? MaxX : MaxY; tgi_setcolor (COLOR_FORE); tgi_clear (); for (X = 0; X <= Min; X += 10) { tgi_line (0, 0, Min, X); tgi_line (0, 0, X, Min); tgi_line (Min, Min, 0, Min-X); tgi_line (Min, Min, Min-X, 0); wait (9); } cgetc (); } void main (void) { /* Install the driver */ tgi_install (tgi_static_stddrv); tgi_init (); /* Get stuff from the driver */ MaxX = tgi_getmaxx (); MaxY = tgi_getmaxy (); AspectRatio = tgi_getaspectratio (); /* Do graphics stuff */ DoCircles (); DoCheckerboard (); DoDiagram (); DoLines (); }
b29b1b9882c03de59086cb80fcf84658913a2990
010279e2ba272d09e9d2c4e903722e5faba2cf7a
/contrib/python/psutil/psutil/_psutil_osx.c
13d0bb685608ebc87b351185bd0201ce68e85fa6
[ "Apache-2.0", "BSD-3-Clause" ]
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
59,556
c
_psutil_osx.c
/* * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * * macOS platform-specific module methods. */ #include <Python.h> #include <assert.h> #include <errno.h> #include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <utmpx.h> #include <sys/sysctl.h> #include <sys/vmmeter.h> #include <libproc.h> #include <sys/proc_info.h> #include <netinet/tcp_fsm.h> #include <arpa/inet.h> #include <net/if_dl.h> #include <pwd.h> #include <unistd.h> #include <mach/mach.h> #include <mach/task.h> #include <mach/mach_init.h> #include <mach/host_info.h> #include <mach/mach_host.h> #include <mach/mach_traps.h> #include <mach/mach_vm.h> #include <mach/shared_region.h> #include <mach-o/loader.h> #include <CoreFoundation/CoreFoundation.h> #include <IOKit/IOKitLib.h> #include <IOKit/storage/IOBlockStorageDriver.h> #include <IOKit/storage/IOMedia.h> #include <IOKit/IOBSD.h> #include <IOKit/ps/IOPowerSources.h> #include <IOKit/ps/IOPSKeys.h> #include "_psutil_common.h" #include "_psutil_posix.h" #include "arch/osx/process_info.h" #define PSUTIL_TV2DOUBLE(t) ((t).tv_sec + (t).tv_usec / 1000000.0) static PyObject *ZombieProcessError; /* * A wrapper around host_statistics() invoked with HOST_VM_INFO. */ int psutil_sys_vminfo(vm_statistics_data_t *vmstat) { kern_return_t ret; mach_msg_type_number_t count = sizeof(*vmstat) / sizeof(integer_t); mach_port_t mport = mach_host_self(); ret = host_statistics(mport, HOST_VM_INFO, (host_info_t)vmstat, &count); if (ret != KERN_SUCCESS) { PyErr_Format( PyExc_RuntimeError, "host_statistics(HOST_VM_INFO) syscall failed: %s", mach_error_string(ret)); return 0; } mach_port_deallocate(mach_task_self(), mport); return 1; } /* * A wrapper around task_for_pid() which sucks big time: * - it's not documented * - errno is set only sometimes * - sometimes errno is ENOENT (?!?) * - for PIDs != getpid() or PIDs which are not members of the procmod * it requires root * As such we can only guess what the heck went wrong and fail either * with NoSuchProcess, ZombieProcessError or giveup with AccessDenied. * Here's some history: * https://github.com/giampaolo/psutil/issues/1181 * https://github.com/giampaolo/psutil/issues/1209 * https://github.com/giampaolo/psutil/issues/1291#issuecomment-396062519 */ int psutil_task_for_pid(pid_t pid, mach_port_t *task) { // See: https://github.com/giampaolo/psutil/issues/1181 kern_return_t err = KERN_SUCCESS; err = task_for_pid(mach_task_self(), pid, task); if (err != KERN_SUCCESS) { if (psutil_pid_exists(pid) == 0) NoSuchProcess("task_for_pid"); else if (psutil_is_zombie(pid) == 1) PyErr_SetString(ZombieProcessError, "task_for_pid -> psutil_is_zombie -> 1"); else { psutil_debug( "task_for_pid() failed (pid=%ld, err=%i, errno=%i, msg='%s'); " "setting AccessDenied()", pid, err, errno, mach_error_string(err)); AccessDenied("task_for_pid"); } return 1; } return 0; } /* * Return a Python list of all the PIDs running on the system. */ static PyObject * psutil_pids(PyObject *self, PyObject *args) { kinfo_proc *proclist = NULL; kinfo_proc *orig_address = NULL; size_t num_processes; size_t idx; PyObject *py_pid = NULL; PyObject *py_retlist = PyList_New(0); if (py_retlist == NULL) return NULL; if (psutil_get_proc_list(&proclist, &num_processes) != 0) goto error; // save the address of proclist so we can free it later orig_address = proclist; for (idx = 0; idx < num_processes; idx++) { py_pid = PyLong_FromPid(proclist->kp_proc.p_pid); if (! py_pid) goto error; if (PyList_Append(py_retlist, py_pid)) goto error; Py_CLEAR(py_pid); proclist++; } free(orig_address); return py_retlist; error: Py_XDECREF(py_pid); Py_DECREF(py_retlist); if (orig_address != NULL) free(orig_address); return NULL; } /* * Return multiple process info as a Python tuple in one shot by * using sysctl() and filling up a kinfo_proc struct. * It should be possible to do this for all processes without * incurring into permission (EPERM) errors. * This will also succeed for zombie processes returning correct * information. */ static PyObject * psutil_proc_kinfo_oneshot(PyObject *self, PyObject *args) { pid_t pid; struct kinfo_proc kp; PyObject *py_name; PyObject *py_retlist; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) return NULL; if (psutil_get_kinfo_proc(pid, &kp) == -1) return NULL; py_name = PyUnicode_DecodeFSDefault(kp.kp_proc.p_comm); if (! py_name) { // Likely a decoding error. We don't want to fail the whole // operation. The python module may retry with proc_name(). PyErr_Clear(); py_name = Py_None; } py_retlist = Py_BuildValue( _Py_PARSE_PID "llllllidiO", kp.kp_eproc.e_ppid, // (pid_t) ppid (long)kp.kp_eproc.e_pcred.p_ruid, // (long) real uid (long)kp.kp_eproc.e_ucred.cr_uid, // (long) effective uid (long)kp.kp_eproc.e_pcred.p_svuid, // (long) saved uid (long)kp.kp_eproc.e_pcred.p_rgid, // (long) real gid (long)kp.kp_eproc.e_ucred.cr_groups[0], // (long) effective gid (long)kp.kp_eproc.e_pcred.p_svgid, // (long) saved gid kp.kp_eproc.e_tdev, // (int) tty nr PSUTIL_TV2DOUBLE(kp.kp_proc.p_starttime), // (double) create time (int)kp.kp_proc.p_stat, // (int) status py_name // (pystr) name ); if (py_retlist != NULL) { // XXX shall we decref() also in case of Py_BuildValue() error? Py_DECREF(py_name); } return py_retlist; } /* * Return multiple process info as a Python tuple in one shot by * using proc_pidinfo(PROC_PIDTASKINFO) and filling a proc_taskinfo * struct. * Contrarily from proc_kinfo above this function will fail with * EACCES for PIDs owned by another user and with ESRCH for zombie * processes. */ static PyObject * psutil_proc_pidtaskinfo_oneshot(PyObject *self, PyObject *args) { pid_t pid; struct proc_taskinfo pti; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) return NULL; if (psutil_proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &pti, sizeof(pti)) <= 0) return NULL; return Py_BuildValue( "(ddKKkkkk)", (float)pti.pti_total_user / 1000000000.0, // (float) cpu user time (float)pti.pti_total_system / 1000000000.0, // (float) cpu sys time // Note about memory: determining other mem stats on macOS is a mess: // http://www.opensource.apple.com/source/top/top-67/libtop.c?txt // I just give up. // struct proc_regioninfo pri; // psutil_proc_pidinfo(pid, PROC_PIDREGIONINFO, 0, &pri, sizeof(pri)) pti.pti_resident_size, // (uns long long) rss pti.pti_virtual_size, // (uns long long) vms pti.pti_faults, // (uns long) number of page faults (pages) pti.pti_pageins, // (uns long) number of actual pageins (pages) pti.pti_threadnum, // (uns long) num threads // Unvoluntary value seems not to be available; // pti.pti_csw probably refers to the sum of the two; // getrusage() numbers seems to confirm this theory. pti.pti_csw // (uns long) voluntary ctx switches ); } /* * Return process name from kinfo_proc as a Python string. */ static PyObject * psutil_proc_name(PyObject *self, PyObject *args) { pid_t pid; struct kinfo_proc kp; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) return NULL; if (psutil_get_kinfo_proc(pid, &kp) == -1) return NULL; return PyUnicode_DecodeFSDefault(kp.kp_proc.p_comm); } /* * Return process current working directory. * Raises NSP in case of zombie process. */ static PyObject * psutil_proc_cwd(PyObject *self, PyObject *args) { pid_t pid; struct proc_vnodepathinfo pathinfo; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) return NULL; if (psutil_proc_pidinfo( pid, PROC_PIDVNODEPATHINFO, 0, &pathinfo, sizeof(pathinfo)) <= 0) { return NULL; } return PyUnicode_DecodeFSDefault(pathinfo.pvi_cdir.vip_path); } /* * Return path of the process executable. */ static PyObject * psutil_proc_exe(PyObject *self, PyObject *args) { pid_t pid; char buf[PATH_MAX]; int ret; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) return NULL; errno = 0; ret = proc_pidpath(pid, &buf, sizeof(buf)); if (ret == 0) { if (pid == 0) { AccessDenied("automatically set for PID 0"); return NULL; } else if (errno == ENOENT) { // It may happen (file not found error) if the process is // still alive but the executable which launched it got // deleted, see: // https://github.com/giampaolo/psutil/issues/1738 return Py_BuildValue("s", ""); } else { psutil_raise_for_pid(pid, "proc_pidpath()"); return NULL; } } return PyUnicode_DecodeFSDefault(buf); } /* * Return process cmdline as a Python list of cmdline arguments. */ static PyObject * psutil_proc_cmdline(PyObject *self, PyObject *args) { pid_t pid; PyObject *py_retlist = NULL; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) return NULL; // get the commandline, defined in arch/osx/process_info.c py_retlist = psutil_get_cmdline(pid); return py_retlist; } /* * Return process environment as a Python string. */ static PyObject * psutil_proc_environ(PyObject *self, PyObject *args) { pid_t pid; PyObject *py_retdict = NULL; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) return NULL; // get the environment block, defined in arch/osx/process_info.c py_retdict = psutil_get_environ(pid); return py_retdict; } /* * Return the number of logical CPUs in the system. * XXX this could be shared with BSD. */ static PyObject * psutil_cpu_count_logical(PyObject *self, PyObject *args) { /* int mib[2]; int ncpu; size_t len; mib[0] = CTL_HW; mib[1] = HW_NCPU; len = sizeof(ncpu); if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) Py_RETURN_NONE; // mimic os.cpu_count() else return Py_BuildValue("i", ncpu); */ int num; size_t size = sizeof(int); if (sysctlbyname("hw.logicalcpu", &num, &size, NULL, 2)) Py_RETURN_NONE; // mimic os.cpu_count() else return Py_BuildValue("i", num); } /* * Return the number of physical CPUs in the system. */ static PyObject * psutil_cpu_count_phys(PyObject *self, PyObject *args) { int num; size_t size = sizeof(int); if (sysctlbyname("hw.physicalcpu", &num, &size, NULL, 0)) Py_RETURN_NONE; // mimic os.cpu_count() else return Py_BuildValue("i", num); } /* * Indicates if the given virtual address on the given architecture is in the * shared VM region. */ static bool psutil_in_shared_region(mach_vm_address_t addr, cpu_type_t type) { mach_vm_address_t base; mach_vm_address_t size; switch (type) { case CPU_TYPE_ARM: base = SHARED_REGION_BASE_ARM; size = SHARED_REGION_SIZE_ARM; break; case CPU_TYPE_I386: base = SHARED_REGION_BASE_I386; size = SHARED_REGION_SIZE_I386; break; case CPU_TYPE_X86_64: base = SHARED_REGION_BASE_X86_64; size = SHARED_REGION_SIZE_X86_64; break; default: return false; } return base <= addr && addr < (base + size); } /* * Returns the USS (unique set size) of the process. Reference: * https://dxr.mozilla.org/mozilla-central/source/xpcom/base/ * nsMemoryReporterManager.cpp */ static PyObject * psutil_proc_memory_uss(PyObject *self, PyObject *args) { pid_t pid; size_t len; cpu_type_t cpu_type; size_t private_pages = 0; mach_vm_size_t size = 0; mach_msg_type_number_t info_count = VM_REGION_TOP_INFO_COUNT; kern_return_t kr; long pagesize = psutil_getpagesize(); mach_vm_address_t addr = MACH_VM_MIN_ADDRESS; mach_port_t task = MACH_PORT_NULL; vm_region_top_info_data_t info; mach_port_t object_name; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) return NULL; if (psutil_task_for_pid(pid, &task) != 0) return NULL; len = sizeof(cpu_type); if (sysctlbyname("sysctl.proc_cputype", &cpu_type, &len, NULL, 0) != 0) { return PyErr_SetFromOSErrnoWithSyscall( "sysctlbyname('sysctl.proc_cputype')"); } // Roughly based on libtop_update_vm_regions in // http://www.opensource.apple.com/source/top/top-100.1.2/libtop.c for (addr = 0; ; addr += size) { kr = mach_vm_region( task, &addr, &size, VM_REGION_TOP_INFO, (vm_region_info_t)&info, &info_count, &object_name); if (kr == KERN_INVALID_ADDRESS) { // Done iterating VM regions. break; } else if (kr != KERN_SUCCESS) { PyErr_Format( PyExc_RuntimeError, "mach_vm_region(VM_REGION_TOP_INFO) syscall failed"); return NULL; } if (psutil_in_shared_region(addr, cpu_type) && info.share_mode != SM_PRIVATE) { continue; } switch (info.share_mode) { #ifdef SM_LARGE_PAGE case SM_LARGE_PAGE: // NB: Large pages are not shareable and always resident. #endif case SM_PRIVATE: private_pages += info.private_pages_resident; private_pages += info.shared_pages_resident; break; case SM_COW: private_pages += info.private_pages_resident; if (info.ref_count == 1) { // Treat copy-on-write pages as private if they only // have one reference. private_pages += info.shared_pages_resident; } break; case SM_SHARED: default: break; } } mach_port_deallocate(mach_task_self(), task); return Py_BuildValue("K", private_pages * pagesize); } /* * Return system virtual memory stats. * See: * https://opensource.apple.com/source/system_cmds/system_cmds-790/ * vm_stat.tproj/vm_stat.c.auto.html */ static PyObject * psutil_virtual_mem(PyObject *self, PyObject *args) { int mib[2]; uint64_t total; size_t len = sizeof(total); vm_statistics_data_t vm; long pagesize = psutil_getpagesize(); // physical mem mib[0] = CTL_HW; mib[1] = HW_MEMSIZE; // This is also available as sysctlbyname("hw.memsize"). if (sysctl(mib, 2, &total, &len, NULL, 0)) { if (errno != 0) PyErr_SetFromErrno(PyExc_OSError); else PyErr_Format( PyExc_RuntimeError, "sysctl(HW_MEMSIZE) syscall failed"); return NULL; } // vm if (!psutil_sys_vminfo(&vm)) return NULL; return Py_BuildValue( "KKKKKK", total, (unsigned long long) vm.active_count * pagesize, // active (unsigned long long) vm.inactive_count * pagesize, // inactive (unsigned long long) vm.wire_count * pagesize, // wired (unsigned long long) vm.free_count * pagesize, // free (unsigned long long) vm.speculative_count * pagesize // speculative ); } /* * Return stats about swap memory. */ static PyObject * psutil_swap_mem(PyObject *self, PyObject *args) { int mib[2]; size_t size; struct xsw_usage totals; vm_statistics_data_t vmstat; long pagesize = psutil_getpagesize(); mib[0] = CTL_VM; mib[1] = VM_SWAPUSAGE; size = sizeof(totals); if (sysctl(mib, 2, &totals, &size, NULL, 0) == -1) { if (errno != 0) PyErr_SetFromErrno(PyExc_OSError); else PyErr_Format( PyExc_RuntimeError, "sysctl(VM_SWAPUSAGE) syscall failed"); return NULL; } if (!psutil_sys_vminfo(&vmstat)) return NULL; return Py_BuildValue( "LLLKK", totals.xsu_total, totals.xsu_used, totals.xsu_avail, (unsigned long long)vmstat.pageins * pagesize, (unsigned long long)vmstat.pageouts * pagesize); } /* * Return a Python tuple representing user, kernel and idle CPU times */ static PyObject * psutil_cpu_times(PyObject *self, PyObject *args) { mach_msg_type_number_t count = HOST_CPU_LOAD_INFO_COUNT; kern_return_t error; host_cpu_load_info_data_t r_load; mach_port_t host_port = mach_host_self(); error = host_statistics(host_port, HOST_CPU_LOAD_INFO, (host_info_t)&r_load, &count); if (error != KERN_SUCCESS) { return PyErr_Format( PyExc_RuntimeError, "host_statistics(HOST_CPU_LOAD_INFO) syscall failed: %s", mach_error_string(error)); } mach_port_deallocate(mach_task_self(), host_port); return Py_BuildValue( "(dddd)", (double)r_load.cpu_ticks[CPU_STATE_USER] / CLK_TCK, (double)r_load.cpu_ticks[CPU_STATE_NICE] / CLK_TCK, (double)r_load.cpu_ticks[CPU_STATE_SYSTEM] / CLK_TCK, (double)r_load.cpu_ticks[CPU_STATE_IDLE] / CLK_TCK ); } /* * Return a Python list of tuple representing per-cpu times */ static PyObject * psutil_per_cpu_times(PyObject *self, PyObject *args) { natural_t cpu_count; natural_t i; processor_info_array_t info_array; mach_msg_type_number_t info_count; kern_return_t error; processor_cpu_load_info_data_t *cpu_load_info = NULL; int ret; PyObject *py_retlist = PyList_New(0); PyObject *py_cputime = NULL; if (py_retlist == NULL) return NULL; mach_port_t host_port = mach_host_self(); error = host_processor_info(host_port, PROCESSOR_CPU_LOAD_INFO, &cpu_count, &info_array, &info_count); if (error != KERN_SUCCESS) { PyErr_Format( PyExc_RuntimeError, "host_processor_info(PROCESSOR_CPU_LOAD_INFO) syscall failed: %s", mach_error_string(error)); goto error; } mach_port_deallocate(mach_task_self(), host_port); cpu_load_info = (processor_cpu_load_info_data_t *) info_array; for (i = 0; i < cpu_count; i++) { py_cputime = Py_BuildValue( "(dddd)", (double)cpu_load_info[i].cpu_ticks[CPU_STATE_USER] / CLK_TCK, (double)cpu_load_info[i].cpu_ticks[CPU_STATE_NICE] / CLK_TCK, (double)cpu_load_info[i].cpu_ticks[CPU_STATE_SYSTEM] / CLK_TCK, (double)cpu_load_info[i].cpu_ticks[CPU_STATE_IDLE] / CLK_TCK ); if (!py_cputime) goto error; if (PyList_Append(py_retlist, py_cputime)) goto error; Py_CLEAR(py_cputime); } ret = vm_deallocate(mach_task_self(), (vm_address_t)info_array, info_count * sizeof(int)); if (ret != KERN_SUCCESS) PyErr_WarnEx(PyExc_RuntimeWarning, "vm_deallocate() failed", 2); return py_retlist; error: Py_XDECREF(py_cputime); Py_DECREF(py_retlist); if (cpu_load_info != NULL) { ret = vm_deallocate(mach_task_self(), (vm_address_t)info_array, info_count * sizeof(int)); if (ret != KERN_SUCCESS) PyErr_WarnEx(PyExc_RuntimeWarning, "vm_deallocate() failed", 2); } return NULL; } /* * Retrieve CPU frequency. */ static PyObject * psutil_cpu_freq(PyObject *self, PyObject *args) { int64_t curr; int64_t min; int64_t max; size_t size = sizeof(int64_t); if (sysctlbyname("hw.cpufrequency", &curr, &size, NULL, 0)) { return PyErr_SetFromOSErrnoWithSyscall( "sysctlbyname('hw.cpufrequency')"); } if (sysctlbyname("hw.cpufrequency_min", &min, &size, NULL, 0)) { return PyErr_SetFromOSErrnoWithSyscall( "sysctlbyname('hw.cpufrequency_min')"); } if (sysctlbyname("hw.cpufrequency_max", &max, &size, NULL, 0)) { return PyErr_SetFromOSErrnoWithSyscall( "sysctlbyname('hw.cpufrequency_max')"); } return Py_BuildValue( "KKK", curr / 1000 / 1000, min / 1000 / 1000, max / 1000 / 1000); } /* * Return a Python float indicating the system boot time expressed in * seconds since the epoch. */ static PyObject * psutil_boot_time(PyObject *self, PyObject *args) { // fetch sysctl "kern.boottime" static int request[2] = { CTL_KERN, KERN_BOOTTIME }; struct timeval result; size_t result_len = sizeof result; time_t boot_time = 0; if (sysctl(request, 2, &result, &result_len, NULL, 0) == -1) return PyErr_SetFromErrno(PyExc_OSError); boot_time = result.tv_sec; return Py_BuildValue("f", (float)boot_time); } /* * Return a list of tuples including device, mount point and fs type * for all partitions mounted on the system. */ static PyObject * psutil_disk_partitions(PyObject *self, PyObject *args) { int num; int i; int len; uint64_t flags; char opts[400]; struct statfs *fs = NULL; PyObject *py_dev = NULL; PyObject *py_mountp = NULL; PyObject *py_tuple = NULL; PyObject *py_retlist = PyList_New(0); if (py_retlist == NULL) return NULL; // get the number of mount points Py_BEGIN_ALLOW_THREADS num = getfsstat(NULL, 0, MNT_NOWAIT); Py_END_ALLOW_THREADS if (num == -1) { PyErr_SetFromErrno(PyExc_OSError); goto error; } len = sizeof(*fs) * num; fs = malloc(len); if (fs == NULL) { PyErr_NoMemory(); goto error; } Py_BEGIN_ALLOW_THREADS num = getfsstat(fs, len, MNT_NOWAIT); Py_END_ALLOW_THREADS if (num == -1) { PyErr_SetFromErrno(PyExc_OSError); goto error; } for (i = 0; i < num; i++) { opts[0] = 0; flags = fs[i].f_flags; // see sys/mount.h if (flags & MNT_RDONLY) strlcat(opts, "ro", sizeof(opts)); else strlcat(opts, "rw", sizeof(opts)); if (flags & MNT_SYNCHRONOUS) strlcat(opts, ",sync", sizeof(opts)); if (flags & MNT_NOEXEC) strlcat(opts, ",noexec", sizeof(opts)); if (flags & MNT_NOSUID) strlcat(opts, ",nosuid", sizeof(opts)); if (flags & MNT_UNION) strlcat(opts, ",union", sizeof(opts)); if (flags & MNT_ASYNC) strlcat(opts, ",async", sizeof(opts)); if (flags & MNT_EXPORTED) strlcat(opts, ",exported", sizeof(opts)); if (flags & MNT_QUARANTINE) strlcat(opts, ",quarantine", sizeof(opts)); if (flags & MNT_LOCAL) strlcat(opts, ",local", sizeof(opts)); if (flags & MNT_QUOTA) strlcat(opts, ",quota", sizeof(opts)); if (flags & MNT_ROOTFS) strlcat(opts, ",rootfs", sizeof(opts)); if (flags & MNT_DOVOLFS) strlcat(opts, ",dovolfs", sizeof(opts)); if (flags & MNT_DONTBROWSE) strlcat(opts, ",dontbrowse", sizeof(opts)); if (flags & MNT_IGNORE_OWNERSHIP) strlcat(opts, ",ignore-ownership", sizeof(opts)); if (flags & MNT_AUTOMOUNTED) strlcat(opts, ",automounted", sizeof(opts)); if (flags & MNT_JOURNALED) strlcat(opts, ",journaled", sizeof(opts)); if (flags & MNT_NOUSERXATTR) strlcat(opts, ",nouserxattr", sizeof(opts)); if (flags & MNT_DEFWRITE) strlcat(opts, ",defwrite", sizeof(opts)); if (flags & MNT_MULTILABEL) strlcat(opts, ",multilabel", sizeof(opts)); if (flags & MNT_NOATIME) strlcat(opts, ",noatime", sizeof(opts)); if (flags & MNT_UPDATE) strlcat(opts, ",update", sizeof(opts)); if (flags & MNT_RELOAD) strlcat(opts, ",reload", sizeof(opts)); if (flags & MNT_FORCE) strlcat(opts, ",force", sizeof(opts)); if (flags & MNT_CMDFLAGS) strlcat(opts, ",cmdflags", sizeof(opts)); py_dev = PyUnicode_DecodeFSDefault(fs[i].f_mntfromname); if (! py_dev) goto error; py_mountp = PyUnicode_DecodeFSDefault(fs[i].f_mntonname); if (! py_mountp) goto error; py_tuple = Py_BuildValue( "(OOss)", py_dev, // device py_mountp, // mount point fs[i].f_fstypename, // fs type opts); // options if (!py_tuple) goto error; if (PyList_Append(py_retlist, py_tuple)) goto error; Py_CLEAR(py_dev); Py_CLEAR(py_mountp); Py_CLEAR(py_tuple); } free(fs); return py_retlist; error: Py_XDECREF(py_dev); Py_XDECREF(py_mountp); Py_XDECREF(py_tuple); Py_DECREF(py_retlist); if (fs != NULL) free(fs); return NULL; } /* * Return process threads */ static PyObject * psutil_proc_threads(PyObject *self, PyObject *args) { pid_t pid; int err, ret; kern_return_t kr; unsigned int info_count = TASK_BASIC_INFO_COUNT; mach_port_t task = MACH_PORT_NULL; struct task_basic_info tasks_info; thread_act_port_array_t thread_list = NULL; thread_info_data_t thinfo_basic; thread_basic_info_t basic_info_th; mach_msg_type_number_t thread_count, thread_info_count, j; PyObject *py_tuple = NULL; PyObject *py_retlist = PyList_New(0); if (py_retlist == NULL) return NULL; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) goto error; if (psutil_task_for_pid(pid, &task) != 0) goto error; info_count = TASK_BASIC_INFO_COUNT; err = task_info(task, TASK_BASIC_INFO, (task_info_t)&tasks_info, &info_count); if (err != KERN_SUCCESS) { // errcode 4 is "invalid argument" (access denied) if (err == 4) { AccessDenied("task_info"); } else { // otherwise throw a runtime error with appropriate error code PyErr_Format(PyExc_RuntimeError, "task_info(TASK_BASIC_INFO) syscall failed"); } goto error; } err = task_threads(task, &thread_list, &thread_count); if (err != KERN_SUCCESS) { PyErr_Format(PyExc_RuntimeError, "task_threads() syscall failed"); goto error; } for (j = 0; j < thread_count; j++) { thread_info_count = THREAD_INFO_MAX; kr = thread_info(thread_list[j], THREAD_BASIC_INFO, (thread_info_t)thinfo_basic, &thread_info_count); if (kr != KERN_SUCCESS) { PyErr_Format(PyExc_RuntimeError, "thread_info(THREAD_BASIC_INFO) syscall failed"); goto error; } basic_info_th = (thread_basic_info_t)thinfo_basic; py_tuple = Py_BuildValue( "Iff", j + 1, basic_info_th->user_time.seconds + \ (float)basic_info_th->user_time.microseconds / 1000000.0, basic_info_th->system_time.seconds + \ (float)basic_info_th->system_time.microseconds / 1000000.0 ); if (!py_tuple) goto error; if (PyList_Append(py_retlist, py_tuple)) goto error; Py_CLEAR(py_tuple); } ret = vm_deallocate(task, (vm_address_t)thread_list, thread_count * sizeof(int)); if (ret != KERN_SUCCESS) PyErr_WarnEx(PyExc_RuntimeWarning, "vm_deallocate() failed", 2); mach_port_deallocate(mach_task_self(), task); return py_retlist; error: if (task != MACH_PORT_NULL) mach_port_deallocate(mach_task_self(), task); Py_XDECREF(py_tuple); Py_DECREF(py_retlist); if (thread_list != NULL) { ret = vm_deallocate(task, (vm_address_t)thread_list, thread_count * sizeof(int)); if (ret != KERN_SUCCESS) PyErr_WarnEx(PyExc_RuntimeWarning, "vm_deallocate() failed", 2); } return NULL; } /* * Return process open files as a Python tuple. * References: * - lsof source code: http://goo.gl/SYW79 and http://goo.gl/m78fd * - /usr/include/sys/proc_info.h */ static PyObject * psutil_proc_open_files(PyObject *self, PyObject *args) { pid_t pid; int pidinfo_result; int iterations; int i; unsigned long nb; struct proc_fdinfo *fds_pointer = NULL; struct proc_fdinfo *fdp_pointer; struct vnode_fdinfowithpath vi; PyObject *py_retlist = PyList_New(0); PyObject *py_tuple = NULL; PyObject *py_path = NULL; if (py_retlist == NULL) return NULL; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) goto error; pidinfo_result = psutil_proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0); if (pidinfo_result <= 0) goto error; fds_pointer = malloc(pidinfo_result); if (fds_pointer == NULL) { PyErr_NoMemory(); goto error; } pidinfo_result = psutil_proc_pidinfo( pid, PROC_PIDLISTFDS, 0, fds_pointer, pidinfo_result); if (pidinfo_result <= 0) goto error; iterations = (pidinfo_result / PROC_PIDLISTFD_SIZE); for (i = 0; i < iterations; i++) { fdp_pointer = &fds_pointer[i]; if (fdp_pointer->proc_fdtype == PROX_FDTYPE_VNODE) { errno = 0; nb = proc_pidfdinfo((pid_t)pid, fdp_pointer->proc_fd, PROC_PIDFDVNODEPATHINFO, &vi, sizeof(vi)); // --- errors checking if ((nb <= 0) || nb < sizeof(vi)) { if ((errno == ENOENT) || (errno == EBADF)) { // no such file or directory or bad file descriptor; // let's assume the file has been closed or removed continue; } else { psutil_raise_for_pid( pid, "proc_pidinfo(PROC_PIDFDVNODEPATHINFO)"); goto error; } } // --- /errors checking // --- construct python list py_path = PyUnicode_DecodeFSDefault(vi.pvip.vip_path); if (! py_path) goto error; py_tuple = Py_BuildValue( "(Oi)", py_path, (int)fdp_pointer->proc_fd); if (!py_tuple) goto error; if (PyList_Append(py_retlist, py_tuple)) goto error; Py_CLEAR(py_tuple); Py_CLEAR(py_path); // --- /construct python list } } free(fds_pointer); return py_retlist; error: Py_XDECREF(py_tuple); Py_XDECREF(py_path); Py_DECREF(py_retlist); if (fds_pointer != NULL) free(fds_pointer); return NULL; // exception has already been set earlier } /* * Return process TCP and UDP connections as a list of tuples. * Raises NSP in case of zombie process. * References: * - lsof source code: http://goo.gl/SYW79 and http://goo.gl/wNrC0 * - /usr/include/sys/proc_info.h */ static PyObject * psutil_proc_connections(PyObject *self, PyObject *args) { pid_t pid; int pidinfo_result; int iterations; int i; unsigned long nb; struct proc_fdinfo *fds_pointer = NULL; struct proc_fdinfo *fdp_pointer; struct socket_fdinfo si; PyObject *py_retlist = PyList_New(0); PyObject *py_tuple = NULL; PyObject *py_laddr = NULL; PyObject *py_raddr = NULL; PyObject *py_af_filter = NULL; PyObject *py_type_filter = NULL; if (py_retlist == NULL) return NULL; if (! PyArg_ParseTuple(args, _Py_PARSE_PID "OO", &pid, &py_af_filter, &py_type_filter)) { goto error; } if (!PySequence_Check(py_af_filter) || !PySequence_Check(py_type_filter)) { PyErr_SetString(PyExc_TypeError, "arg 2 or 3 is not a sequence"); goto error; } if (pid == 0) return py_retlist; pidinfo_result = psutil_proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0); if (pidinfo_result <= 0) goto error; fds_pointer = malloc(pidinfo_result); if (fds_pointer == NULL) { PyErr_NoMemory(); goto error; } pidinfo_result = psutil_proc_pidinfo( pid, PROC_PIDLISTFDS, 0, fds_pointer, pidinfo_result); if (pidinfo_result <= 0) goto error; iterations = (pidinfo_result / PROC_PIDLISTFD_SIZE); for (i = 0; i < iterations; i++) { py_tuple = NULL; py_laddr = NULL; py_raddr = NULL; fdp_pointer = &fds_pointer[i]; if (fdp_pointer->proc_fdtype == PROX_FDTYPE_SOCKET) { errno = 0; nb = proc_pidfdinfo(pid, fdp_pointer->proc_fd, PROC_PIDFDSOCKETINFO, &si, sizeof(si)); // --- errors checking if ((nb <= 0) || (nb < sizeof(si))) { if (errno == EBADF) { // let's assume socket has been closed continue; } else { psutil_raise_for_pid( pid, "proc_pidinfo(PROC_PIDFDSOCKETINFO)"); goto error; } } // --- /errors checking // int fd, family, type, lport, rport, state; char lip[200], rip[200]; int inseq; PyObject *py_family; PyObject *py_type; fd = (int)fdp_pointer->proc_fd; family = si.psi.soi_family; type = si.psi.soi_type; // apply filters py_family = PyLong_FromLong((long)family); inseq = PySequence_Contains(py_af_filter, py_family); Py_DECREF(py_family); if (inseq == 0) continue; py_type = PyLong_FromLong((long)type); inseq = PySequence_Contains(py_type_filter, py_type); Py_DECREF(py_type); if (inseq == 0) continue; if (errno != 0) { PyErr_SetFromErrno(PyExc_OSError); goto error; } if ((family == AF_INET) || (family == AF_INET6)) { if (family == AF_INET) { inet_ntop(AF_INET, &si.psi.soi_proto.pri_tcp.tcpsi_ini. \ insi_laddr.ina_46.i46a_addr4, lip, sizeof(lip)); inet_ntop(AF_INET, &si.psi.soi_proto.pri_tcp.tcpsi_ini.insi_faddr. \ ina_46.i46a_addr4, rip, sizeof(rip)); } else { inet_ntop(AF_INET6, &si.psi.soi_proto.pri_tcp.tcpsi_ini. \ insi_laddr.ina_6, lip, sizeof(lip)); inet_ntop(AF_INET6, &si.psi.soi_proto.pri_tcp.tcpsi_ini. \ insi_faddr.ina_6, rip, sizeof(rip)); } // check for inet_ntop failures if (errno != 0) { PyErr_SetFromOSErrnoWithSyscall("inet_ntop()"); goto error; } lport = ntohs(si.psi.soi_proto.pri_tcp.tcpsi_ini.insi_lport); rport = ntohs(si.psi.soi_proto.pri_tcp.tcpsi_ini.insi_fport); if (type == SOCK_STREAM) state = (int)si.psi.soi_proto.pri_tcp.tcpsi_state; else state = PSUTIL_CONN_NONE; py_laddr = Py_BuildValue("(si)", lip, lport); if (!py_laddr) goto error; if (rport != 0) py_raddr = Py_BuildValue("(si)", rip, rport); else py_raddr = Py_BuildValue("()"); if (!py_raddr) goto error; // construct the python list py_tuple = Py_BuildValue( "(iiiNNi)", fd, family, type, py_laddr, py_raddr, state); if (!py_tuple) goto error; if (PyList_Append(py_retlist, py_tuple)) goto error; Py_CLEAR(py_tuple); } else if (family == AF_UNIX) { py_laddr = PyUnicode_DecodeFSDefault( si.psi.soi_proto.pri_un.unsi_addr.ua_sun.sun_path); if (!py_laddr) goto error; py_raddr = PyUnicode_DecodeFSDefault( si.psi.soi_proto.pri_un.unsi_caddr.ua_sun.sun_path); if (!py_raddr) goto error; // construct the python list py_tuple = Py_BuildValue( "(iiiOOi)", fd, family, type, py_laddr, py_raddr, PSUTIL_CONN_NONE); if (!py_tuple) goto error; if (PyList_Append(py_retlist, py_tuple)) goto error; Py_CLEAR(py_tuple); Py_CLEAR(py_laddr); Py_CLEAR(py_raddr); } } } free(fds_pointer); return py_retlist; error: Py_XDECREF(py_tuple); Py_XDECREF(py_laddr); Py_XDECREF(py_raddr); Py_DECREF(py_retlist); if (fds_pointer != NULL) free(fds_pointer); return NULL; } /* * Return number of file descriptors opened by process. * Raises NSP in case of zombie process. */ static PyObject * psutil_proc_num_fds(PyObject *self, PyObject *args) { pid_t pid; int pidinfo_result; int num; struct proc_fdinfo *fds_pointer; if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid)) return NULL; pidinfo_result = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0); if (pidinfo_result <= 0) return PyErr_SetFromErrno(PyExc_OSError); fds_pointer = malloc(pidinfo_result); if (fds_pointer == NULL) return PyErr_NoMemory(); pidinfo_result = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, fds_pointer, pidinfo_result); if (pidinfo_result <= 0) { free(fds_pointer); return PyErr_SetFromErrno(PyExc_OSError); } num = (pidinfo_result / PROC_PIDLISTFD_SIZE); free(fds_pointer); return Py_BuildValue("i", num); } /* * Return a Python list of named tuples with overall network I/O information */ static PyObject * psutil_net_io_counters(PyObject *self, PyObject *args) { char *buf = NULL, *lim, *next; struct if_msghdr *ifm; int mib[6]; mib[0] = CTL_NET; // networking subsystem mib[1] = PF_ROUTE; // type of information mib[2] = 0; // protocol (IPPROTO_xxx) mib[3] = 0; // address family mib[4] = NET_RT_IFLIST2; // operation mib[5] = 0; size_t len; PyObject *py_ifc_info = NULL; PyObject *py_retdict = PyDict_New(); if (py_retdict == NULL) return NULL; if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) { PyErr_SetFromErrno(PyExc_OSError); goto error; } buf = malloc(len); if (buf == NULL) { PyErr_NoMemory(); goto error; } if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) { PyErr_SetFromErrno(PyExc_OSError); goto error; } lim = buf + len; for (next = buf; next < lim; ) { ifm = (struct if_msghdr *)next; next += ifm->ifm_msglen; if (ifm->ifm_type == RTM_IFINFO2) { py_ifc_info = NULL; struct if_msghdr2 *if2m = (struct if_msghdr2 *)ifm; struct sockaddr_dl *sdl = (struct sockaddr_dl *)(if2m + 1); char ifc_name[32]; strncpy(ifc_name, sdl->sdl_data, sdl->sdl_nlen); ifc_name[sdl->sdl_nlen] = 0; py_ifc_info = Py_BuildValue( "(KKKKKKKi)", if2m->ifm_data.ifi_obytes, if2m->ifm_data.ifi_ibytes, if2m->ifm_data.ifi_opackets, if2m->ifm_data.ifi_ipackets, if2m->ifm_data.ifi_ierrors, if2m->ifm_data.ifi_oerrors, if2m->ifm_data.ifi_iqdrops, 0); // dropout not supported if (!py_ifc_info) goto error; if (PyDict_SetItemString(py_retdict, ifc_name, py_ifc_info)) goto error; Py_CLEAR(py_ifc_info); } else { continue; } } free(buf); return py_retdict; error: Py_XDECREF(py_ifc_info); Py_DECREF(py_retdict); if (buf != NULL) free(buf); return NULL; } /* * Return a Python dict of tuples for disk I/O information */ static PyObject * psutil_disk_io_counters(PyObject *self, PyObject *args) { CFDictionaryRef parent_dict; CFDictionaryRef props_dict; CFDictionaryRef stats_dict; io_registry_entry_t parent; io_registry_entry_t disk; io_iterator_t disk_list; PyObject *py_disk_info = NULL; PyObject *py_retdict = PyDict_New(); if (py_retdict == NULL) return NULL; // Get list of disks if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching(kIOMediaClass), &disk_list) != kIOReturnSuccess) { PyErr_SetString( PyExc_RuntimeError, "unable to get the list of disks."); goto error; } // Iterate over disks while ((disk = IOIteratorNext(disk_list)) != 0) { py_disk_info = NULL; parent_dict = NULL; props_dict = NULL; stats_dict = NULL; if (IORegistryEntryGetParentEntry(disk, kIOServicePlane, &parent) != kIOReturnSuccess) { PyErr_SetString(PyExc_RuntimeError, "unable to get the disk's parent."); IOObjectRelease(disk); goto error; } if (IOObjectConformsTo(parent, "IOBlockStorageDriver")) { if (IORegistryEntryCreateCFProperties( disk, (CFMutableDictionaryRef *) &parent_dict, kCFAllocatorDefault, kNilOptions ) != kIOReturnSuccess) { PyErr_SetString(PyExc_RuntimeError, "unable to get the parent's properties."); IOObjectRelease(disk); IOObjectRelease(parent); goto error; } if (IORegistryEntryCreateCFProperties( parent, (CFMutableDictionaryRef *) &props_dict, kCFAllocatorDefault, kNilOptions ) != kIOReturnSuccess) { PyErr_SetString(PyExc_RuntimeError, "unable to get the disk properties."); CFRelease(props_dict); IOObjectRelease(disk); IOObjectRelease(parent); goto error; } const int kMaxDiskNameSize = 64; CFStringRef disk_name_ref = (CFStringRef)CFDictionaryGetValue( parent_dict, CFSTR(kIOBSDNameKey)); char disk_name[kMaxDiskNameSize]; CFStringGetCString(disk_name_ref, disk_name, kMaxDiskNameSize, CFStringGetSystemEncoding()); stats_dict = (CFDictionaryRef)CFDictionaryGetValue( props_dict, CFSTR(kIOBlockStorageDriverStatisticsKey)); if (stats_dict == NULL) { PyErr_SetString(PyExc_RuntimeError, "Unable to get disk stats."); goto error; } CFNumberRef number; int64_t reads = 0; int64_t writes = 0; int64_t read_bytes = 0; int64_t write_bytes = 0; int64_t read_time = 0; int64_t write_time = 0; // Get disk reads/writes if ((number = (CFNumberRef)CFDictionaryGetValue( stats_dict, CFSTR(kIOBlockStorageDriverStatisticsReadsKey)))) { CFNumberGetValue(number, kCFNumberSInt64Type, &reads); } if ((number = (CFNumberRef)CFDictionaryGetValue( stats_dict, CFSTR(kIOBlockStorageDriverStatisticsWritesKey)))) { CFNumberGetValue(number, kCFNumberSInt64Type, &writes); } // Get disk bytes read/written if ((number = (CFNumberRef)CFDictionaryGetValue( stats_dict, CFSTR(kIOBlockStorageDriverStatisticsBytesReadKey)))) { CFNumberGetValue(number, kCFNumberSInt64Type, &read_bytes); } if ((number = (CFNumberRef)CFDictionaryGetValue( stats_dict, CFSTR(kIOBlockStorageDriverStatisticsBytesWrittenKey)))) { CFNumberGetValue(number, kCFNumberSInt64Type, &write_bytes); } // Get disk time spent reading/writing (nanoseconds) if ((number = (CFNumberRef)CFDictionaryGetValue( stats_dict, CFSTR(kIOBlockStorageDriverStatisticsTotalReadTimeKey)))) { CFNumberGetValue(number, kCFNumberSInt64Type, &read_time); } if ((number = (CFNumberRef)CFDictionaryGetValue( stats_dict, CFSTR(kIOBlockStorageDriverStatisticsTotalWriteTimeKey)))) { CFNumberGetValue(number, kCFNumberSInt64Type, &write_time); } // Read/Write time on macOS comes back in nanoseconds and in psutil // we've standardized on milliseconds so do the conversion. py_disk_info = Py_BuildValue( "(KKKKKK)", reads, writes, read_bytes, write_bytes, read_time / 1000 / 1000, write_time / 1000 / 1000); if (!py_disk_info) goto error; if (PyDict_SetItemString(py_retdict, disk_name, py_disk_info)) goto error; Py_CLEAR(py_disk_info); CFRelease(parent_dict); IOObjectRelease(parent); CFRelease(props_dict); IOObjectRelease(disk); } } IOObjectRelease (disk_list); return py_retdict; error: Py_XDECREF(py_disk_info); Py_DECREF(py_retdict); return NULL; } /* * Return currently connected users as a list of tuples. */ static PyObject * psutil_users(PyObject *self, PyObject *args) { struct utmpx *utx; PyObject *py_username = NULL; PyObject *py_tty = NULL; PyObject *py_hostname = NULL; PyObject *py_tuple = NULL; PyObject *py_retlist = PyList_New(0); if (py_retlist == NULL) return NULL; while ((utx = getutxent()) != NULL) { if (utx->ut_type != USER_PROCESS) continue; py_username = PyUnicode_DecodeFSDefault(utx->ut_user); if (! py_username) goto error; py_tty = PyUnicode_DecodeFSDefault(utx->ut_line); if (! py_tty) goto error; py_hostname = PyUnicode_DecodeFSDefault(utx->ut_host); if (! py_hostname) goto error; py_tuple = Py_BuildValue( "(OOOfi)", py_username, // username py_tty, // tty py_hostname, // hostname (float)utx->ut_tv.tv_sec, // start time utx->ut_pid // process id ); if (!py_tuple) { endutxent(); goto error; } if (PyList_Append(py_retlist, py_tuple)) { endutxent(); goto error; } Py_CLEAR(py_username); Py_CLEAR(py_tty); Py_CLEAR(py_hostname); Py_CLEAR(py_tuple); } endutxent(); return py_retlist; error: Py_XDECREF(py_username); Py_XDECREF(py_tty); Py_XDECREF(py_hostname); Py_XDECREF(py_tuple); Py_DECREF(py_retlist); return NULL; } /* * Return CPU statistics. */ static PyObject * psutil_cpu_stats(PyObject *self, PyObject *args) { struct vmmeter vmstat; kern_return_t ret; mach_msg_type_number_t count = sizeof(vmstat) / sizeof(integer_t); mach_port_t mport = mach_host_self(); ret = host_statistics(mport, HOST_VM_INFO, (host_info_t)&vmstat, &count); if (ret != KERN_SUCCESS) { PyErr_Format( PyExc_RuntimeError, "host_statistics(HOST_VM_INFO) failed: %s", mach_error_string(ret)); return NULL; } mach_port_deallocate(mach_task_self(), mport); return Py_BuildValue( "IIIII", vmstat.v_swtch, // ctx switches vmstat.v_intr, // interrupts vmstat.v_soft, // software interrupts vmstat.v_syscall, // syscalls vmstat.v_trap // traps ); } /* * Return battery information. */ static PyObject * psutil_sensors_battery(PyObject *self, PyObject *args) { PyObject *py_tuple = NULL; CFTypeRef power_info = NULL; CFArrayRef power_sources_list = NULL; CFDictionaryRef power_sources_information = NULL; CFNumberRef capacity_ref = NULL; CFNumberRef time_to_empty_ref = NULL; CFStringRef ps_state_ref = NULL; uint32_t capacity; /* units are percent */ int time_to_empty; /* units are minutes */ int is_power_plugged; power_info = IOPSCopyPowerSourcesInfo(); if (!power_info) { PyErr_SetString(PyExc_RuntimeError, "IOPSCopyPowerSourcesInfo() syscall failed"); goto error; } power_sources_list = IOPSCopyPowerSourcesList(power_info); if (!power_sources_list) { PyErr_SetString(PyExc_RuntimeError, "IOPSCopyPowerSourcesList() syscall failed"); goto error; } /* Should only get one source. But in practice, check for > 0 sources */ if (!CFArrayGetCount(power_sources_list)) { PyErr_SetString(PyExc_NotImplementedError, "no battery"); goto error; } power_sources_information = IOPSGetPowerSourceDescription( power_info, CFArrayGetValueAtIndex(power_sources_list, 0)); capacity_ref = (CFNumberRef) CFDictionaryGetValue( power_sources_information, CFSTR(kIOPSCurrentCapacityKey)); if (!CFNumberGetValue(capacity_ref, kCFNumberSInt32Type, &capacity)) { PyErr_SetString(PyExc_RuntimeError, "No battery capacity infomration in power sources info"); goto error; } ps_state_ref = (CFStringRef) CFDictionaryGetValue( power_sources_information, CFSTR(kIOPSPowerSourceStateKey)); is_power_plugged = CFStringCompare( ps_state_ref, CFSTR(kIOPSACPowerValue), 0) == kCFCompareEqualTo; time_to_empty_ref = (CFNumberRef) CFDictionaryGetValue( power_sources_information, CFSTR(kIOPSTimeToEmptyKey)); if (!CFNumberGetValue(time_to_empty_ref, kCFNumberIntType, &time_to_empty)) { /* This value is recommended for non-Apple power sources, so it's not * an error if it doesn't exist. We'll return -1 for "unknown" */ /* A value of -1 indicates "Still Calculating the Time" also for * apple power source */ time_to_empty = -1; } py_tuple = Py_BuildValue("Iii", capacity, time_to_empty, is_power_plugged); if (!py_tuple) { goto error; } CFRelease(power_info); CFRelease(power_sources_list); /* Caller should NOT release power_sources_information */ return py_tuple; error: if (power_info) CFRelease(power_info); if (power_sources_list) CFRelease(power_sources_list); Py_XDECREF(py_tuple); return NULL; } /* * define the psutil C module methods and initialize the module. */ static PyMethodDef mod_methods[] = { // --- per-process functions {"proc_kinfo_oneshot", psutil_proc_kinfo_oneshot, METH_VARARGS, "Return multiple process info."}, {"proc_pidtaskinfo_oneshot", psutil_proc_pidtaskinfo_oneshot, METH_VARARGS, "Return multiple process info."}, {"proc_name", psutil_proc_name, METH_VARARGS, "Return process name"}, {"proc_cmdline", psutil_proc_cmdline, METH_VARARGS, "Return process cmdline as a list of cmdline arguments"}, {"proc_environ", psutil_proc_environ, METH_VARARGS, "Return process environment data"}, {"proc_exe", psutil_proc_exe, METH_VARARGS, "Return path of the process executable"}, {"proc_cwd", psutil_proc_cwd, METH_VARARGS, "Return process current working directory."}, {"proc_memory_uss", psutil_proc_memory_uss, METH_VARARGS, "Return process USS memory"}, {"proc_threads", psutil_proc_threads, METH_VARARGS, "Return process threads as a list of tuples"}, {"proc_open_files", psutil_proc_open_files, METH_VARARGS, "Return files opened by process as a list of tuples"}, {"proc_num_fds", psutil_proc_num_fds, METH_VARARGS, "Return the number of fds opened by process."}, {"proc_connections", psutil_proc_connections, METH_VARARGS, "Get process TCP and UDP connections as a list of tuples"}, // --- system-related functions {"pids", psutil_pids, METH_VARARGS, "Returns a list of PIDs currently running on the system"}, {"cpu_count_logical", psutil_cpu_count_logical, METH_VARARGS, "Return number of logical CPUs on the system"}, {"cpu_count_phys", psutil_cpu_count_phys, METH_VARARGS, "Return number of physical CPUs on the system"}, {"virtual_mem", psutil_virtual_mem, METH_VARARGS, "Return system virtual memory stats"}, {"swap_mem", psutil_swap_mem, METH_VARARGS, "Return stats about swap memory, in bytes"}, {"cpu_times", psutil_cpu_times, METH_VARARGS, "Return system cpu times as a tuple (user, system, nice, idle, irc)"}, {"per_cpu_times", psutil_per_cpu_times, METH_VARARGS, "Return system per-cpu times as a list of tuples"}, {"cpu_freq", psutil_cpu_freq, METH_VARARGS, "Return cpu current frequency"}, {"boot_time", psutil_boot_time, METH_VARARGS, "Return the system boot time expressed in seconds since the epoch."}, {"disk_partitions", psutil_disk_partitions, METH_VARARGS, "Return a list of tuples including device, mount point and " "fs type for all partitions mounted on the system."}, {"net_io_counters", psutil_net_io_counters, METH_VARARGS, "Return dict of tuples of networks I/O information."}, {"disk_io_counters", psutil_disk_io_counters, METH_VARARGS, "Return dict of tuples of disks I/O information."}, {"users", psutil_users, METH_VARARGS, "Return currently connected users as a list of tuples"}, {"cpu_stats", psutil_cpu_stats, METH_VARARGS, "Return CPU statistics"}, {"sensors_battery", psutil_sensors_battery, METH_VARARGS, "Return battery information."}, // --- others {"set_testing", psutil_set_testing, METH_NOARGS, "Set psutil in testing mode"}, {NULL, NULL, 0, NULL} }; #if PY_MAJOR_VERSION >= 3 #define INITERR return NULL static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_psutil_osx", NULL, -1, mod_methods, NULL, NULL, NULL, NULL }; PyObject *PyInit__psutil_osx(void) #else /* PY_MAJOR_VERSION */ #define INITERR return void init_psutil_osx(void) #endif /* PY_MAJOR_VERSION */ { #if PY_MAJOR_VERSION >= 3 PyObject *mod = PyModule_Create(&moduledef); #else PyObject *mod = Py_InitModule("_psutil_osx", mod_methods); #endif if (mod == NULL) INITERR; if (psutil_setup() != 0) INITERR; if (PyModule_AddIntConstant(mod, "version", PSUTIL_VERSION)) INITERR; // process status constants, defined in: // http://fxr.watson.org/fxr/source/bsd/sys/proc.h?v=xnu-792.6.70#L149 if (PyModule_AddIntConstant(mod, "SIDL", SIDL)) INITERR; if (PyModule_AddIntConstant(mod, "SRUN", SRUN)) INITERR; if (PyModule_AddIntConstant(mod, "SSLEEP", SSLEEP)) INITERR; if (PyModule_AddIntConstant(mod, "SSTOP", SSTOP)) INITERR; if (PyModule_AddIntConstant(mod, "SZOMB", SZOMB)) INITERR; // connection status constants if (PyModule_AddIntConstant(mod, "TCPS_CLOSED", TCPS_CLOSED)) INITERR; if (PyModule_AddIntConstant(mod, "TCPS_CLOSING", TCPS_CLOSING)) INITERR; if (PyModule_AddIntConstant(mod, "TCPS_CLOSE_WAIT", TCPS_CLOSE_WAIT)) INITERR; if (PyModule_AddIntConstant(mod, "TCPS_LISTEN", TCPS_LISTEN)) INITERR; if (PyModule_AddIntConstant(mod, "TCPS_ESTABLISHED", TCPS_ESTABLISHED)) INITERR; if (PyModule_AddIntConstant(mod, "TCPS_SYN_SENT", TCPS_SYN_SENT)) INITERR; if (PyModule_AddIntConstant(mod, "TCPS_SYN_RECEIVED", TCPS_SYN_RECEIVED)) INITERR; if (PyModule_AddIntConstant(mod, "TCPS_FIN_WAIT_1", TCPS_FIN_WAIT_1)) INITERR; if (PyModule_AddIntConstant(mod, "TCPS_FIN_WAIT_2", TCPS_FIN_WAIT_2)) INITERR; if (PyModule_AddIntConstant(mod, "TCPS_LAST_ACK", TCPS_LAST_ACK)) INITERR; if (PyModule_AddIntConstant(mod, "TCPS_TIME_WAIT", TCPS_TIME_WAIT)) INITERR; if (PyModule_AddIntConstant(mod, "PSUTIL_CONN_NONE", PSUTIL_CONN_NONE)) INITERR; // Exception. ZombieProcessError = PyErr_NewException( "_psutil_osx.ZombieProcessError", NULL, NULL); if (ZombieProcessError == NULL) INITERR; Py_INCREF(ZombieProcessError); if (PyModule_AddObject(mod, "ZombieProcessError", ZombieProcessError)) { Py_DECREF(ZombieProcessError); INITERR; } if (mod == NULL) INITERR; #if PY_MAJOR_VERSION >= 3 return mod; #endif }
e10bb9c340b6603f844573cbaf0cd6428fdbc4e0
9ceacf33fd96913cac7ef15492c126d96cae6911
/usr.sbin/installboot/sparc64_softraid.c
b86db68df404ff5159adc540844950b6d22c130f
[]
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
2,137
c
sparc64_softraid.c
/* $OpenBSD: sparc64_softraid.c,v 1.9 2022/11/08 12:08:53 kn Exp $ */ /* * Copyright (c) 2012 Joel Sing <jsing@openbsd.org> * * Permission to use, copy, modify, and 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. */ #include <sys/ioctl.h> #include <sys/stat.h> #include <dev/biovar.h> #include <err.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include "installboot.h" #include "sparc64_installboot.h" void sr_install_bootblk(int devfd, int vol, int disk) { struct bioc_disk bd; char *realdev; int diskfd; char part; diskfd = sr_open_chunk(devfd, vol, disk, &bd, &realdev, &part); if (diskfd == -1) return; if (verbose) fprintf(stderr, "%s%c: %s boot blocks on %s\n", bd.bd_vendor, part, (nowrite ? "would install" : "installing"), realdev); /* Write boot blocks to device. */ md_installboot(diskfd, realdev); close(diskfd); } void sr_install_bootldr(int devfd, char *dev) { struct bioc_installboot bb; /* * Install boot loader into softraid boot loader storage area. */ memset(&bb, 0, sizeof(bb)); bb.bb_bootblk = blkstore; bb.bb_bootblk_size = blksize; bb.bb_bootldr = ldrstore; bb.bb_bootldr_size = ldrsize; strncpy(bb.bb_dev, dev, sizeof(bb.bb_dev)); if (verbose) fprintf(stderr, "%s: %s boot loader on softraid volume\n", dev, (nowrite ? "would install" : "installing")); if (!nowrite) { if (ioctl(devfd, BIOCINSTALLBOOT, &bb) == -1) errx(1, "softraid installboot failed"); sr_status(&bb.bb_bio.bio_status); } }
3d5fbe7f22650044720aa81c854c5255ad6027ac
167c6226bc77c5daaedab007dfdad4377f588ef4
/cpp/ql/test/library-tests/locations/enum_initialisers/enum_initialisers.c
d2f6963e8865b05e1e2e396a700be214a1f9474e
[ "LicenseRef-scancode-public-domain", "MIT" ]
permissive
github/codeql
1eebb449a34f774db9e881b52cb8f7a1b1a53612
d109637e2d7ab3b819812eb960c05cb31d9d2168
refs/heads/main
2023-08-20T11:32:39.162059
2023-08-18T14:33:32
2023-08-18T14:33:32
143,040,428
5,987
1,363
MIT
2023-09-14T19:36:50
2018-07-31T16:35:51
CodeQL
UTF-8
C
false
false
109
c
enum_initialisers.c
enum MisleadingAlphabet { alpha, bravo = alpha }; int main() { int result = bravo; return result; }
6e94082f50993300aafbb41dc58f72fe622daa63
736bc705b28a4cb4288948b26b4253835acbfd1e
/value-range-analysis/test-cases/test-cases/test11.c
f2e184174e0d59ea61900f95c99187575f1add90
[ "WTFPL" ]
permissive
lijiansong/clang-llvm-tutorial
18aac7b5f7b3519f5c81e5a671c5ef20786c0161
91e7d8a7e967c44d54e21f5994260175dc1c7f8a
refs/heads/master
2022-05-11T05:06:20.398914
2022-04-16T01:57:24
2022-04-16T01:57:24
77,628,811
253
62
null
null
null
null
UTF-8
C
false
false
473
c
test11.c
int foo(int a, int b) { int x = 0; int y = 100; // range of y is [100..100] int z = 100; if (a) { x = 0; } else { x = 10; } // range of x is [0..10] if (b) { y = x + 1; //range of y is [1..11] z = y * x; //range of z is [0..110] } else { y = x -1; // range of y is [-1..9] z = y * x; //range of z is [-10..90] } // range of z is [-10, 110] return z; } /// Expected output /// [-10..110]
0969af408fa95e8f5a88644ef930270883aef350
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/allwinner/libraries/sunxi-hal/hal/source/usb/core/usb_gen_hcd_rh.c
aab29e2d78ddb29601efd6986bf7be55fc96f853
[ "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
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
21,086
c
usb_gen_hcd_rh.c
/* ******************************************************************************* * usb host module * * Copyright(C), 2006-2008, SoftWinners Co., Ltd. * All Rights Reserved * * File Name : * * Author : GLHuang(HoLiGun) * * Version : 1.0 * * Date : 2008.05.xx * * Description : * gen hcd的root hub部分 * History : ******************************************************************************************************************** */ //#include "usb_host_config.h" //#include "usb_host_base_types.h" //#include "usb_os_platform.h" #include <string.h> #include <usb_host_common.h> #include <usb_list.h> #include <usb_host_hub.h> #include <usb_utils_find_zero_bit.h> #include "usb_core_base.h" #include "usb_msg.h" #include <sunxi_hal_common.h> #include "usb_virt_bus.h" #include <usb_gen_dev_mod.h> #include "usb_gen_hcd.h" #include "usb_gen_hub.h" #include "usb_core_config.h" #include "urb.h" #include "usb_gen_hub.h" #include "usb_core_interface.h" #include <log.h> //#include <util.h> static hal_spinlock_t lock; /* usb 2.0 root hub device descriptor */ static const u8 usb2_rh_dev_descriptor [18] = { 0x12, /* __u8 bLength; */ 0x01, /* __u8 bDescriptorType; Device */ 0x00, 0x02, /* __le16 bcdUSB; v2.0 */ 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ 0x00, /* __u8 bDeviceSubClass; */ 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */ 0x00, 0x00, /* __le16 idVendor; */ 0x00, 0x00, /* __le16 idProduct; */ 0x00, 0x00, /* __le16 bcdDevice */ 0x03, /* __u8 iManufacturer; */ 0x02, /* __u8 iProduct; */ 0x01, /* __u8 iSerialNumber; */ 0x01 /* __u8 bNumConfigurations; */ }; /* no usb 2.0 root hub "device qualifier" descriptor: one speed only */ /* usb 1.1 root hub device descriptor */ static const u8 usb11_rh_dev_descriptor [18] = { 0x12, /* __u8 bLength; */ 0x01, /* __u8 bDescriptorType; Device */ 0x10, 0x01, /* __le16 bcdUSB; v1.1 */ 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ 0x00, /* __u8 bDeviceSubClass; */ 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */ 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */ 0x00, 0x00, /* __le16 idVendor; */ 0x00, 0x00, /* __le16 idProduct; */ 0x00, 0x00, /* __le16 bcdDevice */ 0x03, /* __u8 iManufacturer; */ 0x02, /* __u8 iProduct; */ 0x01, /* __u8 iSerialNumber; */ 0x01 /* __u8 bNumConfigurations; */ }; /* Configuration descriptors for our root hubs */ static const u8 fs_rh_config_descriptor [] = { /* one configuration */ 0x09, /* __u8 bLength; */ 0x02, /* __u8 bDescriptorType; Configuration */ 0x19, 0x00, /* __le16 wTotalLength; */ 0x01, /* __u8 bNumInterfaces; (1) */ 0x01, /* __u8 bConfigurationValue; */ 0x00, /* __u8 iConfiguration; */ 0xc0, /* __u8 bmAttributes; Bit 7: must be set, 6: Self-powered, 5: Remote wakeup, 4..0: resvd */ 0x00, /* __u8 MaxPower; */ /* USB 1.1: * USB 2.0, single TT organization (mandatory): * one interface, protocol 0 * * USB 2.0, multiple TT organization (optional): * two interfaces, protocols 1 (like single TT) * and 2 (multiple TT mode) ... config is * sometimes settable * NOT IMPLEMENTED */ /* one interface */ 0x09, /* __u8 if_bLength; */ 0x04, /* __u8 if_bDescriptorType; Interface */ 0x00, /* __u8 if_bInterfaceNumber; */ 0x00, /* __u8 if_bAlternateSetting; */ 0x01, /* __u8 if_bNumEndpoints; */ 0x09, /* __u8 if_bInterfaceClass; HUB_CLASSCODE */ 0x00, /* __u8 if_bInterfaceSubClass; */ 0x00, /* __u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ 0x00, /* __u8 if_iInterface; */ /* one endpoint (status change endpoint) */ 0x07, /* __u8 ep_bLength; */ 0x05, /* __u8 ep_bDescriptorType; Endpoint */ 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ 0x03, /* __u8 ep_bmAttributes; Interrupt */ 0x02, 0x00, /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ 0xff /* __u8 ep_bInterval; (255ms -- usb 2.0 spec) */ }; static const u8 hs_rh_config_descriptor [] = { /* one configuration */ 0x09, /* __u8 bLength; */ 0x02, /* __u8 bDescriptorType; Configuration */ 0x19, 0x00, /* __le16 wTotalLength; */ 0x01, /* __u8 bNumInterfaces; (1) */ 0x01, /* __u8 bConfigurationValue; */ 0x00, /* __u8 iConfiguration; */ 0xc0, /* __u8 bmAttributes; Bit 7: must be set, 6: Self-powered, 5: Remote wakeup, 4..0: resvd */ 0x00, /* __u8 MaxPower; */ /* USB 1.1: * USB 2.0, single TT organization (mandatory): * one interface, protocol 0 * * USB 2.0, multiple TT organization (optional): * two interfaces, protocols 1 (like single TT) * and 2 (multiple TT mode) ... config is * sometimes settable * NOT IMPLEMENTED */ /* one interface */ 0x09, /* __u8 if_bLength; */ 0x04, /* __u8 if_bDescriptorType; Interface */ 0x00, /* __u8 if_bInterfaceNumber; */ 0x00, /* __u8 if_bAlternateSetting; */ 0x01, /* __u8 if_bNumEndpoints; */ 0x09, /* __u8 if_bInterfaceClass; HUB_CLASSCODE */ 0x00, /* __u8 if_bInterfaceSubClass; */ 0x00, /* __u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ 0x00, /* __u8 if_iInterface; */ /* one endpoint (status change endpoint) */ 0x07, /* __u8 ep_bLength; */ 0x05, /* __u8 ep_bDescriptorType; Endpoint */ 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ 0x03, /* __u8 ep_bmAttributes; Interrupt */ 0x02, 0x00, /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */ }; /* timer到时处理函数,其实就是直接调用hc_driver的hub_status_data() */ void rh_timer_func(void *timer_para_hcd) { usb_hcd_poll_rh_status((struct hc_gen_dev *) timer_para_hcd); } /* * Root Hub interrupt transfers are polled using a timer if the * driver requests it; otherwise the driver is responsible for * calling usb_hcd_poll_rh_status() when an event occurs. * * Completions are called in_interrupt(), but they may or may not * be in_irq(). */ /* ******************************************************************************** * usb_hcd_poll_rh_status * Description: * 可以被如下几个用户调用: * 1,rh hub的timer到时间 * 2,具体的hcd,发现有事件发生 * Arguments: * hcd : input. * Return value: * void * note: * void ********************************************************************************* */ void usb_hcd_poll_rh_status(struct hc_gen_dev *hcd) { struct urb *urb; int length; uint32_t cpu_sr; u8 buffer[4]; // Any root hubs with > 31 ports if (!hcd->uses_new_polling && !hcd->status_urb) { hal_log_err("usb_hcd_poll_rh_status() hcd->uses_new_polling = %d ,hcd->status_urb= %d", hcd->uses_new_polling, hcd->status_urb); return; } //--<1>--获得低层hub端口的状态 length = hcd->driver->hub_status_data(hcd, buffer); if (length > 0) { /* try to complete the status urb */ cpu_sr = hal_spin_lock_irqsave(&lock); urb = hcd->status_urb; if (urb) { if (urb->status == -EINPROGRESS) { hcd->poll_pending = 0; hcd->status_urb = NULL; urb->status = 0; urb->hcpriv = NULL; urb->actual_length = length; memcpy(urb->transfer_buffer, buffer, length); } else // urb has been unlinked { length = 0; } } else { length = 0; } // local irqs are always blocked in completions if (length > 0) { usb_hcd_giveback_urb(hcd, urb); } else { hcd->poll_pending = 1; } hal_spin_unlock_irqrestore(&lock, cpu_sr); } #if 0 /* The USB 2.0 spec says 256 ms. This is close enough and won't * exceed that limit if HZ is 100. */ if (hcd->uses_new_polling ? hcd->poll_rh : (length == 0 && hcd->status_urb != NULL)) { mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(250)); } #endif } /* * rh_string - provides manufacturer, product and serial strings for root hub * @id: the string ID number (1: serial number, 2: product, 3: vendor) * @hcd: the host controller for this root hub * @type: string describing our driver * @data: return packet in UTF-16 LE * @len: length of the return packet * * Produces either a manufacturer, product or serial number string for the * virtual root hub device. */ static int rh_string(int id, struct hc_gen_dev *hcd, u8 *data, int len) { char buf [100]; buf[0] = 4; buf[1] = 3; /* 4 bytes string data */ buf[2] = 0x09; buf[3] = 0x04; /* MSFT-speak for "en-us" */ len = min(len, 4); memcpy(data, buf, len); return len; #if 0 // language ids if (id == 0) { buf[0] = 4; buf[1] = 3; /* 4 bytes string data */ buf[2] = 0x09; buf[3] = 0x04; /* MSFT-speak for "en-us" */ len = min(len, 4); memcpy(data, buf, len); return len; // serial number } else if (id == 1) { strlcpy(buf, hcd->self.bus_name, sizeof buf); // product description } else if (id == 2) { strlcpy(buf, hcd->product_desc, sizeof buf); // id 3 == vendor description } else if (id == 3) { snprintf(buf, sizeof buf, "%s %s %s", system_utsname.sysname, system_utsname.release, hcd->driver->description); // unsupported IDs --> "protocol stall" } else { return -EPIPE; } switch (len) /* All cases fall through */ { default: len = 2 + ascii2utf(buf, data + 2, len - 2); case 2: data [1] = 3; /* type == string */ case 1: data [0] = 2 * (strlen(buf) + 1); case 0: ; /* Compiler wants a statement here */ } return len; #endif } /* 查询rh的status,是通过timer实现,所以这里只mod_timer timer到时处理函数rh_timer_func(): */ static int rh_queue_status(struct hc_gen_dev *hcd, struct urb *urb) { int retval; uint32_t cpu_sr; int len = 1 + (urb->dev->maxchild / 8); cpu_sr = hal_spin_lock_irqsave(&lock); if (urb->status != -EINPROGRESS) /* already unlinked */ { retval = urb->status; } else if (hcd->status_urb || urb->transfer_buffer_length < len) { hal_log_err("not queuing rh status urb\n"); retval = -EINVAL; } else { hcd->status_urb = urb; urb->hcpriv = hcd; /* indicate it's queued */ #if 0 if (!hcd->uses_new_polling) { mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(250)); /* If a status change has already occurred, report it ASAP */ } else if (hcd->poll_pending) { mod_timer(&hcd->rh_timer, jiffies); } #endif retval = 0; } hal_spin_unlock_irqrestore(&lock, cpu_sr); return retval; } /* Root hub control transfers execute synchronously */ /* rh的控制 请求,其实直接调用hcd driver->hub_control */ static int rh_call_control(struct hc_gen_dev *hcd, struct urb *urb) { struct usb_ctrlrequest *cmd = NULL; u16 typeReq = 0, wValue = 0, wIndex = 0, wLength = 0; u8 *ubuf = urb->transfer_buffer; u8 tbuf[sizeof(struct usb_hub_descriptor)] __attribute__((aligned(4))); const u8 *bufp = tbuf; u32 len = 0; // u32 patch_wakeup = 0; u32 flags = 0; uint32_t cpu_sr; s32 status = 0; s32 n = 0; cmd = (struct usb_ctrlrequest *) urb->setup_packet; typeReq = (cmd->bRequestType << 8) | cmd->bRequest; wValue = le16_to_cpu(cmd->wValue); wIndex = le16_to_cpu(cmd->wIndex); wLength = le16_to_cpu(cmd->wLength); if (wLength > urb->transfer_buffer_length) { goto error; } urb->actual_length = 0; switch (typeReq) { case DeviceRequest | USB_REQ_GET_STATUS: tbuf [0] = (hcd->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP) | (1 << USB_DEVICE_SELF_POWERED); tbuf [1] = 0; len = 2; break; case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: if (wValue == USB_DEVICE_REMOTE_WAKEUP) { hcd->remote_wakeup = 0; } else { goto error; } break; case DeviceOutRequest | USB_REQ_SET_FEATURE: if (hcd->can_wakeup && wValue == USB_DEVICE_REMOTE_WAKEUP) { hcd->remote_wakeup = 1; } else { goto error; } break; case DeviceRequest | USB_REQ_GET_CONFIGURATION: tbuf [0] = 1; len = 1; break; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: break; case DeviceRequest | USB_REQ_GET_DESCRIPTOR: switch (wValue & 0xff00) { case USB_DT_DEVICE << 8: if (hcd->driver->flags & HC_DRIVER_FLAG_HCD_USB2) { bufp = usb2_rh_dev_descriptor; } else if (hcd->driver->flags & HC_DRIVER_FLAG_HCD_USB11) { bufp = usb11_rh_dev_descriptor; } else { goto error; } len = 18; break; case USB_DT_CONFIG << 8: if (hcd->driver->flags & HC_DRIVER_FLAG_HCD_USB2) { bufp = hs_rh_config_descriptor; len = sizeof hs_rh_config_descriptor; } else { bufp = fs_rh_config_descriptor; len = sizeof fs_rh_config_descriptor; } //if (hcd->can_wakeup) //patch_wakeup = 1; break; case USB_DT_STRING << 8: n = rh_string(wValue & 0xff, hcd, ubuf, wLength); if (n < 0) { goto error; } urb->actual_length = n; break; default: goto error; } break; case DeviceRequest | USB_REQ_GET_INTERFACE: tbuf [0] = 0; len = 1; break; /* FALLTHROUGH */ case DeviceOutRequest | USB_REQ_SET_INTERFACE: break; case DeviceOutRequest | USB_REQ_SET_ADDRESS: // wValue == urb->dev->devaddr break; /* INTERFACE REQUESTS (no defined feature/status flags) */ /* ENDPOINT REQUESTS */ case EndpointRequest | USB_REQ_GET_STATUS: // ENDPOINT_HALT flag tbuf [0] = 0; tbuf [1] = 0; len = 2; hal_log_info("no endpoint features yet\n"); break; case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: case EndpointOutRequest | USB_REQ_SET_FEATURE: hal_log_info("no endpoint features yet\n"); break; /* CLASS REQUESTS (and errors) */ default: /* non-generic request */ if (HC_GEN_DEV_IS_SUSPENDED(hcd->state)) { status = -EAGAIN; } else { switch (typeReq) { case GetHubStatus: case GetPortStatus: len = 4; break; case GetHubDescriptor: len = sizeof(struct usb_hub_descriptor); break; } //直接调用具体的hub驱动 //hal_log_info("-----rh_call_control---1\n"); status = hcd->driver->hub_control(hcd, typeReq, wValue, wIndex, (u8 *)tbuf, wLength); } break; error: /* "protocol stall" on error */ status = -EPIPE; } if (status) { len = 0; if (status != -EPIPE) { hal_log_err("CTRL: TypeReq=0x%x val=0x%x " "idx=0x%x len=%d ==> %d\n", typeReq, wValue, wIndex, wLength, urb->status); } } if (len) { if (urb->transfer_buffer_length < len) { len = urb->transfer_buffer_length; } urb->actual_length = len; // always USB_DIR_IN, toward host memcpy(ubuf, bufp, len); /* report whether RH hardware supports remote wakeup */ #if 0 if (patch_wakeup && len > offsetof(struct usb_config_descriptor, bmAttributes)) ((struct usb_config_descriptor *)ubuf)->bmAttributes |= USB_CONFIG_ATT_WAKEUP; #endif } /* any errors get returned through the urb completion */ cpu_sr = hal_spin_lock_irqsave(&lock); if (urb->status == -EINPROGRESS) { urb->status = status; } usb_hcd_giveback_urb(hcd, urb); hal_spin_unlock_irqrestore(&lock, cpu_sr); return 0; } /* root hub的urb enqueue特殊通道, 都是被指向hc_driver的两个rh操作 */ int rh_urb_enqueue(struct hc_gen_dev *hcd, struct urb *urb) { /* 查询rh的status,其实就是开启timer直接查询hc_driver的 hub_status_data(),获得root_hub的当前状态 */ //hal_log_info("----rh_urb_ehqueue\n"); if (usb_pipeint(urb->pipe)) { //hal_log_info("----rh_urb_ehqueue--1\n"); return rh_queue_status(hcd, urb); //hal_log_info("----rh_urb_ehqueue--2\n"); } if (usb_pipecontrol(urb->pipe)) { //hal_log_info("----rh_urb_ehqueue---3\n"); return rh_call_control(hcd, urb); //hal_log_info("----rh_urb_ehqueue--4\n"); } return -EINVAL; } /* Asynchronous unlinks of root-hub control URBs are legal, but they * don't do anything. Status URB unlinks must be made in process context * with interrupts enabled. */ int rh_urb_dequeue(struct hc_gen_dev *hcd, struct urb *urb) { uint32_t sr; int rc; rc = usb_hcd_check_unlink_urb(hcd, urb); if (rc) goto done; if (usb_pipeendpoint(urb->pipe) == 0) /* Control URB */ { /* if (in_interrupt()) return 0; //nothing to do */ sr = hal_spin_lock_irqsave(&urb->lock_urb); ++urb->reject; hal_spin_unlock_irqrestore(&urb->lock_urb, sr); /* wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); */ sr = hal_spin_lock_irqsave(&urb->lock_urb); --urb->reject; hal_spin_unlock_irqrestore(&urb->lock_urb, sr); } else /* Status URB */ { // if (!hcd->uses_new_polling){ // del_timer_sync (&hcd->rh_timer); // } sr = hal_spin_lock_irqsave(&lock); if (urb == hcd->status_urb) { hcd->status_urb = NULL; urb->hcpriv = NULL; } else { urb = NULL; /* wasn't fully queued */ } if (urb) { usb_hcd_giveback_urb(hcd, urb); } hal_spin_unlock_irqrestore(&lock, sr); } done: return rc; }
2e5ccffb3d15ffd1e5180eb18d11d7bb69dbcaed
7744859512f027ef0da8b1bde0f8518e631b98eb
/soh/assets/scenes/dungeons/MIZUsin/MIZUsin_room_17.h
d231ac6eba95b179d665abcfa10d7f704cb93466
[]
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
4,138
h
MIZUsin_room_17.h
#pragma once #include "align_asset_macro.h" #define dMIZUsin_room_17DL_003458 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_003458" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_003458[] = dMIZUsin_room_17DL_003458; #define dMIZUsin_room_17DL_0041C8 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_0041C8" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_0041C8[] = dMIZUsin_room_17DL_0041C8; #define dMIZUsin_room_17DL_001010 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_001010" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_001010[] = dMIZUsin_room_17DL_001010; #define dMIZUsin_room_17Tex_006AA8 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17Tex_006AA8" static const ALIGN_ASSET(2) char MIZUsin_room_17Tex_006AA8[] = dMIZUsin_room_17Tex_006AA8; #define dMIZUsin_room_17Tex_007AA8 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17Tex_007AA8" static const ALIGN_ASSET(2) char MIZUsin_room_17Tex_007AA8[] = dMIZUsin_room_17Tex_007AA8; #define dMIZUsin_room_17Tex_0072A8 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17Tex_0072A8" static const ALIGN_ASSET(2) char MIZUsin_room_17Tex_0072A8[] = dMIZUsin_room_17Tex_0072A8; #define dMIZUsin_room_17Tex_0082A8 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17Tex_0082A8" static const ALIGN_ASSET(2) char MIZUsin_room_17Tex_0082A8[] = dMIZUsin_room_17Tex_0082A8; #define dMIZUsin_room_17DL_005928 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_005928" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_005928[] = dMIZUsin_room_17DL_005928; #define dMIZUsin_room_17DL_0056E8 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_0056E8" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_0056E8[] = dMIZUsin_room_17DL_0056E8; #define dMIZUsin_room_17Tex_005AA8 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17Tex_005AA8" static const ALIGN_ASSET(2) char MIZUsin_room_17Tex_005AA8[] = dMIZUsin_room_17Tex_005AA8; #define dMIZUsin_room_17DL_0016E0 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_0016E0" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_0016E0[] = dMIZUsin_room_17DL_0016E0; #define dMIZUsin_room_17Tex_0062A8 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17Tex_0062A8" static const ALIGN_ASSET(2) char MIZUsin_room_17Tex_0062A8[] = dMIZUsin_room_17Tex_0062A8; #define dMIZUsin_room_17DL_001910 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_001910" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_001910[] = dMIZUsin_room_17DL_001910; #define dMIZUsin_room_17DL_003B00 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_003B00" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_003B00[] = dMIZUsin_room_17DL_003B00; #define dMIZUsin_room_17DL_002C70 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_002C70" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_002C70[] = dMIZUsin_room_17DL_002C70; #define dMIZUsin_room_17DL_0038C0 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_0038C0" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_0038C0[] = dMIZUsin_room_17DL_0038C0; #define dMIZUsin_room_17DL_0025F8 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_0025F8" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_0025F8[] = dMIZUsin_room_17DL_0025F8; #define dMIZUsin_room_17DL_005118 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_005118" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_005118[] = dMIZUsin_room_17DL_005118; #define dMIZUsin_room_17DL_002910 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_002910" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_002910[] = dMIZUsin_room_17DL_002910; #define dMIZUsin_room_17DL_0054E0 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_0054E0" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_0054E0[] = dMIZUsin_room_17DL_0054E0; #define dMIZUsin_room_17DL_0020B8 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_0020B8" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_0020B8[] = dMIZUsin_room_17DL_0020B8; #define dMIZUsin_room_17DL_004B30 "__OTR__scenes/nonmq/MIZUsin_scene/MIZUsin_room_17DL_004B30" static const ALIGN_ASSET(2) char MIZUsin_room_17DL_004B30[] = dMIZUsin_room_17DL_004B30;
51616bc54e6bcb2ca1214176b5caf9c60ff262a6
8838eb997879add5759b6dfb23f9a646464e53ca
/src/compat/linux/include/linux/if_ether.h
b785e1bccd74d8d2e63d24d9421ba49a2911605b
[ "BSD-2-Clause" ]
permissive
embox/embox
d6aacec876978522f01cdc4b8de37a668c6f4c80
98e3c06e33f3fdac10a29c069c20775568e0a6d1
refs/heads/master
2023-09-04T03:02:20.165042
2023-09-02T14:55:31
2023-09-02T14:55:31
33,078,138
1,087
325
BSD-2-Clause
2023-09-14T16:58:34
2015-03-29T15:27:48
C
UTF-8
C
false
false
239
h
if_ether.h
/** * @file * @brief linux wrapper * * @date 19.01.14 * @author Ilia Vaprol */ #ifndef COMPAT_LINUX_LINUX_IF_ETHER_H_ #define COMPAT_LINUX_LINUX_IF_ETHER_H_ #include <net/l2/ethernet.h> #endif /* COMPAT_LINUX_LINUX_IF_ETHER_H_ */
4f9842af41e484e45113e851db6e2cd606192dd2
cb80ffbfe6b12be3f42322537aff3552fd9239f2
/examples/core/core_loading_thread.c
0538dcee31a54b95bcdb6d8af48cd18c7c1e378a
[ "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
6,049
c
core_loading_thread.c
/******************************************************************************************* * * raylib [core] example - loading thread * * NOTE: This example requires linking with pthreads library on MinGW, * it can be accomplished passing -static parameter to compiler * * Example originally created with raylib 2.5, last time updated with raylib 3.0 * * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * * Copyright (c) 2014-2023 Ramon Santamaria (@raysan5) * ********************************************************************************************/ #include "raylib.h" // WARNING: This example does not build on Windows with MSVC compiler #include "pthread.h" // POSIX style threads management #include <stdatomic.h> // C11 atomic data types #include <time.h> // Required for: clock() // Using C11 atomics for synchronization // NOTE: A plain bool (or any plain data type for that matter) can't be used for inter-thread synchronization static atomic_bool dataLoaded = false; // Data Loaded completion indicator static void *LoadDataThread(void *arg); // Loading data thread function declaration static atomic_int dataProgress = 0; // Data progress accumulator //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread"); pthread_t threadId; // Loading data thread id enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING; int framesCounter = 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 //---------------------------------------------------------------------------------- switch (state) { case STATE_WAITING: { if (IsKeyPressed(KEY_ENTER)) { int error = pthread_create(&threadId, NULL, &LoadDataThread, NULL); if (error != 0) TraceLog(LOG_ERROR, "Error creating loading thread"); else TraceLog(LOG_INFO, "Loading thread initialized successfully"); state = STATE_LOADING; } } break; case STATE_LOADING: { framesCounter++; if (atomic_load_explicit(&dataLoaded, memory_order_relaxed)) { framesCounter = 0; int error = pthread_join(threadId, NULL); if (error != 0) TraceLog(LOG_ERROR, "Error joining loading thread"); else TraceLog(LOG_INFO, "Loading thread terminated successfully"); state = STATE_FINISHED; } } break; case STATE_FINISHED: { if (IsKeyPressed(KEY_ENTER)) { // Reset everything to launch again atomic_store_explicit(&dataLoaded, false, memory_order_relaxed); atomic_store_explicit(&dataProgress, 0, memory_order_relaxed); state = STATE_WAITING; } } break; default: break; } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); switch (state) { case STATE_WAITING: DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY); break; case STATE_LOADING: { DrawRectangle(150, 200, atomic_load_explicit(&dataProgress, memory_order_relaxed), 60, SKYBLUE); if ((framesCounter/15)%2) DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE); } break; case STATE_FINISHED: { DrawRectangle(150, 200, 500, 60, LIME); DrawText("DATA LOADED!", 250, 210, 40, GREEN); } break; default: break; } DrawRectangleLines(150, 200, 500, 60, DARKGRAY); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; } // Loading data thread function definition static void *LoadDataThread(void *arg) { int timeCounter = 0; // Time counted in ms clock_t prevTime = clock(); // Previous time // We simulate data loading with a time counter for 5 seconds while (timeCounter < 5000) { clock_t currentTime = clock() - prevTime; timeCounter = currentTime*1000/CLOCKS_PER_SEC; // We accumulate time over a global variable to be used in // main thread as a progress bar atomic_store_explicit(&dataProgress, timeCounter/10, memory_order_relaxed); } // When data has finished loading, we set global variable atomic_store_explicit(&dataLoaded, true, memory_order_relaxed); return NULL; }
12ddc625ce517ac4210d72afc4fb8e7337d04912
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/cris/include/asm/switch_to.h
d842e1163ba1edf1b61b99995007c7a326ba4b37
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
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
410
h
switch_to.h
#ifndef __ASM_CRIS_SWITCH_TO_H #define __ASM_CRIS_SWITCH_TO_H /* the switch_to macro calls resume, an asm function in entry.S which does the actual * task switching. */ extern struct task_struct *resume(struct task_struct *prev, struct task_struct *next, int); #define switch_to(prev,next,last) last = resume(prev,next, \ (int)&((struct task_struct *)0)->thread) #endif /* __ASM_CRIS_SWITCH_TO_H */
c1403e60406a960afc52824c5bb7c7d2d18543fd
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/mn10300/kernel/traps.c
a7a987c7954f0a8abeecb8016b2f0379dbf28bf8
[ "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
17,258
c
traps.c
/* MN10300 Exception handling * * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. * Modified by David Howells (dhowells@redhat.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public Licence * as published by the Free Software Foundation; either version * 2 of the Licence, or (at your option) any later version. */ #include <linux/sched.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/errno.h> #include <linux/ptrace.h> #include <linux/timer.h> #include <linux/mm.h> #include <linux/smp.h> #include <linux/init.h> #include <linux/delay.h> #include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/kallsyms.h> #include <linux/pci.h> #include <linux/kdebug.h> #include <linux/bug.h> #include <linux/irq.h> #include <linux/export.h> #include <asm/processor.h> #include <linux/uaccess.h> #include <asm/io.h> #include <linux/atomic.h> #include <asm/smp.h> #include <asm/pgalloc.h> #include <asm/cacheflush.h> #include <asm/cpu-regs.h> #include <asm/busctl-regs.h> #include <unit/leds.h> #include <asm/fpu.h> #include <asm/sections.h> #include <asm/debugger.h> #include "internal.h" #if (CONFIG_INTERRUPT_VECTOR_BASE & 0xffffff) #error "INTERRUPT_VECTOR_BASE not aligned to 16MiB boundary!" #endif int kstack_depth_to_print = 24; spinlock_t die_lock = __SPIN_LOCK_UNLOCKED(die_lock); struct exception_to_signal_map { u8 signo; u32 si_code; }; static const struct exception_to_signal_map exception_to_signal_map[256] = { /* MMU exceptions */ [EXCEP_ITLBMISS >> 3] = { 0, 0 }, [EXCEP_DTLBMISS >> 3] = { 0, 0 }, [EXCEP_IAERROR >> 3] = { 0, 0 }, [EXCEP_DAERROR >> 3] = { 0, 0 }, /* system exceptions */ [EXCEP_TRAP >> 3] = { SIGTRAP, TRAP_BRKPT }, [EXCEP_ISTEP >> 3] = { SIGTRAP, TRAP_TRACE }, /* Monitor */ [EXCEP_IBREAK >> 3] = { SIGTRAP, TRAP_HWBKPT }, /* Monitor */ [EXCEP_OBREAK >> 3] = { SIGTRAP, TRAP_HWBKPT }, /* Monitor */ [EXCEP_PRIVINS >> 3] = { SIGILL, ILL_PRVOPC }, [EXCEP_UNIMPINS >> 3] = { SIGILL, ILL_ILLOPC }, [EXCEP_UNIMPEXINS >> 3] = { SIGILL, ILL_ILLOPC }, [EXCEP_MEMERR >> 3] = { SIGSEGV, SEGV_ACCERR }, [EXCEP_MISALIGN >> 3] = { SIGBUS, BUS_ADRALN }, [EXCEP_BUSERROR >> 3] = { SIGBUS, BUS_ADRERR }, [EXCEP_ILLINSACC >> 3] = { SIGSEGV, SEGV_ACCERR }, [EXCEP_ILLDATACC >> 3] = { SIGSEGV, SEGV_ACCERR }, [EXCEP_IOINSACC >> 3] = { SIGSEGV, SEGV_ACCERR }, [EXCEP_PRIVINSACC >> 3] = { SIGSEGV, SEGV_ACCERR }, /* userspace */ [EXCEP_PRIVDATACC >> 3] = { SIGSEGV, SEGV_ACCERR }, /* userspace */ [EXCEP_DATINSACC >> 3] = { SIGSEGV, SEGV_ACCERR }, [EXCEP_DOUBLE_FAULT >> 3] = { SIGILL, ILL_BADSTK }, /* FPU exceptions */ [EXCEP_FPU_DISABLED >> 3] = { SIGILL, ILL_COPROC }, [EXCEP_FPU_UNIMPINS >> 3] = { SIGILL, ILL_COPROC }, [EXCEP_FPU_OPERATION >> 3] = { SIGFPE, FPE_INTDIV }, /* interrupts */ [EXCEP_WDT >> 3] = { SIGALRM, 0 }, [EXCEP_NMI >> 3] = { SIGQUIT, 0 }, [EXCEP_IRQ_LEVEL0 >> 3] = { SIGINT, 0 }, [EXCEP_IRQ_LEVEL1 >> 3] = { 0, 0 }, [EXCEP_IRQ_LEVEL2 >> 3] = { 0, 0 }, [EXCEP_IRQ_LEVEL3 >> 3] = { 0, 0 }, [EXCEP_IRQ_LEVEL4 >> 3] = { 0, 0 }, [EXCEP_IRQ_LEVEL5 >> 3] = { 0, 0 }, [EXCEP_IRQ_LEVEL6 >> 3] = { 0, 0 }, /* system calls */ [EXCEP_SYSCALL0 >> 3] = { 0, 0 }, [EXCEP_SYSCALL1 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL2 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL3 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL4 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL5 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL6 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL7 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL8 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL9 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL10 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL11 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL12 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL13 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL14 >> 3] = { SIGILL, ILL_ILLTRP }, [EXCEP_SYSCALL15 >> 3] = { SIGABRT, 0 }, }; /* * Handle kernel exceptions. * * See if there's a fixup handler we can force a jump to when an exception * happens due to something kernel code did */ int die_if_no_fixup(const char *str, struct pt_regs *regs, enum exception_code code) { u8 opcode; int signo, si_code; if (user_mode(regs)) return 0; peripheral_leds_display_exception(code); signo = exception_to_signal_map[code >> 3].signo; si_code = exception_to_signal_map[code >> 3].si_code; switch (code) { /* see if we can fixup the kernel accessing memory */ case EXCEP_ITLBMISS: case EXCEP_DTLBMISS: case EXCEP_IAERROR: case EXCEP_DAERROR: case EXCEP_MEMERR: case EXCEP_MISALIGN: case EXCEP_BUSERROR: case EXCEP_ILLDATACC: case EXCEP_IOINSACC: case EXCEP_PRIVINSACC: case EXCEP_PRIVDATACC: case EXCEP_DATINSACC: if (fixup_exception(regs)) return 1; break; case EXCEP_TRAP: case EXCEP_UNIMPINS: if (probe_kernel_read(&opcode, (u8 *)regs->pc, 1) < 0) break; if (opcode == 0xff) { if (notify_die(DIE_BREAKPOINT, str, regs, code, 0, 0)) return 1; if (at_debugger_breakpoint(regs)) regs->pc++; signo = SIGTRAP; si_code = TRAP_BRKPT; } break; case EXCEP_SYSCALL1 ... EXCEP_SYSCALL14: /* syscall return addr is _after_ the instruction */ regs->pc -= 2; break; case EXCEP_SYSCALL15: if (report_bug(regs->pc, regs) == BUG_TRAP_TYPE_WARN) return 1; /* syscall return addr is _after_ the instruction */ regs->pc -= 2; break; default: break; } if (debugger_intercept(code, signo, si_code, regs) == 0) return 1; if (notify_die(DIE_GPF, str, regs, code, 0, 0)) return 1; /* make the process die as the last resort */ die(str, regs, code); } /* * General exception handler */ asmlinkage void handle_exception(struct pt_regs *regs, u32 intcode) { siginfo_t info; /* deal with kernel exceptions here */ if (die_if_no_fixup(NULL, regs, intcode)) return; /* otherwise it's a userspace exception */ info.si_signo = exception_to_signal_map[intcode >> 3].signo; info.si_code = exception_to_signal_map[intcode >> 3].si_code; info.si_errno = 0; info.si_addr = (void *) regs->pc; force_sig_info(info.si_signo, &info, current); } /* * handle NMI */ asmlinkage void nmi(struct pt_regs *regs, enum exception_code code) { /* see if gdbstub wants to deal with it */ if (debugger_intercept(code, SIGQUIT, 0, regs)) return; printk(KERN_WARNING "--- Register Dump ---\n"); show_registers(regs); printk(KERN_WARNING "---------------------\n"); } /* * show a stack trace from the specified stack pointer */ void show_trace(unsigned long *sp) { unsigned long bottom, stack, addr, fp, raslot; printk(KERN_EMERG "\nCall Trace:\n"); //stack = (unsigned long)sp; asm("mov sp,%0" : "=a"(stack)); asm("mov a3,%0" : "=r"(fp)); raslot = ULONG_MAX; bottom = (stack + THREAD_SIZE) & ~(THREAD_SIZE - 1); for (; stack < bottom; stack += sizeof(addr)) { addr = *(unsigned long *)stack; if (stack == fp) { if (addr > stack && addr < bottom) { fp = addr; raslot = stack + sizeof(addr); continue; } fp = 0; raslot = ULONG_MAX; } if (__kernel_text_address(addr)) { printk(" [<%08lx>]", addr); if (stack >= raslot) raslot = ULONG_MAX; else printk(" ?"); print_symbol(" %s", addr); printk("\n"); } } printk("\n"); } /* * show the raw stack from the specified stack pointer */ void show_stack(struct task_struct *task, unsigned long *sp) { unsigned long *stack; int i; if (!sp) sp = (unsigned long *) &sp; stack = sp; printk(KERN_EMERG "Stack:"); for (i = 0; i < kstack_depth_to_print; i++) { if (((long) stack & (THREAD_SIZE - 1)) == 0) break; if ((i % 8) == 0) printk(KERN_EMERG " "); printk("%08lx ", *stack++); } show_trace(sp); } /* * dump the register file in the specified exception frame */ void show_registers_only(struct pt_regs *regs) { unsigned long ssp; ssp = (unsigned long) regs + sizeof(*regs); printk(KERN_EMERG "PC: %08lx EPSW: %08lx SSP: %08lx mode: %s\n", regs->pc, regs->epsw, ssp, user_mode(regs) ? "User" : "Super"); printk(KERN_EMERG "d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n", regs->d0, regs->d1, regs->d2, regs->d3); printk(KERN_EMERG "a0: %08lx a1: %08lx a2: %08lx a3: %08lx\n", regs->a0, regs->a1, regs->a2, regs->a3); printk(KERN_EMERG "e0: %08lx e1: %08lx e2: %08lx e3: %08lx\n", regs->e0, regs->e1, regs->e2, regs->e3); printk(KERN_EMERG "e4: %08lx e5: %08lx e6: %08lx e7: %08lx\n", regs->e4, regs->e5, regs->e6, regs->e7); printk(KERN_EMERG "lar: %08lx lir: %08lx mdr: %08lx usp: %08lx\n", regs->lar, regs->lir, regs->mdr, regs->sp); printk(KERN_EMERG "cvf: %08lx crl: %08lx crh: %08lx drq: %08lx\n", regs->mcvf, regs->mcrl, regs->mcrh, regs->mdrq); printk(KERN_EMERG "threadinfo=%p task=%p)\n", current_thread_info(), current); if ((unsigned long) current >= PAGE_OFFSET && (unsigned long) current < (unsigned long)high_memory) printk(KERN_EMERG "Process %s (pid: %d)\n", current->comm, current->pid); #ifdef CONFIG_SMP printk(KERN_EMERG "CPUID: %08x\n", CPUID); #endif printk(KERN_EMERG "CPUP: %04hx\n", CPUP); printk(KERN_EMERG "TBR: %08x\n", TBR); printk(KERN_EMERG "DEAR: %08x\n", DEAR); printk(KERN_EMERG "sISR: %08x\n", sISR); printk(KERN_EMERG "NMICR: %04hx\n", NMICR); printk(KERN_EMERG "BCBERR: %08x\n", BCBERR); printk(KERN_EMERG "BCBEAR: %08x\n", BCBEAR); printk(KERN_EMERG "MMUFCR: %08x\n", MMUFCR); printk(KERN_EMERG "IPTEU : %08x IPTEL2: %08x\n", IPTEU, IPTEL2); printk(KERN_EMERG "DPTEU: %08x DPTEL2: %08x\n", DPTEU, DPTEL2); } /* * dump the registers and the stack */ void show_registers(struct pt_regs *regs) { unsigned long sp; int i; show_registers_only(regs); if (!user_mode(regs)) sp = (unsigned long) regs + sizeof(*regs); else sp = regs->sp; /* when in-kernel, we also print out the stack and code at the * time of the fault.. */ if (!user_mode(regs)) { printk(KERN_EMERG "\n"); show_stack(current, (unsigned long *) sp); #if 0 printk(KERN_EMERG "\nCode: "); if (regs->pc < PAGE_OFFSET) goto bad; for (i = 0; i < 20; i++) { unsigned char c; if (__get_user(c, &((unsigned char *) regs->pc)[i])) goto bad; printk("%02x ", c); } #else i = 0; #endif } printk("\n"); return; #if 0 bad: printk(KERN_EMERG " Bad PC value."); break; #endif } /* * */ void show_trace_task(struct task_struct *tsk) { unsigned long sp = tsk->thread.sp; /* User space on another CPU? */ if ((sp ^ (unsigned long) tsk) & (PAGE_MASK << 1)) return; show_trace((unsigned long *) sp); } /* * note the untimely death of part of the kernel */ void die(const char *str, struct pt_regs *regs, enum exception_code code) { console_verbose(); spin_lock_irq(&die_lock); printk(KERN_EMERG "\n%s: %04x\n", str, code & 0xffff); show_registers(regs); if (regs->pc >= 0x02000000 && regs->pc < 0x04000000 && (regs->epsw & (EPSW_IM | EPSW_IE)) != (EPSW_IM | EPSW_IE)) { printk(KERN_EMERG "Exception in usermode interrupt handler\n"); printk(KERN_EMERG "\nPlease connect to kernel debugger !!\n"); asm volatile ("0: bra 0b"); } spin_unlock_irq(&die_lock); do_exit(SIGSEGV); } /* * display the register file when the stack pointer gets clobbered */ asmlinkage void do_double_fault(struct pt_regs *regs) { struct task_struct *tsk = current; strcpy(tsk->comm, "emergency tsk"); tsk->pid = 0; console_verbose(); printk(KERN_EMERG "--- double fault ---\n"); show_registers(regs); } /* * asynchronous bus error (external, usually I/O DMA) */ asmlinkage void io_bus_error(u32 bcberr, u32 bcbear, struct pt_regs *regs) { console_verbose(); printk(KERN_EMERG "Asynchronous I/O Bus Error\n"); printk(KERN_EMERG "==========================\n"); if (bcberr & BCBERR_BEME) printk(KERN_EMERG "- Multiple recorded errors\n"); printk(KERN_EMERG "- Faulting Buses:%s%s%s\n", bcberr & BCBERR_BEMR_CI ? " CPU-Ins-Fetch" : "", bcberr & BCBERR_BEMR_CD ? " CPU-Data" : "", bcberr & BCBERR_BEMR_DMA ? " DMA" : ""); printk(KERN_EMERG "- %s %s access made to %s at address %08x\n", bcberr & BCBERR_BEBST ? "Burst" : "Single", bcberr & BCBERR_BERW ? "Read" : "Write", bcberr & BCBERR_BESB_MON ? "Monitor Space" : bcberr & BCBERR_BESB_IO ? "Internal CPU I/O Space" : bcberr & BCBERR_BESB_EX ? "External I/O Bus" : bcberr & BCBERR_BESB_OPEX ? "External Memory Bus" : "On Chip Memory", bcbear ); printk(KERN_EMERG "- Detected by the %s\n", bcberr&BCBERR_BESD ? "Bus Control Unit" : "Slave Bus"); #ifdef CONFIG_PCI #define BRIDGEREGB(X) (*(volatile __u8 *)(0xBE040000 + (X))) #define BRIDGEREGW(X) (*(volatile __u16 *)(0xBE040000 + (X))) #define BRIDGEREGL(X) (*(volatile __u32 *)(0xBE040000 + (X))) printk(KERN_EMERG "- PCI Memory Paging Reg: %08x\n", *(volatile __u32 *) (0xBFFFFFF4)); printk(KERN_EMERG "- PCI Bridge Base Address 0: %08x\n", BRIDGEREGL(PCI_BASE_ADDRESS_0)); printk(KERN_EMERG "- PCI Bridge AMPCI Base Address: %08x\n", BRIDGEREGL(0x48)); printk(KERN_EMERG "- PCI Bridge Command: %04hx\n", BRIDGEREGW(PCI_COMMAND)); printk(KERN_EMERG "- PCI Bridge Status: %04hx\n", BRIDGEREGW(PCI_STATUS)); printk(KERN_EMERG "- PCI Bridge Int Status: %08hx\n", BRIDGEREGL(0x4c)); #endif printk(KERN_EMERG "\n"); show_registers(regs); panic("Halted due to asynchronous I/O Bus Error\n"); } /* * handle an exception for which a handler has not yet been installed */ asmlinkage void uninitialised_exception(struct pt_regs *regs, enum exception_code code) { /* see if gdbstub wants to deal with it */ if (debugger_intercept(code, SIGSYS, 0, regs) == 0) return; peripheral_leds_display_exception(code); printk(KERN_EMERG "Uninitialised Exception 0x%04x\n", code & 0xFFFF); show_registers(regs); for (;;) continue; } /* * set an interrupt stub to jump to a handler * ! NOTE: this does *not* flush the caches */ void __init __set_intr_stub(enum exception_code code, void *handler) { unsigned long addr; u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code); addr = (unsigned long) handler - (unsigned long) vector; vector[0] = 0xdc; /* JMP handler */ vector[1] = addr; vector[2] = addr >> 8; vector[3] = addr >> 16; vector[4] = addr >> 24; vector[5] = 0xcb; vector[6] = 0xcb; vector[7] = 0xcb; } /* * set an interrupt stub to jump to a handler */ void __init set_intr_stub(enum exception_code code, void *handler) { unsigned long addr; u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code); unsigned long flags; addr = (unsigned long) handler - (unsigned long) vector; flags = arch_local_cli_save(); vector[0] = 0xdc; /* JMP handler */ vector[1] = addr; vector[2] = addr >> 8; vector[3] = addr >> 16; vector[4] = addr >> 24; vector[5] = 0xcb; vector[6] = 0xcb; vector[7] = 0xcb; arch_local_irq_restore(flags); #ifndef CONFIG_MN10300_CACHE_SNOOP mn10300_dcache_flush_inv(); mn10300_icache_inv(); #endif } /* * initialise the exception table */ void __init trap_init(void) { set_excp_vector(EXCEP_TRAP, handle_exception); set_excp_vector(EXCEP_ISTEP, handle_exception); set_excp_vector(EXCEP_IBREAK, handle_exception); set_excp_vector(EXCEP_OBREAK, handle_exception); set_excp_vector(EXCEP_PRIVINS, handle_exception); set_excp_vector(EXCEP_UNIMPINS, handle_exception); set_excp_vector(EXCEP_UNIMPEXINS, handle_exception); set_excp_vector(EXCEP_MEMERR, handle_exception); set_excp_vector(EXCEP_MISALIGN, misalignment); set_excp_vector(EXCEP_BUSERROR, handle_exception); set_excp_vector(EXCEP_ILLINSACC, handle_exception); set_excp_vector(EXCEP_ILLDATACC, handle_exception); set_excp_vector(EXCEP_IOINSACC, handle_exception); set_excp_vector(EXCEP_PRIVINSACC, handle_exception); set_excp_vector(EXCEP_PRIVDATACC, handle_exception); set_excp_vector(EXCEP_DATINSACC, handle_exception); set_excp_vector(EXCEP_FPU_UNIMPINS, handle_exception); set_excp_vector(EXCEP_FPU_OPERATION, fpu_exception); set_excp_vector(EXCEP_NMI, nmi); set_excp_vector(EXCEP_SYSCALL1, handle_exception); set_excp_vector(EXCEP_SYSCALL2, handle_exception); set_excp_vector(EXCEP_SYSCALL3, handle_exception); set_excp_vector(EXCEP_SYSCALL4, handle_exception); set_excp_vector(EXCEP_SYSCALL5, handle_exception); set_excp_vector(EXCEP_SYSCALL6, handle_exception); set_excp_vector(EXCEP_SYSCALL7, handle_exception); set_excp_vector(EXCEP_SYSCALL8, handle_exception); set_excp_vector(EXCEP_SYSCALL9, handle_exception); set_excp_vector(EXCEP_SYSCALL10, handle_exception); set_excp_vector(EXCEP_SYSCALL11, handle_exception); set_excp_vector(EXCEP_SYSCALL12, handle_exception); set_excp_vector(EXCEP_SYSCALL13, handle_exception); set_excp_vector(EXCEP_SYSCALL14, handle_exception); set_excp_vector(EXCEP_SYSCALL15, handle_exception); } /* * determine if a program counter value is a valid bug address */ int is_valid_bugaddr(unsigned long pc) { return pc >= PAGE_OFFSET; }
6254a53d42fd9ed9465ea5239894dcc2949eac94
fa4dc69bc2b887a91a9ae0eb319d8abf7194e1bf
/msock.c
c493bba8c97ca24a8545016010c89743f89e0d7c
[ "MIT" ]
permissive
sustrik/libdill
83effaf3e3e2ab51ca24dad81126c0c9e01a3bac
32d0e8b733416208e0412a56490332772bc5c6e1
refs/heads/master
2023-08-23T18:12:06.941810
2022-08-10T09:33:51
2022-08-10T09:33:51
49,762,853
1,779
192
MIT
2022-12-02T16:48:56
2016-01-16T06:46:15
C
UTF-8
C
false
false
2,527
c
msock.c
/* Copyright (c) 2017 Martin Sustrik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <errno.h> #include <stddef.h> #define DILL_DISABLE_RAW_NAMES #include "libdillimpl.h" #include "utils.h" dill_unique_id(dill_msock_type); int dill_msend(int s, const void *buf, size_t len, int64_t deadline) { struct dill_msock_vfs *m = dill_hquery(s, dill_msock_type); if(dill_slow(!m)) return -1; struct dill_iolist iol = {(void*)buf, len, NULL, 0}; return m->msendl(m, &iol, &iol, deadline); } ssize_t dill_mrecv(int s, void *buf, size_t len, int64_t deadline) { struct dill_msock_vfs *m = dill_hquery(s, dill_msock_type); if(dill_slow(!m)) return -1; struct dill_iolist iol = {buf, len, NULL, 0}; return m->mrecvl(m, &iol, &iol, deadline); } int dill_msendl(int s, struct dill_iolist *first, struct dill_iolist *last, int64_t deadline) { struct dill_msock_vfs *m = dill_hquery(s, dill_msock_type); if(dill_slow(!m)) return -1; if(dill_slow(!first || !last || last->iol_next)) { errno = EINVAL; return -1;} return m->msendl(m, first, last, deadline); } ssize_t dill_mrecvl(int s, struct dill_iolist *first, struct dill_iolist *last, int64_t deadline) { struct dill_msock_vfs *m = dill_hquery(s, dill_msock_type); if(dill_slow(!m)) return -1; if(dill_slow((last && last->iol_next) || (!first && last) || (first && !last))) { errno = EINVAL; return -1;} return m->mrecvl(m, first, last, deadline); }
aa3ad297ecad139cbd4d76b8efad3d48a2734e9b
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/arm64/kernel/opcodes.c
ceb5a04a1e12e23d162745e63f0a9b5830aae237
[ "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,308
c
opcodes.c
/* * Copied from linux/arch/arm/kernel/opcodes.c * * A32 condition code lookup feature moved from nwfpe/fpopcode.c * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/module.h> #include <asm/opcodes.h> #define ARM_OPCODE_CONDITION_UNCOND 0xf /* * condition code lookup table * index into the table is test code: EQ, NE, ... LT, GT, AL, NV * * bit position in short is condition code: NZCV */ static const unsigned short cc_map[16] = { 0xF0F0, /* EQ == Z set */ 0x0F0F, /* NE */ 0xCCCC, /* CS == C set */ 0x3333, /* CC */ 0xFF00, /* MI == N set */ 0x00FF, /* PL */ 0xAAAA, /* VS == V set */ 0x5555, /* VC */ 0x0C0C, /* HI == C set && Z clear */ 0xF3F3, /* LS == C clear || Z set */ 0xAA55, /* GE == (N==V) */ 0x55AA, /* LT == (N!=V) */ 0x0A05, /* GT == (!Z && (N==V)) */ 0xF5FA, /* LE == (Z || (N!=V)) */ 0xFFFF, /* AL always */ 0 /* NV */ }; /* * Returns: * ARM_OPCODE_CONDTEST_FAIL - if condition fails * ARM_OPCODE_CONDTEST_PASS - if condition passes (including AL) * ARM_OPCODE_CONDTEST_UNCOND - if NV condition, or separate unconditional * opcode space from v5 onwards * * Code that tests whether a conditional instruction would pass its condition * check should check that return value == ARM_OPCODE_CONDTEST_PASS. * * Code that tests if a condition means that the instruction would be executed * (regardless of conditional or unconditional) should instead check that the * return value != ARM_OPCODE_CONDTEST_FAIL. */ asmlinkage unsigned int arm_check_condition(u32 opcode, u64 psr) { u32 cc_bits = opcode >> 28; u32 psr_cond = (u32)(psr & 0xffffffff) >> 28; unsigned int ret; if (cc_bits != ARM_OPCODE_CONDITION_UNCOND) { if ((cc_map[cc_bits] >> (psr_cond)) & 1) ret = ARM_OPCODE_CONDTEST_PASS; else ret = ARM_OPCODE_CONDTEST_FAIL; } else { ret = ARM_OPCODE_CONDTEST_UNCOND; } return ret; } EXPORT_SYMBOL_GPL(arm_check_condition);
6181cc72507299a12bf93c61c1be744d0995e7b1
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/net/bind918/patches/patch-bin_named_main.c
5019909568fe476d1bf7b3345266fd38bfe1d4e7
[]
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
723
c
patch-bin_named_main.c
$NetBSD: patch-bin_named_main.c,v 1.1 2022/12/11 01:57:55 sekiya Exp $ * Based on NetBSD, add support for blocklist(blacklist). --- bin/named/main.c.orig 2022-11-08 07:17:42.008258118 +0900 +++ bin/named/main.c 2022-12-10 10:08:58.013997862 +0900 @@ -98,6 +98,10 @@ #ifdef HAVE_LIBNGHTTP2 #include <nghttp2/nghttp2.h> #endif +#if defined(HAVE_BLACKLIST_H) || defined(HAVE_BLOCKLIST_H) +#include <ns/pfilter.h> +#endif + /* * Include header files for database drivers here. */ @@ -1530,6 +1534,10 @@ parse_command_line(argc, argv); +#if defined(HAVE_BLACKLIST_H) || defined(HAVE_BLOCKLIST_H) + pfilter_enable(); +#endif + #ifdef ENABLE_AFL if (named_g_fuzz_type != isc_fuzz_none) { named_fuzz_setup();
4af83b29af0ebb46b895c88bd90349a5e3c3b069
39568e19301a7a112398be542154950af25591de
/third_party/coremark/top_earlgrey/cvt.c
333e8ead2533bc82b14239aa3ad7a0667f8919a5
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
lowRISC/opentitan
493995bc7cf7cb3aee486a5203af3fd62bba3bfc
51f6017b8425b14d5a4aa9abace8fe5a25ef08c8
refs/heads/master
2023-08-31T22:05:09.425796
2023-08-14T14:52:15
2023-08-31T20:31:13
204,516,692
2,077
634
Apache-2.0
2023-09-14T21:16:21
2019-08-26T16:30:16
SystemVerilog
UTF-8
C
false
false
2,770
c
cvt.c
/* Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC) 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> #define CVTBUFSIZE 80 static char CVTBUF[CVTBUFSIZE]; static char * cvt(double arg, int ndigits, int *decpt, int *sign, char *buf, int eflag) { int r2; double fi, fj; char * p, *p1; if (ndigits < 0) ndigits = 0; if (ndigits >= CVTBUFSIZE - 1) ndigits = CVTBUFSIZE - 2; r2 = 0; *sign = 0; p = &buf[0]; if (arg < 0) { *sign = 1; arg = -arg; } arg = modf(arg, &fi); p1 = &buf[CVTBUFSIZE]; if (fi != 0) { p1 = &buf[CVTBUFSIZE]; while (fi != 0) { fj = modf(fi / 10, &fi); *--p1 = (int)((fj + .03) * 10) + '0'; r2++; } while (p1 < &buf[CVTBUFSIZE]) *p++ = *p1++; } else if (arg > 0) { while ((fj = arg * 10) < 1) { arg = fj; r2--; } } p1 = &buf[ndigits]; if (eflag == 0) p1 += r2; *decpt = r2; if (p1 < &buf[0]) { buf[0] = '\0'; return buf; } while (p <= p1 && p < &buf[CVTBUFSIZE]) { arg *= 10; arg = modf(arg, &fj); *p++ = (int)fj + '0'; } if (p1 >= &buf[CVTBUFSIZE]) { buf[CVTBUFSIZE - 1] = '\0'; return buf; } p = p1; *p1 += 5; while (*p1 > '9') { *p1 = '0'; if (p1 > buf) ++*--p1; else { *p1 = '1'; (*decpt)++; if (eflag == 0) { if (p > buf) *p = '0'; p++; } } } *p = '\0'; return buf; } char * ecvt(double arg, int ndigits, int *decpt, int *sign) { return cvt(arg, ndigits, decpt, sign, CVTBUF, 1); } char * ecvtbuf(double arg, int ndigits, int *decpt, int *sign, char *buf) { return cvt(arg, ndigits, decpt, sign, buf, 1); } char * fcvt(double arg, int ndigits, int *decpt, int *sign) { return cvt(arg, ndigits, decpt, sign, CVTBUF, 0); } char * fcvtbuf(double arg, int ndigits, int *decpt, int *sign, char *buf) { return cvt(arg, ndigits, decpt, sign, buf, 0); }
86da672ec564159f2cd2f9d94decd1a5bf62588e
fbef550c1f0206aac0582a58f7e3db945f442a9a
/Pods/Headers/Public/MIKMIDI/MIKMIDIOutputPort.h
8bc97039d6f2ac476138de5487bc2890cf4f70a3
[ "MIT" ]
permissive
Hammerspoon/hammerspoon
0f03b4dd2ef3b44ea4c0a1cd0b94fcb513b5f2b7
0ccc9d07641a660140d1d2f05b76f682b501a0e8
refs/heads/master
2023-08-19T01:26:41.898873
2023-06-20T22:52:50
2023-06-20T22:52:50
24,956,772
11,379
676
MIT
2023-06-09T02:51:33
2014-10-08T19:24:44
Objective-C
UTF-8
C
false
false
43
h
MIKMIDIOutputPort.h
../../../MIKMIDI/Source/MIKMIDIOutputPort.h
eaf37f317dbe68978d1fd6051aa8191f6d7c0266
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/ppapi/c/ppp_graphics_3d.h
03b901bc3b5338f7143abd94cc7c7ca02b291f26
[ "LicenseRef-scancode-khronos", "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C
false
false
1,064
h
ppp_graphics_3d.h
/* Copyright 2012 The Chromium Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From ppp_graphics_3d.idl modified Wed Mar 21 17:35:39 2012. */ #ifndef PPAPI_C_PPP_GRAPHICS_3D_H_ #define PPAPI_C_PPP_GRAPHICS_3D_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" #define PPP_GRAPHICS_3D_INTERFACE_1_0 "PPP_Graphics_3D;1.0" #define PPP_GRAPHICS_3D_INTERFACE PPP_GRAPHICS_3D_INTERFACE_1_0 /** * @file * Defines the <code>PPP_Graphics3D</code> struct representing a 3D graphics * context within the browser. */ /** * @addtogroup Interfaces * @{ */ /** * <code>PPP_Graphics3D</code> defines the notification interface for a 3D * graphics context. */ struct PPP_Graphics3D_1_0 { /** * Called when the OpenGL ES window is invalidated and needs to be repainted. */ void (*Graphics3DContextLost)(PP_Instance instance); }; typedef struct PPP_Graphics3D_1_0 PPP_Graphics3D; /** * @} */ #endif /* PPAPI_C_PPP_GRAPHICS_3D_H_ */
bd28b299bf05edb4676f16ae334d2a914514a921
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/drivers/power/pmic/pmic_tps65090.c
337903acec8a56c493c32543cafbe978fd8f3b2e
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "GPL-2.0-or-later" ]
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
6,313
c
pmic_tps65090.c
/* * Copyright (c) 2012 The Chromium OS Authors. * * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> #include <errno.h> #include <fdtdec.h> #include <i2c.h> #include <power/pmic.h> #include <power/tps65090_pmic.h> DECLARE_GLOBAL_DATA_PTR; #define TPS65090_NAME "TPS65090_PMIC" /* TPS65090 register addresses */ enum { REG_IRQ1 = 0, REG_CG_CTRL0 = 4, REG_CG_STATUS1 = 0xa, REG_FET1_CTRL = 0x0f, REG_FET2_CTRL, REG_FET3_CTRL, REG_FET4_CTRL, REG_FET5_CTRL, REG_FET6_CTRL, REG_FET7_CTRL, TPS65090_NUM_REGS, }; enum { IRQ1_VBATG = 1 << 3, CG_CTRL0_ENC_MASK = 0x01, MAX_FET_NUM = 7, MAX_CTRL_READ_TRIES = 5, /* TPS65090 FET_CTRL register values */ FET_CTRL_TOFET = 1 << 7, /* Timeout, startup, overload */ FET_CTRL_PGFET = 1 << 4, /* Power good for FET status */ FET_CTRL_WAIT = 3 << 2, /* Overcurrent timeout max */ FET_CTRL_ADENFET = 1 << 1, /* Enable output auto discharge */ FET_CTRL_ENFET = 1 << 0, /* Enable FET */ }; /** * Checks for a valid FET number * * @param fet_id FET number to check * @return 0 if ok, -EINVAL if FET value is out of range */ static int tps65090_check_fet(unsigned int fet_id) { if (fet_id == 0 || fet_id > MAX_FET_NUM) { debug("parameter fet_id is out of range, %u not in 1 ~ %u\n", fet_id, MAX_FET_NUM); return -EINVAL; } return 0; } /** * Set the power state for a FET * * @param pmic pmic structure for the tps65090 * @param fet_id Fet number to set (1..MAX_FET_NUM) * @param set 1 to power on FET, 0 to power off * @return -EIO if we got a comms error, -EAGAIN if the FET failed to * change state. If all is ok, returns 0. */ static int tps65090_fet_set(struct pmic *pmic, int fet_id, bool set) { int retry; u32 reg, value; value = FET_CTRL_ADENFET | FET_CTRL_WAIT; if (set) value |= FET_CTRL_ENFET; if (pmic_reg_write(pmic, REG_FET1_CTRL + fet_id - 1, value)) return -EIO; /* Try reading until we get a result */ for (retry = 0; retry < MAX_CTRL_READ_TRIES; retry++) { if (pmic_reg_read(pmic, REG_FET1_CTRL + fet_id - 1, &reg)) return -EIO; /* Check that the fet went into the expected state */ if (!!(reg & FET_CTRL_PGFET) == set) return 0; /* If we got a timeout, there is no point in waiting longer */ if (reg & FET_CTRL_TOFET) break; mdelay(1); } debug("FET %d: Power good should have set to %d but reg=%#02x\n", fet_id, set, reg); return -EAGAIN; } int tps65090_fet_enable(unsigned int fet_id) { struct pmic *pmic; ulong start; int loops; int ret; ret = tps65090_check_fet(fet_id); if (ret) return ret; pmic = pmic_get(TPS65090_NAME); if (!pmic) return -EACCES; start = get_timer(0); for (loops = 0;; loops++) { ret = tps65090_fet_set(pmic, fet_id, true); if (!ret) break; if (get_timer(start) > 100) break; /* Turn it off and try again until we time out */ tps65090_fet_set(pmic, fet_id, false); } if (ret) debug("%s: FET%d failed to power on: time=%lums, loops=%d\n", __func__, fet_id, get_timer(start), loops); else if (loops) debug("%s: FET%d powered on after %lums, loops=%d\n", __func__, fet_id, get_timer(start), loops); /* * Unfortunately, there are some conditions where the power * good bit will be 0, but the fet still comes up. One such * case occurs with the lcd backlight. We'll just return 0 here * and assume that the fet will eventually come up. */ if (ret == -EAGAIN) ret = 0; return ret; } int tps65090_fet_disable(unsigned int fet_id) { struct pmic *pmic; int ret; ret = tps65090_check_fet(fet_id); if (ret) return ret; pmic = pmic_get(TPS65090_NAME); if (!pmic) return -EACCES; ret = tps65090_fet_set(pmic, fet_id, false); return ret; } int tps65090_fet_is_enabled(unsigned int fet_id) { struct pmic *pmic; u32 reg; int ret; ret = tps65090_check_fet(fet_id); if (ret) return ret; pmic = pmic_get(TPS65090_NAME); if (!pmic) return -ENODEV; ret = pmic_reg_read(pmic, REG_FET1_CTRL + fet_id - 1, &reg); if (ret) { debug("fail to read FET%u_CTRL register over I2C", fet_id); return -EIO; } return reg & FET_CTRL_ENFET; } int tps65090_get_charging(void) { struct pmic *pmic; u32 val; int ret; pmic = pmic_get(TPS65090_NAME); if (!pmic) return -EACCES; ret = pmic_reg_read(pmic, REG_CG_CTRL0, &val); if (ret) return ret; return !!(val & CG_CTRL0_ENC_MASK); } static int tps65090_charger_state(struct pmic *pmic, int state, int current) { u32 val; int ret; ret = pmic_reg_read(pmic, REG_CG_CTRL0, &val); if (!ret) { if (state == PMIC_CHARGER_ENABLE) val |= CG_CTRL0_ENC_MASK; else val &= ~CG_CTRL0_ENC_MASK; ret = pmic_reg_write(pmic, REG_CG_CTRL0, val); } if (ret) { debug("%s: Failed to read/write register\n", __func__); return ret; } return 0; } int tps65090_get_status(void) { struct pmic *pmic; u32 val; int ret; pmic = pmic_get(TPS65090_NAME); if (!pmic) return -EACCES; ret = pmic_reg_read(pmic, REG_CG_STATUS1, &val); if (ret) return ret; return val; } static int tps65090_charger_bat_present(struct pmic *pmic) { u32 val; int ret; ret = pmic_reg_read(pmic, REG_IRQ1, &val); if (ret) return ret; return !!(val & IRQ1_VBATG); } static struct power_chrg power_chrg_pmic_ops = { .chrg_bat_present = tps65090_charger_bat_present, .chrg_state = tps65090_charger_state, }; int tps65090_init(void) { struct pmic *p; int bus; int addr; const void *blob = gd->fdt_blob; int node, parent; node = fdtdec_next_compatible(blob, 0, COMPAT_TI_TPS65090); if (node < 0) { debug("PMIC: No node for PMIC Chip in device tree\n"); debug("node = %d\n", node); return -ENODEV; } parent = fdt_parent_offset(blob, node); if (parent < 0) { debug("%s: Cannot find node parent\n", __func__); return -EINVAL; } bus = i2c_get_bus_num_fdt(parent); if (bus < 0) { debug("%s: Cannot find I2C bus\n", __func__); return -ENOENT; } addr = fdtdec_get_int(blob, node, "reg", TPS65090_I2C_ADDR); p = pmic_alloc(); if (!p) { printf("%s: POWER allocation error!\n", __func__); return -ENOMEM; } p->name = TPS65090_NAME; p->bus = bus; p->interface = PMIC_I2C; p->number_of_regs = TPS65090_NUM_REGS; p->hw.i2c.addr = addr; p->hw.i2c.tx_num = 1; p->chrg = &power_chrg_pmic_ops; puts("TPS65090 PMIC init\n"); return 0; }
1482b07223511b00780d02a0a836b39460800ac4
afd2087e80478010d9df66e78280f75e1ff17d45
/aten/src/ATen/native/quantized/cpu/qnnpack/src/qnnpack/x8zip.h
7f3430dc50b4892141bc81ba8eacd4d5758c903c
[ "BSD-3-Clause", "BSD-2-Clause", "LicenseRef-scancode-secret-labs-2011", "LicenseRef-scancode-generic-cla", "BSL-1.0", "Apache-2.0" ]
permissive
pytorch/pytorch
7521ac50c47d18b916ae47a6592c4646c2cb69b5
a6f7dd4707ac116c0f5fb5f44f42429f38d23ab4
refs/heads/main
2023-08-03T05:05:02.822937
2023-08-03T00:40:33
2023-08-03T04:14:52
65,600,975
77,092
24,610
NOASSERTION
2023-09-14T21:58:39
2016-08-13T05:26:41
Python
UTF-8
C
false
false
1,253
h
x8zip.h
/* * Copyright (c) Facebook, Inc. and its affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <stddef.h> #include <stdint.h> #include <qnnpack/common.h> #include <qnnpack/params.h> #ifdef __cplusplus extern "C" { #endif #define DECLARE_PYTORCH_XZIPC_UKERNEL_FUNCTION(fn_name) \ PYTORCH_QNNP_INTERNAL void fn_name(size_t n, const void* x, void* y); DECLARE_PYTORCH_XZIPC_UKERNEL_FUNCTION(pytorch_qnnp_x8zip_x2__neon) DECLARE_PYTORCH_XZIPC_UKERNEL_FUNCTION(pytorch_qnnp_x8zip_x2__sse2) DECLARE_PYTORCH_XZIPC_UKERNEL_FUNCTION(pytorch_qnnp_x8zip_x3__neon) DECLARE_PYTORCH_XZIPC_UKERNEL_FUNCTION(pytorch_qnnp_x8zip_x3__sse2) DECLARE_PYTORCH_XZIPC_UKERNEL_FUNCTION(pytorch_qnnp_x8zip_x4__neon) DECLARE_PYTORCH_XZIPC_UKERNEL_FUNCTION(pytorch_qnnp_x8zip_x4__sse2) #define DECLARE_PYTORCH_XZIPV_UKERNEL_FUNCTION(fn_name) \ PYTORCH_QNNP_INTERNAL void fn_name( \ size_t n, size_t m, const void* x, void* y); DECLARE_PYTORCH_XZIPV_UKERNEL_FUNCTION(pytorch_qnnp_x8zip_xm__neon) DECLARE_PYTORCH_XZIPV_UKERNEL_FUNCTION(pytorch_qnnp_x8zip_xm__sse2) #ifdef __cplusplus } /* extern "C" */ #endif
35215d1de522469a3c852af342cd3473f38f66b0
2af283f8a587bcc3d2a744f7d86007ab2428f9bc
/src/coap/server/CoAPPlatform.c
7468cbf5e03c7cb71f6190250bbf83d032f40de5
[ "Apache-2.0" ]
permissive
aliyun/iotkit-embedded
bfda585c8a5db3fea215ad15fe7699cebde1dfc8
3010153fb53865ce3925f8e43900adbbfa358874
refs/heads/v3.0.1
2023-03-12T23:14:04.902446
2022-11-11T07:12:05
2022-11-11T09:01:43
106,364,205
544
289
Apache-2.0
2023-08-22T06:00:04
2017-10-10T03:30:08
C
UTF-8
C
false
false
2,816
c
CoAPPlatform.c
/* * Copyright (C) 2015-2018 Alibaba Group Holding Limited */ #include <stdio.h> #include <ctype.h> unsigned int platform_aton(const char *ip_str) { char c; unsigned char base; unsigned int val = 0; unsigned int parts[4] = {0}; unsigned int *pp = parts; c = *ip_str; for (;;) { /* * Collect number up to ``.''. * Values are specified as for C: * 0x=hex, 0=octal, 1-9=decimal. */ if (!isdigit(c)) return (0); val = 0; base = 10; if (c == '0') { c = *++ip_str; if (c == 'x' || c == 'X') { base = 16; c = *++ip_str; } else { base = 8; } } for (;;) { if (isdigit(c)) { val = (val * base) + (int)(c - '0'); c = *++ip_str; } else if (base == 16 && isxdigit(c)) { val = (val << 4) | (int)(c + 10 - (islower(c) ? 'a' : 'A')); c = *++ip_str; } else { break; } } if (c == '.') { /* * Internet format: * a.b.c.d * a.b.c (with c treated as 16 bits) * a.b (with b treated as 24 bits) */ if (pp >= parts + 3) return (0); *pp++ = val; c = *++ip_str; } else { break; } } /* * Check for trailing characters. */ if (c != '\0' && !isspace(c)) return (0); /* * Concoct the address according to * the number of parts specified. */ switch (pp - parts + 1) { case 0: return (0); /* initial nondigit */ case 1: /* a -- 32 bits */ break; case 2: /* a.b -- 8.24 bits */ if (val > 0xffffffUL) return (0); val |= parts[0] << 24; break; case 3: /* a.b.c -- 8.8.16 bits */ if (val > 0xffff) return (0); val |= (parts[0] << 24) | (parts[1] << 16); break; case 4: /* a.b.c.d -- 8.8.8.8 bits */ if (val > 0xff) return (0); val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); break; default: break; } return val; } int platform_is_multicast(const char *ip_str) { unsigned int addr_in; addr_in = platform_aton(ip_str); return (addr_in > 0xE00000FF && addr_in <= 0xEFFFFFFF); }
cb2bc32f8a69f09b277a85fe8981e8e34769fe97
6ff1ea5c8fb7534e1ce0c6d2aac273ffb1c5babd
/bin/ch/HostConfigFlagsList.h
2e07b6704aa85617474cba1947a33b9c47aafa94
[ "MIT" ]
permissive
chakra-core/ChakraCore
654e775f42e093e1ebbbc066212bbcdfccab15d5
c3ead3f8a6e0bb8e32e043adc091c68cba5935e9
refs/heads/master
2023-09-02T08:10:10.008146
2023-03-21T21:22:11
2023-03-22T08:47:02
49,086,513
855
185
MIT
2023-07-05T00:15:56
2016-01-05T19:05:31
JavaScript
UTF-8
C
false
false
2,168
h
HostConfigFlagsList.h
//------------------------------------------------------------------------------------------------------- // Copyright (C) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. //------------------------------------------------------------------------------------------------------- #ifdef FLAG FLAG(BSTR, dbgbaseline, "Baseline file to compare debugger output", NULL) FLAG(bool, DebugLaunch, "Create the test debugger and execute test in the debug mode", false) FLAG(BSTR, GenerateLibraryByteCodeHeader, "Generate bytecode header file from library code", NULL) FLAG(bool, GenerateParserStateCache, "Parse source file to create parser state cache and write it to file or console", false) FLAG(bool, UseParserStateCache, "Create parser state cache while parsing and use it during script execution", false) FLAG(int, InspectMaxStringLength, "Max string length to dump in locals inspection", 16) FLAG(BSTR, Serialized, "If source is UTF8, deserializes from bytecode file", NULL) FLAG(bool, OOPJIT, "Run JIT in a separate process", false) FLAG(bool, EnsureCloseJITServer, "JIT process will be force closed when ch is terminated", true) FLAG(bool, IgnoreScriptErrorCode, "Don't return error code on script error", false) FLAG(bool, MuteHostErrorMsg, "Mute host error output, e.g. module load failures", false) FLAG(bool, TraceHostCallback, "Output traces for host callbacks", false) FLAG(bool, Test262, "load Test262 harness", false) FLAG(bool, Module, "load the script as a module", false) FLAG(bool, TrackRejectedPromises, "Enable tracking of unhandled promise rejections", false) FLAG(BSTR, CustomConfigFile, "Custom config file to be used to pass in additional flags to Chakra", NULL) FLAG(bool, ExecuteWithBgParse, "Load script with bgparse (note: requires bgparse and parserstatecache be on as well)", false) #undef FLAG #endif
7b23e240f63943e073a5e4d6d5af31b4cf48541d
61be4a7bfc24468a1227ea797150520c83257844
/event/Demo004_0.c
2dbb4d6aa3c3a588ec72c0c9d176538c88931e3b
[]
no_license
MrCheeze/botw-tools
491e6a2d06191efa7fc7048aefb48b3b38a59a52
9a9e845beed87f5ec417c01e515d0fa01366366c
refs/heads/master
2022-06-26T01:34:38.353269
2022-06-20T14:52:01
2022-06-20T14:53:26
85,882,713
238
92
null
2017-05-01T22:15:30
2017-03-22T22:34:34
Python
UTF-8
C
false
false
76,408
c
Demo004_0.c
-------- EventFlow: Demo004_0 -------- Actor: GameRomCamera entrypoint: None() actions: ['Demo_CameraAnimFlow', 'Demo_AnimFlowForMapTower', 'Demo_PlayerHideOff', 'Demo_GameCamera'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: EventSystemActor entrypoint: None() actions: ['Demo_WaitFrame', 'Demo_FlagON', 'Demo_WarpPlayer', 'Demo_WarpPlayerToDestination', 'Demo_CallDemo', 'Demo_AdvanceTime', 'Demo_ForceSetPlayerSavePosAngle', 'Demo_CloseItemMenu', 'Demo_IncreaseGameDataInt', 'Demo_DownloadSensorMoveIcon', 'Demo_DownloadShiekSensor', 'Demo_StartShiekSensorGaugeDemo'] queries: ['CheckFlag'] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: GameROMPlayer entrypoint: None() actions: ['Demo_Unequip', 'Demo_PlayASAdapt', 'Demo_ResetBoneCtrl', 'Demo_LookAtObjectNow'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0, 'Weapon': '', 'DisableWeapon': False, 'Shield': '', 'DisableShield': False, 'Bow': '', 'DisableBow': False, 'ArmorHead': '', 'ArmorUpper': '', 'ArmorLower': '', 'DisableSheikPad': False} Actor: NPC_DRCVoice entrypoint: None() actions: ['Demo_Talk', 'Demo_OpenMessageDialog'] queries: [] params: {'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0, 'CreateMode': 1} Actor: NPC_GodVoice entrypoint: None() actions: ['Demo_Talk'] queries: [] params: {'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0, 'CreateMode': 1} Actor: SoundTriggerTag entrypoint: None() actions: ['Demo_SoundTrigger'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: Item_Conductor entrypoint: None() actions: ['Demo_Bind'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: SceneSoundCtrlTag entrypoint: None() actions: ['Demo_SetStartProc', 'Demo_Ctrl'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01_First entrypoint: None() actions: ['Demo_XLinkEventCreate', 'Demo_PlayASForDemo'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal07_Before] entrypoint: None() actions: ['Demo_PlayASForDemo'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal08] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody07] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal02] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal03] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal04] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal05] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal06] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal09] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal10] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal11] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal12] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal13] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal14] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal15] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing08] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase08] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint08] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody08] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal07] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase07] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint07] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing02] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase02] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint02] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody02] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing03] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint03] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody03] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerLong_A_01[TowerBase03] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing04] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase04] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint04] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody04] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing05] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase05] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint05] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody05] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing06] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase06] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint06] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody06] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing09] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase09] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint09] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody09] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing10] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase10] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint10] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody10] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing11] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase11] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint11] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody11] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing12] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase12] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint12] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody12] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing13] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase13] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint13] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody13] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing14] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase14] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint14] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody14] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing15] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase15] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint15] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody15] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: Fader entrypoint: None() actions: ['Demo_FadeOut', 'Demo_FadeIn'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: EventSystemActor[C10-1] entrypoint: None() actions: ['Demo_WaitFrame'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: EventControllerRumble entrypoint: None() actions: ['Demo_RumbleMiddle', 'Demo_RumbleLarge'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: EventMessageTransmitter1 entrypoint: None() actions: ['Demo_Msg2CameraKeepState'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: Starter entrypoint: None() actions: ['Demo_SendSignal', 'Demo_StartMapOpenDemo', 'Demo_WaitUntilMapOpenDemoEnd'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: EventCameraRumble entrypoint: None() actions: ['Demo_Rumble'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: EventBgmCtrlTag entrypoint: None() actions: ['Demo_Start'] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminal_A_01[TowerTerminal01] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTowerWingBefore_A_01[TowerWing01] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01[TowerBase01] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: DgnObj_WarpPoint_A_01[TowerWarpPoint01] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_DownloadTerminalBody_A_01[TowerTerminalBody01] entrypoint: None() actions: [] queries: [] params: {'CreateMode': 0, 'IsGrounding': False, 'IsWorld': False, 'PosX': 0.0, 'PosY': 0.0, 'PosZ': 0.0, 'RotX': 0.0, 'RotY': 0.0, 'RotZ': 0.0} Actor: FldObj_MapTower_A_01_First[C01(FldObj_MapTower_A_01_First)] entrypoint: C01(FldObj_MapTower_A_01_First) actions: [] queries: [] params: None Actor: FldObj_DownloadTerminal_A_01[C03(FldObj_DownloadTerminal_A_01)] entrypoint: C03(FldObj_DownloadTerminal_A_01) actions: [] queries: [] params: None Actor: FldObj_MapTowerWingBefore_A_01[C04(FldObj_MapTowerWingBefore_A_01)] entrypoint: C04(FldObj_MapTowerWingBefore_A_01) actions: ['Demo_XLinkEventCreate', 'Demo_PlayASForDemo'] queries: [] params: None Actor: FldObj_MapTower_A_01[C04(FldObj_MapTower_A_01)] entrypoint: C04(FldObj_MapTower_A_01) actions: ['Demo_XLinkEventCreate', 'Demo_PlayASForDemo'] queries: [] params: None Actor: DgnObj_WarpPoint_A_01[C05(DgnObj_WarpPoint_A_01)] entrypoint: C05(DgnObj_WarpPoint_A_01) actions: ['Demo_XLinkEventCreate', 'Demo_PlayASForDemo'] queries: [] params: None Actor: FldObj_MapTower_A_01[C06(FldObj_MapTower_A_01)] entrypoint: C06(FldObj_MapTower_A_01) actions: ['Demo_PlayASForDemo'] queries: [] params: None Actor: FldObj_DownloadTerminal_A_01[C06(FldObj_DownloadTerminal_A_01)] entrypoint: C06(FldObj_DownloadTerminal_A_01) actions: ['Demo_TrigNullASPlay', 'Demo_PlayASForDemo', 'Demo_OnWaitRevival'] queries: [] params: None Actor: DgnObj_WarpPoint_A_01[C06(DgnObj_WarpPoint_A_01)] entrypoint: C06(DgnObj_WarpPoint_A_01) actions: ['Demo_Idling'] queries: [] params: None Actor: FldObj_DownloadTerminalBody_A_01[C08(FldObj_DownloadTerminalBody_A_01)] entrypoint: C08(FldObj_DownloadTerminalBody_A_01) actions: ['Demo_XLinkEventCreate', 'Demo_PlayASForDemo'] queries: [] params: None Actor: FldObj_DownloadTerminalBody_A_01[C10(FldObj_DownloadTerminalBody_A_01)] entrypoint: C10(FldObj_DownloadTerminalBody_A_01) actions: ['Demo_PlayASForDemo', 'Demo_XLinkEventFade'] queries: [] params: None Actor: FldObj_DownloadTerminal_A_01[C10(FldObj_DownloadTerminal_A_01)] entrypoint: C10(FldObj_DownloadTerminal_A_01) actions: [] queries: [] params: None Actor: FldObj_DownloadTerminal_A_01[C11(FldObj_DownloadTerminal_A_01)] entrypoint: C11(FldObj_DownloadTerminal_A_01) actions: [] queries: [] params: None Actor: FldObj_DownloadTerminalBody_A_01[MapTower07_After(FldObj_DownloadTerminalBody_A_01)] entrypoint: MapTower07_After(FldObj_DownloadTerminalBody_A_01) actions: [] queries: [] params: None Actor: FldObj_DownloadTerminal_A_01[MapTower07_After(FldObj_DownloadTerminal_A_01)] entrypoint: MapTower07_After(FldObj_DownloadTerminal_A_01) actions: [] queries: [] params: None Actor: FldObj_MapTower_A_01[MapTower07_After(FldObj_MapTower_A_01)] entrypoint: MapTower07_After(FldObj_MapTower_A_01) actions: [] queries: [] params: None Actor: DgnObj_WarpPoint_A_01[MapTower07_After(DgnObj_WarpPoint_A_01)] entrypoint: MapTower07_After(DgnObj_WarpPoint_A_01) actions: [] queries: [] params: None Actor: FldObj_DownloadTerminal_A_01[Demo004_0_Main(FldObj_DownloadTerminal_A_01)] entrypoint: Demo004_0_Main(FldObj_DownloadTerminal_A_01) actions: ['Demo_PlayASForDemo'] queries: [] params: None Actor: FldObj_MapTowerWingBefore_A_01[Demo004_0_Main(FldObj_MapTowerWingBefore_A_01)] entrypoint: Demo004_0_Main(FldObj_MapTowerWingBefore_A_01) actions: [] queries: [] params: None Actor: FldObj_MapTower_A_01[Demo004_0_Main(FldObj_MapTower_A_01)] entrypoint: Demo004_0_Main(FldObj_MapTower_A_01) actions: [] queries: [] params: None Actor: DgnObj_WarpPoint_A_01[Demo004_0_Main(DgnObj_WarpPoint_A_01)] entrypoint: Demo004_0_Main(DgnObj_WarpPoint_A_01) actions: [] queries: [] params: None Actor: FldObj_DownloadTerminalBody_A_01[Demo004_0_Main(FldObj_DownloadTerminalBody_A_01)] entrypoint: Demo004_0_Main(FldObj_DownloadTerminalBody_A_01) actions: [] queries: [] params: None void Demo004_0_FirstTower() { EventMessageTransmitter1.Demo_Msg2CameraKeepState({'IsWaitFinish': True}) FldObj_DownloadTerminal_A_01[TowerTerminal07_Before].Demo_PlayASForDemo({'IsWaitFinish': False, 'ASName': 'PlayerCloseInWait', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) call C01({'CameraTagetTerminal_UniqueName': 'TowerTerminal07_Before', 'FldObj_MapTower_A_01_First': ActorIdentifier(name="FldObj_MapTower_A_01_First")}) call C02() call Demo166() EventSystemActor.Demo_FlagON({'IsWaitFinish': True, 'FlagName': 'IsPlayed_Demo166_0'}) call MapTower07_After({'CameraTagetTerminal_UniqueName': 'TowerTerminal07', 'ShiekerStoneBindTargetActorName': 'FldObj_DownloadTerminal_A_01', 'ShiekerStoneBindTargetUniqueName': 'TowerTerminal07', 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody07"), 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal07"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase07"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint07")}) EventSystemActor.Demo_FlagON({'IsWaitFinish': True, 'FlagName': 'MapTower_DemoFirst'}) EventSystemActor.Demo_CallDemo({'IsWaitFinish': True, 'EntryPointName': '', 'DemoName': 'Demo164_0', 'EndFade': 0}) EventSystemActor.Demo_ForceSetPlayerSavePosAngle({'UniqueName': 'DownloadEnd_PlayerSavePos', 'AnchorName': 'ForceSetPosDirAutoSaveAnchor', 'IsWaitFinish': True}) EventSystemActor.Demo_FlagON({'IsWaitFinish': True, 'FlagName': 'IsPlayed_Demo164_0'}) } void C01() { fork { EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 30}) NPC_DRCVoice.Demo_OpenMessageDialog({'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text021', 'IsCloseMessageDialog': True, 'IsWaitFinish': True, 'ASName': '', 'IsBecomingSpeaker': False, 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'MessageOpenDelayTime': 0}) } fork { GameROMPlayer.Demo_PlayASAdapt({'ASName': 'Demo004_0-C01-Link-A-0', 'IsWaitFinish': False, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'IsOneTimeEndKeep': False, 'TargetIndex': -1, 'SeqBank': 0, 'NoErrorCheck': False, 'MorphingFrame': -1.0, 'ClothWarpMode': -1}) } { EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 270}) call Demo041_0.DownloadTermial_Activate({'ActorName': 'FldObj_DownloadTerminal_A_01', 'SheikerStoneTarget_UniqueName': 'TowerTerminal07_Before', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal07_Before")}) } NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsCloseMessageDialog': False, 'IsBecomingSpeaker': False, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text015', 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'MessageOpenDelayTime': 0}) NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsCloseMessageDialog': True, 'IsBecomingSpeaker': False, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text016', 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'MessageOpenDelayTime': 0}) SceneSoundCtrlTag.Demo_Ctrl({'BgmCtrlType': 'None', 'SeCtrlType': 'WorldMute', 'IsWaitFinish': True}) fork { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'SceneName': 'C01-1', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'UniqueName': 'TowerTerminal07_Before', 'TargetActor': 3, 'ActorName': 'FldObj_DownloadTerminal_A_01', 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } { EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 30}) fork { FldObj_MapTower_A_01_First.Demo_XLinkEventCreate({'IsWaitFinish': False, 'ELinkKey': 'Demo_EmblemShining', 'SLinkKey': 'Demo_EmblemShining', 'IsTargetDemoSLinkUser': False}) FldObj_MapTower_A_01_First.Demo_PlayASForDemo({'IsWaitFinish': False, 'ASName': 'Appear', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': 0, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) SoundTriggerTag.Demo_SoundTrigger({'IsWaitFinish': False, 'Sound': 'Demo004_0_EarthQuake', 'SoundDelay': 0, 'SLinkInst': ''}) } { EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 45}) EventControllerRumble.Demo_RumbleMiddle({'IsWaitFinish': True, 'Count': 4}) } } } void C03() { fork { GameROMPlayer.Demo_PlayASAdapt({'ASName': 'SheikPadSet', 'IsWaitFinish': False, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'IsOneTimeEndKeep': False, 'TargetIndex': -1, 'SeqBank': 0, 'ClothWarpMode': 1, 'MorphingFrame': -1.0, 'NoErrorCheck': False}) } { call Demo041_0.DownloadTermial_Activate({'FldObj_DownloadTerminal_A_01': 'FldObj_DownloadTerminal_A_01', 'ActorName': 'SheikerStoneTarget_ActorName', 'SheikerStoneTarget_UniqueName': 'SheikerStoneTarget_UniqueName'}) } NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsBecomingSpeaker': False, 'IsCloseMessageDialog': True, 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'MessageOpenDelayTime': 0, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text015'}) SceneSoundCtrlTag.Demo_Ctrl({'BgmCtrlType': 'None', 'SeCtrlType': 'WorldMute', 'IsWaitFinish': True}) } void C04() { fork { GameRomCamera.Demo_AnimFlowForMapTower({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'SceneName': 'C04-2', 'ActorName': '', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0, 'TargetActor': -1}) } { EventBgmCtrlTag.Demo_Start({'BgmName': 'SheikersTowerOpenBgm', 'IsWaitFinish': True}) } { GameROMPlayer.Demo_PlayASAdapt({'IsWaitFinish': False, 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'ASName': 'Demo004_0-C04-Link-A-0', 'MorphingFrame': -1.0, 'IsOneTimeEndKeep': True, 'NoErrorCheck': False}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 45}) FldObj_MapTowerWingBefore_A_01[C04(FldObj_MapTowerWingBefore_A_01)].Demo_XLinkEventCreate({'IsWaitFinish': True, 'ELinkKey': '', 'SLinkKey': 'Demo_TowerActive', 'IsTargetDemoSLinkUser': False}) fork { FldObj_MapTowerWingBefore_A_01[C04(FldObj_MapTowerWingBefore_A_01)].Demo_PlayASForDemo({'IsWaitFinish': True, 'ASName': 'Open', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) FldObj_MapTowerWingBefore_A_01[C04(FldObj_MapTowerWingBefore_A_01)].Demo_PlayASForDemo({'IsWaitFinish': False, 'ASName': 'OpenWait', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) } { EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 150}) FldObj_MapTower_A_01[C04(FldObj_MapTower_A_01)].Demo_XLinkEventCreate({'IsWaitFinish': True, 'ELinkKey': 'Demo_TowerActive', 'SLinkKey': 'Demo_TowerActive', 'IsTargetDemoSLinkUser': False}) FldObj_MapTower_A_01[C04(FldObj_MapTower_A_01)].Demo_PlayASForDemo({'IsWaitFinish': True, 'ASName': 'Activate', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': 0, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) FldObj_MapTower_A_01[C04(FldObj_MapTower_A_01)].Demo_PlayASForDemo({'IsWaitFinish': False, 'ASName': 'ActivatedWait', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': 0, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) } } Starter.Demo_SendSignal({'SignalType': 0, 'Value': True, 'IsWaitFinish': False}) } void C05() { SceneSoundCtrlTag.Demo_Ctrl({'BgmCtrlType': 'None', 'IsWaitFinish': True, 'SeCtrlType': 'WorldMuteOff'}) fork { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'SceneName': 'C05-1', 'TargetActor': -1, 'ActorName': '', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } { DgnObj_WarpPoint_A_01[C05(DgnObj_WarpPoint_A_01)].Demo_XLinkEventCreate({'IsWaitFinish': True, 'ELinkKey': 'WarpPointActivate', 'SLinkKey': 'WarpPointActivate', 'IsTargetDemoSLinkUser': False}) DgnObj_WarpPoint_A_01[C05(DgnObj_WarpPoint_A_01)].Demo_PlayASForDemo({'ASName': 'On', 'IsIgnoreSame': True, 'SeqBank': 0, 'TargetIndex': 0, 'IsEnabledAnimeDriven': 0, 'IsWaitFinish': True, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) DgnObj_WarpPoint_A_01[C05(DgnObj_WarpPoint_A_01)].Demo_PlayASForDemo({'IsWaitFinish': False, 'IsIgnoreSame': True, 'SeqBank': 0, 'TargetIndex': 0, 'IsEnabledAnimeDriven': 0, 'ASName': 'OnWait', 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) } { GameROMPlayer.Demo_PlayASAdapt({'IsWaitFinish': False, 'ASName': 'Demo004_0-C05-Link-A-0', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0, 'IsOneTimeEndKeep': True, 'NoErrorCheck': False}) } EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 60}) } void C02() { fork { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'SceneName': 'C02-0', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'TargetActor': 3, 'ActorName': 'FldObj_DownloadTerminal_A_01', 'UniqueName': 'TowerTerminal07_Before', 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } { GameROMPlayer.Demo_PlayASAdapt({'IsWaitFinish': False, 'ASName': 'Demo004_0-C02-Link-A-0', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'MorphingFrame': -1.0, 'IsOneTimeEndKeep': True, 'NoErrorCheck': False, 'ClothWarpMode': -2}) } { EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 49}) EventCameraRumble.Demo_Rumble({'Pattern': 1, 'IsWaitFinish': True, 'Sideways': False, 'Power': 1.0, 'Count': 1}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 6}) Fader.Demo_FadeOut({'IsWaitFinish': True, 'Color': 1, 'DispMode': 'NoLogo', 'Frame': 0}) } { EventControllerRumble.Demo_RumbleMiddle({'IsWaitFinish': True, 'Count': 9}) EventControllerRumble.Demo_RumbleLarge({'IsWaitFinish': True, 'Count': 2}) } EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 60}) } void C06() { EventSystemActor.Demo_FlagON({'IsWaitFinish': False, 'FlagName': 'MapTower_07'}) EventSystemActor.Demo_FlagON({'FlagName': 'MapTower_07_Demo', 'IsWaitFinish': False}) fork { FldObj_MapTower_A_01[C06(FldObj_MapTower_A_01)].Demo_PlayASForDemo({'IsWaitFinish': False, 'ASName': 'ActivatedWait', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': 0, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) } { fork { FldObj_DownloadTerminal_A_01[C06(FldObj_DownloadTerminal_A_01)].Demo_TrigNullASPlay({'IsWaitFinish': False, 'SequenceBank': 0, 'IsIgnoreSame': False, 'ASSlot': 1, 'ASName': 'ActivateEnd_Skl'}) } { FldObj_DownloadTerminal_A_01[C06(FldObj_DownloadTerminal_A_01)].Demo_PlayASForDemo({'IsWaitFinish': False, 'ASName': 'ActivateEnd', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) } FldObj_DownloadTerminal_A_01[C06(FldObj_DownloadTerminal_A_01)].Demo_OnWaitRevival({'IsWaitFinish': False}) } EventSystemActor.Demo_WarpPlayer({'IsWaitFinish': True, 'WarpDestPosName': 'MapTower07_Demo', 'WarpDestMapName': 'E-6'}) fork { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'SceneName': 'C06-0', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'TargetActor': 3, 'ActorName': 'FldObj_DownloadTerminal_A_01', 'UniqueName': 'TowerTerminal07', 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 130}) GameRomCamera.Demo_CameraAnimFlow({'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'SceneName': 'C07-0', 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'TargetActor': 3, 'ActorName': 'FldObj_DownloadTerminal_A_01', 'UniqueName': 'TowerTerminal07', 'IsWaitFinish': False, 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 30}) EventSystemActor.Demo_IncreaseGameDataInt({'IsWaitFinish': False, 'GameDataIntName': 'Location_MapTower07', 'Value': 1}) Starter.Demo_SendSignal({'SignalType': 0, 'Value': True, 'IsWaitFinish': False}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 210}) } { GameROMPlayer.Demo_PlayASAdapt({'IsWaitFinish': False, 'ASName': 'Demo004_0-C06-Link-A-0', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0, 'IsOneTimeEndKeep': True, 'NoErrorCheck': False}) } { DgnObj_WarpPoint_A_01[C06(DgnObj_WarpPoint_A_01)].Demo_Idling({'IsWaitFinish': False, 'DisablePhysics': False}) } { Item_Conductor.Demo_Bind({'NodeName': 'Loc_Stone', 'RotOffsetX': 0.0, 'RotOffsetY': 0.0, 'RotOffsetZ': 0.0, 'TransOffsetX': 0.0, 'TransOffsetY': 0.0, 'TransOffsetZ': 0.0, 'ActorName': 'FldObj_DownloadTerminal_A_01', 'IsWaitFinish': False, 'UniqueName': 'TowerTerminal07'}) } { SceneSoundCtrlTag.Demo_Ctrl({'BgmCtrlType': 'None', 'SeCtrlType': 'WorldMuteOff', 'IsWaitFinish': True}) Fader.Demo_FadeIn({'IsWaitFinish': True, 'Frame': 0, 'Color': 1, 'DispMode': 'NoLogo'}) } NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsBecomingSpeaker': False, 'IsCloseMessageDialog': True, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text017', 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'MessageOpenDelayTime': 0}) } void C08() { fork { if EventSystemActor.CheckFlag({'FlagName': 'MapTower_DemoFirst'}) { fork { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'TargetActor': -1, 'ActorName': '', 'SceneName': 'C13-0', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } { GameROMPlayer.Demo_PlayASAdapt({'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'IsWaitFinish': False, 'ASName': 'SheikPadDownLoadReady', 'MorphingFrame': -1.0, 'IsOneTimeEndKeep': True, 'NoErrorCheck': False}) } } else { fork { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'TargetActor': -1, 'ActorName': '', 'SceneName': 'C08-0', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } { GameROMPlayer.Demo_PlayASAdapt({'IsWaitFinish': True, 'ASName': 'Demo004_0-C08-Link-A-0', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0, 'IsOneTimeEndKeep': True, 'NoErrorCheck': False}) } } } { EventBgmCtrlTag.Demo_Start({'BgmName': 'DownloadDemoBgm', 'IsWaitFinish': True}) } { FldObj_DownloadTerminalBody_A_01[C08(FldObj_DownloadTerminalBody_A_01)].Demo_XLinkEventCreate({'IsWaitFinish': True, 'ELinkKey': 'Start', 'SLinkKey': 'Start', 'IsTargetDemoSLinkUser': False}) FldObj_DownloadTerminalBody_A_01[C08(FldObj_DownloadTerminalBody_A_01)].Demo_PlayASForDemo({'IsWaitFinish': False, 'ASName': 'Start', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) } } void C09() { if EventSystemActor.CheckFlag({'FlagName': 'MapTower_DemoFirst'}) { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'TargetActor': -1, 'ActorName': '', 'SceneName': 'C09-1', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } else { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'TargetActor': -1, 'ActorName': '', 'SceneName': 'C09-0', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 50}) } void C10() { fork { if EventSystemActor.CheckFlag({'FlagName': 'MapTower_DemoFirst'}) { fork { GameRomCamera.Demo_CameraAnimFlow({'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'ActorName': '', 'SceneName': 'C10-1', 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'IsWaitFinish': True, 'TargetActor': -1, 'TargetActorPosReferenceMode': 1, 'TargetActorDirReferenceMode': 0, 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) EventSystemActor[C10-1].Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 100}) GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'SceneName': 'C11-1', 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'ActorName': 'FldObj_DownloadTerminal_A_01', 'TargetActor': 3, 'TargetActorPosReferenceMode': 2, 'TargetActorDirReferenceMode': 2, 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } { GameROMPlayer.Demo_PlayASAdapt({'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'ASName': 'SheikPadDownLoad', 'IsWaitFinish': True, 'MorphingFrame': -1.0, 'IsOneTimeEndKeep': True, 'NoErrorCheck': False}) GameROMPlayer.Demo_PlayASAdapt({'IsWaitFinish': False, 'ASName': 'SheikPadLookPad', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0, 'IsOneTimeEndKeep': True, 'NoErrorCheck': False}) } { call Demo041_0.DripCatch({'FldObj_DownloadTerminal_A_01': 'FldObj_DownloadTerminal_A_01'}) } } else { fork { GameRomCamera.Demo_CameraAnimFlow({'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'UniqueName': 'TowerTerminal07', 'TargetActorPosReferenceMode': 2, 'TargetActorDirReferenceMode': 2, 'ActorName': 'FldObj_DownloadTerminal_A_01', 'SceneName': 'C10-1', 'TargetActor': 3, 'IsWaitFinish': False, 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) EventSystemActor[C10-1].Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 125}) GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'UniqueName': 'TowerTerminal07', 'ActorName': 'FldObj_DownloadTerminal_A_01', 'SceneName': 'C11-1', 'TargetActor': 3, 'TargetActorPosReferenceMode': 2, 'TargetActorDirReferenceMode': 2, 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } { GameROMPlayer.Demo_PlayASAdapt({'ASName': 'Demo004_0-C10-Link-A-0', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'IsWaitFinish': False, 'MorphingFrame': -1.0, 'IsOneTimeEndKeep': True, 'NoErrorCheck': False}) } { call Demo041_0.DripCatch({'FldObj_DownloadTerminal_A_01': 'FldObj_DownloadTerminal_A_01'}) } } } { FldObj_DownloadTerminalBody_A_01[C10(FldObj_DownloadTerminalBody_A_01)].Demo_PlayASForDemo({'IsWaitFinish': False, 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0, 'ASName': 'ActivatedWait'}) FldObj_DownloadTerminalBody_A_01[C10(FldObj_DownloadTerminalBody_A_01)].Demo_XLinkEventFade({'IsWaitFinish': True, 'SLinkKey': '', 'ELinkKey': 'Start'}) } } void C11() { Starter.Demo_StartMapOpenDemo({'IsWaitFinish': True, 'IsPlayerClose': False}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 240}) if EventSystemActor.CheckFlag({'FlagName': 'MapTower_01'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_02'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_03'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_04'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_05'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_06'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_07'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_08'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_09'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_10'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_11'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_12'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_13'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_14'}) && EventSystemActor.CheckFlag({'FlagName': 'MapTower_15'}) { SoundTriggerTag.Demo_SoundTrigger({'Sound': 'Demo_MapDownloadComplete', 'IsWaitFinish': False, 'SoundDelay': 0, 'SLinkInst': ''}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 30}) NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsCloseMessageDialog': True, 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'IsBecomingSpeaker': True, 'MessageOpenDelayTime': 0, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text025'}) Event591: EventSystemActor.Demo_CloseItemMenu({'IsWaitFinish': True}) fork { if EventSystemActor.CheckFlag({'FlagName': 'MapTower_DemoFirst'}) { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'TargetActor': -1, 'ActorName': '', 'SceneName': 'C10-1', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'Accept1FrameDelay': False, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } else { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'TargetActor': -1, 'ActorName': '', 'SceneName': 'C10-0', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'Accept1FrameDelay': False, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } } { call Demo041_0.SheikPadSetOff({'FldObj_DownloadTerminal_A_01': 'FldObj_DownloadTerminal_A_01', 'ShiekerStoneBindTargetActorName': 'ShiekerStoneBindTargetActorName', 'ShiekerStoneBindTargetUniqueName': 'ShiekerStoneBindTargetUniqueName'}) } if EventSystemActor.CheckFlag({'FlagName': 'MapTower_DemoFirst'}) { if EventSystemActor.CheckFlag({'FlagName': 'IsStart_Obj_SheikSensor'}) { call OperationGuide.Guide_Scope() } else { GameRomCamera.Demo_GameCamera({'IsWaitFinish': True}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 30}) NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsBecomingSpeaker': True, 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'MessageOpenDelayTime': 0, 'IsCloseMessageDialog': True, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text023'}) EventSystemActor.Demo_FlagON({'IsWaitFinish': True, 'FlagName': 'MiniMapSensor_Demo'}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 15}) EventSystemActor.Demo_StartShiekSensorGaugeDemo({'ReactionNum': 1, 'IsWaitFinish': True}) NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsBecomingSpeaker': True, 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'MessageOpenDelayTime': 0, 'IsCloseMessageDialog': True, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text027'}) EventSystemActor.Demo_FlagON({'IsWaitFinish': True, 'FlagName': 'IsStart_Obj_SheikSensor'}) } } } else if EventSystemActor.CheckFlag({'FlagName': 'MapTower_DemoFirst'}) { if EventSystemActor.CheckFlag({'FlagName': 'IsGet_Obj_SheikSensor'}) { Event672: NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsCloseMessageDialog': True, 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'IsBecomingSpeaker': True, 'MessageOpenDelayTime': 0, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text026'}) goto Event591 } else { NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsCloseMessageDialog': True, 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text019', 'IsBecomingSpeaker': True, 'MessageOpenDelayTime': 0}) EventSystemActor.Demo_FlagON({'FlagName': 'IsGet_Obj_SheikSensor', 'IsWaitFinish': True}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 30}) EventSystemActor.Demo_DownloadShiekSensor({'IsWaitFinish': True}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 70}) NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsBecomingSpeaker': True, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text020', 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'MessageOpenDelayTime': 0, 'IsCloseMessageDialog': True}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 15}) EventSystemActor.Demo_DownloadSensorMoveIcon({'IsWaitFinish': True}) EventSystemActor.Demo_WaitFrame({'IsWaitFinish': True, 'Frame': 15}) goto Event591 } } else { goto Event672 } } void Demo166() { EventSystemActor.Demo_AdvanceTime({'DirectTime': 11, 'IsWaitFinish': True, 'DestTime': -1, 'PassTime': -1, 'ActReset': False}) EventSystemActor.Demo_CallDemo({'IsWaitFinish': True, 'EntryPointName': '', 'DemoName': 'Demo166_0', 'EndFade': 0}) } void C012() { fork { GameRomCamera.Demo_CameraAnimFlow({'IsWaitFinish': True, 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'TargetActor': -1, 'ActorName': '', 'SceneName': 'C12-0', 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'UniqueName': 'CameraTagetTerminal_UniqueName', 'Accept1FrameDelay': True, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } { GameROMPlayer.Demo_PlayASAdapt({'IsWaitFinish': False, 'ASName': 'Demo004_0-C12-Link-A-0', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'ClothWarpMode': 1, 'MorphingFrame': -1.0, 'IsOneTimeEndKeep': True, 'NoErrorCheck': False}) } NPC_DRCVoice.Demo_Talk({'IsWaitFinish': True, 'ASName': '', 'IsBecomingSpeaker': False, 'IsCloseMessageDialog': True, 'MessageId': 'DemoMsg/Demo004_0:Demo004_0_Text014', 'IsOverWriteLabelActorName': False, 'CloseDialogOption': 0, 'IsWaitAS': False, 'MessageOpenDelayTime': 0}) } void Demo004_0_08() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'CameraTargetTerminal_UniqueName': 'TowerTerminal08', 'SheikerStoneTarget_UniqueName': 'TowerTerminal08', 'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal08"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing08"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase08"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint08"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody08")}) } void MapTower07_After() { call C06({'FldObj_MapTower_A_01': 'FldObj_MapTower_A_01', 'FldObj_DownloadTerminal_A_01': 'FldObj_DownloadTerminal_A_01', 'DgnObj_WarpPoint_A_01': 'DgnObj_WarpPoint_A_01'}) call C08({'CameraTagetTerminal_UniqueName': 'CameraTagetTerminal_UniqueName', 'FldObj_DownloadTerminalBody_A_01': 'FldObj_DownloadTerminalBody_A_01'}) call C09({'CameraTagetTerminal_UniqueName': 'CameraTagetTerminal_UniqueName'}) call C10({'CameraTagetTerminal_UniqueName': 'CameraTagetTerminal_UniqueName', 'FldObj_DownloadTerminalBody_A_01': 'FldObj_DownloadTerminalBody_A_01', 'FldObj_DownloadTerminal_A_01': 'FldObj_DownloadTerminal_A_01'}) call C11({'CameraTagetTerminal_UniqueName': 'CameraTagetTerminal_UniqueName', 'FldObj_DownloadTerminal_A_01': 'FldObj_DownloadTerminal_A_01', 'ShiekerStoneBindTargetActorName': 'ShiekerStoneBindTargetActorName', 'ShiekerStoneBindTargetUniqueName': 'ShiekerStoneBindTargetUniqueName'}) } void Demo004_0() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_FirstTower() } void Demo004_0_Main() { FldObj_DownloadTerminal_A_01[Demo004_0_Main(FldObj_DownloadTerminal_A_01)].Demo_PlayASForDemo({'ASName': 'PlayerCloseInWait', 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'IsEnabledAnimeDriven': -1, 'IsWaitFinish': False, 'ClothWarpMode': 1, 'MorphingFrame': -1.0}) call C03({'FldObj_DownloadTerminal_A_01': 'FldObj_DownloadTerminal_A_01', 'SheikerStoneTarget_ActorName': 'SheikerStoneTarget_ActorName', 'SheikerStoneTarget_UniqueName': 'SheikerStoneTarget_UniqueName'}) call C04({'FldObj_MapTowerWingBefore_A_01': 'FldObj_MapTowerWingBefore_A_01', 'FldObj_MapTower_A_01': 'FldObj_MapTower_A_01', 'CameraTagetTerminal_UniqueName': 'CameraTargetTerminal_UniqueName'}) call C05({'DgnObj_WarpPoint_A_01': 'DgnObj_WarpPoint_A_01', 'CameraTagetTerminal_UniqueName': 'CameraTargetTerminal_UniqueName'}) call C012({'CameraTagetTerminal_UniqueName': 'CameraTargetTerminal_UniqueName'}) call C08({'CameraTagetTerminal_UniqueName': 'CameraTargetTerminal_UniqueName', 'FldObj_DownloadTerminalBody_A_01': 'FldObj_DownloadTerminalBody_A_01'}) call C09({'CameraTagetTerminal_UniqueName': 'CameraTargetTerminal_UniqueName'}) call C10({'CameraTagetTerminal_UniqueName': 'CameraTargetTerminal_UniqueName', 'FldObj_DownloadTerminalBody_A_01': 'FldObj_DownloadTerminalBody_A_01', 'FldObj_DownloadTerminal_A_01': 'FldObj_DownloadTerminal_A_01'}) call C11({'CameraTagetTerminal_UniqueName': 'CameraTargetTerminal_UniqueName', 'FldObj_DownloadTerminal_A_01': 'FldObj_DownloadTerminal_A_01', 'ShiekerStoneBindTargetActorName': 'SheikerStoneTarget_ActorName', 'ShiekerStoneBindTargetUniqueName': 'SheikerStoneTarget_UniqueName'}) } void Demo004_0_Common() { EventSystemActor.Demo_FlagON({'FlagName': 'IsDownloadDemo', 'IsWaitFinish': True}) SceneSoundCtrlTag.Demo_SetStartProc({'IsWaitFinish': True, 'BgmCtrlType': 'StopWithFade', 'SeCtrlType': 'EnvReduce'}) GameROMPlayer.Demo_Unequip({'IsWaitFinish': True}) fork { GameRomCamera.Demo_CameraAnimFlow({'SceneName': 'C01-0', 'BgCheck': False, 'CameraName': '', 'FocalLength': 0.0, 'Aperture': 0.0, 'InterpolateCount': 0.0, 'DOFUse': False, 'DOFStartFrame': 0.0, 'DOFEndFrame': 0.0, 'FocalLengthEnd': 0.0, 'ApertureEnd': 0.0, 'ActorName': '', 'IsWaitFinish': False, 'TargetActorDirReferenceMode': 0, 'DOFBlurStart': 2.0, 'DOFBlurEnd': 2.0, 'StartFrame': 0.0, 'EndFrame': -1.0, 'TargetActorPosReferenceMode': 1, 'TargetActor': -1, 'UniqueName': '', 'Accept1FrameDelay': False, 'OverwriteAt': False, 'OverwriteAtDist': 1.0}) } { GameROMPlayer.Demo_ResetBoneCtrl({'IsWaitFinish': True, 'ResetTarget': 0}) GameROMPlayer.Demo_PlayASAdapt({'ASName': 'DemoWait', 'IsWaitFinish': False, 'ClothWarpMode': 1, 'IsEnabledAnimeDriven': -1, 'IsOneTimeEndKeep': False, 'NoErrorCheck': False, 'TargetIndex': -1, 'SeqBank': 0, 'IsIgnoreSame': False, 'MorphingFrame': 0.0}) EventSystemActor.Demo_WarpPlayerToDestination({'IsWaitFinish': False, 'DestinationX': 'Arg_DestinationX', 'DestinationY': 'Arg_DestinationY', 'DestinationZ': 'Arg_DestinationZ', 'DirectionY': 'Arg_DestinationDirY'}) } GameRomCamera.Demo_PlayerHideOff({'IsWaitFinish': True}) } void Demo004_0_01() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal01"), 'CameraTargetTerminal_UniqueName': 'TowerTerminal01', 'SheikerStoneTarget_UniqueName': 'TowerTerminal01', 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing01"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase01"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint01"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody01")}) } void Demo004_0_02() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal02', 'SheikerStoneTarget_UniqueName': 'TowerTerminal02', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal02"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing02"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase02"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint02"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody02")}) } void Demo004_0_03() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal03', 'SheikerStoneTarget_UniqueName': 'TowerTerminal03', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal03"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing03"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTowerLong_A_01", sub_name="TowerBase03"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint03"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody03")}) } void Demo004_0_04() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal04', 'SheikerStoneTarget_UniqueName': 'TowerTerminal04', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal04"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing04"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase04"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint04"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody04")}) } void Demo004_0_05() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal05', 'SheikerStoneTarget_UniqueName': 'TowerTerminal05', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal05"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing05"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase05"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint05"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody05")}) } void Demo004_0_06() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal06', 'SheikerStoneTarget_UniqueName': 'TowerTerminal06', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal06"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing06"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase06"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint06"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody06")}) } void Demo004_0_09() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal09', 'SheikerStoneTarget_UniqueName': 'TowerTerminal09', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal09"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing09"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase09"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint09"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody09")}) } void Demo004_0_10() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal10', 'SheikerStoneTarget_UniqueName': 'TowerTerminal10', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal10"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing10"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase10"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint10"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody10")}) } void Demo004_0_11() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal11', 'SheikerStoneTarget_UniqueName': 'TowerTerminal11', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal11"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing11"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase11"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint11"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody11")}) } void Demo004_0_12() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal12', 'SheikerStoneTarget_UniqueName': 'TowerTerminal12', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal12"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing12"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase12"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint12"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody12")}) } void Demo004_0_13() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal13', 'SheikerStoneTarget_UniqueName': 'TowerTerminal13', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal13"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing13"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase13"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint13"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody13")}) } void Demo004_0_14() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal14', 'SheikerStoneTarget_UniqueName': 'TowerTerminal14', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal14"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing14"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase14"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint14"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody14")}) } void Demo004_0_15() { call Demo004_0_Common({'Arg_DestinationX': 'Arg_DestinationX', 'Arg_DestinationY': 'Arg_DestinationY', 'Arg_DestinationZ': 'Arg_DestinationZ', 'Arg_DestinationDirY': 'Arg_DestinationDirY'}) call Demo004_0_Main({'SheikerStoneTarget_ActorName': 'FldObj_DownloadTerminal_A_01', 'CameraTargetTerminal_UniqueName': 'TowerTerminal15', 'SheikerStoneTarget_UniqueName': 'TowerTerminal15', 'FldObj_DownloadTerminal_A_01': ActorIdentifier(name="FldObj_DownloadTerminal_A_01", sub_name="TowerTerminal15"), 'FldObj_MapTowerWingBefore_A_01': ActorIdentifier(name="FldObj_MapTowerWingBefore_A_01", sub_name="TowerWing15"), 'FldObj_MapTower_A_01': ActorIdentifier(name="FldObj_MapTower_A_01", sub_name="TowerBase15"), 'DgnObj_WarpPoint_A_01': ActorIdentifier(name="DgnObj_WarpPoint_A_01", sub_name="TowerWarpPoint15"), 'FldObj_DownloadTerminalBody_A_01': ActorIdentifier(name="FldObj_DownloadTerminalBody_A_01", sub_name="TowerTerminalBody15")}) }
b007f08ea9309d5253bbc6e77aefab0e985805d8
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/graphics/rayshade/files/patch-libray_libobj_hf.c
f313c3c73eed9ba03263a8ffc8c76a6195599a2e
[ "BSD-2-Clause" ]
permissive
freebsd/freebsd-ports
86f2e89d43913412c4f6b2be3e255bc0945eac12
605a2983f245ac63f5420e023e7dce56898ad801
refs/heads/main
2023-08-30T21:46:28.720924
2023-08-30T19:33:44
2023-08-30T19:33:44
1,803,961
916
918
NOASSERTION
2023-09-08T04:06:26
2011-05-26T11:15:35
null
UTF-8
C
false
false
279
c
patch-libray_libobj_hf.c
--- libray/libobj/hf.c.orig 1992-02-10 03:04:18 UTC +++ libray/libobj/hf.c @@ -42,7 +42,7 @@ typedef struct { Vector cp, pDX, pDY; } Trav2D; -hfTri *CreateHfTriangle(), *GetQueuedTri(); +static hfTri *CreateHfTriangle(), *GetQueuedTri(); unsigned long HFTests, HFHits;
5a8cb633d64c1da4af822d360c398bc093d42ce5
ff443629c167f318d071f62886581167c51690c4
/src/secp256k1/src/ecmult.h
326a5eeb43449039b7650f44876f80b2be4075ef
[ "MIT" ]
permissive
bitcoin/bitcoin
a618b2555d9fe5a2b613e5fec0f4b1eca3b4d86f
6f03c45f6bb5a6edaa3051968b6a1ca4f84d2ccb
refs/heads/master
2023-09-05T00:16:48.295861
2023-09-02T17:43:00
2023-09-02T17:46:33
1,181,927
77,104
33,708
MIT
2023-09-14T20:47:31
2010-12-19T15:16:43
C++
UTF-8
C
false
false
2,679
h
ecmult.h
/*********************************************************************** * Copyright (c) 2013, 2014, 2017 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ #ifndef SECP256K1_ECMULT_H #define SECP256K1_ECMULT_H #include "group.h" #include "scalar.h" #include "scratch.h" #ifndef ECMULT_WINDOW_SIZE # define ECMULT_WINDOW_SIZE 15 # ifdef DEBUG_CONFIG # pragma message DEBUG_CONFIG_MSG("ECMULT_WINDOW_SIZE undefined, assuming default value") # endif #endif #ifdef DEBUG_CONFIG # pragma message DEBUG_CONFIG_DEF(ECMULT_WINDOW_SIZE) #endif /* No one will ever need more than a window size of 24. The code might * be correct for larger values of ECMULT_WINDOW_SIZE but this is not * tested. * * The following limitations are known, and there are probably more: * If WINDOW_G > 27 and size_t has 32 bits, then the code is incorrect * because the size of the memory object that we allocate (in bytes) * will not fit in a size_t. * If WINDOW_G > 31 and int has 32 bits, then the code is incorrect * because certain expressions will overflow. */ #if ECMULT_WINDOW_SIZE < 2 || ECMULT_WINDOW_SIZE > 24 # error Set ECMULT_WINDOW_SIZE to an integer in range [2..24]. #endif /** The number of entries a table with precomputed multiples needs to have. */ #define ECMULT_TABLE_SIZE(w) (1L << ((w)-2)) /** Double multiply: R = na*A + ng*G */ static void secp256k1_ecmult(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng); typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data); /** * Multi-multiply: R = inp_g_sc * G + sum_i ni * Ai. * Chooses the right algorithm for a given number of points and scratch space * size. Resets and overwrites the given scratch space. If the points do not * fit in the scratch space the algorithm is repeatedly run with batches of * points. If no scratch space is given then a simple algorithm is used that * simply multiplies the points with the corresponding scalars and adds them up. * Returns: 1 on success (including when inp_g_sc is NULL and n is 0) * 0 if there is not enough scratch space for a single point or * callback returns 0 */ static int secp256k1_ecmult_multi_var(const secp256k1_callback* error_callback, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n); #endif /* SECP256K1_ECMULT_H */
a45171fb6f9cfef9105cddb5232a531cad3b9bed
7e6afb4986a53c420d40a2039240f8c5ed3f9549
/libs/math/src/CSparse/cs_post.c
a84c1edfa9eed95659e17a82afd4ef5efb272bd3
[ "BSD-3-Clause", "LGPL-2.1-or-later", "LGPL-2.0-or-later", "DOC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
MRPT/mrpt
9ea3c39a76de78eacaca61a10e7e96646647a6da
34077ec74a90b593b587f2057d3280ea520a3609
refs/heads/develop
2023-08-17T23:37:29.722496
2023-08-17T15:39:54
2023-08-17T15:39:54
13,708,826
1,695
646
BSD-3-Clause
2023-09-12T22:02:53
2013-10-19T21:09:23
C++
UTF-8
C
false
false
1,233
c
cs_post.c
// CSparse/Source/cs_post: postorder a forest // CSparse, Copyright (c) 2006-2023, Timothy A. Davis. All Rights Reserved. // SPDX-License-Identifier: LGPL-2.1+ #include "cs.h" /* post order a forest */ int *cs_post (const int *parent, int n) { int j, k = 0, *post, *w, *head, *next, *stack ; if (!parent) return (NULL) ; /* check inputs */ post = cs_malloc (n, sizeof (int)) ; /* allocate result */ w = cs_malloc (3*n, sizeof (int)) ; /* get workspace */ if (!w || !post) return (cs_idone (post, NULL, w, 0)) ; head = w ; next = w + n ; stack = w + 2*n ; for (j = 0 ; j < n ; j++) head [j] = -1 ; /* empty linked lists */ for (j = n-1 ; j >= 0 ; j--) /* traverse nodes in reverse order*/ { if (parent [j] == -1) continue ; /* j is a root */ next [j] = head [parent [j]] ; /* add j to list of its parent */ head [parent [j]] = j ; } for (j = 0 ; j < n ; j++) { if (parent [j] != -1) continue ; /* skip j if it is not a root */ k = cs_tdfs (j, k, head, next, post, stack) ; } return (cs_idone (post, NULL, w, 1)) ; /* success; free w, return post */ }
0d01bb605f0a06d09389f7115e0a05aa945c6e66
37d4423c0b464a84f90b716ceb8e8bfd0510a295
/runtime/util/to-string.c
00ea11af88d9ebee54a487e53867e52fb7b66972
[ "SMLNJ" ]
permissive
UBMLtonGroup/RTMLton
01963d13032cdc35fac81381e98537bb16627e40
846b826008085c12724adc3e65ddcceff6d4f75f
refs/heads/conc-stacklets
2023-03-08T06:36:22.743693
2021-12-13T20:39:41
2021-12-13T20:39:41
44,258,707
114
4
NOASSERTION
2022-01-03T21:15:53
2015-10-14T15:48:38
Standard ML
UTF-8
C
false
false
1,833
c
to-string.c
/* Copyright (C) 2012,2013 Matthew Fluet. * Copyright (C) 2004-2008 Henry Cejtin, Matthew Fluet, Suresh * Jagannathan, and Stephen Weeks. * * MLton is released under a BSD-style license. * See the file MLton-LICENSE for details. */ #include "util.h" const char* boolToString (bool b) { return b ? "TRUE" : "FALSE"; } #define BUF_SIZE 64 char* intmaxToCommaString (intmax_t n) { static char buf1[BUF_SIZE]; static char buf2[BUF_SIZE]; static char buf3[BUF_SIZE]; static char buf4[BUF_SIZE]; static char buf5[BUF_SIZE]; static char *bufs[] = {buf1, buf2, buf3, buf4, buf5}; static int bufIndex = 0; static char *buf; char tmp[BUF_SIZE]; int i, j, k, l; buf = bufs[bufIndex++]; bufIndex %= 5; l = snprintf(tmp, BUF_SIZE, "%"PRIdMAX, n); if (tmp[0] == '-') { buf[0] = '-'; i = 1; j = 1; k = (l - 1) % 3; } else { i = 0; j = 0; k = l % 3; } if (k == 0) { k = 3; } buf[j++] = tmp[i++]; k--; while (tmp[i] != '\000') { if (k == 0) { buf[j++] = ','; k = 3; } buf[j++] = tmp[i++]; k--; } buf[j] = '\000'; return buf; } char* uintmaxToCommaString (uintmax_t n) { static char buf1[BUF_SIZE]; static char buf2[BUF_SIZE]; static char buf3[BUF_SIZE]; static char buf4[BUF_SIZE]; static char buf5[BUF_SIZE]; static char *bufs[] = {buf1, buf2, buf3, buf4, buf5}; static int bufIndex = 0; static char *buf; char tmp[BUF_SIZE]; int i, j, k, l; buf = bufs[bufIndex++]; bufIndex %= 5; l = snprintf(tmp, BUF_SIZE, "%"PRIuMAX, n); i = 0; j = 0; k = l % 3; if (k == 0) { k = 3; } buf[j++] = tmp[i++]; k--; while (tmp[i] != '\000') { if (k == 0) { buf[j++] = ','; k = 3; } buf[j++] = tmp[i++]; k--; } buf[j] = '\000'; return buf; } #undef BUF_SIZE
90959ce6ccbcd02740c3bb7504ed00e853212d95
5c72e3dec37038e313beab6250acaa54b4b03b93
/viostor/virtio_stor.h
c19d238a38b2a639738bcc6907480d4cda371be1
[ "BSD-3-Clause", "GPL-1.0-or-later" ]
permissive
virtio-win/kvm-guest-drivers-windows
eb29c92b6949d6bfb0ee8c70004e359180ee2398
19a79901f36aa552b85f8b4c3c9645ebe90d9ec5
refs/heads/master
2023-09-06T00:50:32.529282
2023-08-25T10:21:53
2023-08-31T07:30:16
2,524,933
1,424
294
BSD-3-Clause
2023-08-26T16:02:39
2011-10-06T09:06:41
C
UTF-8
C
false
false
9,978
h
virtio_stor.h
/* * Main include file * This file contains various routines and globals * * Copyright (c) 2008-2017 Red Hat, Inc. * * 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 names of the copyright holders nor the names of their 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 HOLDERS 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 ___VIOSTOR_H__ #define ___VIOSTOR_H__ #include <ntddk.h> #include <storport.h> #include <ntddscsi.h> #include "osdep.h" #include "virtio_pci.h" #include "virtio.h" #include "virtio_ring.h" #include "virtio_stor_utils.h" #include "virtio_stor_hw_helper.h" typedef struct VirtIOBufferDescriptor VIO_SG, *PVIO_SG; /* Feature bits */ #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */ #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */ #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */ #define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */ #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */ #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ #define VIRTIO_BLK_F_FLUSH 9 /* Flush command supported */ #define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */ #define VIRTIO_BLK_F_CONFIG_WCE 11 /* Writeback mode available in config */ #define VIRTIO_BLK_F_MQ 12 /* support more than one vq */ #define VIRTIO_BLK_F_DISCARD 13 /* DISCARD is supported */ #define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */ /* These two define direction. */ #define VIRTIO_BLK_T_IN 0 #define VIRTIO_BLK_T_OUT 1 #define VIRTIO_BLK_T_SCSI_CMD 2 #define VIRTIO_BLK_T_FLUSH 4 #define VIRTIO_BLK_T_GET_ID 8 #define VIRTIO_BLK_T_DISCARD 11 #define VIRTIO_BLK_T_WRITE_ZEROES 13 #define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001 #define VIRTIO_BLK_S_OK 0 #define VIRTIO_BLK_S_IOERR 1 #define VIRTIO_BLK_S_UNSUPP 2 #define SECTOR_SIZE 512 #define SECTOR_SHIFT 9 #define IO_PORT_LENGTH 0x40 #define MAX_CPU 256u #define MAX_DISCARD_SEGMENTS 256u #define VIRTIO_BLK_QUEUE_LAST MAX_CPU #define VIRTIO_BLK_MSIX_CONFIG_VECTOR 0 #define MIN_DISCARD_SECTOR_ALIGNMENT 8 #define BLOCK_SERIAL_STRLEN 20 #define MAX_PHYS_SEGMENTS 512 #define VIRTIO_MAX_SG (3+MAX_PHYS_SEGMENTS) #define VIOBLK_POOL_TAG 'BoiV' #ifndef NTDDI_WINTHRESHOLD #define NTDDI_WINTHRESHOLD 0x0A000000 /* ABRACADABRA_THRESHOLD */ #endif #pragma pack(1) typedef struct virtio_blk_config { /* The capacity (in 512-byte sectors). */ u64 capacity; /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */ u32 size_max; /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */ u32 seg_max; /* geometry the device (if VIRTIO_BLK_F_GEOMETRY) */ struct virtio_blk_geometry { u16 cylinders; u8 heads; u8 sectors; } geometry; /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */ u32 blk_size; u8 physical_block_exp; u8 alignment_offset; u16 min_io_size; u32 opt_io_size; /* writeback mode (if VIRTIO_BLK_F_CONFIG_WCE) */ u8 wce; u8 unused; /* number of vqs, only available when VIRTIO_BLK_F_MQ is set */ u16 num_queues; /* the next 3 entries are guarded by VIRTIO_BLK_F_DISCARD */ /* * The maximum discard sectors (in 512-byte sectors) for * one segment. */ u32 max_discard_sectors; /* * The maximum number of discard segments in a * discard command. */ u32 max_discard_seg; /* Discard commands must be aligned to this number of sectors. */ u32 discard_sector_alignment; /* the next 3 entries are guarded by VIRTIO_BLK_F_WRITE_ZEROES */ /* * The maximum number of write zeroes sectors (in 512-byte sectors) in * one segment. */ u32 max_write_zeroes_sectors; /* * The maximum number of segments in a write zeroes * command. */ u32 max_write_zeroes_seg; /* * Set if a VIRTIO_BLK_T_WRITE_ZEROES request may result in the * deallocation of one or more of the sectors. */ u8 write_zeroes_may_unmap; u8 unused1[3]; }blk_config, *pblk_config; #pragma pack() typedef struct virtio_blk_outhdr { /* VIRTIO_BLK_T* */ u32 type; /* io priority. */ u32 ioprio; /* Sector (ie. 512 byte offset) */ u64 sector; }blk_outhdr, *pblk_outhdr; /* Discard/write zeroes range for each request. */ typedef struct virtio_blk_discard_write_zeroes { /* discard/write zeroes start sector */ u64 sector; /* number of discard/write zeroes sectors */ u32 num_sectors; /* flags for this range */ u32 flags; }blk_discard_write_zeroes, *pblk_discard_write_zeroes; typedef struct virtio_blk_req { LIST_ENTRY list_entry; PVOID req; blk_outhdr out_hdr; u8 status; }blk_req, *pblk_req; typedef struct virtio_bar { PHYSICAL_ADDRESS BasePA; ULONG uLength; PVOID pBase; BOOLEAN bPortSpace; } VIRTIO_BAR, *PVIRTIO_BAR; typedef struct _SENSE_INFO { UCHAR senseKey; UCHAR additionalSenseCode; UCHAR additionalSenseCodeQualifier; } SENSE_INFO, *PSENSE_INFO; typedef struct _REQUEST_LIST { LIST_ENTRY srb_list; ULONG srb_cnt; } REQUEST_LIST, *PREQUEST_LIST; typedef struct _ADAPTER_EXTENSION { VirtIODevice vdev; PVOID pageAllocationVa; ULONG pageAllocationSize; ULONG pageOffset; PVOID poolAllocationVa; ULONG poolAllocationSize; ULONG poolOffset; struct virtqueue * vq[VIRTIO_BLK_QUEUE_LAST]; USHORT num_queues; INQUIRYDATA inquiry_data; blk_config info; ULONG queue_depth; BOOLEAN dump_mode; ULONG msix_vectors; BOOLEAN msix_enabled; BOOLEAN msix_one_vector; ULONGLONG features; CHAR sn[BLOCK_SERIAL_STRLEN]; BOOLEAN sn_ok; blk_req vbr; BOOLEAN indirect; ULONGLONG lastLBA; union { PCI_COMMON_HEADER pci_config; UCHAR pci_config_buf[sizeof(PCI_COMMON_CONFIG)]; }; VIRTIO_BAR pci_bars[PCI_TYPE0_ADDRESSES]; ULONG system_io_bus_number; ULONG slot_number; ULONG perfFlags; PSTOR_DPC dpc; BOOLEAN dpc_ok; BOOLEAN check_condition; SENSE_INFO sense_info; BOOLEAN removed; BOOLEAN stopped; ULONG max_tx_length; PGROUP_AFFINITY pmsg_affinity; ULONG num_affinity; STOR_ADDR_BTL8 device_address; blk_discard_write_zeroes blk_discard[16]; REQUEST_LIST processing_srbs[MAX_CPU]; BOOLEAN reset_in_progress; #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD) ULONGLONG fw_ver; #endif #ifdef DBG LONG srb_cnt; LONG inqueue_cnt; #endif }ADAPTER_EXTENSION, *PADAPTER_EXTENSION; typedef struct _VRING_DESC_ALIAS { union { ULONGLONG data[2]; UCHAR chars[SIZE_OF_SINGLE_INDIRECT_DESC]; }u; }VRING_DESC_ALIAS; typedef struct _SRB_EXTENSION { blk_req vbr; ULONG out; ULONG in; ULONG MessageID; BOOLEAN fua; VIO_SG sg[VIRTIO_MAX_SG]; VRING_DESC_ALIAS desc[VIRTIO_MAX_SG]; }SRB_EXTENSION, *PSRB_EXTENSION; BOOLEAN VirtIoInterrupt( IN PVOID DeviceExtension ); #ifndef PCIX_TABLE_POINTER typedef struct { union { struct { ULONG BaseIndexRegister :3; ULONG Reserved :29; }; ULONG TableOffset; }; } PCIX_TABLE_POINTER, *PPCIX_TABLE_POINTER; #endif #ifndef PCI_MSIX_CAPABILITY typedef struct { PCI_CAPABILITIES_HEADER Header; struct { USHORT TableSize :11; USHORT Reserved :3; USHORT FunctionMask :1; USHORT MSIXEnable :1; } MessageControl; PCIX_TABLE_POINTER MessageTable; PCIX_TABLE_POINTER PBATable; } PCI_MSIX_CAPABILITY, *PPCI_MSIX_CAPABILITY; #endif #endif ___VIOSTOR__H__
93a78d294eb03774c46f78f26e30dc245b8022fb
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/include/pmmintrin.h
ee660e95d274424c720698a08d528985fa479663
[ "MIT" ]
permissive
ziglang/zig
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
refs/heads/master
2023-08-31T13:16:45.980913
2023-08-31T05:50:29
2023-08-31T05:50:29
40,276,274
25,560
2,399
MIT
2023-09-14T21:09:50
2015-08-06T00:51:28
Zig
UTF-8
C
false
false
10,468
h
pmmintrin.h
/*===---- pmmintrin.h - SSE3 intrinsics ------------------------------------=== * * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. * See https://llvm.org/LICENSE.txt for license information. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception * *===-----------------------------------------------------------------------=== */ #ifndef __PMMINTRIN_H #define __PMMINTRIN_H #if !defined(__i386__) && !defined(__x86_64__) #error "This header is only meant to be used on x86 and x64 architecture" #endif #include <emmintrin.h> /* Define the default attributes for the functions in this file. */ #define __DEFAULT_FN_ATTRS \ __attribute__((__always_inline__, __nodebug__, __target__("sse3"), __min_vector_width__(128))) /// Loads data from an unaligned memory location to elements in a 128-bit /// vector. /// /// If the address of the data is not 16-byte aligned, the instruction may /// read two adjacent aligned blocks of memory to retrieve the requested /// data. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> VLDDQU </c> instruction. /// /// \param __p /// A pointer to a 128-bit integer vector containing integer values. /// \returns A 128-bit vector containing the moved values. static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_lddqu_si128(__m128i_u const *__p) { return (__m128i)__builtin_ia32_lddqu((char const *)__p); } /// Adds the even-indexed values and subtracts the odd-indexed values of /// two 128-bit vectors of [4 x float]. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> VADDSUBPS </c> instruction. /// /// \param __a /// A 128-bit vector of [4 x float] containing the left source operand. /// \param __b /// A 128-bit vector of [4 x float] containing the right source operand. /// \returns A 128-bit vector of [4 x float] containing the alternating sums and /// differences of both operands. static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_addsub_ps(__m128 __a, __m128 __b) { return __builtin_ia32_addsubps((__v4sf)__a, (__v4sf)__b); } /// Horizontally adds the adjacent pairs of values contained in two /// 128-bit vectors of [4 x float]. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> VHADDPS </c> instruction. /// /// \param __a /// A 128-bit vector of [4 x float] containing one of the source operands. /// The horizontal sums of the values are stored in the lower bits of the /// destination. /// \param __b /// A 128-bit vector of [4 x float] containing one of the source operands. /// The horizontal sums of the values are stored in the upper bits of the /// destination. /// \returns A 128-bit vector of [4 x float] containing the horizontal sums of /// both operands. static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_hadd_ps(__m128 __a, __m128 __b) { return __builtin_ia32_haddps((__v4sf)__a, (__v4sf)__b); } /// Horizontally subtracts the adjacent pairs of values contained in two /// 128-bit vectors of [4 x float]. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> VHSUBPS </c> instruction. /// /// \param __a /// A 128-bit vector of [4 x float] containing one of the source operands. /// The horizontal differences between the values are stored in the lower /// bits of the destination. /// \param __b /// A 128-bit vector of [4 x float] containing one of the source operands. /// The horizontal differences between the values are stored in the upper /// bits of the destination. /// \returns A 128-bit vector of [4 x float] containing the horizontal /// differences of both operands. static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_hsub_ps(__m128 __a, __m128 __b) { return __builtin_ia32_hsubps((__v4sf)__a, (__v4sf)__b); } /// Moves and duplicates odd-indexed values from a 128-bit vector /// of [4 x float] to float values stored in a 128-bit vector of /// [4 x float]. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> VMOVSHDUP </c> instruction. /// /// \param __a /// A 128-bit vector of [4 x float]. \n /// Bits [127:96] of the source are written to bits [127:96] and [95:64] of /// the destination. \n /// Bits [63:32] of the source are written to bits [63:32] and [31:0] of the /// destination. /// \returns A 128-bit vector of [4 x float] containing the moved and duplicated /// values. static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_movehdup_ps(__m128 __a) { return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 1, 1, 3, 3); } /// Duplicates even-indexed values from a 128-bit vector of /// [4 x float] to float values stored in a 128-bit vector of [4 x float]. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> VMOVSLDUP </c> instruction. /// /// \param __a /// A 128-bit vector of [4 x float] \n /// Bits [95:64] of the source are written to bits [127:96] and [95:64] of /// the destination. \n /// Bits [31:0] of the source are written to bits [63:32] and [31:0] of the /// destination. /// \returns A 128-bit vector of [4 x float] containing the moved and duplicated /// values. static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_moveldup_ps(__m128 __a) { return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 2, 2); } /// Adds the even-indexed values and subtracts the odd-indexed values of /// two 128-bit vectors of [2 x double]. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> VADDSUBPD </c> instruction. /// /// \param __a /// A 128-bit vector of [2 x double] containing the left source operand. /// \param __b /// A 128-bit vector of [2 x double] containing the right source operand. /// \returns A 128-bit vector of [2 x double] containing the alternating sums /// and differences of both operands. static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_addsub_pd(__m128d __a, __m128d __b) { return __builtin_ia32_addsubpd((__v2df)__a, (__v2df)__b); } /// Horizontally adds the pairs of values contained in two 128-bit /// vectors of [2 x double]. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> VHADDPD </c> instruction. /// /// \param __a /// A 128-bit vector of [2 x double] containing one of the source operands. /// The horizontal sum of the values is stored in the lower bits of the /// destination. /// \param __b /// A 128-bit vector of [2 x double] containing one of the source operands. /// The horizontal sum of the values is stored in the upper bits of the /// destination. /// \returns A 128-bit vector of [2 x double] containing the horizontal sums of /// both operands. static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_hadd_pd(__m128d __a, __m128d __b) { return __builtin_ia32_haddpd((__v2df)__a, (__v2df)__b); } /// Horizontally subtracts the pairs of values contained in two 128-bit /// vectors of [2 x double]. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> VHSUBPD </c> instruction. /// /// \param __a /// A 128-bit vector of [2 x double] containing one of the source operands. /// The horizontal difference of the values is stored in the lower bits of /// the destination. /// \param __b /// A 128-bit vector of [2 x double] containing one of the source operands. /// The horizontal difference of the values is stored in the upper bits of /// the destination. /// \returns A 128-bit vector of [2 x double] containing the horizontal /// differences of both operands. static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_hsub_pd(__m128d __a, __m128d __b) { return __builtin_ia32_hsubpd((__v2df)__a, (__v2df)__b); } /// Moves and duplicates one double-precision value to double-precision /// values stored in a 128-bit vector of [2 x double]. /// /// \headerfile <x86intrin.h> /// /// \code /// __m128d _mm_loaddup_pd(double const *dp); /// \endcode /// /// This intrinsic corresponds to the <c> VMOVDDUP </c> instruction. /// /// \param dp /// A pointer to a double-precision value to be moved and duplicated. /// \returns A 128-bit vector of [2 x double] containing the moved and /// duplicated values. #define _mm_loaddup_pd(dp) _mm_load1_pd(dp) /// Moves and duplicates the double-precision value in the lower bits of /// a 128-bit vector of [2 x double] to double-precision values stored in a /// 128-bit vector of [2 x double]. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> VMOVDDUP </c> instruction. /// /// \param __a /// A 128-bit vector of [2 x double]. Bits [63:0] are written to bits /// [127:64] and [63:0] of the destination. /// \returns A 128-bit vector of [2 x double] containing the moved and /// duplicated values. static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_movedup_pd(__m128d __a) { return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0); } /// Establishes a linear address memory range to be monitored and puts /// the processor in the monitor event pending state. Data stored in the /// monitored address range causes the processor to exit the pending state. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> MONITOR </c> instruction. /// /// \param __p /// The memory range to be monitored. The size of the range is determined by /// CPUID function 0000_0005h. /// \param __extensions /// Optional extensions for the monitoring state. /// \param __hints /// Optional hints for the monitoring state. static __inline__ void __DEFAULT_FN_ATTRS _mm_monitor(void const *__p, unsigned __extensions, unsigned __hints) { __builtin_ia32_monitor(__p, __extensions, __hints); } /// Used with the MONITOR instruction to wait while the processor is in /// the monitor event pending state. Data stored in the monitored address /// range causes the processor to exit the pending state. /// /// \headerfile <x86intrin.h> /// /// This intrinsic corresponds to the <c> MWAIT </c> instruction. /// /// \param __extensions /// Optional extensions for the monitoring state, which may vary by /// processor. /// \param __hints /// Optional hints for the monitoring state, which may vary by processor. static __inline__ void __DEFAULT_FN_ATTRS _mm_mwait(unsigned __extensions, unsigned __hints) { __builtin_ia32_mwait(__extensions, __hints); } #undef __DEFAULT_FN_ATTRS #endif /* __PMMINTRIN_H */
450f99017e8443e503b9eb46ad3656adcae52876
42ab733e143d02091d13424fb4df16379d5bba0d
/third_party/libsdl2/test/testautomation_render.c
5a1bc9b8c5c25d159967f125032f3f9b911a6b26
[ "LicenseRef-scancode-public-domain", "Zlib", "Apache-2.0", "CC0-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
google/filament
11cd37ac68790fcf8b33416b7d8d8870e48181f0
0aa0efe1599798d887fa6e33c412c09e81bea1bf
refs/heads/main
2023-08-29T17:58:22.496956
2023-08-28T17:27:38
2023-08-28T17:27:38
143,455,116
16,631
1,961
Apache-2.0
2023-09-14T16:23:39
2018-08-03T17:26:00
C++
UTF-8
C
false
false
34,596
c
testautomation_render.c
/** * Original code: automated SDL platform test written by Edgar Simo "bobbens" * Extended and extensively updated by aschiffler at ferzkopp dot net */ #include <stdio.h> #include "SDL.h" #include "SDL_test.h" /* ================= Test Case Implementation ================== */ #define TESTRENDER_SCREEN_W 80 #define TESTRENDER_SCREEN_H 60 #define RENDER_COMPARE_FORMAT SDL_PIXELFORMAT_ARGB8888 #define RENDER_COMPARE_AMASK 0xff000000 /**< Alpha bit mask. */ #define RENDER_COMPARE_RMASK 0x00ff0000 /**< Red bit mask. */ #define RENDER_COMPARE_GMASK 0x0000ff00 /**< Green bit mask. */ #define RENDER_COMPARE_BMASK 0x000000ff /**< Blue bit mask. */ #define ALLOWABLE_ERROR_OPAQUE 0 #define ALLOWABLE_ERROR_BLENDED 64 /* Test window and renderer */ SDL_Window *window = NULL; SDL_Renderer *renderer = NULL; /* Prototypes for helper functions */ static int _clearScreen (void); static void _compare(SDL_Surface *reference, int allowable_error); static int _hasTexAlpha(void); static int _hasTexColor(void); static SDL_Texture *_loadTestFace(void); static int _hasBlendModes(void); static int _hasDrawColor(void); static int _isSupported(int code); /** * Create software renderer for tests */ void InitCreateRenderer(void *arg) { int posX = 100, posY = 100, width = 320, height = 240; renderer = NULL; window = SDL_CreateWindow("render_testCreateRenderer", posX, posY, width, height, 0); SDLTest_AssertPass("SDL_CreateWindow()"); SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); if (window == NULL) { return; } renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); SDLTest_AssertPass("SDL_CreateRenderer()"); SDLTest_AssertCheck(renderer != 0, "Check SDL_CreateRenderer result"); if (renderer == NULL) { SDL_DestroyWindow(window); return; } } /* * Destroy renderer for tests */ void CleanupDestroyRenderer(void *arg) { if (renderer != NULL) { SDL_DestroyRenderer(renderer); renderer = NULL; SDLTest_AssertPass("SDL_DestroyRenderer()"); } if (window != NULL) { SDL_DestroyWindow(window); window = NULL; SDLTest_AssertPass("SDL_DestroyWindow"); } } /** * @brief Tests call to SDL_GetNumRenderDrivers * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetNumRenderDrivers */ int render_testGetNumRenderDrivers(void *arg) { int n; n = SDL_GetNumRenderDrivers(); SDLTest_AssertCheck(n >= 1, "Number of renderers >= 1, reported as %i", n); return TEST_COMPLETED; } /** * @brief Tests the SDL primitives for rendering. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect * http://wiki.libsdl.org/moin.cgi/SDL_RenderDrawLine * */ int render_testPrimitives (void *arg) { int ret; int x, y; SDL_Rect rect; SDL_Surface *referenceSurface = NULL; int checkFailCount1; int checkFailCount2; /* Clear surface. */ _clearScreen(); /* Need drawcolor or just skip test. */ SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor"); /* Draw a rectangle. */ rect.x = 40; rect.y = 0; rect.w = 40; rect.h = 80; ret = SDL_SetRenderDrawColor(renderer, 13, 73, 200, SDL_ALPHA_OPAQUE ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); ret = SDL_RenderFillRect(renderer, &rect ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); /* Draw a rectangle. */ rect.x = 10; rect.y = 10; rect.w = 60; rect.h = 40; ret = SDL_SetRenderDrawColor(renderer, 200, 0, 100, SDL_ALPHA_OPAQUE ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); ret = SDL_RenderFillRect(renderer, &rect ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); /* Draw some points like so: * X.X.X.X.. * .X.X.X.X. * X.X.X.X.. */ checkFailCount1 = 0; checkFailCount2 = 0; for (y=0; y<3; y++) { for (x = y % 2; x<TESTRENDER_SCREEN_W; x+=2) { ret = SDL_SetRenderDrawColor(renderer, x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE ); if (ret != 0) checkFailCount1++; ret = SDL_RenderDrawPoint(renderer, x, y ); if (ret != 0) checkFailCount2++; } } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount2); /* Draw some lines. */ ret = SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor"); ret = SDL_RenderDrawLine(renderer, 0, 30, TESTRENDER_SCREEN_W, 30 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); ret = SDL_SetRenderDrawColor(renderer, 55, 55, 5, SDL_ALPHA_OPAQUE ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); ret = SDL_RenderDrawLine(renderer, 40, 30, 40, 60 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); ret = SDL_SetRenderDrawColor(renderer, 5, 105, 105, SDL_ALPHA_OPAQUE ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); ret = SDL_RenderDrawLine(renderer, 0, 0, 29, 29 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); ret = SDL_RenderDrawLine(renderer, 29, 30, 0, 59 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); ret = SDL_RenderDrawLine(renderer, 79, 0, 50, 29 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); ret = SDL_RenderDrawLine(renderer, 79, 59, 50, 30 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderDrawLine, expected: 0, got: %i", ret); /* Make current */ SDL_RenderPresent(renderer); /* See if it's the same. */ referenceSurface = SDLTest_ImagePrimitives(); _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); /* Clean up. */ SDL_FreeSurface(referenceSurface); referenceSurface = NULL; return TEST_COMPLETED; } /** * @brief Tests the SDL primitives with alpha for rendering. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect */ int render_testPrimitivesBlend (void *arg) { int ret; int i, j; SDL_Rect rect; SDL_Surface *referenceSurface = NULL; int checkFailCount1; int checkFailCount2; int checkFailCount3; /* Clear surface. */ _clearScreen(); /* Need drawcolor and blendmode or just skip test. */ SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor"); SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes"); /* Create some rectangles for each blend mode. */ ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret); ret = SDL_RenderFillRect(renderer, NULL ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); rect.x = 10; rect.y = 25; rect.w = 40; rect.h = 25; ret = SDL_SetRenderDrawColor(renderer, 240, 10, 10, 75 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret); ret = SDL_RenderFillRect(renderer, &rect ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); rect.x = 30; rect.y = 40; rect.w = 45; rect.h = 15; ret = SDL_SetRenderDrawColor(renderer, 10, 240, 10, 100 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret); ret = SDL_RenderFillRect(renderer, &rect ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); rect.x = 25; rect.y = 25; rect.w = 25; rect.h = 25; ret = SDL_SetRenderDrawColor(renderer, 10, 10, 240, 125 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret); ret = SDL_RenderFillRect(renderer, &rect ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret); /* Draw blended lines, lines for everyone. */ checkFailCount1 = 0; checkFailCount2 = 0; checkFailCount3 = 0; for (i=0; i<TESTRENDER_SCREEN_W; i+=2) { ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i ); if (ret != 0) checkFailCount1++; ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); if (ret != 0) checkFailCount2++; ret = SDL_RenderDrawLine(renderer, 0, 0, i, 59 ); if (ret != 0) checkFailCount3++; } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2); SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawLine, expected: 0, got: %i", checkFailCount3); checkFailCount1 = 0; checkFailCount2 = 0; checkFailCount3 = 0; for (i=0; i<TESTRENDER_SCREEN_H; i+=2) { ret = SDL_SetRenderDrawColor(renderer, 60+2*i, 240-2*i, 50, 3*i ); if (ret != 0) checkFailCount1++; ret = SDL_SetRenderDrawBlendMode(renderer,(((i/2)%3)==0) ? SDL_BLENDMODE_BLEND : (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); if (ret != 0) checkFailCount2++; ret = SDL_RenderDrawLine(renderer, 0, 0, 79, i ); if (ret != 0) checkFailCount3++; } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2); SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawLine, expected: 0, got: %i", checkFailCount3); /* Draw points. */ checkFailCount1 = 0; checkFailCount2 = 0; checkFailCount3 = 0; for (j=0; j<TESTRENDER_SCREEN_H; j+=3) { for (i=0; i<TESTRENDER_SCREEN_W; i+=3) { ret = SDL_SetRenderDrawColor(renderer, j*4, i*3, j*4, i*3 ); if (ret != 0) checkFailCount1++; ret = SDL_SetRenderDrawBlendMode(renderer, ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND : ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_NONE ); if (ret != 0) checkFailCount2++; ret = SDL_RenderDrawPoint(renderer, i, j ); if (ret != 0) checkFailCount3++; } } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2); SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount3); /* Make current */ SDL_RenderPresent(renderer); /* See if it's the same. */ referenceSurface = SDLTest_ImagePrimitivesBlend(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); /* Clean up. */ SDL_FreeSurface(referenceSurface); referenceSurface = NULL; return TEST_COMPLETED; } /** * @brief Tests some blitting routines. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture */ int render_testBlit(void *arg) { int ret; SDL_Rect rect; SDL_Texture *tface; SDL_Surface *referenceSurface = NULL; Uint32 tformat; int taccess, tw, th; int i, j, ni, nj; int checkFailCount1; /* Clear surface. */ _clearScreen(); /* Need drawcolor or just skip test. */ SDLTest_AssertCheck(_hasDrawColor(), "_hasDrawColor)"); /* Create face surface. */ tface = _loadTestFace(); SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); if (tface == NULL) { return TEST_ABORTED; } /* Constant values. */ ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret); rect.w = tw; rect.h = th; ni = TESTRENDER_SCREEN_W - tw; nj = TESTRENDER_SCREEN_H - th; /* Loop blit. */ checkFailCount1 = 0; for (j=0; j <= nj; j+=4) { for (i=0; i <= ni; i+=4) { /* Blitting. */ rect.x = i; rect.y = j; ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); if (ret != 0) checkFailCount1++; } } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount1); /* Make current */ SDL_RenderPresent(renderer); /* See if it's the same */ referenceSurface = SDLTest_ImageBlit(); _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); /* Clean up. */ SDL_DestroyTexture( tface ); SDL_FreeSurface(referenceSurface); referenceSurface = NULL; return TEST_COMPLETED; } /** * @brief Blits doing color tests. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture */ int render_testBlitColor (void *arg) { int ret; SDL_Rect rect; SDL_Texture *tface; SDL_Surface *referenceSurface = NULL; Uint32 tformat; int taccess, tw, th; int i, j, ni, nj; int checkFailCount1; int checkFailCount2; /* Clear surface. */ _clearScreen(); /* Create face surface. */ tface = _loadTestFace(); SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); if (tface == NULL) { return TEST_ABORTED; } /* Constant values. */ ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret); rect.w = tw; rect.h = th; ni = TESTRENDER_SCREEN_W - tw; nj = TESTRENDER_SCREEN_H - th; /* Test blitting with color mod. */ checkFailCount1 = 0; checkFailCount2 = 0; for (j=0; j <= nj; j+=4) { for (i=0; i <= ni; i+=4) { /* Set color mod. */ ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j ); if (ret != 0) checkFailCount1++; /* Blitting. */ rect.x = i; rect.y = j; ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); if (ret != 0) checkFailCount2++; } } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2); /* Make current */ SDL_RenderPresent(renderer); /* See if it's the same. */ referenceSurface = SDLTest_ImageBlitColor(); _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); /* Clean up. */ SDL_DestroyTexture( tface ); SDL_FreeSurface(referenceSurface); referenceSurface = NULL; return TEST_COMPLETED; } /** * @brief Tests blitting with alpha. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture */ int render_testBlitAlpha (void *arg) { int ret; SDL_Rect rect; SDL_Texture *tface; SDL_Surface *referenceSurface = NULL; Uint32 tformat; int taccess, tw, th; int i, j, ni, nj; int checkFailCount1; int checkFailCount2; /* Clear surface. */ _clearScreen(); /* Need alpha or just skip test. */ SDLTest_AssertCheck(_hasTexAlpha(), "_hasTexAlpha"); /* Create face surface. */ tface = _loadTestFace(); SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); if (tface == NULL) { return TEST_ABORTED; } /* Constant values. */ ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret); rect.w = tw; rect.h = th; ni = TESTRENDER_SCREEN_W - tw; nj = TESTRENDER_SCREEN_H - th; /* Test blitting with alpha mod. */ checkFailCount1 = 0; checkFailCount2 = 0; for (j=0; j <= nj; j+=4) { for (i=0; i <= ni; i+=4) { /* Set alpha mod. */ ret = SDL_SetTextureAlphaMod( tface, (255/ni)*i ); if (ret != 0) checkFailCount1++; /* Blitting. */ rect.x = i; rect.y = j; ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); if (ret != 0) checkFailCount2++; } } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2); /* Make current */ SDL_RenderPresent(renderer); /* See if it's the same. */ referenceSurface = SDLTest_ImageBlitAlpha(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); /* Clean up. */ SDL_DestroyTexture( tface ); SDL_FreeSurface(referenceSurface); referenceSurface = NULL; return TEST_COMPLETED; } /* Helper functions */ /** * @brief Tests a blend mode. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureBlendMode * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy */ static void _testBlitBlendMode( SDL_Texture * tface, int mode ) { int ret; Uint32 tformat; int taccess, tw, th; int i, j, ni, nj; SDL_Rect rect; int checkFailCount1; int checkFailCount2; /* Clear surface. */ _clearScreen(); /* Constant values. */ ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret); rect.w = tw; rect.h = th; ni = TESTRENDER_SCREEN_W - tw; nj = TESTRENDER_SCREEN_H - th; /* Test blend mode. */ checkFailCount1 = 0; checkFailCount2 = 0; for (j=0; j <= nj; j+=4) { for (i=0; i <= ni; i+=4) { /* Set blend mode. */ ret = SDL_SetTextureBlendMode( tface, (SDL_BlendMode)mode ); if (ret != 0) checkFailCount1++; /* Blitting. */ rect.x = i; rect.y = j; ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); if (ret != 0) checkFailCount2++; } } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureBlendMode, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2); } /** * @brief Tests some more blitting routines. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureBlendMode * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture */ int render_testBlitBlend (void *arg) { int ret; SDL_Rect rect; SDL_Texture *tface; SDL_Surface *referenceSurface = NULL; Uint32 tformat; int taccess, tw, th; int i, j, ni, nj; int mode; int checkFailCount1; int checkFailCount2; int checkFailCount3; int checkFailCount4; SDLTest_AssertCheck(_hasBlendModes(), "_hasBlendModes"); SDLTest_AssertCheck(_hasTexColor(), "_hasTexColor"); SDLTest_AssertCheck(_hasTexAlpha(), "_hasTexAlpha"); /* Create face surface. */ tface = _loadTestFace(); SDLTest_AssertCheck(tface != NULL, "Verify _loadTestFace() result"); if (tface == NULL) { return TEST_ABORTED; } /* Constant values. */ ret = SDL_QueryTexture(tface, &tformat, &taccess, &tw, &th); SDLTest_AssertCheck(ret == 0, "Verify result from SDL_QueryTexture, expected 0, got %i", ret); rect.w = tw; rect.h = th; ni = TESTRENDER_SCREEN_W - tw; nj = TESTRENDER_SCREEN_H - th; /* Set alpha mod. */ ret = SDL_SetTextureAlphaMod( tface, 100 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetTextureAlphaMod, expected: 0, got: %i", ret); /* Test None. */ _testBlitBlendMode( tface, SDL_BLENDMODE_NONE ); referenceSurface = SDLTest_ImageBlitBlendNone(); /* Make current and compare */ SDL_RenderPresent(renderer); _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); SDL_FreeSurface(referenceSurface); referenceSurface = NULL; /* Test Blend. */ _testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ); referenceSurface = SDLTest_ImageBlitBlend(); /* Make current and compare */ SDL_RenderPresent(renderer); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); SDL_FreeSurface(referenceSurface); referenceSurface = NULL; /* Test Add. */ _testBlitBlendMode( tface, SDL_BLENDMODE_ADD ); referenceSurface = SDLTest_ImageBlitBlendAdd(); /* Make current and compare */ SDL_RenderPresent(renderer); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); SDL_FreeSurface(referenceSurface); referenceSurface = NULL; /* Test Mod. */ _testBlitBlendMode( tface, SDL_BLENDMODE_MOD); referenceSurface = SDLTest_ImageBlitBlendMod(); /* Make current and compare */ SDL_RenderPresent(renderer); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); SDL_FreeSurface(referenceSurface); referenceSurface = NULL; /* Clear surface. */ _clearScreen(); /* Loop blit. */ checkFailCount1 = 0; checkFailCount2 = 0; checkFailCount3 = 0; checkFailCount4 = 0; for (j=0; j <= nj; j+=4) { for (i=0; i <= ni; i+=4) { /* Set color mod. */ ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j ); if (ret != 0) checkFailCount1++; /* Set alpha mod. */ ret = SDL_SetTextureAlphaMod( tface, (100/ni)*i ); if (ret != 0) checkFailCount2++; /* Crazy blending mode magic. */ mode = (i/4*j/4) % 4; if (mode==0) mode = SDL_BLENDMODE_NONE; else if (mode==1) mode = SDL_BLENDMODE_BLEND; else if (mode==2) mode = SDL_BLENDMODE_ADD; else if (mode==3) mode = SDL_BLENDMODE_MOD; ret = SDL_SetTextureBlendMode( tface, (SDL_BlendMode)mode ); if (ret != 0) checkFailCount3++; /* Blitting. */ rect.x = i; rect.y = j; ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); if (ret != 0) checkFailCount4++; } } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureColorMod, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount2); SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetTextureBlendMode, expected: 0, got: %i", checkFailCount3); SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount4); /* Clean up. */ SDL_DestroyTexture( tface ); /* Make current */ SDL_RenderPresent(renderer); /* Check to see if final image matches. */ referenceSurface = SDLTest_ImageBlitBlendAll(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); SDL_FreeSurface(referenceSurface); referenceSurface = NULL; return TEST_COMPLETED; } /** * @brief Checks to see if functionality is supported. Helper function. */ static int _isSupported( int code ) { return (code == 0); } /** * @brief Test to see if we can vary the draw color. Helper function. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawColor */ static int _hasDrawColor (void) { int ret, fail; Uint8 r, g, b, a; fail = 0; /* Set color. */ ret = SDL_SetRenderDrawColor(renderer, 100, 100, 100, 100 ); if (!_isSupported(ret)) fail = 1; ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a ); if (!_isSupported(ret)) fail = 1; /* Restore natural. */ ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE ); if (!_isSupported(ret)) fail = 1; /* Something failed, consider not available. */ if (fail) return 0; /* Not set properly, consider failed. */ else if ((r != 100) || (g != 100) || (b != 100) || (a != 100)) return 0; return 1; } /** * @brief Test to see if we can vary the blend mode. Helper function. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawBlendMode */ static int _hasBlendModes (void) { int fail; int ret; SDL_BlendMode mode; fail = 0; ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND ); if (!_isSupported(ret)) fail = 1; ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); if (!_isSupported(ret)) fail = 1; ret = (mode != SDL_BLENDMODE_BLEND); if (!_isSupported(ret)) fail = 1; ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD ); if (!_isSupported(ret)) fail = 1; ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); if (!_isSupported(ret)) fail = 1; ret = (mode != SDL_BLENDMODE_ADD); if (!_isSupported(ret)) fail = 1; ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_MOD ); if (!_isSupported(ret)) fail = 1; ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); if (!_isSupported(ret)) fail = 1; ret = (mode != SDL_BLENDMODE_MOD); if (!_isSupported(ret)) fail = 1; ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); if (!_isSupported(ret)) fail = 1; ret = SDL_GetRenderDrawBlendMode(renderer, &mode ); if (!_isSupported(ret)) fail = 1; ret = (mode != SDL_BLENDMODE_NONE); if (!_isSupported(ret)) fail = 1; return !fail; } /** * @brief Loads the test image 'Face' as texture. Helper function. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_CreateTextureFromSurface */ static SDL_Texture * _loadTestFace(void) { SDL_Surface *face; SDL_Texture *tface; face = SDLTest_ImageFace(); if (face == NULL) { return NULL; } tface = SDL_CreateTextureFromSurface(renderer, face); if (tface == NULL) { SDLTest_LogError("SDL_CreateTextureFromSurface() failed with error: %s", SDL_GetError()); } SDL_FreeSurface(face); return tface; } /** * @brief Test to see if can set texture color mode. Helper function. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureColorMod * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture */ static int _hasTexColor (void) { int fail; int ret; SDL_Texture *tface; Uint8 r, g, b; /* Get test face. */ tface = _loadTestFace(); if (tface == NULL) return 0; /* See if supported. */ fail = 0; ret = SDL_SetTextureColorMod( tface, 100, 100, 100 ); if (!_isSupported(ret)) fail = 1; ret = SDL_GetTextureColorMod( tface, &r, &g, &b ); if (!_isSupported(ret)) fail = 1; /* Clean up. */ SDL_DestroyTexture( tface ); if (fail) return 0; else if ((r != 100) || (g != 100) || (b != 100)) return 0; return 1; } /** * @brief Test to see if we can vary the alpha of the texture. Helper function. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureAlphaMod * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture */ static int _hasTexAlpha(void) { int fail; int ret; SDL_Texture *tface; Uint8 a; /* Get test face. */ tface = _loadTestFace(); if (tface == NULL) return 0; /* See if supported. */ fail = 0; ret = SDL_SetTextureAlphaMod( tface, 100 ); if (!_isSupported(ret)) fail = 1; ret = SDL_GetTextureAlphaMod( tface, &a ); if (!_isSupported(ret)) fail = 1; /* Clean up. */ SDL_DestroyTexture( tface ); if (fail) return 0; else if (a != 100) return 0; return 1; } /** * @brief Compares screen pixels with image pixels. Helper function. * * @param s Image to compare against. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_RenderReadPixels * http://wiki.libsdl.org/moin.cgi/SDL_CreateRGBSurfaceFrom * http://wiki.libsdl.org/moin.cgi/SDL_FreeSurface */ static void _compare(SDL_Surface *referenceSurface, int allowable_error) { int result; SDL_Rect rect; Uint8 *pixels; SDL_Surface *testSurface; /* Read pixels. */ pixels = (Uint8 *)SDL_malloc(4*TESTRENDER_SCREEN_W*TESTRENDER_SCREEN_H); SDLTest_AssertCheck(pixels != NULL, "Validate allocated temp pixel buffer"); if (pixels == NULL) return; /* Explicitly specify the rect in case the window isn't the expected size... */ rect.x = 0; rect.y = 0; rect.w = TESTRENDER_SCREEN_W; rect.h = TESTRENDER_SCREEN_H; result = SDL_RenderReadPixels(renderer, &rect, RENDER_COMPARE_FORMAT, pixels, 80*4 ); SDLTest_AssertCheck(result == 0, "Validate result from SDL_RenderReadPixels, expected: 0, got: %i", result); /* Create surface. */ testSurface = SDL_CreateRGBSurfaceFrom(pixels, TESTRENDER_SCREEN_W, TESTRENDER_SCREEN_H, 32, TESTRENDER_SCREEN_W*4, RENDER_COMPARE_RMASK, RENDER_COMPARE_GMASK, RENDER_COMPARE_BMASK, RENDER_COMPARE_AMASK); SDLTest_AssertCheck(testSurface != NULL, "Verify result from SDL_CreateRGBSurfaceFrom is not NULL"); /* Compare surface. */ result = SDLTest_CompareSurfaces( testSurface, referenceSurface, allowable_error ); SDLTest_AssertCheck(result == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", result); /* Clean up. */ SDL_free(pixels); SDL_FreeSurface(testSurface); } /** * @brief Clears the screen. Helper function. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor * http://wiki.libsdl.org/moin.cgi/SDL_RenderClear * http://wiki.libsdl.org/moin.cgi/SDL_RenderPresent * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode */ static int _clearScreen(void) { int ret; /* Set color. */ ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); /* Clear screen. */ ret = SDL_RenderClear(renderer); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderClear, expected: 0, got: %i", ret); /* Make current */ SDL_RenderPresent(renderer); /* Set defaults. */ ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawBlendMode, expected: 0, got: %i", ret); ret = SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE ); SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret); return 0; } /* ================= Test References ================== */ /* Render test cases */ static const SDLTest_TestCaseReference renderTest1 = { (SDLTest_TestCaseFp)render_testGetNumRenderDrivers, "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED }; static const SDLTest_TestCaseReference renderTest2 = { (SDLTest_TestCaseFp)render_testPrimitives, "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED }; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ static const SDLTest_TestCaseReference renderTest3 = { (SDLTest_TestCaseFp)render_testPrimitivesBlend, "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_DISABLED }; static const SDLTest_TestCaseReference renderTest4 = { (SDLTest_TestCaseFp)render_testBlit, "render_testBlit", "Tests blitting", TEST_ENABLED }; static const SDLTest_TestCaseReference renderTest5 = { (SDLTest_TestCaseFp)render_testBlitColor, "render_testBlitColor", "Tests blitting with color", TEST_ENABLED }; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ static const SDLTest_TestCaseReference renderTest6 = { (SDLTest_TestCaseFp)render_testBlitAlpha, "render_testBlitAlpha", "Tests blitting with alpha", TEST_DISABLED }; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ static const SDLTest_TestCaseReference renderTest7 = { (SDLTest_TestCaseFp)render_testBlitBlend, "render_testBlitBlend", "Tests blitting with blending", TEST_DISABLED }; /* Sequence of Render test cases */ static const SDLTest_TestCaseReference *renderTests[] = { &renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL }; /* Render test suite (global) */ SDLTest_TestSuiteReference renderTestSuite = { "Render", InitCreateRenderer, renderTests, CleanupDestroyRenderer };
ac35fe7f4fbb578ca091986296b98bef05a919e7
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/wayland-protocols/gtk/gdk/gdkdebug.h
2098774739bd39dd2d9a849fdf0a7e82243956d2
[ "LGPL-2.1-only", "MIT", "LGPL-2.0-or-later", "LGPL-2.0-only", "BSD-3-Clause", "Apache-2.0", "GPL-1.0-or-later" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C
false
false
2,613
h
gdkdebug.h
/* GDK - The GIMP Drawing Kit * Copyright (C) 2020 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GDK_DEBUG_H__ #define __GDK_DEBUG_H__ G_BEGIN_DECLS typedef enum { GDK_DEBUG_MISC = 1 << 0, GDK_DEBUG_EVENTS = 1 << 1, GDK_DEBUG_DND = 1 << 2, GDK_DEBUG_INPUT = 1 << 3, GDK_DEBUG_EVENTLOOP = 1 << 4, GDK_DEBUG_FRAMES = 1 << 5, GDK_DEBUG_SETTINGS = 1 << 6, GDK_DEBUG_OPENGL = 1 << 7, GDK_DEBUG_VULKAN = 1 << 8, GDK_DEBUG_SELECTION = 1 << 9, GDK_DEBUG_CLIPBOARD = 1 << 10, /* flags below are influencing behavior */ GDK_DEBUG_NOGRABS = 1 << 11, GDK_DEBUG_GL_DISABLE = 1 << 12, GDK_DEBUG_GL_SOFTWARE = 1 << 13, GDK_DEBUG_GL_TEXTURE_RECT = 1 << 14, GDK_DEBUG_GL_LEGACY = 1 << 15, GDK_DEBUG_GL_GLES = 1 << 16, GDK_DEBUG_GL_DEBUG = 1 << 17, GDK_DEBUG_VULKAN_DISABLE = 1 << 18, GDK_DEBUG_VULKAN_VALIDATE = 1 << 19, GDK_DEBUG_DEFAULT_SETTINGS= 1 << 20 } GdkDebugFlags; extern guint _gdk_debug_flags; GdkDebugFlags gdk_display_get_debug_flags (GdkDisplay *display); void gdk_display_set_debug_flags (GdkDisplay *display, GdkDebugFlags flags); #ifdef G_ENABLE_DEBUG #define GDK_DISPLAY_DEBUG_CHECK(display,type) \ G_UNLIKELY (gdk_display_get_debug_flags (display) & GDK_DEBUG_##type) #define GDK_DISPLAY_NOTE(display,type,action) G_STMT_START { \ if (GDK_DISPLAY_DEBUG_CHECK (display,type)) \ { action; }; } G_STMT_END #else /* !G_ENABLE_DEBUG */ #define GDK_DISPLAY_DEBUG_CHECK(display,type) 0 #define GDK_DISPLAY_NOTE(display,type,action) #endif /* G_ENABLE_DEBUG */ #define GDK_DEBUG_CHECK(type) GDK_DISPLAY_DEBUG_CHECK (NULL,type) #define GDK_NOTE(type,action) GDK_DISPLAY_NOTE (NULL,type,action) #endif
0c31de1c944ff1a00cc8d5b3aaeb627b7884e2cc
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/arm/mach-omap1/i2c.c
7f5761cffd2eaf75561b3b77112b4c8553b020f4
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
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,525
c
i2c.c
/* * Helper module for board specific I2C bus registration * * Copyright (C) 2009 Nokia Corporation. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #include <linux/i2c-omap.h> #include <mach/mux.h> #include "soc.h" #include <plat/i2c.h> #define OMAP_I2C_SIZE 0x3f #define OMAP1_I2C_BASE 0xfffb3800 #define OMAP1_INT_I2C (32 + 4) static const char name[] = "omap_i2c"; static struct resource i2c_resources[2] = { }; static struct platform_device omap_i2c_devices[1] = { }; static void __init omap1_i2c_mux_pins(int bus_id) { if (cpu_is_omap7xx()) { omap_cfg_reg(I2C_7XX_SDA); omap_cfg_reg(I2C_7XX_SCL); } else { omap_cfg_reg(I2C_SDA); omap_cfg_reg(I2C_SCL); } } int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *pdata, int bus_id) { struct platform_device *pdev; struct resource *res; if (bus_id > 1) return -EINVAL; omap1_i2c_mux_pins(bus_id); pdev = &omap_i2c_devices[bus_id - 1]; pdev->id = bus_id; pdev->name = name; pdev->num_resources = ARRAY_SIZE(i2c_resources); res = i2c_resources; res[0].start = OMAP1_I2C_BASE; res[0].end = res[0].start + OMAP_I2C_SIZE; res[0].flags = IORESOURCE_MEM; res[1].start = OMAP1_INT_I2C; res[1].flags = IORESOURCE_IRQ; pdev->resource = res; /* all OMAP1 have IP version 1 register set */ pdata->rev = OMAP_I2C_IP_VERSION_1; /* all OMAP1 I2C are implemented like this */ pdata->flags = OMAP_I2C_FLAG_NO_FIFO | OMAP_I2C_FLAG_SIMPLE_CLOCK | OMAP_I2C_FLAG_16BIT_DATA_REG | OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK; /* how the cpu bus is wired up differs for 7xx only */ if (cpu_is_omap7xx()) pdata->flags |= OMAP_I2C_FLAG_BUS_SHIFT_1; else pdata->flags |= OMAP_I2C_FLAG_BUS_SHIFT_2; pdev->dev.platform_data = pdata; return platform_device_register(pdev); } static int __init omap_i2c_cmdline(void) { return omap_register_i2c_bus_cmdline(); } subsys_initcall(omap_i2c_cmdline);
74cb75e1d9c1cce8315a0eaa6e5285e5f08ca993
1577e1cf4e89584a125cffb855ca50a9654c6d55
/Heimdal/lib/hcrypto/bn.c
fe48cadc1ac2f2c0754258ed68e3185850112f1c
[ "BSD-3-Clause" ]
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
10,863
c
bn.c
/* * Copyright (c) 2006 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * 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 Institute 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 INSTITUTE 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 INSTITUTE 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. */ #include <config.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #include <krb5-types.h> #include <roken.h> #include <rfc2459_asn1.h> /* XXX */ #include <der.h> #include <bn.h> #include <rand.h> #include <hex.h> BIGNUM * BN_new(void) { heim_integer *hi; hi = calloc(1, sizeof(*hi)); return (BIGNUM *)hi; } void BN_free(BIGNUM *bn) { BN_clear(bn); free(bn); } void BN_clear(BIGNUM *bn) { heim_integer *hi = (heim_integer *)bn; if (hi->data) { memset(hi->data, 0, hi->length); free(hi->data); } memset(hi, 0, sizeof(*hi)); } void BN_clear_free(BIGNUM *bn) { BN_free(bn); } BIGNUM * BN_dup(const BIGNUM *bn) { BIGNUM *b = BN_new(); if (der_copy_heim_integer((const heim_integer *)bn, (heim_integer *)b)) { BN_free(b); return NULL; } return b; } /* * If the caller really want to know the number of bits used, subtract * one from the length, multiply by 8, and then lookup in the table * how many bits the hightest byte uses. */ int BN_num_bits(const BIGNUM *bn) { static unsigned char num2bits[256] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4, 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, }; const heim_integer *i = (const void *)bn; if (i->length == 0) return 0; return (i->length - 1) * 8 + num2bits[((unsigned char *)i->data)[0]]; } int BN_num_bytes(const BIGNUM *bn) { return ((const heim_integer *)bn)->length; } /* * Ignore negative flag. */ BIGNUM * BN_bin2bn(const void *s, int len, BIGNUM *bn) { heim_integer *hi = (void *)bn; if (len < 0) return NULL; if (hi == NULL) { hi = (heim_integer *)BN_new(); if (hi == NULL) return NULL; } if (hi->data) BN_clear((BIGNUM *)hi); hi->negative = 0; hi->data = malloc(len); if (hi->data == NULL && len != 0) { if (bn == NULL) BN_free((BIGNUM *)hi); return NULL; } hi->length = len; memcpy(hi->data, s, len); return (BIGNUM *)hi; } int BN_bn2bin(const BIGNUM *bn, void *to) { const heim_integer *hi = (const void *)bn; memcpy(to, hi->data, hi->length); return hi->length; } int BN_hex2bn(BIGNUM **bnp, const char *in) { int negative; ssize_t ret; size_t len; void *data; len = strlen(in); data = malloc(len); if (data == NULL) return 0; if (*in == '-') { negative = 1; in++; } else negative = 0; ret = hex_decode(in, data, len); if (ret < 0) { free(data); return 0; } *bnp = BN_bin2bn(data, ret, NULL); free(data); if (*bnp == NULL) return 0; BN_set_negative(*bnp, negative); return 1; } char * BN_bn2hex(const BIGNUM *bn) { ssize_t ret; size_t len; void *data; char *str; len = BN_num_bytes(bn); data = malloc(len); if (data == NULL) return 0; len = BN_bn2bin(bn, data); ret = hex_encode(data, len, &str); free(data); if (ret < 0) return 0; return str; } int BN_cmp(const BIGNUM *bn1, const BIGNUM *bn2) { return der_heim_integer_cmp((const heim_integer *)bn1, (const heim_integer *)bn2); } void BN_set_negative(BIGNUM *bn, int flag) { ((heim_integer *)bn)->negative = (flag ? 1 : 0); } int BN_is_negative(const BIGNUM *bn) { return ((const heim_integer *)bn)->negative ? 1 : 0; } static const unsigned char is_set[8] = { 1, 2, 4, 8, 16, 32, 64, 128 }; int BN_is_bit_set(const BIGNUM *bn, int bit) { heim_integer *hi = (heim_integer *)bn; unsigned char *p = hi->data; if (bit < 0) return 0; if (((size_t)bit / 8) >= hi->length || hi->length == 0) return 0; return p[hi->length - 1 - (bit / 8)] & is_set[bit % 8]; } int BN_set_bit(BIGNUM *bn, int bit) { heim_integer *hi = (heim_integer *)bn; unsigned char *p; if (bit < 0) return 0; if (((size_t)bit / 8) > hi->length || hi->length == 0) { size_t len = (bit + 7) / 8; void *d = realloc(hi->data, len); if (d == NULL) return 0; hi->data = d; p = hi->data; memset(&p[hi->length], 0, len); hi->length = len; } else p = hi->data; p[hi->length - 1 - (bit / 8)] |= is_set[bit % 8]; return 1; } int BN_clear_bit(BIGNUM *bn, int bit) { heim_integer *hi = (heim_integer *)bn; unsigned char *p = hi->data; if (bit < 0) return 0; if (((size_t)bit / 8) > hi->length || hi->length == 0) return 0; p[hi->length - 1 - (bit / 8)] &= (unsigned char)(~(is_set[bit % 8])); return 1; } int BN_set_word(BIGNUM *bn, unsigned long num) { unsigned char p[sizeof(num)]; unsigned long num2; int i, len; for (num2 = num, i = 0; num2 > 0; i++) num2 = num2 >> 8; len = i; for (; i > 0; i--) { p[i - 1] = (num & 0xff); num = num >> 8; } if (BN_bin2bn(p, len, bn) == NULL) return 0; return 1; } unsigned long BN_get_word(const BIGNUM *bn) { heim_integer *hi = (heim_integer *)bn; unsigned long num = 0; size_t i; if (hi->negative || hi->length > sizeof(num)) return ULONG_MAX; for (i = 0; i < hi->length; i++) num = ((unsigned char *)hi->data)[i] | (num << 8); return num; } int BN_rand(BIGNUM *bn, int bits, int top, int bottom) { size_t len = (bits + 7) / 8; heim_integer *i = (heim_integer *)bn; BN_clear(bn); i->negative = 0; i->data = malloc(len); if (i->data == NULL && len != 0) return 0; i->length = len; if (RAND_bytes(i->data, i->length) != 1) { free(i->data); i->data = NULL; return 0; } { int j = len * 8; while(j > bits) { BN_clear_bit(bn, j - 1); j--; } } if (top == -1) { ; } else if (top == 0 && bits > 0) { BN_set_bit(bn, bits - 1); } else if (top == 1 && bits > 1) { BN_set_bit(bn, bits - 1); BN_set_bit(bn, bits - 2); } else { BN_clear(bn); return 0; } if (bottom && bits > 0) BN_set_bit(bn, 0); return 1; } /* * */ int BN_uadd(BIGNUM *res, const BIGNUM *a, const BIGNUM *b) { const heim_integer *ai = (const heim_integer *)a; const heim_integer *bi = (const heim_integer *)b; const unsigned char *ap, *bp; unsigned char *cp; heim_integer ci; int carry = 0; ssize_t len; if (ai->negative && bi->negative) return 0; if (ai->length < bi->length) { const heim_integer *si = bi; bi = ai; ai = si; } ci.negative = 0; ci.length = ai->length + 1; ci.data = malloc(ci.length); if (ci.data == NULL) return 0; ap = &((const unsigned char *)ai->data)[ai->length - 1]; bp = &((const unsigned char *)bi->data)[bi->length - 1]; cp = &((unsigned char *)ci.data)[ci.length - 1]; for (len = bi->length; len > 0; len--) { carry = *ap + *bp + carry; *cp = carry & 0xff; carry = (carry & ~0xff) ? 1 : 0; ap--; bp--; cp--; } for (len = ai->length - bi->length; len > 0; len--) { carry = *ap + carry; *cp = carry & 0xff; carry = (carry & ~0xff) ? 1 : 0; ap--; cp--; } if (!carry) memmove(cp, cp + 1, --ci.length); else *cp = carry; BN_clear(res); *((heim_integer *)res) = ci; return 1; } /* * Callback when doing slow generation of numbers, like primes. */ void BN_GENCB_set(BN_GENCB *gencb, int (*cb_2)(int, int, BN_GENCB *), void *ctx) { gencb->ver = 2; gencb->cb.cb_2 = cb_2; gencb->arg = ctx; } int BN_GENCB_call(BN_GENCB *cb, int a, int b) { if (cb == NULL || cb->cb.cb_2 == NULL) return 1; return cb->cb.cb_2(a, b, cb); } /* * */ struct BN_CTX { struct { BIGNUM **val; size_t used; size_t len; } bn; struct { size_t *val; size_t used; size_t len; } stack; }; BN_CTX * BN_CTX_new(void) { struct BN_CTX *c; c = calloc(1, sizeof(*c)); return c; } void BN_CTX_free(BN_CTX *c) { size_t i; for (i = 0; i < c->bn.len; i++) BN_free(c->bn.val[i]); free(c->bn.val); free(c->stack.val); } BIGNUM * BN_CTX_get(BN_CTX *c) { if (c->bn.used == c->bn.len) { void *ptr; size_t i; c->bn.len += 16; ptr = realloc(c->bn.val, c->bn.len * sizeof(c->bn.val[0])); if (ptr == NULL) return NULL; c->bn.val = ptr; for (i = c->bn.used; i < c->bn.len; i++) { c->bn.val[i] = BN_new(); if (c->bn.val[i] == NULL) { c->bn.len = i; return NULL; } } } return c->bn.val[c->bn.used++]; } void BN_CTX_start(BN_CTX *c) { if (c->stack.used == c->stack.len) { void *ptr; c->stack.len += 16; ptr = realloc(c->stack.val, c->stack.len * sizeof(c->stack.val[0])); if (ptr == NULL) abort(); c->stack.val = ptr; } c->stack.val[c->stack.used++] = c->bn.used; } void BN_CTX_end(BN_CTX *c) { const size_t prev = c->stack.val[c->stack.used - 1]; size_t i; if (c->stack.used == 0) abort(); for (i = prev; i < c->bn.used; i++) BN_clear(c->bn.val[i]); c->stack.used--; c->bn.used = prev; }
eb1bb44364ee9eb861d2f8ef19c791931129bef8
03666e5f961946fc1a0ac67781ac1425562ef0d7
/src/mdserver/rpc/LoadPluginsRPC.C
59e72e5905ec53396a04a06b5d5096f16f2157ff
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
visit-dav/visit
e9f81b4d4b9b9930a0db9d5282cd1bcabf465e2e
601ae46e0bef2e18425b482a755d03490ade0493
refs/heads/develop
2023-09-06T08:19:38.397058
2023-09-05T21:29:32
2023-09-05T21:29:32
165,565,988
335
120
BSD-3-Clause
2023-09-14T00:53:37
2019-01-13T23:27:26
C
UTF-8
C
false
false
2,390
c
LoadPluginsRPC.C
// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt // Project developers. See the top-level LICENSE file for dates and other // details. No copyright assignment is required to contribute to VisIt. #include <LoadPluginsRPC.h> // **************************************************************************** // Method: LoadPluginsRPC::LoadPluginsRPC // // Purpose: // Constructor for the LoadPluginsRPC class. // // Programmer: Hank Childs // Creation: January 22, 2004 // // **************************************************************************** LoadPluginsRPC::LoadPluginsRPC() : NonBlockingRPC("") { } // **************************************************************************** // Method: LoadPluginsRPC::~LoadPluginsRPC // // Purpose: // Destructor for the LoadPluginsRPC class. // // Programmer: Hank Childs // Creation: January 22, 2004 // // Modifications: // // **************************************************************************** LoadPluginsRPC::~LoadPluginsRPC() { } // **************************************************************************** // Method: LoadPluginsRPC::operator() // // Purpose: // This is the invokation method for this function object. It copies the // arguments into local attributes and calls RPC's Execute method. // // Programmer: Hank Childs // Creation: January 22, 2004 // // **************************************************************************** void LoadPluginsRPC::operator()(void) { Execute(); } // **************************************************************************** // Method: LoadPluginsRPC::SelectAll // // Purpose: // Gets the addresses of the local attributes so the attributes can be // transmitted over the network as AttributeGroups. // // Programmer: Hank Childs // Creation: January 22, 2004 // // **************************************************************************** void LoadPluginsRPC::SelectAll() { } // **************************************************************************** // Method: LoadPluginsRPC::TypeName // // Purpose: // Returns the RPC name. // // Programmer: Brad Whitlock // Creation: Fri Dec 7 11:09:23 PST 2007 // // Modifications: // // **************************************************************************** const std::string LoadPluginsRPC::TypeName() const { return "LoadPluginsRPC"; }