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
7d5746c8308a49b3d7e0e4ee59753e9d97b4f949
c9bc99866cfab223c777cfb741083be3e9439d81
/product/optee-stm32mp1/fw/config_scmi_clocks.c
478ae58827f5e436a05eee1b7a57c17caa07f30a
[ "BSD-3-Clause" ]
permissive
ARM-software/SCP-firmware
4738ca86ce42d82588ddafc2226a1f353ff2c797
f6bcca436768359ffeadd84d65e8ea0c3efc7ef1
refs/heads/master
2023-09-01T16:13:36.962036
2023-08-17T13:00:20
2023-08-31T07:43:37
134,399,880
211
165
NOASSERTION
2023-09-13T14:27:10
2018-05-22T10:35:56
C
UTF-8
C
false
false
8,956
c
config_scmi_clocks.c
/* * Arm SCP/MCP Software * Copyright (c) 2022, Linaro Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include <fwk_element.h> #include <fwk_id.h> #include <fwk_module.h> #include <fwk_module_idx.h> #include <mod_clock.h> #include <mod_optee_clock.h> #include <mod_scmi_clock.h> #include <scmi_agents.h> #include <assert.h> #include <stddef.h> #include <stdint.h> #include <dt-bindings/clock/stm32mp1-clks.h> #include <stm32_util.h> #include <util.h> /* * Indices of clock elements exposed through a SCMI agent. * As all exposed SCMI clocks relate to a single backend dirver * these indices are used as indices for fwk elements for modules * CLOCK and STM32_CLOCK. Note these are not the clock ID values * exposed through SCMI. */ enum clock_elt_idx { /* Clocks exposed to agent SCMI */ CLK_IDX_SCMI_HSE, CLK_IDX_SCMI_HSI, CLK_IDX_SCMI_CSI, CLK_IDX_SCMI_LSE, CLK_IDX_SCMI_LSI, CLK_IDX_SCMI_PLL2_Q, CLK_IDX_SCMI_PLL2_R, CLK_IDX_SCMI_MPU, CLK_IDX_SCMI_AXI, CLK_IDX_SCMI_BSEC, CLK_IDX_SCMI_CRYP1, CLK_IDX_SCMI_GPIOZ, CLK_IDX_SCMI_HASH1, CLK_IDX_SCMI_I2C4, CLK_IDX_SCMI_I2C6, CLK_IDX_SCMI_IWDG1, CLK_IDX_SCMI_RNG1, CLK_IDX_SCMI_RTC, CLK_IDX_SCMI_RTCAPB, CLK_IDX_SCMI_SPI6, CLK_IDX_SCMI_USART1, /* Count indices */ CLK_IDX_COUNT }; struct mod_stm32_clock_dev_config { const char *name; unsigned long rcc_clk_id; bool default_enabled; }; /* * stm32_clock_cfg - Common configuration for exposed SCMI clocks * * Clock name defined here is used for all CLOCK and STM32_CLOCK * fwk elements names. */ #define STM32_CLOCK_CFG(_idx, _rcc_clk_id, _name, _default_enabled) \ [(_idx)] = { \ .rcc_clk_id = (_rcc_clk_id), \ .name = (_name), \ .default_enabled = (_default_enabled), \ } static const struct mod_stm32_clock_dev_config stm32_clock_cfg[] = { STM32_CLOCK_CFG(CLK_IDX_SCMI_HSE, CK_HSE, "ck_hse", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_HSI, CK_HSI, "ck_hsi", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_CSI, CK_CSI, "ck_csi", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_LSE, CK_LSE, "ck_lse", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_LSI, CK_LSI, "ck_lsi", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_PLL2_Q, PLL2_Q, "pll2_q", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_PLL2_R, PLL2_R, "pll2_r", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_MPU, CK_MCU, "ck_mpu", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_AXI, CK_AXI, "ck_axi", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_BSEC, BSEC, "bsec", false), STM32_CLOCK_CFG(CLK_IDX_SCMI_CRYP1, CRYP1, "cryp1", false), STM32_CLOCK_CFG(CLK_IDX_SCMI_GPIOZ, GPIOZ, "gpioz", false), STM32_CLOCK_CFG(CLK_IDX_SCMI_HASH1, HASH1, "hash1", false), STM32_CLOCK_CFG(CLK_IDX_SCMI_I2C4, I2C4_K, "i2c4_k", false), STM32_CLOCK_CFG(CLK_IDX_SCMI_I2C6, I2C6_K, "i2c6_k", false), STM32_CLOCK_CFG(CLK_IDX_SCMI_IWDG1, IWDG1, "iwdg1", false), STM32_CLOCK_CFG(CLK_IDX_SCMI_RNG1, RNG1_K, "rng1_k", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_RTC, RTC, "ck_rtc", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_RTCAPB, RTCAPB, "rtcapb", true), STM32_CLOCK_CFG(CLK_IDX_SCMI_SPI6, SPI6_K, "spi6_k", false), STM32_CLOCK_CFG(CLK_IDX_SCMI_USART1, USART1_K, "usart1_k", false), }; /* * Bindgins between SCMI clock_id value and clock module element in fwk */ #define SCMI_CLOCK_ELT_ID(_idx) \ { .element_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, (_idx)) } static struct mod_scmi_clock_device scmi_clock_device[] = { [CK_SCMI_HSE] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_HSE), [CK_SCMI_HSI] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_HSI), [CK_SCMI_CSI] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_CSI), [CK_SCMI_LSE] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_LSE), [CK_SCMI_LSI] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_LSI), [CK_SCMI_PLL2_Q] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_PLL2_Q), [CK_SCMI_PLL2_R] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_PLL2_R), [CK_SCMI_MPU] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_MPU), [CK_SCMI_AXI] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_AXI), [CK_SCMI_BSEC] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_BSEC), [CK_SCMI_CRYP1] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_CRYP1), [CK_SCMI_GPIOZ] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_GPIOZ), [CK_SCMI_HASH1] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_HASH1), [CK_SCMI_I2C4] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_I2C4), [CK_SCMI_I2C6] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_I2C6), [CK_SCMI_IWDG1] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_IWDG1), [CK_SCMI_RNG1] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_RNG1), [CK_SCMI_RTC] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_RTC), [CK_SCMI_RTCAPB] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_RTCAPB), [CK_SCMI_SPI6] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_SPI6), [CK_SCMI_USART1] = SCMI_CLOCK_ELT_ID(CLK_IDX_SCMI_USART1), }; /* Agents and clocks references */ static const struct mod_scmi_clock_agent clk_agent_tbl[SCMI_AGENT_ID_COUNT] = { [SCMI_AGENT_ID_NSEC0] = { .device_table = (void *)scmi_clock_device, .device_count = FWK_ARRAY_SIZE(scmi_clock_device), }, }; /* Exported configuration data for module SCMI_CLOCK */ struct fwk_module_config config_scmi_clock = { .data = &((struct mod_scmi_clock_config){ .agent_table = clk_agent_tbl, .agent_count = FWK_ARRAY_SIZE(clk_agent_tbl), }), }; /* * Clock backend driver configuration * STM32_CLOCK element index is the related CLOCK element index. */ #define CLOCK_DATA(_idx) ((struct mod_clock_dev_config){ \ .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_OPTEE_CLOCK, \ (_idx)), \ .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_OPTEE_CLOCK, 0), \ }) #define CLOCK_ELT(_idx) [(_idx)] = { \ .name = stm32_clock_cfg[(_idx)].name, \ .data = &CLOCK_DATA((_idx)), \ } /* Element names are the clock names exposed by the SCMI service */ static struct fwk_element clock_elt[] = { /* Clocks exposed to agent SCMI */ CLOCK_ELT(CLK_IDX_SCMI_HSE), CLOCK_ELT(CLK_IDX_SCMI_HSI), CLOCK_ELT(CLK_IDX_SCMI_CSI), CLOCK_ELT(CLK_IDX_SCMI_LSE), CLOCK_ELT(CLK_IDX_SCMI_LSI), CLOCK_ELT(CLK_IDX_SCMI_PLL2_Q), CLOCK_ELT(CLK_IDX_SCMI_PLL2_R), CLOCK_ELT(CLK_IDX_SCMI_MPU), CLOCK_ELT(CLK_IDX_SCMI_AXI), CLOCK_ELT(CLK_IDX_SCMI_BSEC), CLOCK_ELT(CLK_IDX_SCMI_CRYP1), CLOCK_ELT(CLK_IDX_SCMI_GPIOZ), CLOCK_ELT(CLK_IDX_SCMI_HASH1), CLOCK_ELT(CLK_IDX_SCMI_I2C4), CLOCK_ELT(CLK_IDX_SCMI_I2C6), CLOCK_ELT(CLK_IDX_SCMI_IWDG1), CLOCK_ELT(CLK_IDX_SCMI_RNG1), CLOCK_ELT(CLK_IDX_SCMI_RTC), CLOCK_ELT(CLK_IDX_SCMI_RTCAPB), CLOCK_ELT(CLK_IDX_SCMI_SPI6), CLOCK_ELT(CLK_IDX_SCMI_USART1), /* Termination entry */ [CLK_IDX_COUNT] = { 0 } }; static_assert(FWK_ARRAY_SIZE(clock_elt) == CLK_IDX_COUNT + 1, "Invalid range for CLOCK and STM32_CLOCK indices"); /* Exported configuration data for module VOLTAGE_DOMAIN */ const struct fwk_module_config config_clock = { .elements = FWK_MODULE_STATIC_ELEMENTS_PTR(clock_elt), }; #define CLOCK_COUNT FWK_ARRAY_SIZE(stm32_clock_cfg) static struct mod_optee_clock_config optee_clock_cfg[CLOCK_COUNT]; #define OPTEE_CLOCK_ELT(_idx) \ [(_idx)] = { \ .name = stm32_clock_cfg[(_idx)].name, \ .data = &optee_clock_cfg[(_idx)], \ } static const struct fwk_element optee_clock_elt[] = { /* Clocks exposed to agent SCMI */ OPTEE_CLOCK_ELT(CLK_IDX_SCMI_HSE), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_HSI), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_CSI), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_LSE), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_LSI), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_PLL2_Q), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_PLL2_R), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_MPU), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_AXI), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_BSEC), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_CRYP1), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_GPIOZ), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_HASH1), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_I2C4), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_I2C6), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_IWDG1), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_RNG1), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_RTC), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_RTCAPB), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_SPI6), OPTEE_CLOCK_ELT(CLK_IDX_SCMI_USART1), /* Termination entry */ [CLK_IDX_COUNT] = { 0 } }; static_assert(FWK_ARRAY_SIZE(optee_clock_elt) == CLK_IDX_COUNT + 1, "Invalid range for CLOCK and STM32_CLOCK indices"); static const struct fwk_element *optee_clock_get_elt_table(fwk_id_t module_id) { size_t n; for (n = 0; n < FWK_ARRAY_SIZE(optee_clock_cfg); n++) { optee_clock_cfg[n].clk = stm32mp_rcc_clock_id_to_clk(stm32_clock_cfg[n].rcc_clk_id); optee_clock_cfg[n].default_enabled = stm32_clock_cfg[n].default_enabled; } return optee_clock_elt; } struct fwk_module_config config_optee_clock = { .elements = FWK_MODULE_DYNAMIC_ELEMENTS(optee_clock_get_elt_table), };
b700dde0592c657ad0c673d398f1a4ffab797107
de21f9075f55640514c29ef0f1fe3f0690845764
/regression/contracts-dfcc/assigns_type_checking_invalid_case_02/main.c
380604fd314f7d109acbe5b98601545b900f66e0
[ "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
491
c
main.c
#include <assert.h> void bar(char d[]) __CPROVER_assigns(d[7]) { } int main() { char b[10]; b[0] = 'a'; b[1] = 'b'; b[2] = 'c'; b[3] = 'd'; b[4] = 'e'; b[5] = 'f'; b[6] = 'g'; b[7] = 'h'; b[8] = 'i'; b[9] = 'j'; bar(b); assert(b[0] == 'a'); assert(b[1] == 'b'); assert(b[2] == 'c'); assert(b[3] == 'd'); assert(b[4] == 'e'); assert(b[5] == 'f'); assert(b[6] == 'g'); assert(b[7] == 'h'); assert(b[8] == 'i'); assert(b[9] == 'j'); return 0; }
0566aecdf093fb1f284ed7ac52bce9884b323760
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/stm32/stm32mp157a-st-ev1/board/ports/drv_nand.h
094635ebfbbcc58ba32935b836ebf9d6db80ed9a
[ "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
1,818
h
drv_nand.h
/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2020-00-30 thread-liu first version */ #ifndef __DRV_NAND_H__ #define __DRV_NAND_H__ #include "board.h" #ifdef __cplusplus extern "C" { #endif #define NAND_MAX_PAGE_SIZE 4096 #define NAND_ECC_SECTOR_SIZE 512 #define NAND_TWHR_DELAY 25 #define NAND_TBERS_DELAY 4 #define MT29F8G08ABACAH4 0x64A690D3 /* id */ #define NAND_ADDR ((rt_uint32_t)0x80000000) /* nand base address */ #define NAND_ADDR_AREA (*(__IO rt_uint8_t *)NAND_ADDR) #define NAND_CMD_AREA (*(__IO rt_uint8_t *)(NAND_ADDR | 1 << 16)) /* command */ #define NAND_DATA_AREA (*(__IO rt_uint8_t *)(NAND_ADDR | 1 << 17)) /* data */ /* nand flash command */ #define NAND_READID 0x90 #define NAND_FEATURE 0xEF #define NAND_RESET 0xFF #define NAND_READSTA 0x70 #define NAND_AREA_A 0x00 #define NAND_AREA_TRUE1 0x30 #define NAND_WRITE0 0x80 #define NAND_WRITE_TURE1 0x10 #define NAND_ERASE0 0x60 #define NAND_ERASE1 0xD0 #define NAND_MOVEDATA_CMD0 0x00 #define NAND_MOVEDATA_CMD1 0x35 #define NAND_MOVEDATA_CMD2 0x85 #define NAND_MOVEDATA_CMD3 0x10 /* nand flash status */ #define NAND_READY 0x40 /* read */ #define NAND_ECC1BITERR 0x03 /* ECC 1bit err */ #define NAND_ECC2BITERR 0x04 /* ECC 2bit or more err */ #ifdef __cplusplus } #endif #endif
390ceea5d832914946dec6fa2c41b82eaa6d3d58
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/isdn/hysdn/hysdn_defs.h
cdac46a21692a97db26cec433d421923710f41f8
[ "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
10,861
h
hysdn_defs.h
/* $Id: hysdn_defs.h,v 1.5.6.3 2001/09/23 22:24:54 kai Exp $ * * Linux driver for HYSDN cards * global definitions and exported vars and functions. * * Author Werner Cornelius (werner@titro.de) for Hypercope GmbH * Copyright 1999 by Werner Cornelius (werner@titro.de) * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ #ifndef HYSDN_DEFS_H #define HYSDN_DEFS_H #include <linux/hysdn_if.h> #include <linux/interrupt.h> #include <linux/workqueue.h> #include <linux/skbuff.h> #include "ince1pc.h" #ifdef CONFIG_HYSDN_CAPI #include <linux/capi.h> #include <linux/isdn/capicmd.h> #include <linux/isdn/capiutil.h> #include <linux/isdn/capilli.h> /***************************/ /* CAPI-Profile values. */ /***************************/ #define GLOBAL_OPTION_INTERNAL_CONTROLLER 0x0001 #define GLOBAL_OPTION_EXTERNAL_CONTROLLER 0x0002 #define GLOBAL_OPTION_HANDSET 0x0004 #define GLOBAL_OPTION_DTMF 0x0008 #define GLOBAL_OPTION_SUPPL_SERVICES 0x0010 #define GLOBAL_OPTION_CHANNEL_ALLOCATION 0x0020 #define GLOBAL_OPTION_B_CHANNEL_OPERATION 0x0040 #define B1_PROT_64KBIT_HDLC 0x0001 #define B1_PROT_64KBIT_TRANSPARENT 0x0002 #define B1_PROT_V110_ASYNCH 0x0004 #define B1_PROT_V110_SYNCH 0x0008 #define B1_PROT_T30 0x0010 #define B1_PROT_64KBIT_INV_HDLC 0x0020 #define B1_PROT_56KBIT_TRANSPARENT 0x0040 #define B2_PROT_ISO7776 0x0001 #define B2_PROT_TRANSPARENT 0x0002 #define B2_PROT_SDLC 0x0004 #define B2_PROT_LAPD 0x0008 #define B2_PROT_T30 0x0010 #define B2_PROT_PPP 0x0020 #define B2_PROT_TRANSPARENT_IGNORE_B1_FRAMING_ERRORS 0x0040 #define B3_PROT_TRANSPARENT 0x0001 #define B3_PROT_T90NL 0x0002 #define B3_PROT_ISO8208 0x0004 #define B3_PROT_X25_DCE 0x0008 #define B3_PROT_T30 0x0010 #define B3_PROT_T30EXT 0x0020 #define HYSDN_MAXVERSION 8 /* Number of sendbuffers in CAPI-queue */ #define HYSDN_MAX_CAPI_SKB 20 #endif /* CONFIG_HYSDN_CAPI*/ /************************************************/ /* constants and bits for debugging/log outputs */ /************************************************/ #define LOG_MAX_LINELEN 120 #define DEB_OUT_SYSLOG 0x80000000 /* output to syslog instead of proc fs */ #define LOG_MEM_ERR 0x00000001 /* log memory errors like kmalloc failure */ #define LOG_POF_OPEN 0x00000010 /* log pof open and close activities */ #define LOG_POF_RECORD 0x00000020 /* log pof record parser */ #define LOG_POF_WRITE 0x00000040 /* log detailed pof write operation */ #define LOG_POF_CARD 0x00000080 /* log pof related card functions */ #define LOG_CNF_LINE 0x00000100 /* all conf lines are put to procfs */ #define LOG_CNF_DATA 0x00000200 /* non comment conf lines are shown with channel */ #define LOG_CNF_MISC 0x00000400 /* additional conf line debug outputs */ #define LOG_SCHED_ASYN 0x00001000 /* debug schedulers async tx routines */ #define LOG_PROC_OPEN 0x00100000 /* open and close from procfs are logged */ #define LOG_PROC_ALL 0x00200000 /* all actions from procfs are logged */ #define LOG_NET_INIT 0x00010000 /* network init and deinit logging */ #define DEF_DEB_FLAGS 0x7fff000f /* everything is logged to procfs */ /**********************************/ /* proc filesystem name constants */ /**********************************/ #define PROC_SUBDIR_NAME "hysdn" #define PROC_CONF_BASENAME "cardconf" #define PROC_LOG_BASENAME "cardlog" /***********************************/ /* PCI 32 bit parms for IO and MEM */ /***********************************/ #define PCI_REG_PLX_MEM_BASE 0 #define PCI_REG_PLX_IO_BASE 1 #define PCI_REG_MEMORY_BASE 3 /**************/ /* card types */ /**************/ #define BD_NONE 0U #define BD_PERFORMANCE 1U #define BD_VALUE 2U #define BD_PCCARD 3U #define BD_ERGO 4U #define BD_METRO 5U #define BD_CHAMP2 6U #define BD_PLEXUS 7U /******************************************************/ /* defined states for cards shown by reading cardconf */ /******************************************************/ #define CARD_STATE_UNUSED 0 /* never been used or booted */ #define CARD_STATE_BOOTING 1 /* booting is in progress */ #define CARD_STATE_BOOTERR 2 /* a previous boot was aborted */ #define CARD_STATE_RUN 3 /* card is active */ /*******************************/ /* defines for error_log_state */ /*******************************/ #define ERRLOG_STATE_OFF 0 /* error log is switched off, nothing to do */ #define ERRLOG_STATE_ON 1 /* error log is switched on, wait for data */ #define ERRLOG_STATE_START 2 /* start error logging */ #define ERRLOG_STATE_STOP 3 /* stop error logging */ /*******************************/ /* data structure for one card */ /*******************************/ typedef struct HYSDN_CARD { /* general variables for the cards */ int myid; /* own driver card id */ unsigned char bus; /* pci bus the card is connected to */ unsigned char devfn; /* slot+function bit encoded */ unsigned short subsysid;/* PCI subsystem id */ unsigned char brdtype; /* type of card */ unsigned int bchans; /* number of available B-channels */ unsigned int faxchans; /* number of available fax-channels */ unsigned char mac_addr[6];/* MAC Address read from card */ unsigned int irq; /* interrupt number */ unsigned int iobase; /* IO-port base address */ unsigned long plxbase; /* PLX memory base */ unsigned long membase; /* DPRAM memory base */ unsigned long memend; /* DPRAM memory end */ void *dpram; /* mapped dpram */ int state; /* actual state of card -> CARD_STATE_** */ struct HYSDN_CARD *next; /* pointer to next card */ /* data areas for the /proc file system */ void *proclog; /* pointer to proclog filesystem specific data */ void *procconf; /* pointer to procconf filesystem specific data */ /* debugging and logging */ unsigned char err_log_state;/* actual error log state of the card */ unsigned long debug_flags;/* tells what should be debugged and where */ void (*set_errlog_state) (struct HYSDN_CARD *, int); /* interrupt handler + interrupt synchronisation */ struct work_struct irq_queue; /* interrupt task queue */ unsigned char volatile irq_enabled;/* interrupt enabled if != 0 */ unsigned char volatile hw_lock;/* hardware is currently locked -> no access */ /* boot process */ void *boot; /* pointer to boot private data */ int (*writebootimg) (struct HYSDN_CARD *, unsigned char *, unsigned long); int (*writebootseq) (struct HYSDN_CARD *, unsigned char *, int); int (*waitpofready) (struct HYSDN_CARD *); int (*testram) (struct HYSDN_CARD *); /* scheduler for data transfer (only async parts) */ unsigned char async_data[256];/* async data to be sent (normally for config) */ unsigned short volatile async_len;/* length of data to sent */ unsigned short volatile async_channel;/* channel number for async transfer */ int volatile async_busy; /* flag != 0 sending in progress */ int volatile net_tx_busy; /* a network packet tx is in progress */ /* network interface */ void *netif; /* pointer to network structure */ /* init and deinit stopcard for booting, too */ void (*stopcard) (struct HYSDN_CARD *); void (*releasehardware) (struct HYSDN_CARD *); spinlock_t hysdn_lock; #ifdef CONFIG_HYSDN_CAPI struct hycapictrl_info { char cardname[32]; spinlock_t lock; int versionlen; char versionbuf[1024]; char *version[HYSDN_MAXVERSION]; char infobuf[128]; /* for function procinfo */ struct HYSDN_CARD *card; struct capi_ctr capi_ctrl; struct sk_buff *skbs[HYSDN_MAX_CAPI_SKB]; int in_idx, out_idx; /* indexes to buffer ring */ int sk_count; /* number of buffers currently in ring */ struct sk_buff *tx_skb; /* buffer for tx operation */ struct list_head ncci_head; } *hyctrlinfo; #endif /* CONFIG_HYSDN_CAPI */ } hysdn_card; #ifdef CONFIG_HYSDN_CAPI typedef struct hycapictrl_info hycapictrl_info; #endif /* CONFIG_HYSDN_CAPI */ /*****************/ /* exported vars */ /*****************/ extern hysdn_card *card_root; /* pointer to first card */ /*************************/ /* im/exported functions */ /*************************/ /* hysdn_procconf.c */ extern int hysdn_procconf_init(void); /* init proc config filesys */ extern void hysdn_procconf_release(void); /* deinit proc config filesys */ /* hysdn_proclog.c */ extern int hysdn_proclog_init(hysdn_card *); /* init proc log entry */ extern void hysdn_proclog_release(hysdn_card *); /* deinit proc log entry */ extern void hysdn_addlog(hysdn_card *, char *, ...); /* output data to log */ extern void hysdn_card_errlog(hysdn_card *, tErrLogEntry *, int); /* output card log */ /* boardergo.c */ extern int ergo_inithardware(hysdn_card *card); /* get hardware -> module init */ /* hysdn_boot.c */ extern int pof_write_close(hysdn_card *); /* close proc file after writing pof */ extern int pof_write_open(hysdn_card *, unsigned char **); /* open proc file for writing pof */ extern int pof_write_buffer(hysdn_card *, int); /* write boot data to card */ extern int EvalSysrTokData(hysdn_card *, unsigned char *, int); /* Check Sysready Token Data */ /* hysdn_sched.c */ extern int hysdn_sched_tx(hysdn_card *, unsigned char *, unsigned short volatile *, unsigned short volatile *, unsigned short); extern int hysdn_sched_rx(hysdn_card *, unsigned char *, unsigned short, unsigned short); extern int hysdn_tx_cfgline(hysdn_card *, unsigned char *, unsigned short); /* send one cfg line */ /* hysdn_net.c */ extern unsigned int hynet_enable; extern int hysdn_net_create(hysdn_card *); /* create a new net device */ extern int hysdn_net_release(hysdn_card *); /* delete the device */ extern char *hysdn_net_getname(hysdn_card *); /* get name of net interface */ extern void hysdn_tx_netack(hysdn_card *); /* acknowledge a packet tx */ extern struct sk_buff *hysdn_tx_netget(hysdn_card *); /* get next network packet */ extern void hysdn_rx_netpkt(hysdn_card *, unsigned char *, unsigned short); /* rxed packet from network */ #ifdef CONFIG_HYSDN_CAPI extern unsigned int hycapi_enable; extern int hycapi_capi_create(hysdn_card *); /* create a new capi device */ extern int hycapi_capi_release(hysdn_card *); /* delete the device */ extern int hycapi_capi_stop(hysdn_card *card); /* suspend */ extern void hycapi_rx_capipkt(hysdn_card *card, unsigned char *buf, unsigned short len); extern void hycapi_tx_capiack(hysdn_card *card); extern struct sk_buff *hycapi_tx_capiget(hysdn_card *card); extern int hycapi_init(void); extern void hycapi_cleanup(void); #endif /* CONFIG_HYSDN_CAPI */ #endif /* HYSDN_DEFS_H */
a76dc73a1a2f69a312a2e37b8fbcaeb2dfe8c061
1db673907c7946c2ea857cc9aa8b6f7f4060e36a
/Chapter/08_Device/Core/SkyAPI.h
8469462e985bdcca774d866b03765729a6feefa2
[ "BSD-3-Clause" ]
permissive
pdpdds/SkyOS
a973cd9f1b4e541ae4ac26d19df29aa3f4110db3
db2ce044c581fc2dfe068723fb0be2336c7f18d9
refs/heads/master
2023-07-21T15:24:46.457637
2023-07-17T16:32:04
2023-07-17T16:32:04
97,029,119
160
49
null
2023-04-30T15:33:47
2017-07-12T16:23:01
C
UHC
C
false
false
1,492
h
SkyAPI.h
#pragma once #include "windef.h" #include "SkyStruct.h" #include "time.h" #define ASSERT(a, b) if(a == false) SkyConsole::Print("Kernel Panic : %s\n", b); _asm hlt #define SKY_ASSERT(Expr, Msg) \ __SKY_ASSERT(#Expr, Expr, __FILE__, __LINE__, Msg) void __SKY_ASSERT(const char* expr_str, bool expr, const char* file, int line, const char* msg); #define kprintf SkyConsole::Print #define kEnterCriticalSection() __asm PUSHFD __asm CLI #define kLeaveCriticalSection() __asm POPFD ///////////////////////////////////////////////////////////////////////////// //동기화 ///////////////////////////////////////////////////////////////////////////// typedef struct _CRITICAL_SECTION { LONG LockRecursionCount; HANDLE OwningThread; // from the thread's ClientId->UniqueThread } CRITICAL_SECTION, *LPCRITICAL_SECTION;; ///////////////////////////////////////////////////////////////////////////// //스레드 ///////////////////////////////////////////////////////////////////////////// DWORD SKYAPI kGetCurrentThreadId(); bool GetLocalTime(LPSYSTEMTIME lpSystemTime); BYTE SetLocalTime(LPSYSTEMTIME lpSystemTime); void printf(const char* str, ...); void DumpMemory(void *data, size_t nbytes, size_t bytes_per_line); void ksleep(int millisecond); HANDLE CreateThread(SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreateionFlags, LPDWORD lpThreadId); void PauseSystem(const char* msg);
7e801b58b8913c11a1345fb09cd2961802040fae
01d69a143d554479a7e4218eeac1c1f28bbea356
/graphql-c_parser/ext/graphql_c_parser_ext/lexer.h
0bcd40ec6be90ba4bfdb08f7c590b8346b67fd35
[ "MIT" ]
permissive
rmosolgo/graphql-ruby
968ca6c55049d87a95f78c83b6e90b657d3d6a27
3e199f60f5a37289c67c94fba8a72b071efee21e
refs/heads/master
2023-08-30T09:04:02.535358
2023-08-29T14:26:28
2023-08-29T14:26:28
30,337,170
5,662
1,672
MIT
2023-09-14T13:20:58
2015-02-05T04:11:22
Ruby
UTF-8
C
false
false
145
h
lexer.h
#ifndef Graphql_lexer_h #define Graphql_lexer_h #include <ruby.h> VALUE tokenize(VALUE query_rbstr); void setup_static_token_variables(); #endif
ff81cdad2617f8c00ea373066ec8bbc07dca437e
c59784458e4dcb34eadd6941bc4297c28c1a7e53
/Compilers/glcc/gigatron/libc/_doprint.c
a2242b82e0e5ac89e6fe91770456db582b05e045
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-proprietary-license", "GPL-1.0-or-later", "BSD-2-Clause" ]
permissive
kervinck/gigatron-rom
42af9ce548d34d64ee667f662337ea7aa6d331e8
5d24889a661793ef0a9fb8d714bab9127307ee30
refs/heads/master
2023-07-30T02:11:24.748356
2023-07-07T06:27:20
2023-07-07T06:27:20
106,879,621
216
85
BSD-2-Clause
2023-08-08T09:40:32
2017-10-13T22:40:14
C
UTF-8
C
false
false
5,083
c
_doprint.c
#include <stdarg.h> #include <ctype.h> #include <string.h> #include <errno.h> #include "_doprint.h" void _doprint_putc(register doprint_t *dp, int c, register size_t cnt) { dp->cnt += cnt; while (cnt) { dp->f(dp->closure, (char*)&c, 1); cnt -= 1; } } void _doprint_puts(register doprint_t *dp, register const char *s, register size_t cnt) { register const char *e; if (e = memchr(s, 0, cnt)) cnt = e - s; dp->cnt += cnt; dp->f(dp->closure, s, cnt); } static const char *parsespec(const char *s, doprintspec_t *spec, va_list *ap) { static char fl[] = " + #0 - "; static char fv[] = { DPR_SPC, DPR_SGN, 0, DPR_ALT, DPR_ZEROJ, 0, DPR_LEFTJ, 0 }; register int f = spec->flags; register int c; register int *np; register int nf; c = *++s; /* Flags */ for(;;) { nf = (c ^ (c >> 2)) & 0x7; /* perfect hash */ if (fl[nf] != c) break; f |= fv[nf]; c = *++s; } /* Width and precision */ nf = DPR_WIDTH; np = &spec->width; num: if (c == '*') { f |= nf; *np = va_arg(*ap, int); c = *++s; } else { while (_isdigit(c)) { f |= nf; *np = *np * 10 + c - '0'; c = *++s; } } if (nf == DPR_WIDTH) { if (*np < 0) { f |= DPR_LEFTJ; *np = - *np; } if (c == '.') { c = *++s; nf = DPR_PREC; np = &spec->prec; goto num; } } /* Size modifier */ for(;;) { if (c == 'l') f |= DPR_LONG; else if (c != 'h') break; c = *++s; } spec->flags = f; spec->conv = c; return s; } static void do_str(doprint_t *dd, doprintspec_t *spec, const char *s, size_t l) { register const char *p; register int f = spec->flags; register int b = 0; if (l == 0) { l = 0xffffu; if (f & DPR_PREC) l = spec->prec; } if (p = memchr(s, 0, l)) l = p - s; if (f & DPR_WIDTH) b = spec->width - l; if (b > 0 && !(f & DPR_LEFTJ)) _doprint_putc(dd, ' ', b); _doprint_puts(dd, s, l); if (b > 0 && (f & DPR_LEFTJ)) _doprint_putc(dd, ' ', b); } static void upcase(char *s) { register int c; while (c = *s) { if (_islower(c)) *s = c ^ 0x20; s += 1; } } void _doprint_num(register doprint_t *dd, register doprintspec_t *spec, register int b, register char *s) { register int l, z; register int f = spec->flags; register char *p = ""; if (*s == '-') { p = "-"; s += 1; } else if (b & 1) { if (f & DPR_SGN) p = "+"; else if (f & DPR_SPC) p = " "; } if (*s == '0') { if (f & DPR_PREC) s += 1; } else if (f & DPR_ALT) { if (b == 8) { p = "0"; spec->prec -= 1; } else if (b == 16) p = "0x"; } b = strlen(p); l = strlen(s) + b; z = 0; if (f & DPR_PREC) { if ((z = spec->prec - l + b) < 0) z = 0; } else if (f & DPR_ZEROJ) { if ((z = spec->width - l) < 0) z = 0; } l = l + z; b = spec->width - l; if (_isupper(spec->conv)) { upcase(s); if (p[1]=='x') p = "0X"; } if (b > 0 && !(f & DPR_LEFTJ)) _doprint_putc(dd, ' ', b); if (p[0]) _doprint_puts(dd, p, 4); if (z > 0) _doprint_putc(dd, '0', z); _doprint_puts(dd, s, l); if (b > 0 && (f & DPR_LEFTJ)) _doprint_putc(dd, ' ', b); } static void do_int(register doprint_t *dd, register doprintspec_t *spec, register int b, register unsigned int x) { char buffer[8]; register char *s; register int f = spec->flags; if (b == 11) { s = itoa(x, buffer, 10); } else s = utoa(x, buffer, b); _doprint_num(dd, spec, b, s); } static int _doprint_conv_info(int c) { /* return n such that: - n == 0 for incorrect conversion letter - n == 129 for float conversions - n == 32, 64, 96 for c/s/n conversions - n & 0x1e is the radix for int conversions - n & 0x01 is nonzero when the format is signed */ static char convl[] = "EGxounsFegcipdXf"; static char displ[] = {/* EGxo */ 129, 129, 16, 8, /* unsF */ 10, 96, 64, 129, /* egci */ 129, 129, 32, 11, /* pdXf */ 16, 11, 16, 129 }; register int i = c; /* perfect hash */ if (i & 1) i += 58; if ((i ^ 199) - 187 > 0) i -= 187; i = (i ^ (i >> 2)) & 0xf; if (convl[i] == c) return displ[i]; return 0; } int _doprint(register doprint_t *dd, register const char *fmt, __va_list ap) { doprintspec_t spobj; register doprintspec_t *spec = &spobj; register int c; register unsigned int i; register const char *s; char tmp; /* loop */ for(; *fmt; fmt = s) { s = fmt; while((c = *s) && c != '%') s += 1; if (s != fmt) { pfmt: _doprint_puts(dd, fmt, s-fmt); continue; } if (s[1] == '%') { s += 1; fmt += 1; goto pfmt; } memset(spec, 0, sizeof(*spec)); s = parsespec(s, spec, &ap); if (! (c = _doprint_conv_info(*s++))) goto pfmt; if ((spec->flags & DPR_LONG) && (c & 0x1e)) { _doprint_long(dd, spec, c, &ap); } else if (c == 129) { _doprint_double(dd, spec, &ap); } else { i = va_arg(ap, unsigned int); if (c == 32) { tmp = (char)i; do_str(dd, spec, (const char*)&tmp, 1); } else if (c == 64) { do_str(dd, spec, (const char*)i, 0); } else if (c == 96) { *(int*)i = dd->cnt; } else { do_int(dd, spec, c, i); } } } return dd->cnt; }
add67e156507f84b3f45bf9298a9977b775dc132
e1d9c54e9925e30e388a255b53a93cccad0b94cb
/kubernetes/model/v1beta2_priority_level_configuration.c
dbbfdf4f920babcb58db745332147cefdc27792d
[ "Apache-2.0", "curl" ]
permissive
kubernetes-client/c
dd4fd8095485c083e0f40f2b48159b1609a6141b
5ac5ff25e9809a92a48111b1f77574b6d040b711
refs/heads/master
2023-08-13T10:51:03.702497
2023-08-07T19:18:32
2023-08-07T19:18:32
247,958,425
127
47
Apache-2.0
2023-09-07T20:07:00
2020-03-17T11:59:05
C
UTF-8
C
false
false
7,432
c
v1beta2_priority_level_configuration.c
#include <stdlib.h> #include <string.h> #include <stdio.h> #include "v1beta2_priority_level_configuration.h" v1beta2_priority_level_configuration_t *v1beta2_priority_level_configuration_create( char *api_version, char *kind, v1_object_meta_t *metadata, v1beta2_priority_level_configuration_spec_t *spec, v1beta2_priority_level_configuration_status_t *status ) { v1beta2_priority_level_configuration_t *v1beta2_priority_level_configuration_local_var = malloc(sizeof(v1beta2_priority_level_configuration_t)); if (!v1beta2_priority_level_configuration_local_var) { return NULL; } v1beta2_priority_level_configuration_local_var->api_version = api_version; v1beta2_priority_level_configuration_local_var->kind = kind; v1beta2_priority_level_configuration_local_var->metadata = metadata; v1beta2_priority_level_configuration_local_var->spec = spec; v1beta2_priority_level_configuration_local_var->status = status; return v1beta2_priority_level_configuration_local_var; } void v1beta2_priority_level_configuration_free(v1beta2_priority_level_configuration_t *v1beta2_priority_level_configuration) { if(NULL == v1beta2_priority_level_configuration){ return ; } listEntry_t *listEntry; if (v1beta2_priority_level_configuration->api_version) { free(v1beta2_priority_level_configuration->api_version); v1beta2_priority_level_configuration->api_version = NULL; } if (v1beta2_priority_level_configuration->kind) { free(v1beta2_priority_level_configuration->kind); v1beta2_priority_level_configuration->kind = NULL; } if (v1beta2_priority_level_configuration->metadata) { v1_object_meta_free(v1beta2_priority_level_configuration->metadata); v1beta2_priority_level_configuration->metadata = NULL; } if (v1beta2_priority_level_configuration->spec) { v1beta2_priority_level_configuration_spec_free(v1beta2_priority_level_configuration->spec); v1beta2_priority_level_configuration->spec = NULL; } if (v1beta2_priority_level_configuration->status) { v1beta2_priority_level_configuration_status_free(v1beta2_priority_level_configuration->status); v1beta2_priority_level_configuration->status = NULL; } free(v1beta2_priority_level_configuration); } cJSON *v1beta2_priority_level_configuration_convertToJSON(v1beta2_priority_level_configuration_t *v1beta2_priority_level_configuration) { cJSON *item = cJSON_CreateObject(); // v1beta2_priority_level_configuration->api_version if(v1beta2_priority_level_configuration->api_version) { if(cJSON_AddStringToObject(item, "apiVersion", v1beta2_priority_level_configuration->api_version) == NULL) { goto fail; //String } } // v1beta2_priority_level_configuration->kind if(v1beta2_priority_level_configuration->kind) { if(cJSON_AddStringToObject(item, "kind", v1beta2_priority_level_configuration->kind) == NULL) { goto fail; //String } } // v1beta2_priority_level_configuration->metadata if(v1beta2_priority_level_configuration->metadata) { cJSON *metadata_local_JSON = v1_object_meta_convertToJSON(v1beta2_priority_level_configuration->metadata); if(metadata_local_JSON == NULL) { goto fail; //model } cJSON_AddItemToObject(item, "metadata", metadata_local_JSON); if(item->child == NULL) { goto fail; } } // v1beta2_priority_level_configuration->spec if(v1beta2_priority_level_configuration->spec) { cJSON *spec_local_JSON = v1beta2_priority_level_configuration_spec_convertToJSON(v1beta2_priority_level_configuration->spec); if(spec_local_JSON == NULL) { goto fail; //model } cJSON_AddItemToObject(item, "spec", spec_local_JSON); if(item->child == NULL) { goto fail; } } // v1beta2_priority_level_configuration->status if(v1beta2_priority_level_configuration->status) { cJSON *status_local_JSON = v1beta2_priority_level_configuration_status_convertToJSON(v1beta2_priority_level_configuration->status); if(status_local_JSON == NULL) { goto fail; //model } cJSON_AddItemToObject(item, "status", status_local_JSON); if(item->child == NULL) { goto fail; } } return item; fail: if (item) { cJSON_Delete(item); } return NULL; } v1beta2_priority_level_configuration_t *v1beta2_priority_level_configuration_parseFromJSON(cJSON *v1beta2_priority_level_configurationJSON){ v1beta2_priority_level_configuration_t *v1beta2_priority_level_configuration_local_var = NULL; // define the local variable for v1beta2_priority_level_configuration->metadata v1_object_meta_t *metadata_local_nonprim = NULL; // define the local variable for v1beta2_priority_level_configuration->spec v1beta2_priority_level_configuration_spec_t *spec_local_nonprim = NULL; // define the local variable for v1beta2_priority_level_configuration->status v1beta2_priority_level_configuration_status_t *status_local_nonprim = NULL; // v1beta2_priority_level_configuration->api_version cJSON *api_version = cJSON_GetObjectItemCaseSensitive(v1beta2_priority_level_configurationJSON, "apiVersion"); if (api_version) { if(!cJSON_IsString(api_version) && !cJSON_IsNull(api_version)) { goto end; //String } } // v1beta2_priority_level_configuration->kind cJSON *kind = cJSON_GetObjectItemCaseSensitive(v1beta2_priority_level_configurationJSON, "kind"); if (kind) { if(!cJSON_IsString(kind) && !cJSON_IsNull(kind)) { goto end; //String } } // v1beta2_priority_level_configuration->metadata cJSON *metadata = cJSON_GetObjectItemCaseSensitive(v1beta2_priority_level_configurationJSON, "metadata"); if (metadata) { metadata_local_nonprim = v1_object_meta_parseFromJSON(metadata); //nonprimitive } // v1beta2_priority_level_configuration->spec cJSON *spec = cJSON_GetObjectItemCaseSensitive(v1beta2_priority_level_configurationJSON, "spec"); if (spec) { spec_local_nonprim = v1beta2_priority_level_configuration_spec_parseFromJSON(spec); //nonprimitive } // v1beta2_priority_level_configuration->status cJSON *status = cJSON_GetObjectItemCaseSensitive(v1beta2_priority_level_configurationJSON, "status"); if (status) { status_local_nonprim = v1beta2_priority_level_configuration_status_parseFromJSON(status); //nonprimitive } v1beta2_priority_level_configuration_local_var = v1beta2_priority_level_configuration_create ( api_version && !cJSON_IsNull(api_version) ? strdup(api_version->valuestring) : NULL, kind && !cJSON_IsNull(kind) ? strdup(kind->valuestring) : NULL, metadata ? metadata_local_nonprim : NULL, spec ? spec_local_nonprim : NULL, status ? status_local_nonprim : NULL ); return v1beta2_priority_level_configuration_local_var; end: if (metadata_local_nonprim) { v1_object_meta_free(metadata_local_nonprim); metadata_local_nonprim = NULL; } if (spec_local_nonprim) { v1beta2_priority_level_configuration_spec_free(spec_local_nonprim); spec_local_nonprim = NULL; } if (status_local_nonprim) { v1beta2_priority_level_configuration_status_free(status_local_nonprim); status_local_nonprim = NULL; } return NULL; }
53b9849bb999fe34b9955e125fc616e1c30cf54d
dae15b230f6a39e8451420b2dea61fb719f9ffdf
/example/common/linux_sigaction.h
6c43fda3095cf7ae667e541a0fe4b7565b6290e1
[ "BSD-3-Clause", "GPL-1.0-or-later" ]
permissive
OpenFastPath/ofp
2b97bbd152fd877cb8b2125128d6826c0f4491dd
6b48500af9752c7d51a290390751988759a8256d
refs/heads/master
2023-05-25T15:21:17.682339
2023-05-10T07:14:01
2023-05-10T11:01:16
37,121,923
367
146
BSD-3-Clause
2023-09-13T14:19:24
2015-06-09T09:08:43
C
UTF-8
C
false
false
299
h
linux_sigaction.h
/* Copyright (c) 2014, ENEA Software AB * Copyright (c) 2014, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef __OFP_EXAMPLE_SIGACTION__ #define __OFP_EXAMPLE_SIGACTION__ int ofp_sigactions_set(void (*sig_func)(int)); #endif /* __OFP_EXAMPLE_SIGACTION__ */
f0779739d7655fd1d54d662972e1236d8f15614d
0a3363c1d3d5867f1340de49b84eab84defa3fb8
/hal/simd.h
ab24f10ac6355d21bd6727e5c698bfd9613a6a4a
[ "MIT" ]
permissive
odevices/er-301
b09bc53f1b11ff1bba2be8a51220ebfe932dd935
3a7b592fe5d223d5a96b2d8e90b578b23bbdabe5
refs/heads/develop
2023-02-17T16:31:01.764589
2023-02-14T06:55:32
2023-02-14T06:55:32
343,000,824
124
26
MIT
2023-02-14T06:55:34
2021-02-28T02:06:10
C
UTF-8
C
false
false
2,095
h
simd.h
#pragma once #ifdef __cplusplus extern "C" { #endif #include <hal/neon.h> #include <stdbool.h> // Transcendentals float32x4_t simd_log(float32x4_t x); float32x4_t simd_exp(float32x4_t x); float32x4_t simd_pow(float32x4_t x, float32x4_t m); void simd_sincos(float32x4_t x, float32x4_t *ysin, float32x4_t *ycos); float32x4_t simd_sin(float32x4_t x); float32x4_t simd_cos(float32x4_t x); float32x4_t simd_invert(float32x4_t x); // Interpolation void simd_linear_interpolate(float *__restrict__ out, const float *__restrict__ recent0, const float *__restrict__ recent1, const float *__restrict__ phase); void simd_quadratic_interpolate(float *__restrict__ out, const float *__restrict__ recent0, const float *__restrict__ recent1, const float *__restrict__ recent2, const float *__restrict__ phase); void simd_quadratic_interpolate_stereo(float *out, float *recent, float phase); float32x4_t simd_quadratic_interpolate_with_return( const float *__restrict__ recent0, const float *__restrict__ recent1, const float *__restrict__ recent2, const float *__restrict__ phase); void simd_interpolate_env_accumulate( float *__restrict__ out, const float *__restrict__ recent0, const float *__restrict__ recent1, const float *__restrict__ recent2, const float *__restrict__ phase, float32x4_t ep, float gain); // Envelopes float32x4_t simd_sine_env(const float *envPhase); float32x4_t simd_hanning(const float *envPhase); // |x| < 1 then 1, else 0 float32x4_t simd_boxcar(float32x4_t x); // Comparisons bool simd_any_greater(float *in, int n, float32x4_t threshold); bool simd_any_positive(float *in, int n); int simd_first_positive(float *in, int n); int simd_first_positive_4x(float *in, int n); // Constant set void simd_set(float *out, int n, float value); #ifdef __cplusplus } #endif
1986fad8ef064cbe4578b6d445ea247a91bada25
de21f9075f55640514c29ef0f1fe3f0690845764
/regression/ansi-c/switch1/main.c
b0ccf834df752271f2c6faf43c1a8eeb497bbc76
[ "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
88
c
main.c
int main () { switch (0) case 0: case ( sizeof (long long) == 4) :; ; return 0; }
c26ee8970587151a183c8dfdbd76ff628f3dd86d
baa9fffc817a2a993d4ecc774d3f277783308c20
/src/uct/rocm/ipc/rocm_ipc_md.c
dbe2da40b6ee0938be048b527b8e1d2f89433690
[ "BSD-3-Clause" ]
permissive
openucx/ucx
9a0f2205295afbdf3cff14b5d24af781b123f5ea
73a48700badb7cbace64d94b82f408e2a26fca32
refs/heads/master
2023-09-01T16:51:26.913950
2023-09-01T13:02:25
2023-09-01T13:02:25
25,379,390
966
420
NOASSERTION
2023-09-14T12:29:35
2014-10-17T22:17:24
C
UTF-8
C
false
false
6,383
c
rocm_ipc_md.c
/* * Copyright (C) Advanced Micro Devices, Inc. 2019. ALL RIGHTS RESERVED. * Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2020. ALL RIGHTS RESERVED. * See file LICENSE for terms. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include "rocm_ipc_md.h" #include <uct/rocm/base/rocm_base.h> #include <uct/api/v2/uct_v2.h> static ucs_config_field_t uct_rocm_ipc_md_config_table[] = { {"", "", NULL, ucs_offsetof(uct_rocm_ipc_md_config_t, super), UCS_CONFIG_TYPE_TABLE(uct_md_config_table)}, {NULL} }; static ucs_status_t uct_rocm_ipc_md_query(uct_md_h md, uct_md_attr_v2_t *md_attr) { md_attr->rkey_packed_size = sizeof(uct_rocm_ipc_key_t); md_attr->flags = UCT_MD_FLAG_REG | UCT_MD_FLAG_NEED_RKEY; md_attr->reg_mem_types = UCS_BIT(UCS_MEMORY_TYPE_ROCM); md_attr->reg_nonblock_mem_types = 0; md_attr->cache_mem_types = UCS_BIT(UCS_MEMORY_TYPE_ROCM); md_attr->alloc_mem_types = 0; md_attr->access_mem_types = UCS_BIT(UCS_MEMORY_TYPE_ROCM); md_attr->detect_mem_types = 0; md_attr->dmabuf_mem_types = 0; md_attr->max_alloc = 0; md_attr->max_reg = ULONG_MAX; /* TODO: get accurate number */ md_attr->reg_cost = ucs_linear_func_make(9e-9, 0); memset(&md_attr->local_cpus, 0xff, sizeof(md_attr->local_cpus)); return UCS_OK; } static ucs_status_t uct_rocm_ipc_mkey_pack(uct_md_h uct_md, uct_mem_h memh, const uct_md_mkey_pack_params_t *params, void *mkey_buffer) { uct_rocm_ipc_key_t *packed = mkey_buffer; uct_rocm_ipc_key_t *key = memh; *packed = *key; return UCS_OK; } static hsa_status_t uct_rocm_ipc_pack_key(void *address, size_t length, uct_rocm_ipc_key_t *key) { void *base_ptr = NULL; size_t size = 0; hsa_status_t status; hsa_agent_t agent; hsa_amd_pointer_type_t mem_type; status = uct_rocm_base_get_ptr_info(address, length, &base_ptr, &size, &mem_type, &agent, NULL); if ((status != HSA_STATUS_SUCCESS) || (size < length) || (mem_type == HSA_EXT_POINTER_TYPE_UNKNOWN)) { ucs_error("failed to get base ptr for %p/%lx, ROCm returned %p/%lx", address, length, base_ptr, size); return status; } status = hsa_amd_ipc_memory_create(base_ptr, size, &key->ipc); if (status != HSA_STATUS_SUCCESS) { ucs_error("Failed to create ipc for %p/%lx", address, length); return status; } key->address = (uintptr_t)base_ptr; key->length = size; key->dev_num = uct_rocm_base_get_dev_num(agent); return HSA_STATUS_SUCCESS; } static ucs_status_t uct_rocm_ipc_mem_reg(uct_md_h md, void *address, size_t length, const uct_md_mem_reg_params_t *params, uct_mem_h *memh_p) { uct_rocm_ipc_key_t *key; hsa_status_t status; key = ucs_malloc(sizeof(*key), "uct_rocm_ipc_key_t"); if (NULL == key) { ucs_error("Failed to allocate memory for uct_rocm_ipc_key_t"); return UCS_ERR_NO_MEMORY; } status = uct_rocm_ipc_pack_key(address, length, key); if (status != HSA_STATUS_SUCCESS) { ucs_free(key); return UCS_ERR_INVALID_ADDR; } *memh_p = key; return UCS_OK; } static ucs_status_t uct_rocm_ipc_mem_dereg(uct_md_h md, const uct_md_mem_dereg_params_t *params) { uct_rocm_ipc_key_t *mem_hndl; UCT_MD_MEM_DEREG_CHECK_PARAMS(params, 0); mem_hndl = params->memh; ucs_free(mem_hndl); return UCS_OK; } static ucs_status_t uct_rocm_ipc_md_open(uct_component_h component, const char *md_name, const uct_md_config_t *uct_md_config, uct_md_h *md_p) { static uct_md_ops_t md_ops = { .close = (uct_md_close_func_t)ucs_empty_function, .query = uct_rocm_ipc_md_query, .mkey_pack = uct_rocm_ipc_mkey_pack, .mem_reg = uct_rocm_ipc_mem_reg, .mem_dereg = uct_rocm_ipc_mem_dereg, .mem_attach = ucs_empty_function_return_unsupported, .mem_query = ucs_empty_function_return_unsupported, .detect_memory_type = ucs_empty_function_return_unsupported, }; static uct_md_t md = { .ops = &md_ops, .component = &uct_rocm_ipc_component, }; *md_p = &md; return UCS_OK; } static ucs_status_t uct_rocm_ipc_rkey_unpack(uct_component_t *component, const void *rkey_buffer, uct_rkey_t *rkey_p, void **handle_p) { uct_rocm_ipc_key_t *packed = (uct_rocm_ipc_key_t *)rkey_buffer; uct_rocm_ipc_key_t *key; key = ucs_malloc(sizeof(uct_rocm_ipc_key_t), "uct_rocm_ipc_key_t"); if (NULL == key) { ucs_error("Failed to allocate memory for uct_rocm_ipc_key_t"); return UCS_ERR_NO_MEMORY; } *key = *packed; *handle_p = NULL; *rkey_p = (uintptr_t)key; return UCS_OK; } static ucs_status_t uct_rocm_ipc_rkey_release(uct_component_t *component, uct_rkey_t rkey, void *handle) { ucs_assert(NULL == handle); ucs_free((void *)rkey); return UCS_OK; } uct_component_t uct_rocm_ipc_component = { .query_md_resources = uct_rocm_base_query_md_resources, .md_open = uct_rocm_ipc_md_open, .cm_open = ucs_empty_function_return_unsupported, .rkey_unpack = uct_rocm_ipc_rkey_unpack, .rkey_ptr = ucs_empty_function_return_unsupported, .rkey_release = uct_rocm_ipc_rkey_release, .name = "rocm_ipc", .md_config = { .name = "ROCm-IPC memory domain", .prefix = "ROCM_IPC_MD_", .table = uct_rocm_ipc_md_config_table, .size = sizeof(uct_rocm_ipc_md_config_t), }, .cm_config = UCS_CONFIG_EMPTY_GLOBAL_LIST_ENTRY, .tl_list = UCT_COMPONENT_TL_LIST_INITIALIZER(&uct_rocm_ipc_component), .flags = 0, .md_vfs_init = (uct_component_md_vfs_init_func_t)ucs_empty_function }; UCT_COMPONENT_REGISTER(&uct_rocm_ipc_component);
71a324878b33f322f0203e7b6ea1420efbb9698e
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/board/freescale/t1040qds/t1040qds.c
0e83d172dac53f582ac8f00f7b247893dfd95fb0
[ "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,205
c
t1040qds.c
/* * Copyright 2013 Freescale Semiconductor, Inc. * * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> #include <command.h> #include <i2c.h> #include <netdev.h> #include <linux/compiler.h> #include <asm/mmu.h> #include <asm/processor.h> #include <asm/cache.h> #include <asm/immap_85xx.h> #include <asm/fsl_law.h> #include <asm/fsl_serdes.h> #include <asm/fsl_portals.h> #include <asm/fsl_liodn.h> #include <fm_eth.h> #include <hwconfig.h> #include <asm/mpc85xx_gpio.h> #include "../common/qixis.h" #include "t1040qds.h" #include "t1040qds_qixis.h" DECLARE_GLOBAL_DATA_PTR; int checkboard(void) { char buf[64]; u8 sw; struct cpu_type *cpu = gd->arch.cpu; static const char *const freq[] = {"100", "125", "156.25", "161.13", "122.88", "122.88", "122.88"}; int clock; printf("Board: %sQDS, ", cpu->name); printf("Sys ID: 0x%02x, Sys Ver: 0x%02x, ", QIXIS_READ(id), QIXIS_READ(arch)); sw = QIXIS_READ(brdcfg[0]); sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT; if (sw < 0x8) printf("vBank: %d\n", sw); else if (sw == 0x8) puts("PromJet\n"); else if (sw == 0x9) puts("NAND\n"); else if (sw == 0x15) printf("IFCCard\n"); else printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH); printf("FPGA: v%d (%s), build %d", (int)QIXIS_READ(scver), qixis_read_tag(buf), (int)qixis_read_minor()); /* the timestamp string contains "\n" at the end */ printf(" on %s", qixis_read_time(buf)); /* * Display the actual SERDES reference clocks as configured by the * dip switches on the board. Note that the SWx registers could * technically be set to force the reference clocks to match the * values that the SERDES expects (or vice versa). For now, however, * we just display both values and hope the user notices when they * don't match. */ puts("SERDES Reference: "); sw = QIXIS_READ(brdcfg[2]); clock = (sw >> 6) & 3; printf("Clock1=%sMHz ", freq[clock]); clock = (sw >> 4) & 3; printf("Clock2=%sMHz\n", freq[clock]); return 0; } int select_i2c_ch_pca9547(u8 ch) { int ret; ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1); if (ret) { puts("PCA: failed to select proper channel\n"); return ret; } return 0; } static void qe_board_setup(void) { u8 brdcfg15, brdcfg9; if (hwconfig("qe") && hwconfig("tdm")) { brdcfg15 = QIXIS_READ(brdcfg[15]); /* * TDMRiser uses QE-TDM * Route QE_TDM signals to TDM Riser slot */ QIXIS_WRITE(brdcfg[15], brdcfg15 | 7); } else if (hwconfig("qe") && hwconfig("uart")) { brdcfg15 = QIXIS_READ(brdcfg[15]); brdcfg9 = QIXIS_READ(brdcfg[9]); /* * Route QE_TDM signals to UCC * ProfiBus controlled by UCC3 */ brdcfg15 &= 0xfc; QIXIS_WRITE(brdcfg[15], brdcfg15 | 2); QIXIS_WRITE(brdcfg[9], brdcfg9 | 4); } } int board_early_init_r(void) { #ifdef CONFIG_SYS_FLASH_BASE const unsigned int flashbase = CONFIG_SYS_FLASH_BASE; const u8 flash_esel = find_tlb_idx((void *)flashbase, 1); /* * Remap Boot flash + PROMJET region to caching-inhibited * so that flash can be erased properly. */ /* Flush d-cache and invalidate i-cache of any FLASH data */ flush_dcache(); invalidate_icache(); /* invalidate existing TLB entry for flash + promjet */ disable_tlb(flash_esel); set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, 0, flash_esel, BOOKE_PAGESZ_256M, 1); #endif set_liodns(); #ifdef CONFIG_SYS_DPAA_QBMAN setup_portals(); #endif select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT); return 0; } unsigned long get_board_sys_clk(void) { u8 sysclk_conf = QIXIS_READ(brdcfg[1]); switch (sysclk_conf & 0x0F) { case QIXIS_SYSCLK_64: return 64000000; case QIXIS_SYSCLK_83: return 83333333; case QIXIS_SYSCLK_100: return 100000000; case QIXIS_SYSCLK_125: return 125000000; case QIXIS_SYSCLK_133: return 133333333; case QIXIS_SYSCLK_150: return 150000000; case QIXIS_SYSCLK_160: return 160000000; case QIXIS_SYSCLK_166: return 166666666; } return 66666666; } unsigned long get_board_ddr_clk(void) { u8 ddrclk_conf = QIXIS_READ(brdcfg[1]); switch ((ddrclk_conf & 0x30) >> 4) { case QIXIS_DDRCLK_100: return 100000000; case QIXIS_DDRCLK_125: return 125000000; case QIXIS_DDRCLK_133: return 133333333; } return 66666666; } #define NUM_SRDS_BANKS 2 int misc_init_r(void) { u8 sw; serdes_corenet_t *srds_regs = (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR; u32 actual[NUM_SRDS_BANKS] = { 0 }; int i; sw = QIXIS_READ(brdcfg[2]); for (i = 0; i < NUM_SRDS_BANKS; i++) { unsigned int clock = (sw >> (6 - 2 * i)) & 3; switch (clock) { case 0: actual[i] = SRDS_PLLCR0_RFCK_SEL_100; break; case 1: actual[i] = SRDS_PLLCR0_RFCK_SEL_125; break; case 2: actual[i] = SRDS_PLLCR0_RFCK_SEL_156_25; break; } } puts("SerDes1"); for (i = 0; i < NUM_SRDS_BANKS; i++) { u32 pllcr0 = srds_regs->bank[i].pllcr0; u32 expected = pllcr0 & SRDS_PLLCR0_RFCK_SEL_MASK; if (expected != actual[i]) { printf("expects ref clk%d %sMHz, but actual is %sMHz\n", i + 1, serdes_clock_to_string(expected), serdes_clock_to_string(actual[i])); } } qe_board_setup(); return 0; } void ft_board_setup(void *blob, bd_t *bd) { phys_addr_t base; phys_size_t size; ft_cpu_setup(blob, bd); base = getenv_bootm_low(); size = getenv_bootm_size(); fdt_fixup_memory(blob, (u64)base, (u64)size); #ifdef CONFIG_PCI pci_of_setup(blob, bd); #endif fdt_fixup_liodn(blob); #ifdef CONFIG_HAS_FSL_DR_USB fdt_fixup_dr_usb(blob, bd); #endif #ifdef CONFIG_SYS_DPAA_FMAN fdt_fixup_fman_ethernet(blob); fdt_fixup_board_enet(blob); #endif } void qixis_dump_switch(void) { int i, nr_of_cfgsw; QIXIS_WRITE(cms[0], 0x00); nr_of_cfgsw = QIXIS_READ(cms[1]); puts("DIP switch settings dump:\n"); for (i = 1; i <= nr_of_cfgsw; i++) { QIXIS_WRITE(cms[0], i); printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1])); } } int board_need_mem_reset(void) { return 1; } #ifdef CONFIG_DEEP_SLEEP void board_mem_sleep_setup(void) { /* does not provide HW signals for power management */ QIXIS_WRITE(pwr_ctl[1], (QIXIS_READ(pwr_ctl[1]) & ~0x2)); /* Disable MCKE isolation */ gpio_set_value(2, 0); udelay(1); } #endif
14eb57a16c2468437fa7786909c4fc33bac3115c
c6759b857e55991fea3ef0b465dbcee53fa38714
/gap8/rtos/pulp/pulp-os/kernel/alloc_extern.c
41101d2052a2baddfaa67f7b4ec6119fc37aec75
[ "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
7,320
c
alloc_extern.c
/* * Copyright (C) 2018 ETH Zurich and University of Bologna * * 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. */ /* * Copyright (C) 2018 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. */ /* * Authors: Eric Flamand, GreenWaves Technologies (eric.flamand@greenwaves-technologies.com) * Germain Haugou, ETH (germain.haugou@iis.ee.ethz.ch) */ #include "rt/rt_api.h" #include <string.h> #include <stdio.h> // Allocate at least 4 bytes to avoid misaligned accesses when parsing free blocks // and actually 8 to fit free chunk header size and make sure a e free block to always have // at least the size of the header. // This also requires the initial chunk to be correctly aligned. #define MIN_CHUNK_SIZE 8 #define ALIGN_UP(addr,size) (((addr) + (size) - 1) & ~((size) - 1)) #define ALIGN_DOWN(addr,size) ((addr) & ~((size) - 1)) #ifndef Max #define Max(x, y) (((x)>(y))?(x):(y)) #endif /* A semi general purpose memory allocator based on the assumption that when something is freed it's size is known. The rationnal is to get rid of the usual meta data overhead attached to traditionnal memory allocators. */ static inline void __rt_free_chunk(rt_alloc_chunk_extern_t *pt) { rt_free(RT_ALLOC_FC_DATA, (void *)pt, sizeof(rt_alloc_chunk_extern_t)); } static inline rt_alloc_chunk_extern_t *__rt_alloc_chunk() { return (rt_alloc_chunk_extern_t *)rt_alloc(RT_ALLOC_FC_DATA, sizeof(rt_alloc_chunk_extern_t)); } void rt_extern_alloc_info(rt_extern_alloc_t *a, int *_size, void **first_chunk, int *_nb_chunks) { if (first_chunk) *first_chunk = a->first_free; if (_size || _nb_chunks) { int size = 0; int nb_chunks = 0; rt_alloc_chunk_extern_t *pt = a->first_free; for (pt = a->first_free; pt; pt = pt->next) { size += pt->size; nb_chunks++; } if (_size) *_size = size; if (_nb_chunks) *_nb_chunks = nb_chunks; } } void rt_extern_alloc_dump(rt_extern_alloc_t *a) { rt_alloc_chunk_extern_t *pt = a->first_free; printf("======== Memory allocator state: ============\n"); for (pt = a->first_free; pt; pt = pt->next) { printf("DUMP CHUNK %p ALLOC %p\n", pt, a); printf("Free Block at %8X, size: %5d, Next: %8X ", pt->addr, pt->size, (unsigned int) pt->next); if (pt == pt->next) { printf(" CORRUPTED\n"); break; } else printf("\n"); } printf("=============================================\n"); } int rt_extern_alloc_init(rt_extern_alloc_t *a, void *addr, int size) { if (size) { unsigned int start_addr = ALIGN_UP((int)addr, MIN_CHUNK_SIZE); rt_alloc_chunk_extern_t *chunk = __rt_alloc_chunk(); if (chunk == NULL) return -1; size = size - (start_addr - (unsigned int)addr); if (size > 0) { a->first_free = chunk; chunk->size = ALIGN_DOWN(size, MIN_CHUNK_SIZE); chunk->next = NULL; chunk->addr = start_addr; } } else { a->first_free = NULL; } return 0; } void rt_extern_alloc_deinit(rt_extern_alloc_t *a) { __rt_free_chunk(a->first_free); } void *rt_extern_alloc(rt_extern_alloc_t *a, int size) { rt_alloc_chunk_extern_t *pt = a->first_free, *prev = 0; size = ALIGN_UP(size, MIN_CHUNK_SIZE); while (pt && (pt->size < size)) { prev = pt; pt = pt->next; } if (pt) { if (pt->size == size) { // Special case where the whole block disappears // This special case is interesting to support when we allocate aligned pages, to limit fragmentation if (prev) prev->next = pt->next; else a->first_free = pt->next; void *addr = (void *)pt->addr; __rt_free_chunk(pt); return addr; } else { // The free block is bigger than needed // Return the end of the block in order to just update the free block size void *result = (void *)((char *)pt->addr + pt->size - size); pt->size = pt->size - size; return result; } } else { //rt_warning("Not enough memory to allocate\n"); return NULL; } } void *rt_extern_alloc_align(rt_extern_alloc_t *a, int size, int align) { if (align < (int)sizeof(rt_alloc_chunk_extern_t)) return rt_extern_alloc(a, size); // As the user must give back the size of the allocated chunk when freeing it, we must allocate // an aligned chunk with exactly the right size // To do so, we allocate a bigger chunk and we free what is before and what is after // We reserve enough space to free the remaining room before and after the aligned chunk int size_align = size + align + sizeof(rt_alloc_chunk_extern_t) * 2; unsigned int result = (unsigned int)rt_extern_alloc(a, size_align); if (!result) return NULL; unsigned int result_align = (result + align - 1) & -align; unsigned int headersize = result_align - result; // In case we don't get an aligned chunk at first, we must free the room before the first aligned one if (headersize != 0) { // If we don't have enough room before the aligned chunk for freeing the header, take the next aligned one if (result_align - result < sizeof(rt_alloc_chunk_extern_t)) result_align += align; // Free the header rt_extern_free(a, (void *)result, headersize); } // Now free what remains after rt_extern_free(a, (unsigned char *)(result_align + size), size_align - headersize - size); return (void *)result_align; } int __attribute__((noinline)) rt_extern_free(rt_extern_alloc_t *a, void *addr, int size) { rt_alloc_chunk_extern_t *chunk; rt_alloc_chunk_extern_t *next = a->first_free, *prev = 0, *new; size = ALIGN_UP(size, MIN_CHUNK_SIZE); while (next && next->addr < (unsigned int)addr) { prev = next; next = next->next; } if (next && ((char *)addr + size) == (char *)next->addr) { /* Coalesce with next */ next->size = size + next->size; next->addr = (unsigned int)addr; chunk = next; } else { chunk = __rt_alloc_chunk(); if (chunk == NULL) return -1; chunk->size = size; chunk->next = next; chunk->addr = (unsigned int)addr; } if (prev) { if (((char *)prev->addr + prev->size) == (char *)addr) { /* Coalesce with previous */ prev->size += chunk->size; prev->next = chunk->next; __rt_free_chunk(chunk); } else { prev->next = chunk; } } else { a->first_free = chunk; } return 0; }
e6a13b722c21f0536a9c504d668209362a223fdd
03b2c80dbc41e904b167d504666e27d798da5447
/test/test_scope.c
cf0f58a0aef6c2e7ededfffeedc788fb06e7cb62
[ "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
190,338
c
test_scope.c
#include "scope.c" #if 0 #include "array.h" #include "array_make.h" #include "bignum.h" #include "character.h" #include "clos.h" #include "code.h" #include "common.h" #include "condition.h" #include "constant.h" #include "control_operator.h" #include "copy.h" #include "declare.h" #include "degrade.h" #include "lambda.h" #include "ratio.h" #include "reader.h" #include "package.h" #include "pathname.h" #include "stream.h" #include "strtype.h" #include "strvect.h" #include "symbol.h" #include "syscall.h" #include "type.h" #include "type_table.h" /* * memory */ static int test_eval_scope_heap(void) { addr pos; size_t size; begin_eval_stack(Execute_Thread); eval_scope_heap(Execute_Thread, &pos, 0); test(GetType(pos) == LISPTYPE_EVAL, "eval_scope_heap1"); test(RefEvalType(pos) == EVAL_TYPE_SCOPE, "eval_scope_heap2"); eval_scope_heap(Execute_Thread, &pos, 5); lenarray(pos, &size); test(5 <= size, "eval_scope_heap3"); RETURN; } static void test_parse_type(addr *ret, addr type) { if (parse_type_(Execute_Thread, ret, type, Nil)) { Error(fmte_("system error", NULL)); } } static int test_eval_scope_size(void) { addr pos, type, value; readstring_debug(&type, "integer"); test_parse_type(&type, type); fixnum_heap(&value, 10); eval_scope_size(Execute_Thread, &pos, 5, EVAL_PARSE_T, type, value); test(RefEvalScopeType(pos) == EVAL_PARSE_T, "eval_scope_size1"); test(RefEvalScopeThe(pos) == type, "eval_scope_size2"); test(RefEvalScopeValue(pos) == value, "eval_scope_size3"); RETURN; } static int test_make_eval_scope(void) { addr pos, check; GetTypeTable(&pos, T); make_eval_scope(Execute_Thread, &pos, EVAL_PARSE_LET, pos, T); test(GetType(pos) == LISPTYPE_EVAL, "make_eval_scope1"); test(RefEvalType(pos) == EVAL_TYPE_SCOPE, "make_eval_scope2"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_T, "make_eval_scope3"); GetEvalScopeValue(pos, &check); test(check == T, "make_eval_scope4"); RETURN; } static int test_StructEvalScope(void) { EvalParse ptype; addr pos, type, value, check; struct scope_struct *str; readstring_debug(&type, "integer"); test_parse_type(&type, type); fixnum_heap(&value, 10); eval_scope_size(Execute_Thread, &pos, 5, EVAL_PARSE_T, type, value); str = StructEvalScope(pos); test(str->type == EVAL_PARSE_T, "StructEvalScope1"); test(RefEvalScopeType(pos) == EVAL_PARSE_T, "RefEvalScopeType1"); SetEvalScopeType(pos, EVAL_PARSE_NIL); GetEvalScopeType(pos, &ptype); test(ptype == EVAL_PARSE_NIL, "RefEvalScopeType2"); test(RefEvalScopeThe(pos) == type, "RefEvalScopeThe1"); SetEvalScopeThe(pos, T); GetEvalScopeThe(pos, &check); test(check == T, "RefEvalScopeThe2"); test(RefEvalScopeValue(pos) == value, "RefEvalScopeValue1"); fixnum_heap(&value, 20); SetEvalScopeValue(pos, value); GetEvalScopeValue(pos, &check); test(value == check, "RefEvalScopeValue2"); fixnum_heap(&value, 30); SetEvalScopeIndex(pos, 4, value); test(RefEvalScopeIndex(pos, 4) == value, "RefEvalScopeIndex1"); GetEvalScopeIndex(pos, 4, &check); test(value == check, "RefEvalScopeIndex2"); RETURN; } /* * scope constant */ static void eval_parse_execute(addr *ret, addr value) { eval_parse(Execute_Thread, ret, value); } static void parse_eval_string(addr *ret, const char *str) { readstring_debug(ret, str); eval_parse_execute(ret, *ret); } static int test_scope_nil(void) { addr eval, check; parse_eval_string(&eval, "nil"); scope_nil(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_nil1"); test(RefEvalScopeType(eval) == EVAL_PARSE_NIL, "scope_nil2"); GetEvalScopeThe(eval, &check); test(RefLispDecl(check) == LISPDECL_NULL, "scope_nil3"); GetEvalScopeValue(eval, &check); test(check == Nil, "scope_nil4"); RETURN; } static int test_scope_t(void) { addr eval, check; parse_eval_string(&eval, "t"); scope_t(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_t1"); test(RefEvalScopeType(eval) == EVAL_PARSE_T, "scope_t2"); GetEvalScopeThe(eval, &check); test(RefLispDecl(check) == LISPDECL_BOOLEAN, "scope_t3"); GetEvalScopeValue(eval, &check); test(check == T, "scope_t4"); RETURN; } static int test_scope_integer(void) { addr eval, type, check; parse_eval_string(&eval, "100"); scope_integer(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_integer1"); test(RefEvalScopeType(eval) == EVAL_PARSE_INTEGER, "scope_integer2"); GetEvalScopeThe(eval, &type); test(RefLispDecl(type) == LISPDECL_INTEGER, "scope_integer3"); GetArrayType(type, 0, &check); test(check == Nil, "scope_integer4"); GetArrayType(type, 1, &check); test(RefFixnum(check) == 100, "scope_integer5"); GetArrayType(type, 2, &check); test(check == Nil, "scope_integer6"); GetArrayType(type, 3, &check); test(RefFixnum(check) == 100, "scope_integer7"); GetEvalScopeValue(eval, &check); test(RefFixnum(check) == 100, "scope_integer8"); RETURN; } static int test_scope_rational(void) { addr eval, type, check; parse_eval_string(&eval, "100"); scope_rational(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_rational1"); test(RefEvalScopeType(eval) == EVAL_PARSE_RATIONAL, "scope_rational2"); GetEvalScopeThe(eval, &type); test(RefLispDecl(type) == LISPDECL_RATIONAL, "scope_rational3"); GetArrayType(type, 0, &check); test(check == Nil, "scope_rational4"); GetArrayType(type, 1, &check); test(RefFixnum(check) == 100, "scope_rational5"); GetArrayType(type, 2, &check); test(check == Nil, "scope_rational6"); GetArrayType(type, 3, &check); test(RefFixnum(check) == 100, "scope_rational7"); GetEvalScopeValue(eval, &check); test(RefFixnum(check) == 100, "scope_rational8"); RETURN; } static int test_scope_character(void) { addr eval, check; parse_eval_string(&eval, "#\\a"); scope_character(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_character1"); test(RefEvalScopeType(eval) == EVAL_PARSE_CHARACTER, "scope_character2"); GetEvalScopeThe(eval, &check); test(RefLispDecl(check) == LISPDECL_STANDARD_CHAR, "scope_character3"); GetEvalScopeValue(eval, &check); test(RefCharacter(check) == 'a', "scope_character4"); RETURN; } static int test_scope_array(void) { addr eval, check; GetTypeTable(&eval, T); array_make_array(&eval, fixnumh(1), eval, Unbound, Unbound, Nil, Nil, Nil, fixnumh(0)); eval_parse_execute(&eval, eval); scope_array(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_array1"); test(RefEvalScopeType(eval) == EVAL_PARSE_ARRAY, "scope_array2"); GetEvalScopeThe(eval, &check); test(RefLispDecl(check) == LISPDECL_SIMPLE_ARRAY, "scope_array3"); GetEvalScopeValue(eval, &check); test(GetType(check) == LISPTYPE_ARRAY, "scope_array4"); RETURN; } static int test_scope_vector(void) { addr eval, check; parse_eval_string(&eval, "#(10 20 30)"); scope_vector(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_vector1"); test(RefEvalScopeType(eval) == EVAL_PARSE_VECTOR, "scope_vector2"); GetEvalScopeThe(eval, &check); test(RefLispDecl(check) == LISPDECL_SIMPLE_VECTOR, "scope_vector3"); GetEvalScopeValue(eval, &check); test(GetType(check) == LISPTYPE_VECTOR, "scope_vector4"); RETURN; } static int test_scope_string(void) { addr eval, check; strvect_char_heap(&eval, "Hello"); eval_parse_execute(&eval, eval); scope_string(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_string1"); test(RefEvalScopeType(eval) == EVAL_PARSE_STRING, "scope_string2"); GetEvalScopeThe(eval, &check); test(RefLispDecl(check) == LISPDECL_SIMPLE_BASE_STRING, "scope_string3"); GetEvalScopeValue(eval, &check); test(GetType(check) == LISPTYPE_STRING, "scope_string4"); strarray_char_heap(&eval, "Hello"); strarray_setc(eval, 3, 0xF0000000); eval_parse_execute(&eval, eval); scope_string(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_string5"); test(RefEvalScopeType(eval) == EVAL_PARSE_STRING, "scope_string6"); GetEvalScopeThe(eval, &check); test(RefLispDecl(check) == LISPDECL_SIMPLE_STRING, "scope_string7"); GetEvalScopeValue(eval, &check); test(GetType(check) == LISPTYPE_ARRAY, "scope_string8"); RETURN; } static int test_scope_float(void) { addr eval, check; parse_eval_string(&eval, "10.2d0"); scope_float(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_float1"); test(RefEvalScopeType(eval) == EVAL_PARSE_FLOAT, "scope_float2"); GetEvalScopeThe(eval, &check); test(RefLispDecl(check) == LISPDECL_DOUBLE_FLOAT, "scope_float3"); GetEvalScopeValue(eval, &check); test(GetType(check) == LISPTYPE_DOUBLE_FLOAT, "scope_float4"); RETURN; } static int test_scope_quote(void) { addr eval, check, symbol; readstring_debug(&symbol, "hello"); eval_parse_execute(&eval, symbol); scope_quote(Execute_Thread, &eval, eval); test(eval_scope_p(eval), "scope_quote1"); test(RefEvalScopeType(eval) == EVAL_PARSE_QUOTE, "scope_quote2"); GetEvalScopeThe(eval, &check); test(RefLispDecl(check) == LISPDECL_SYMBOL, "scope_quote3"); GetEvalScopeValue(eval, &check); test(check == symbol, "scope_quote4"); RETURN; } static int test_scope_allcons(void) { addr pos, check; Execute ptr; ptr = Execute_Thread; scope_allcons(ptr, &pos, &check, Nil); test(pos == Nil, "scope_allcons1"); test(RefLispDecl(check) == LISPDECL_NULL, "scope_allcons2"); parse_eval_string(&pos, "(progn \"Hello\" #\\a 30)"); GetEvalParse(pos, 0, &pos); scope_allcons(ptr, &pos, &check, pos); test(length_list_unsafe(pos) == 3, "scope_allcons3"); test(RefLispDecl(check) == LISPDECL_INTEGER, "scope_allcons4"); GetCons(pos, &check, &pos); test(RefEvalScopeType(check) == EVAL_PARSE_STRING, "scope_allcons5"); GetCons(pos, &check, &pos); test(RefEvalScopeType(check) == EVAL_PARSE_CHARACTER, "scope_allcons6"); GetCons(pos, &check, &pos); test(RefEvalScopeType(check) == EVAL_PARSE_INTEGER, "scope_allcons7"); RETURN; } static int test_scope_progn(void) { addr pos, check; Execute ptr; ptr = Execute_Thread; parse_eval_string(&pos, "(progn)"); scope_progn(ptr, &pos, pos); GetEvalScopeThe(pos, &check); test(GetType(check) == LISPTYPE_TYPE, "scope_progn1"); test(RefLispDecl(check) == LISPDECL_NULL, "scope_progn2"); GetEvalScopeValue(pos, &pos); test(pos == Nil, "scope_progn3"); parse_eval_string(&pos, "(progn #\\a \"Hello\" 30)"); scope_progn(ptr, &pos, pos); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_INTEGER, "scope_progn4"); GetEvalScopeValue(pos, &check); test(length_list_unsafe(check) == 3, "scope_progn5"); RETURN; } static int test_scope_declaim(void) { addr control, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); parse_eval_string(&pos, "(declaim (special aa bb))"); scope_declaim(ptr, &pos, pos); test(eval_scope_p(pos), "scope_declaim1"); test(RefEvalScopeType(pos) == EVAL_PARSE_DECLAIM, "scope_declaim2"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_NULL, "scope_declaim3"); GetEvalScopeValue(pos, &check); test(eval_declare_p(check), "scope_declaim4"); getglobal_eval(ptr, &pos); GetEvalStackTable(pos, &check); getplist_constant(check, CONSTANT_SYSTEM_TYPE_SPECIAL, &check); readstring_debug(&pos, "aa"); test(find_list_eq_unsafe(pos, check), "scope_declaim5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * apply_declare */ static void setpplist_value(LocalRoot local, addr stack, addr pos, addr value) { addr key, table; GetConstant(CONSTANT_SYSTEM_TABLE_VALUE, &key); GetEvalStackTable(stack, &table); if (setpplist_local(local, table, key, pos, value, &table)) SetEvalStackTable(stack, table); } static void setpplist_function(LocalRoot local, addr stack, addr pos, addr value) { addr key, table; GetConstant(CONSTANT_SYSTEM_TABLE_FUNCTION, &key); GetEvalStackTable(stack, &table); if (GetType(pos) != LISPTYPE_CALLNAME) parse_callname_local(local, &pos, pos); if (setpplist_callname_local(local, table, key, pos, value, &table)) SetEvalStackTable(stack, table); } static int test_find_tablevalue(void) { addr control, stack, pos, value, check; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "aa"); readstring_debug(&value, "bb"); setpplist_value(local, stack, pos, value); readstring_debug(&pos, "cc"); readstring_debug(&value, "dd"); setpplist_value(local, stack, pos, value); readstring_debug(&pos, "aa"); test(find_tablevalue(stack, pos, &check), "find_tablevalue1"); readstring_debug(&value, "bb"); test(check == value, "find_tablevalue2"); test(find_tablevalue(stack, pos, NULL), "find_tablevalue3"); readstring_debug(&pos, "bb"); test(! find_tablevalue(stack, pos, NULL), "find_tablevalue4"); readstring_debug(&pos, "cc"); test(find_tablevalue(stack, pos, &check), "find_tablevalue5"); readstring_debug(&value, "dd"); test(check == value, "find_tablevalue6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_find_tablefunction(void) { addr control, stack, pos, value, check; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "aa"); readstring_debug(&value, "bb"); setpplist_function(local, stack, pos, value); readstring_debug(&pos, "cc"); readstring_debug(&value, "dd"); setpplist_function(local, stack, pos, value); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); test(find_tablefunction(stack, pos, &check), "find_tablefunction1"); readstring_debug(&value, "bb"); test(check == value, "find_tablefunction2"); test(find_tablefunction(stack, pos, NULL), "find_tablefunction3"); readstring_debug(&pos, "bb"); parse_callname_local(local, &pos, pos); test(! find_tablefunction(stack, pos, NULL), "find_tablefunction4"); readstring_debug(&pos, "cc"); parse_callname_local(local, &pos, pos); test(find_tablefunction(stack, pos, &check), "find_tablefunction5"); readstring_debug(&value, "dd"); test(check == value, "find_tablefunction6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_check_value_declare(void) { addr control, stack; addr key1, val1, key2, val2, key3, val3, list, key, value, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&key1, "aa"); readstring_debug(&val1, "bb"); readstring_debug(&key2, "cc"); readstring_debug(&val2, "dd"); readstring_debug(&key3, "ee"); readstring_debug(&val3, "ff"); setpplist_value(local, stack, key1, val1); setpplist_value(local, stack, key3, val3); list_local(local, &list, key1, val1, key2, val2, key3, val3, NULL); pos = Nil; check_value_declare(ptr, stack, list, &pos); nreverse(&list, pos); test(length_list_unsafe(list) == 1, "check_value_declare1"); GetCar(list, &key); GetCons(key, &key, &value); test(eval_tablevalue_p(key), "check_value_declare2"); getname_tablevalue(key, &key); readstring_debug(&pos, "cc"); test(key == pos, "check_value_declare3"); readstring_debug(&pos, "dd"); test(value == pos, "check_value_declare4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_check_function_declare(void) { addr control, stack; addr key1, val1, key2, val2, key3, val3, list, key, value, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&key1, "aa"); readstring_debug(&val1, "bb"); readstring_debug(&key2, "cc"); readstring_debug(&val2, "dd"); readstring_debug(&key3, "ee"); readstring_debug(&val3, "ff"); parse_callname_local(local, &key1, key1); parse_callname_local(local, &key2, key2); parse_callname_local(local, &key3, key3); setpplist_function(local, stack, key1, val1); setpplist_function(local, stack, key3, val3); list_local(local, &list, key1, val1, key2, val2, key3, val3, NULL); pos = Nil; check_function_declare(ptr, stack, list, &pos); nreverse(&list, pos); test(length_list_unsafe(list) == 1, "check_function_declare1"); GetCar(list, &key); GetCons(key, &key, &value); test(eval_tablefunction_p(key), "check_function_declare2"); getname_tablefunction(key, &key); readstring_debug(&pos, "cc"); parse_callname_local(local, &pos, pos); test(equal_callname(key, pos), "check_function_declare3"); readstring_debug(&pos, "dd"); test(value == pos, "check_function_declare4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_check_declare_stack(void) { addr control, stack, decl, pos, value, list, check, check2; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&decl, "((type integer aa bb) (ftype function cc dd ee))"); parse_declare_heap(Execute_Thread, Nil, decl, &decl); readstring_debug(&pos, "aa"); readstring_debug(&value, "hello1"); setpplist_value(local, stack, pos, value); readstring_debug(&pos, "dd"); readstring_debug(&value, "hello2"); setpplist_function(local, stack, pos, value); check_declare_stack(ptr, stack, decl, &list); test(length_list_unsafe(list) == 3, "check_declare_stack1"); GetCons(list, &pos, &list); GetCons(pos, &pos, &value); getname_tablevalue(pos, &pos); readstring_debug(&check, "bb"); test(pos == check, "check_declare_stack2"); test(RefLispDecl(value) == LISPDECL_INTEGER, "check_declare_stack3"); GetCons(list, &pos, &list); GetCons(pos, &pos, &value); getname_tablefunction(pos, &pos); readstring_debug(&check, "cc"); parse_callname_local(local, &check, check); readstring_debug(&check2, "ee"); parse_callname_local(local, &check2, check2); test(equal_callname(pos, check) || equal_callname(pos, check2), "check_declare_stack4"); test(RefLispDecl(value) == LISPDECL_FUNCTION, "check_declare_stack5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_apply_declare(void) { addr control, stack, decl, pos, value, list, check; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&decl, "((type integer aa bb) (ftype function cc dd ee))"); parse_declare_heap(Execute_Thread, Nil, decl, &decl); readstring_debug(&pos, "aa"); readstring_debug(&value, "hello1"); setpplist_value(local, stack, pos, value); readstring_debug(&pos, "dd"); readstring_debug(&value, "hello2"); setpplist_function(local, stack, pos, value); apply_declare(ptr, stack, decl, &list); test(length_list_unsafe(list) == 3, "apply_declare1"); GetConstant(CONSTANT_SYSTEM_TYPE_VALUE, &pos); GetEvalStackTable(stack, &list); readstring_debug(&check, "aa"); test(getpplist(list, pos, check, &check) == 0, "apply_declare2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * let */ static int test_check_scope_variable(void) { addr symbol; readstring_debug(&symbol, "aaa"); check_scope_variable(symbol); test(1, "check_scope_variable1"); RETURN; } static int test_let_init(void) { addr control, pos, var, init, check; Execute ptr; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(let ((a 10) (b (progn 20)) (c)) :hello)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &pos); /* let-args */ str.args = pos; let_init(ptr, &str); pos = str.args; test(length_list_unsafe(pos) == 3, "let_init1"); GetCons(pos, &var, &pos); GetCons(var, &var, &init); readstring_debug(&check, "a"); test(var == check, "let_init2"); test(RefEvalScopeType(init) == EVAL_PARSE_INTEGER, "let_init3"); GetCons(pos, &var, &pos); GetCons(var, &var, &init); readstring_debug(&check, "b"); test(var == check, "let_init4"); test(RefEvalScopeType(init) == EVAL_PARSE_PROGN, "let_init5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_make_tablevalue_stack(void) { int result; addr control, stack, value, symbol, check; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "aa"); make_tablevalue_stack(local, &value, stack, symbol); test(eval_tablevalue_p(value), "make_tablevalue_stack1"); result = find_tablevalue(stack, symbol, &check); test(result, "make_tablevalue_stack2"); test(check == value, "make_tablevalue_stack3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_let_maketable(void) { addr control, pos; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(let ((a 10) (b (progn 20)) (c)) :hello)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &pos); /* let-args */ str.args = pos; let_init(ptr, &str); let_maketable(local, &str); readstring_debug(&pos, "a"); test(find_tablevalue(str.stack, pos, &pos), "let_maketable1"); test(eval_tablevalue_p(pos), "let_maketable2"); gettype_tablevalue(pos, &pos); test(type_asterisk_p(pos), "let_maketable3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_specialp_stack_tablevalue(void) { int result, specialp; addr control, stack, symbol, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "aa"); specialp = 0; result = specialp_stack_tablevalue(stack, symbol, &specialp); test(result == 0, "specialp_stack_tablevalue1"); readstring_debug(&pos, "((special bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = specialp_stack_tablevalue(stack, symbol, &specialp); test(result == 0, "specialp_stack_tablevalue2"); readstring_debug(&pos, "((special aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = specialp_stack_tablevalue(stack, symbol, &specialp); test(result, "specialp_stack_tablevalue3"); test(specialp, "specialp_stack_tablevalue4"); readstring_debug(&symbol, "cc"); make_tablevalue_stack(local, &pos, stack, symbol); result = specialp_stack_tablevalue(stack, symbol, &specialp); test(result, "specialp_stack_tablevalue5"); test(! specialp, "specialp_stack_tablevalue6"); setspecialp_tablevalue(pos, 1); result = specialp_stack_tablevalue(stack, symbol, &specialp); test(result, "specialp_stack_tablevalue7"); test(specialp, "specialp_stack_tablevalue8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_specialp_tablevalue(void) { int specialp; addr control, stack, symbol, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "specialp_tablevalue-temp-symbol"); specialp = specialp_tablevalue(ptr, stack, symbol); test(! specialp, "specialp_tablevalue1"); setspecial_symbol(symbol); specialp = specialp_tablevalue(ptr, stack, symbol); test(specialp, "specialp_tablevalue2"); readstring_debug(&symbol, "aa"); readstring_debug(&pos, "((special aa))"); parse_declaim_heap(Execute_Thread, Nil, pos, &pos); apply_declaim_stack(ptr, pos); specialp = specialp_tablevalue(ptr, stack, symbol); test(specialp, "specialp_tablevalue3"); readstring_debug(&symbol, "bb"); readstring_debug(&pos, "((special bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); specialp = specialp_tablevalue(ptr, stack, symbol); test(specialp, "specialp_tablevalue4"); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); specialp = specialp_tablevalue(ptr, stack, symbol); test(specialp, "specialp_tablevalue5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_dynamic_stack_tablevalue(void) { int result, dynamic; addr control, stack, symbol, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "aa"); dynamic = 999; result = dynamic_stack_tablevalue(stack, symbol, &dynamic); test(result == 0, "dynamic_stack_tablevalue1"); readstring_debug(&pos, "((dynamic-extent bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = dynamic_stack_tablevalue(stack, symbol, &dynamic); test(result == 0, "dynamic_stack_tablevalue2"); readstring_debug(&pos, "((dynamic-extent aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = dynamic_stack_tablevalue(stack, symbol, &dynamic); test(result, "dynamic_stack_tablevalue3"); test(dynamic, "dynamic_stack_tablevalue4"); readstring_debug(&symbol, "cc"); make_tablevalue_stack(local, &pos, stack, symbol); result = dynamic_stack_tablevalue(stack, symbol, &dynamic); test(result, "dynamic_stack_tablevalue5"); test(! dynamic, "dynamic_stack_tablevalue6"); setdynamic_tablevalue(pos, 1); result = dynamic_stack_tablevalue(stack, symbol, &dynamic); test(result, "dynamic_stack_tablevalue7"); test(dynamic, "dynamic_stack_tablevalue8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_dynamic_tablevalue(void) { int dynamic; addr control, stack, symbol, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "aa"); dynamic = dynamic_tablevalue(stack, symbol); test(! dynamic, "dynamic_tablevalue1"); readstring_debug(&symbol, "bb"); readstring_debug(&pos, "((dynamic-extent bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); dynamic = dynamic_tablevalue(stack, symbol); test(dynamic, "dynamic_tablevalue2"); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); dynamic = dynamic_tablevalue(stack, symbol); test(dynamic, "dynamic_tablevalue3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_ignore_stack_tablevalue(void) { enum IgnoreType ignore; int result; addr control, stack, symbol, pos; Execute ptr; LocalRoot local; ignore = IgnoreType_None; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "aa"); result = ignore_stack_tablevalue(stack, symbol, &ignore); test(! result, "ignore_stack_tablevalue1"); readstring_debug(&pos, "((ignorable bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = ignore_stack_tablevalue(stack, symbol, &ignore); test(! result, "ignore_stack_tablevalue2"); readstring_debug(&pos, "((ignore aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = ignore_stack_tablevalue(stack, symbol, &ignore); test(result, "ignore_stack_tablevalue3"); test(ignore == IgnoreType_Ignore, "ignore_stack_tablevalue4"); readstring_debug(&symbol, "bb"); result = ignore_stack_tablevalue(stack, symbol, &ignore); test(result, "ignore_stack_tablevalue5"); test(ignore == IgnoreType_Ignorable, "ignore_stack_tablevalue6"); readstring_debug(&symbol, "cc"); make_tablevalue_stack(local, &pos, stack, symbol); result = ignore_stack_tablevalue(stack, symbol, &ignore); test(result, "ignore_stack_tablevalue7"); test(ignore == IgnoreType_None, "ignore_stack_tablevalue8"); setignore_tablevalue(pos, IgnoreType_Ignore); result = ignore_stack_tablevalue(stack, symbol, &ignore); test(result, "ignore_stack_tablevalue9"); test(ignore == IgnoreType_Ignore, "ignore_stack_tablevalue10"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_ignore_tablevalue(void) { enum IgnoreType ignore; addr control, stack, symbol, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "aa"); ignore = ignore_tablevalue(stack, symbol); test(ignore == IgnoreType_None, "ignore_tablevalue1"); readstring_debug(&symbol, "bb"); readstring_debug(&pos, "((ignore bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); ignore = ignore_tablevalue(stack, symbol); test(ignore == IgnoreType_Ignore, "ignore_tablevalue2"); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); ignore = ignore_tablevalue(stack, symbol); test(ignore == IgnoreType_Ignore, "ignore_tablevalue3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_free_tablevalue(void) { addr control, stack, pos, value; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "((type integer aa bb cc) (string dd ee))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); readstring_debug(&pos, "bb"); test(type_free_tablevalue(stack, pos, &value), "type_free_tablevalue1"); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_free_tablevalue2"); readstring_debug(&pos, "zz"); test(! type_free_tablevalue(stack, pos, &value), "type_free_tablevalue3"); readstring_debug(&pos, "ee"); test(type_free_tablevalue(stack, pos, &value), "type_free_tablevalue4"); test(RefLispDecl(value) == LISPDECL_STRING, "type_free_tablevalue5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_boundary_tablevalue(void) { addr control, stack, pos, value; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "aa"); make_tablevalue_stack(local, &pos, stack, pos); readstring_debug(&value, "integer"); test_parse_type(&value, value); settype_tablevalue(pos, value); readstring_debug(&pos, "bb"); make_tablevalue_stack(local, &pos, stack, pos); readstring_debug(&value, "string"); test_parse_type(&value, value); settype_tablevalue(pos, value); readstring_debug(&pos, "bb"); test(type_boundary_tablevalue(stack, pos, &value), "type_boundary_tablevalue1"); test(RefLispDecl(value) == LISPDECL_STRING, "type_boundary_tablevalue2"); readstring_debug(&pos, "zz"); test(! type_boundary_tablevalue(stack, pos, &value), "type_boundary_tablevalue3"); readstring_debug(&pos, "aa"); test(type_boundary_tablevalue(stack, pos, &value), "type_boundary_tablevalue4"); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_boundary_tablevalue5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_tablevalue_local(void) { addr control, stack, pos, value; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "((type integer aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); readstring_debug(&pos, "aa"); type_tablevalue(ptr, local, stack, pos, 0, &pos); test(length_list_unsafe(pos) == 1, "type_tablevalue_local1"); GetCar(pos, &value); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_tablevalue_local2"); stack = newstack_nil(ptr); readstring_debug(&pos, "((type string aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); readstring_debug(&pos, "aa"); type_tablevalue(ptr, local, stack, pos, 0, &pos); test(length_list_unsafe(pos) == 2, "type_tablevalue_local3"); GetCons(pos, &value, &pos); test(RefLispDecl(value) == LISPDECL_STRING, "type_tablevalue_local4"); GetCar(pos, &value); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_tablevalue_local5"); readstring_debug(&pos, "aa"); make_tablevalue_stack(local, &pos, stack, pos); readstring_debug(&value, "null"); test_parse_type(&value, value); settype_tablevalue(pos, value); readstring_debug(&pos, "aa"); type_tablevalue(ptr, local, stack, pos, 0, &pos); test(length_list_unsafe(pos) == 2, "type_tablevalue_local6"); GetCons(pos, &value, &pos); test(RefLispDecl(value) == LISPDECL_STRING, "type_tablevalue_local7"); GetCar(pos, &value); test(RefLispDecl(value) == LISPDECL_NULL, "type_tablevalue_local8"); readstring_debug(&pos, "aa"); type_tablevalue(ptr, local, stack, pos, 1, &pos); test(length_list_unsafe(pos) == 3, "type_tablevalue_local9"); GetCons(pos, &value, &pos); test(RefLispDecl(value) == LISPDECL_STRING, "type_tablevalue_local10"); GetCons(pos, &value, &pos); test(RefLispDecl(value) == LISPDECL_NULL, "type_tablevalue_local11"); GetCar(pos, &value); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_tablevalue_local12"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_tablevalue_global(void) { addr control, geval, stack, pos, value, type; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "type-tablevalue-global-temp-symbol"); type_tablevalue(ptr, local, stack, pos, 0, &value); test(value == Nil, "type_tablevalue_global1"); readstring_debug(&value, "null"); test_parse_type(&value, value); settype_value_symbol(pos, value); type_tablevalue(ptr, local, stack, pos, 0, &value); test(singlep(value), "type_tablevalue_global2"); GetCar(value, &value); test(RefLispDecl(value) == LISPDECL_NULL, "type_tablevalue_global3"); getglobal_eval(ptr, &geval); make_tablevalue_stack(NULL, &value, geval, pos); readstring_debug(&type, "integer"); test_parse_type(&type, type); settype_tablevalue(value, type); type_tablevalue(ptr, local, stack, pos, 0, &value); test(singlep(value), "type_tablevalue_global4"); GetCar(value, &value); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_tablevalue_global5"); readstring_debug(&value, "((type string type-tablevalue-global-temp-symbol))"); parse_declaim_heap(Execute_Thread, Nil, value, &value); apply_declaim_stack(ptr, value); type_tablevalue(ptr, local, stack, pos, 0, &value); test(singlep(value), "type_tablevalue_global6"); GetCar(value, &value); test(RefLispDecl(value) == LISPDECL_STRING, "type_tablevalue_global7"); make_tablevalue_stack(local, &value, stack, pos); readstring_debug(&type, "null"); test_parse_type(&type, type); settype_tablevalue(value, type); type_tablevalue(ptr, local, stack, pos, 0, &type); test(length_list_unsafe(type) == 1, "type_tablevalue_global8"); GetCons(type, &value, &type); test(RefLispDecl(value) == LISPDECL_NULL, "type_tablevalue_global9"); type_tablevalue(ptr, local, stack, pos, 1, &type); test(length_list_unsafe(type) == 2, "type_tablevalue_global10"); GetCons(type, &value, &type); test(RefLispDecl(value) == LISPDECL_NULL, "type_tablevalue_global11"); GetCons(type, &value, &type); test(RefLispDecl(value) == LISPDECL_STRING, "type_tablevalue_global12"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_and_array(void) { addr pos, cons, check, pos1, pos2, pos3, pos4, pos5; LocalRoot local; LocalStack stack; local = Local_Thread; push_local(local, &stack); test(type_and_array(local, Nil, &pos), "type_and_array1"); GetTypeTable(&pos, Atom); list_local(local, &cons, pos, NULL); test(! type_and_array(local, cons, &check), "type_and_array2"); test(check == pos, "type_and_array3"); GetTypeTable(&pos1, Atom); GetTypeTable(&pos2, Null); GetTypeTable(&pos3, Asterisk); GetTypeTable(&pos4, T); GetTypeTable(&pos5, Fixnum); list_local(local, &cons, pos1, pos2, pos3, pos4, pos5, NULL); test(! type_and_array(local, cons, &check), "type_and_array4"); test(RefLispDecl(check) == LISPDECL_AND, "type_and_array5"); GetArrayType(check, 0, &check); test(lenarrayr(check) == 3, "type_and_array6"); GetArrayA4(check, 0, &pos); test(RefLispDecl(pos) == LISPDECL_ATOM, "type_and_array7"); GetArrayA4(check, 1, &pos); test(RefLispDecl(pos) == LISPDECL_NULL, "type_and_array8"); GetArrayA4(check, 2, &pos); test(RefLispDecl(pos) == LISPDECL_FIXNUM, "type_and_array9"); rollback_local(local, stack); RETURN; } static int test_push_tablevalue_alloc(void) { addr control, stack, symbol, value, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "aa"); push_tablevalue_alloc(ptr, local, stack, symbol, &value); test(! getspecialp_tablevalue(value), "push_tablevalue_alloc1"); readstring_debug(&symbol, "bb"); readstring_debug(&pos, "((special bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); push_tablevalue_alloc(ptr, local, stack, symbol, &value); test(getspecialp_tablevalue(value), "push_tablevalue_alloc2"); getglobal_eval(ptr, &stack); readstring_debug(&symbol, "bb"); readstring_debug(&pos, "((special bb))"); parse_declaim_heap(Execute_Thread, Nil, pos, &pos); apply_declaim_stack(ptr, pos); push_tablevalue_alloc(ptr, NULL, stack, symbol, &value); test(getspecialp_tablevalue(value), "push_tablevalue_alloc3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_checktype_p(void) { int check, warning; addr form, symbol; readstring_debug(&form, "integer"); test_parse_type(&form, form); readstring_debug(&symbol, "real"); test_parse_type(&symbol, symbol); checktype_p_(form, symbol, &check, &warning); test(! check, "checktype_p1"); test(! warning, "checktype_p2"); readstring_debug(&form, "real"); test_parse_type(&form, form); readstring_debug(&symbol, "integer"); test_parse_type(&symbol, symbol); checktype_p_(form, symbol, &check, &warning); test(check, "checktype_p3"); test(! warning, "checktype_p4"); readstring_debug(&form, "string"); test_parse_type(&form, form); readstring_debug(&symbol, "integer"); test_parse_type(&symbol, symbol); checktype_p_(form, symbol, &check, &warning); test(check, "checktype_p5"); test(warning, "checktype_p6"); RETURN; } static int test_checktype_value(void) { addr control, stack, symbol, value, type, init; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "aa"); push_tablevalue_alloc(ptr, local, stack, symbol, &value); readstring_debug(&type, "integer"); test_parse_type(&type, type); settype_tablevalue(value, type); readstring_debug(&type, "fixnum"); test_parse_type(&type, type); make_eval_scope(Execute_Thread, &init, EVAL_PARSE_EMPTY, type, Nil); checktype_value(value, init); test(getcheck_tablevalue(value) == 0, "checktype_value1"); readstring_debug(&type, "real"); test_parse_type(&type, type); make_eval_scope(Execute_Thread, &init, EVAL_PARSE_EMPTY, type, Nil); checktype_value(value, init); test(getcheck_tablevalue(value), "checktype_value2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_let_applytable(void) { addr control, pos, value, type; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(let ((aa 10) (bb 20)) (declare (special bb)) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); /* let-args */ GetEvalParse(pos, 1, &str.decl); /* let-decl */ let_init(ptr, &str); apply_declare_stack(local, str.stack, str.decl); let_applytable(ptr, &str); readstring_debug(&pos, "aa"); test(find_tablevalue(str.stack, pos, &value), "let_applytable1"); test(! getspecialp_tablevalue(value), "let_applytable2"); readstring_debug(&pos, "bb"); test(find_tablevalue(str.stack, pos, &value), "let_applytable3"); test(getspecialp_tablevalue(value), "let_applytable4"); readstring_debug(&pos, "aa"); test(find_tablevalue(str.stack, pos, &value), "let_applytable5"); readstring_debug(&type, "fixnum"); test_parse_type(&type, type); settype_tablevalue(value, type); readstring_debug(&pos, "bb"); test(find_tablevalue(str.stack, pos, &value), "let_applytable6"); readstring_debug(&type, "(satisfies hello)"); test_parse_type(&type, type); settype_tablevalue(value, type); let_applytable(ptr, &str); readstring_debug(&pos, "aa"); test(find_tablevalue(str.stack, pos, &value), "let_applytable7"); test(! getspecialp_tablevalue(value), "let_applytable8"); test(! getcheck_tablevalue(value), "let_applytable9"); readstring_debug(&pos, "bb"); test(find_tablevalue(str.stack, pos, &value), "let_applytable10"); test(getspecialp_tablevalue(value), "let_applytable11"); test(getcheck_tablevalue(value), "let_applytable12"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_ignore_checkvalue(void) { addr control, pos, value; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(let ((aa 10) (bb 20)) (declare (special bb)) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); /* let-args */ GetEvalParse(pos, 1, &str.decl); /* let-decl */ let_init(ptr, &str); apply_declare_stack(local, str.stack, str.decl); let_applytable(ptr, &str); readstring_debug(&pos, "aa"); find_tablevalue(str.stack, pos, &value); setreference_tablevalue(value, 1); readstring_debug(&pos, "bb"); find_tablevalue(str.stack, pos, &value); setreference_tablevalue(value, 1); ignore_checkvalue(str.stack); test(1, "ignore_checkvalue1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_tablevalue_update(void) { addr control, stack, key, pos, value; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "aa"); push_tablevalue_local(ptr, stack, pos, &value); GetConstant(CONSTANT_SYSTEM_TABLE_VALUE, &key); GetEvalStackTable(stack, &stack); test(getplist(stack, key, &stack) == 0, "tablevalue_update1"); tablevalue_update(stack, &value, pos); test(eval_tablevalue_p(value), "tablevalue_update2"); test(! GetStatusDynamic(value), "tablevalue_update3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_let_update(void) { int check; addr control, pos, cons; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(let ((aa 10) (bb 20)) (declare (special bb)) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); /* let-args */ GetEvalParse(pos, 1, &str.decl); /* let-decl */ let_init(ptr, &str); apply_declare_stack(local, str.stack, str.decl); let_applytable(ptr, &str); let_update(ptr, &str); check = 1; for (cons = str.args; cons != Nil; ) { GetCons(cons, &pos, &cons); GetCar(pos, &pos); if (GetStatusDynamic(pos)) { check = 0; break; } } test(check, "let_update1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_let_execute(void) { addr control, pos; Execute ptr; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(let ((aa 10) (bb 20)) " " (declare (special bb) (ignorable aa bb)) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); /* let-args */ GetEvalParse(pos, 1, &str.decl); /* let-decl */ GetEvalParse(pos, 2, &str.cons); /* let-decl */ let_execute(ptr, &str); test(1, "let_execute1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_let(void) { addr control, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(let ((aa 10) (bb 20)) " " (declare (special bb) (ignorable aa bb)) :aa)"); eval_parse_execute(&pos, pos); scope_let(ptr, &pos, pos); test(RefEvalScopeType(pos) == EVAL_PARSE_LET, "scope_let1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_ifdeclvalue(void) { int invalidp; addr control, stack, decl, symbol, value, check, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&decl, "()"); parse_declare_heap(Execute_Thread, Nil, decl, &decl); readstring_debug(&symbol, "aa"); ifdeclvalue_(ptr, stack, symbol, decl, &value); test(eval_tablevalue_p(value), "ifdeclvalue1"); test(! getspecialp_tablevalue(value), "ifdeclvalue2"); gettype_tablevalue(value, &check); test(type_asterisk_p(check), "ifdeclvalue3"); readstring_debug(&decl, "((special bb) (null bb))"); parse_declare_heap(Execute_Thread, Nil, decl, &decl); readstring_debug(&symbol, "bb"); ifdeclvalue_(ptr, stack, symbol, decl, &value); test(eval_tablevalue_p(value), "ifdeclvalue4"); test(getspecialp_tablevalue(value), "ifdeclvalue5"); gettype_tablevalue(value, &check); readstring_debug(&pos, "null"); test_parse_type(&pos, pos); test(subtypep_clang(check, pos, &invalidp), "ifdeclvalue6"); ifdeclvalue_(ptr, stack, symbol, decl, NULL); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_leta_checktype(void) { addr control, pos, value, type; Execute ptr; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(let ((aa 10) (bb 20)) (declare (special bb)) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); /* let-args */ GetEvalParse(pos, 1, &str.decl); /* let-decl */ leta_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); readstring_debug(&pos, "aa"); test(find_tablevalue(str.stack, pos, &value), "leta_checktype1"); readstring_debug(&type, "fixnum"); test_parse_type(&type, type); settype_tablevalue(value, type); readstring_debug(&pos, "bb"); test(find_tablevalue(str.stack, pos, &value), "leta_checktype2"); readstring_debug(&type, "(satisfies hello)"); test_parse_type(&type, type); settype_tablevalue(value, type); leta_checktype(ptr, &str); readstring_debug(&pos, "aa"); test(find_tablevalue(str.stack, pos, &value), "leta_checktype3"); test(! getspecialp_tablevalue(value), "leta_checktype4"); test(! getcheck_tablevalue(value), "leta_checktype5"); readstring_debug(&pos, "bb"); test(find_tablevalue(str.stack, pos, &value), "leta_checktype6"); test(getspecialp_tablevalue(value), "leta_checktype7"); test(getcheck_tablevalue(value), "leta_checktype8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_leta_execute(void) { addr control, pos; Execute ptr; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(let* ((aa 10) (bb 20)) " " (declare (special bb) (ignorable aa bb)) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); /* let-args */ GetEvalParse(pos, 1, &str.decl); /* let-decl */ GetEvalParse(pos, 2, &str.cons); /* let-decl */ leta_execute(ptr, &str); test(1, "leta_execute1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_leta(void) { addr control, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(let* ((aa 10) (bb 20)) " " (declare (special bb) (ignorable aa bb)) :aa)"); eval_parse_execute(&pos, pos); scope_leta(ptr, &pos, pos); test(RefEvalScopeType(pos) == EVAL_PARSE_LETA, "scope_leta1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_let_special(void) { addr control, pos, symbol, value; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(let (aa) (declare (special aa)) :hello)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); GetEvalParse(pos, 1, &str.decl); let_init(ptr, &str); let_maketable(local, &str); apply_declare_stack(local, str.stack, str.decl); let_applytable(ptr, &str); readstring_debug(&symbol, "aa"); find_tablevalue(str.stack, symbol, &value); test(getspecialp_tablevalue(value), "let_special1"); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(let (aa) :hello)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); GetEvalParse(pos, 1, &str.decl); let_init(ptr, &str); let_maketable(local, &str); apply_declare_stack(local, str.stack, str.decl); let_applytable(ptr, &str); readstring_debug(&symbol, "aa"); find_tablevalue(str.stack, symbol, &value); test(! getspecialp_tablevalue(value), "let_special2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * symbol */ static int test_symbol_global_tablevalue(void) { int specialp, result; addr control, symbol, pos, value, stack; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&symbol, "aa"); specialp = symbol_global_tablevalue(ptr, symbol, &pos); test(! specialp, "symbol_global_tablevalue1"); getglobal_eval(ptr, &stack); result = find_tablevalue(stack, symbol, &value); test(result, "symbol_global_tablevalue2"); test(! getspecialp_tablevalue(value), "symbol_global_tablevalue3"); specialp = symbol_global_tablevalue(ptr, symbol, &pos); test(! specialp, "symbol_global_tablevalue4"); readstring_debug(&pos, "((special bb))"); parse_declaim_heap(Execute_Thread, Nil, pos, &pos); apply_declaim_stack(ptr, pos); readstring_debug(&symbol, "bb"); specialp = symbol_global_tablevalue(ptr, symbol, &pos); test(specialp, "symbol_global_tablevalue5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_push_closure_value(void) { #if 0 int result; addr control, stack, symbol, value, check, table, key; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "aa"); readstring_debug(&value, "bb"); push_closure_value(stack, symbol, value); GetConstant(CONSTANT_SYSTEM_CLOSURE_VALUE, &key); GetEvalStackTable(stack, &table); result = getpplist(table, key, symbol, &check); test(result == 0, "push_closure_value1"); test(check == value, "push_closure_value2"); readstring_debug(&check, "cc"); push_closure_value(stack, symbol, check); GetEvalStackTable(stack, &table); result = getpplist(table, key, symbol, &check); test(result == 0, "push_closure_value3"); test(check == value, "push_closure_value4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; #endif return 0; } static int test_symbol_tablevalue(void) { int specialp; addr control, stack, symbol, pos, key, table, value; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "((special bb))"); parse_declaim_heap(Execute_Thread, Nil, pos, &pos); apply_declaim_stack(ptr, pos); readstring_debug(&symbol, "bb"); specialp = symbol_tablevalue(ptr, Nil, symbol, &pos); test(specialp, "symbol_tablevalue1"); readstring_debug(&symbol, "cc"); readstring_debug(&pos, "((special cc))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); push_tablevalue_local(ptr, stack, symbol, &pos); specialp = symbol_tablevalue(ptr, stack, symbol, &pos); test(specialp, "symbol_tablevalue2"); readstring_debug(&symbol, "dd"); specialp = symbol_tablevalue(ptr, stack, symbol, &pos); test(! specialp, "symbol_tablevalue3"); readstring_debug(&pos, "((integer ee))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); readstring_debug(&symbol, "ee"); make_tablevalue_stack(local, &value, stack, symbol); apply_declare_value_stack(local, stack, symbol, pos); push_tablevalue_local(ptr, stack, symbol, &value); stack = newstack_lambda(ptr); newstack_nil(ptr); newstack_nil(ptr); newstack_nil(ptr); newstack_nil(ptr); readstring_debug(&symbol, "cc"); specialp = symbol_tablevalue(ptr, stack, symbol, &pos); test(specialp, "symbol_tablevalue4"); readstring_debug(&symbol, "dd"); specialp = symbol_tablevalue(ptr, stack, symbol, &pos); test(! specialp, "symbol_tablevalue5"); #if 0 GetConstant(CONSTANT_SYSTEM_CLOSURE_VALUE, &key); GetEvalStackTable(stack, &table); specialp = getpplist(table, key, symbol, &pos); test(! specialp , "symbol_tablevalue6"); readstring_debug(&symbol, "ee"); specialp = symbol_tablevalue(ptr, stack, symbol, &pos); test(! specialp, "symbol_tablevalue7"); GetConstant(CONSTANT_SYSTEM_CLOSURE_VALUE, &key); GetEvalStackTable(stack, &table); specialp = getpplist(table, key, symbol, &pos); #endif free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_find_symbol_scope(void) { int specialp; addr control, symbol, value, stack; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&symbol, "aa"); specialp = find_symbol_scope(ptr, symbol, &value); test(! specialp, "find_symbol_scope1"); test(eval_tablevalue_p(value), "find_symbol_scope2"); gettype_tablevalue(value, &value); test(RefLispDecl(value) == LISPDECL_ASTERISK, "find_symbol_scope3"); getstack_eval(ptr, &stack); symbol_tablevalue(ptr, stack, symbol, &value); test(getreference_tablevalue(value), "find_symbol_scope4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_make_scope_symbol(void) { addr control, symbol, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&symbol, "aa"); make_scope_symbol(ptr, symbol, &pos); test(RefEvalScopeType(pos) == EVAL_PARSE_SYMBOL, "make_scope_symbol1"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_ASTERISK, "make_scope_symbol2"); GetEvalScopeValue(pos, &check); test(check == symbol, "make_scope_symbol3"); GetEvalScopeIndex(pos, 0, &check); test(eval_tablevalue_p(check), "make_scope_symbol4"); test(! getspecialp_tablevalue(check), "make_scope_symbol5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_symbol_macrolet_global_p(void) { addr control, stack, symbol, value, v1, v2; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&symbol, "aa"); symbol_global_tablevalue(ptr, symbol, &value); setspecialp_tablevalue(value, 1); test(! symbol_macrolet_global_p(ptr, symbol, &value), "symbol_macrolet_global_p1"); symbol = readr_debug("bb"); fixnum_heap(&v1, 10); fixnum_heap(&v2, 20); getglobal_eval(ptr, &stack); push_symbol_macrolet(stack, symbol, v1, v2); test(symbol_macrolet_global_p(ptr, symbol, &value), "symbol_macrolet_global_p2"); test(consp(value), "symbol_macrolet_global_p3"); symbol = readr_debug("test-symbol-macrolet-global-p"); fixnum_heap(&v1, 10); fixnum_heap(&v2, 20); cons_heap(&v1, v1, v2); setsymbol_macro_symbol(symbol, v1, Nil); test(symbol_macrolet_global_p(ptr, symbol, &value), "symbol_macrolet_global_p4"); test(consp(value), "symbol_macrolet_global_p5"); setspecial_symbol(symbol); test(! symbol_macrolet_global_p(ptr, symbol, &value), "symbol_macrolet_global_p6"); test(consp(value), "symbol_macrolet_global_p7"); remsymbol_macro_symbol(symbol); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_symbol_macrolet_p(void) { addr control, stack, symbol, value, v1, v2, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); newstack_nil(ptr); newstack_nil(ptr); stack = newstack_nil(ptr); newstack_nil(ptr); newstack_nil(ptr); symbol = readr_debug("bb"); fixnum_heap(&v1, 10); fixnum_heap(&v2, 20); push_symbol_macrolet(stack, symbol, v1, v2); test(symbol_macrolet_p(ptr, symbol, &check), "symbol_macrolet_p1"); test(consp(check), "symbol_macrolet_p2"); symbol_tablevalue(ptr, stack, symbol, &value); GetEvalStackTable(stack, &v1); GetConst(SYSTEM_TABLE_VALUE, &v2); if (setpplist_heap(v1, v2, symbol, value, &v1)) SetEvalStackTable(stack, v1); test(! symbol_macrolet_p(ptr, symbol, &check), "symbol_macrolet_p3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_symbol_replace_function(Execute ptr, addr call, addr args, addr env) { addr pos, check; GetConst(SYSTEM_SYMBOL_MACRO_EXPANDER, &check); GetFunctionSymbol(check, &check); if (check != call) { setresult_control(ptr, fixnumh(30)); return 0; } eval_parse_execute(&pos, fixnumh(args == T? 10: 20)); setresult_control(ptr, pos); return 0; } static int test_scope_symbol_replace(void) { addr control, call, hook, pos; Execute ptr; ptr = Execute_Thread; begin_eval_stack(ptr); push_control(ptr, &control); compiled_system(&call, Nil); SetPointer(p_debug1, var3, test_scope_symbol_replace_function); setcompiled_var3(call, p_debug1); GetConst(SPECIAL_MACROEXPAND_HOOK, &hook); pushspecial_control(ptr, hook, call); cons_heap(&pos, T, Nil); /* (form . env) */ scope_symbol_replace(ptr, &pos, pos); test(eval_scope_p(pos), "scope_symbol_replace1"); GetEvalScopeValue(pos, &pos); test(RefFixnum(pos) == 10, "scope_symbol_replace2"); pop_control_(ptr, control); free_eval_stack(ptr); RETURN; } static int test_scope_symbol(void) { addr control, symbol, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&symbol, "aa"); eval_parse_execute(&pos, symbol); scope_symbol(ptr, &pos, pos); test(RefEvalScopeType(pos) == EVAL_PARSE_SYMBOL, "scope_symbol1"); readstring_debug(&symbol, ":aa"); eval_parse_execute(&pos, symbol); scope_symbol(ptr, &pos, pos); test(RefEvalScopeType(pos) == EVAL_PARSE_SYMBOL, "scope_symbol2"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_KEYWORD, "scope_symbol3"); GetEvalScopeValue(pos, &check); test(check == symbol, "scope_symbol4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_setq_cons(void) { addr control, pos, value, cons, type, symbol, check, stack; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); scope_setq_cons(ptr, Nil, &cons, &type); test(cons == Nil, "scope_setq_cons1"); test(RefLispDecl(type) == LISPDECL_NULL, "scope_setq_cons2"); readstring_debug(&cons, "(setq aa 100 bb 200)"); eval_parse_execute(&cons, cons); GetEvalParse(cons, 0, &cons); scope_setq_cons(ptr, cons, &cons, &type); test(length_list_unsafe(cons) == 2, "scope_setq_cons3"); test(RefLispDecl(type) == LISPDECL_INTEGER, "scope_setq_cons4"); GetCons(cons, &pos, &cons); GetCons(pos, &pos, &value); test(eval_tablevalue_p(pos), "scope_setq_cons5"); getname_tablevalue(pos, &symbol); readstring_debug(&check, "aa"); test(symbol == check, "scope_setq_cons6"); test(! getcheck_tablevalue(pos), "scope_setq_cons7"); GetEvalScopeValue(value, &value); test(RefFixnum(value) == 100, "scope_setq_cons8"); GetCons(cons, &pos, &cons); GetCons(pos, &pos, &value); test(eval_tablevalue_p(pos), "scope_setq_cons9"); getname_tablevalue(pos, &symbol); readstring_debug(&check, "bb"); test(symbol == check, "scope_setq_cons10"); test(! getcheck_tablevalue(pos), "scope_setq_cons11"); GetEvalScopeValue(value, &value); test(RefFixnum(value) == 200, "scope_setq_cons12"); stack = newstack_nil(ptr); readstring_debug(&check, "cc"); readstring_debug(&pos, "((type (satisfies hello) cc))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); push_tablevalue_local(ptr, stack, check, &pos); readstring_debug(&cons, "(setq cc 300)"); eval_parse_execute(&cons, cons); GetEvalParse(cons, 0, &cons); scope_setq_cons(ptr, cons, &cons, &type); test(length_list_unsafe(cons) == 1, "scope_setq_cons13"); test(RefLispDecl(type) == LISPDECL_INTEGER, "scope_setq_cons14"); GetCons(cons, &pos, &cons); GetCons(pos, &pos, &value); test(eval_tablevalue_p(pos), "scope_setq_cons15"); getname_tablevalue(pos, &symbol); readstring_debug(&check, "cc"); test(symbol == check, "scope_setq_cons16"); test(getcheck_tablevalue(pos), "scope_setq_cons17"); GetEvalScopeValue(value, &value); test(RefFixnum(value) == 300, "scope_setq_cons18"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_setq(void) { addr control, cons, type; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&cons, "(setq aa 100 bb 200)"); eval_parse_execute(&cons, cons); scope_setq(ptr, &cons, cons); test(RefEvalScopeType(cons) == EVAL_PARSE_SETQ, "scope_setq1"); GetEvalScopeThe(cons, &type); test(RefLispDecl(type) == LISPDECL_INTEGER, "scope_setq2"); GetEvalScopeValue(cons, &cons); test(length_list_unsafe(cons) == 2, "scope_setq3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * function */ static int test_globalp_stack_tablefunction(void) { int result; addr control, stack, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "((ftype function bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); readstring_debug(&pos, "cc"); parse_callname_local(local, &pos, pos); make_tablefunction_stack(local, &pos, stack, pos); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); result = globalp_stack_tablefunction(stack, pos); test(result == 0, "globalp_stack_tablefunction1"); readstring_debug(&pos, "bb"); parse_callname_local(local, &pos, pos); result = globalp_stack_tablefunction(stack, pos); test(result, "globalp_stack_tablefunction2"); readstring_debug(&pos, "cc"); parse_callname_local(local, &pos, pos); result = globalp_stack_tablefunction(stack, pos); test(result, "globalp_stack_tablefunction3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_globalp_tablefunction(void) { int result; addr control, stack, symbol, call, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "aa"); parse_callname_local(local, &call, symbol); result = globalp_tablefunction(ptr, stack, call); test(result, "globalp_tablefunction1"); readstring_debug(&pos, "((ftype function aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = globalp_tablefunction(ptr, stack, call); test(! result, "globalp_tablefunction2"); SetFunctionSymbol(symbol, T); result = globalp_tablefunction(ptr, stack, call); test(! result, "globalp_tablefunction3"); SetFunctionSymbol(symbol, Unbound); result = globalp_tablefunction(ptr, stack, call); test(! result, "globalp_tablefunction4"); readstring_debug(&symbol, "bb"); parse_callname_local(local, &call, symbol); readstring_debug(&pos, "((ftype function aa))"); parse_declaim_heap(Execute_Thread, Nil, pos, &pos); apply_declaim_stack(ptr, pos); result = globalp_tablefunction(ptr, stack, call); test(result, "globalp_tablefunction5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_dynamic_stack_tablefunction(void) { int result, dynamic; addr control, stack, call, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); dynamic = 999; result = dynamic_stack_tablefunction(stack, call, &dynamic); test(result == 0, "dynamic_stack_tablefunction1"); readstring_debug(&pos, "((dynamic-extent #'bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = dynamic_stack_tablefunction(stack, call, &dynamic); test(result == 0, "dynamic_stack_tablefunction2"); readstring_debug(&pos, "((dynamic-extent #'aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = dynamic_stack_tablefunction(stack, call, &dynamic); test(result, "dynamic_stack_tablefunction3"); test(dynamic, "dynamic_stack_tablefunction4"); readstring_debug(&call, "cc"); parse_callname_local(local, &call, call); make_tablefunction_stack(local, &pos, stack, call); result = dynamic_stack_tablefunction(stack, call, &dynamic); test(result, "dynamic_stack_tablefunction5"); test(! dynamic, "dynamic_stack_tablefunction6"); setdynamic_tablefunction(pos, 1); result = dynamic_stack_tablefunction(stack, call, &dynamic); test(result, "dynamic_stack_tablefunction7"); test(dynamic, "dynamic_stack_tablefunction8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_dynamic_tablefunction(void) { int dynamic; addr control, stack, call, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); dynamic = dynamic_tablefunction(stack, call); test(! dynamic, "dynamic_tablefunction1"); readstring_debug(&call, "bb"); parse_callname_local(local, &call, call); readstring_debug(&pos, "((dynamic-extent #'bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); dynamic = dynamic_tablefunction(stack, call); test(dynamic, "dynamic_tablefunction2"); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); dynamic = dynamic_tablefunction(stack, call); test(dynamic, "dynamic_tablefunction3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_ignore_stack_tablefunction(void) { enum IgnoreType ignore; int result; addr control, stack, call, pos; Execute ptr; LocalRoot local; ignore = IgnoreType_None; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); result = ignore_stack_tablefunction(stack, call, &ignore); test(! result, "ignore_stack_tablefunction1"); readstring_debug(&pos, "((ignorable #'bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = ignore_stack_tablefunction(stack, call, &ignore); test(! result, "ignore_stack_tablefunction2"); readstring_debug(&pos, "((ignore #'aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = ignore_stack_tablefunction(stack, call, &ignore); test(result, "ignore_stack_tablefunction3"); test(ignore == IgnoreType_Ignore, "ignore_stack_tablefunction4"); readstring_debug(&call, "bb"); parse_callname_local(local, &call, call); result = ignore_stack_tablefunction(stack, call, &ignore); test(result, "ignore_stack_tablefunction5"); test(ignore == IgnoreType_Ignorable, "ignore_stack_tablefunction6"); readstring_debug(&call, "cc"); parse_callname_local(local, &call, call); make_tablefunction_stack(local, &pos, stack, call); result = ignore_stack_tablefunction(stack, call, &ignore); test(result, "ignore_stack_tablefunction7"); test(ignore == IgnoreType_None, "ignore_stack_tablefunction8"); setignore_tablefunction(pos, IgnoreType_Ignore); result = ignore_stack_tablefunction(stack, call, &ignore); test(result, "ignore_stack_tablefunction9"); test(ignore == IgnoreType_Ignore, "ignore_stack_tablefunction10"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_ignore_tablefunction(void) { enum IgnoreType ignore; addr control, stack, call, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); ignore = ignore_tablefunction(stack, call); test(ignore == IgnoreType_None, "ignore_tablefunction1"); readstring_debug(&call, "bb"); parse_callname_local(local, &call, call); readstring_debug(&pos, "((ignore #'bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); ignore = ignore_tablefunction(stack, call); test(ignore == IgnoreType_Ignore, "ignore_tablefunction2"); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); ignore = ignore_tablefunction(stack, call); test(ignore == IgnoreType_Ignore, "ignore_tablefunction3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_inline_stack_tablefunction(void) { enum InlineType Inline; int result; addr control, stack, call, pos; Execute ptr; LocalRoot local; Inline = InlineType_None; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); result = inline_stack_tablefunction(stack, call, &Inline); test(! result, "inline_stack_tablefunction1"); readstring_debug(&pos, "((notinline bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = inline_stack_tablefunction(stack, call, &Inline); test(! result, "inline_stack_tablefunction2"); readstring_debug(&pos, "((inline aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); result = inline_stack_tablefunction(stack, call, &Inline); test(result, "inline_stack_tablefunction3"); test(Inline == InlineType_Inline, "inline_stack_tablefunction4"); readstring_debug(&call, "bb"); parse_callname_local(local, &call, call); result = inline_stack_tablefunction(stack, call, &Inline); test(result, "inline_stack_tablefunction5"); test(Inline == InlineType_NotInline, "inline_stack_tablefunction6"); readstring_debug(&call, "cc"); parse_callname_local(local, &call, call); make_tablefunction_stack(local, &pos, stack, call); result = inline_stack_tablefunction(stack, call, &Inline); test(result, "inline_stack_tablefunction7"); test(Inline == InlineType_None, "inline_stack_tablefunction8"); setinline_tablefunction(pos, InlineType_Inline); result = inline_stack_tablefunction(stack, call, &Inline); test(result, "inline_stack_tablefunction9"); test(Inline == InlineType_Inline, "inline_stack_tablefunction10"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_inline_tablefunction(void) { enum InlineType Inline; addr control, stack, call, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); Inline = inline_tablefunction(ptr, stack, call); test(Inline == InlineType_None, "inline_tablefunction1"); readstring_debug(&call, "bb"); parse_callname_local(local, &call, call); readstring_debug(&pos, "((inline bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); Inline = inline_tablefunction(ptr, stack, call); test(Inline == InlineType_Inline, "inline_tablefunction2"); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); Inline = inline_tablefunction(ptr, stack, call); test(Inline == InlineType_Inline, "inline_tablefunction3"); readstring_debug(&call, "cc"); parse_callname_local(local, &call, call); readstring_debug(&pos, "((notinline cc))"); parse_declaim_heap(Execute_Thread, Nil, pos, &pos); apply_declaim_stack(ptr, pos); Inline = inline_tablefunction(ptr, stack, call); test(Inline == InlineType_NotInline, "inline_tablefunction4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_gettype_global_callname(void) { addr symbol, call, pos; readstring_debug(&symbol, "gettype-global-callname-temp-symbol"); parse_callname_heap(&call, symbol); gettype_global_callname(NULL, call, &pos); test(pos == Nil, "gettype_global_callname1"); GetTypeTable(&pos, Null); settype_function_symbol(symbol, pos); GetTypeTable(&pos, Atom); settype_setf_symbol(symbol, pos); gettype_global_callname(NULL, call, &pos); test(RefLispDecl(pos) == LISPDECL_NULL, "gettype_global_callname2"); readstring_debug(&call, "(setf gettype-global-callname-temp-symbol)"); parse_callname_heap(&call, call); gettype_global_callname(NULL, call, &pos); test(RefLispDecl(pos) == LISPDECL_ATOM, "gettype_global_callname3"); remtype_function_symbol(symbol); RETURN; } static int test_type_free_tablefunction(void) { addr control, stack, pos, value; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "((ftype (function * integer) aa bb cc) " " (ftype (function * string) dd ee))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); readstring_debug(&pos, "bb"); parse_callname_local(local, &pos, pos); test(type_free_tablefunction(stack, pos, &value), "type_free_tablefunction1"); test(RefLispDecl(value) == LISPDECL_FUNCTION, "type_free_tablefunction2"); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_free_tablefunction3"); readstring_debug(&pos, "zz"); parse_callname_local(local, &pos, pos); test(! type_free_tablefunction(stack, pos, &value), "type_free_tablefunction4"); readstring_debug(&pos, "ee"); parse_callname_local(local, &pos, pos); test(type_free_tablefunction(stack, pos, &value), "type_free_tablefunction5"); test(RefLispDecl(value) == LISPDECL_FUNCTION, "type_free_tablefunction6"); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_STRING, "type_free_tablefunction7"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_boundary_tablefunction(void) { addr control, stack, pos, value; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); make_tablefunction_stack(local, &pos, stack, pos); readstring_debug(&value, "(function * integer)"); test_parse_type(&value, value); settype_tablefunction(pos, value); readstring_debug(&pos, "bb"); parse_callname_local(local, &pos, pos); make_tablefunction_stack(local, &pos, stack, pos); readstring_debug(&value, "(function * string)"); test_parse_type(&value, value); settype_tablefunction(pos, value); readstring_debug(&pos, "bb"); parse_callname_local(local, &pos, pos); test(type_boundary_tablefunction(stack, pos, &value), "type_boundary_tablefunction1"); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_STRING, "type_boundary_tablefunction2"); readstring_debug(&pos, "zz"); parse_callname_local(local, &pos, pos); test(! type_boundary_tablefunction(stack, pos, &value), "type_boundary_tablefunction3"); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); test(type_boundary_tablefunction(stack, pos, &value), "type_boundary_tablefunction4"); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_boundary_tablefunction5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_tablefunction_local(void) { addr control, stack, pos, value; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "((ftype (function * integer) aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); type_tablefunction(ptr, local, stack, pos, &pos); test(length_list_unsafe(pos) == 1, "type_tablefunction_local1"); GetCar(pos, &value); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_tablefunction_local2"); stack = newstack_nil(ptr); readstring_debug(&pos, "((ftype (function * string) aa))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); type_tablefunction(ptr, local, stack, pos, &pos); test(length_list_unsafe(pos) == 2, "type_tablefunction_local3"); GetCons(pos, &value, &pos); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_STRING, "type_tablefunction_local4"); GetCar(pos, &value); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_tablefunction_local5"); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); make_tablefunction_stack(local, &pos, stack, pos); readstring_debug(&value, "(function * null)"); test_parse_type(&value, value); settype_tablefunction(pos, value); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); type_tablefunction(ptr, local, stack, pos, &pos); test(length_list_unsafe(pos) == 2, "type_tablefunction_local6"); GetCons(pos, &value, &pos); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_STRING, "type_tablefunction_local7"); GetCar(pos, &value); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_NULL, "type_tablefunction_local8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_tablefunction_global(void) { addr control, geval, stack, symbol, pos, value, type; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&symbol, "type-tablefunction-global-temp-symbol"); parse_callname_local(local, &pos, symbol); type_tablefunction(ptr, local, stack, pos, &value); test(value == Nil, "type_tablefunction_global1"); readstring_debug(&value, "(function * null)"); test_parse_type(&value, value); settype_function_symbol(symbol, value); type_tablefunction(ptr, local, stack, pos, &value); test(singlep(value), "type_tablefunction_global2"); GetCar(value, &value); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_NULL, "type_tablefunction_global3"); getglobal_eval(ptr, &geval); make_tablefunction_stack(NULL, &value, geval, pos); readstring_debug(&type, "(function * integer)"); test_parse_type(&type, type); settype_tablefunction(value, type); type_tablefunction(ptr, local, stack, pos, &value); test(singlep(value), "type_tablefunction_global4"); GetCar(value, &value); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_INTEGER, "type_tablefunction_global5"); readstring_debug(&value, "((ftype (function * string) " " type-tablefunction-global-temp-symbol))"); parse_declaim_heap(Execute_Thread, Nil, value, &value); apply_declaim_stack(ptr, value); type_tablefunction(ptr, local, stack, pos, &value); test(singlep(value), "type_tablefunction_global6"); GetCar(value, &value); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_STRING, "type_tablefunction_global7"); make_tablefunction_stack(local, &value, stack, pos); readstring_debug(&type, "(function * null)"); test_parse_type(&type, type); settype_tablefunction(value, type); type_tablefunction(ptr, local, stack, pos, &type); test(length_list_unsafe(type) == 1, "type_tablefunction_global8"); GetCons(type, &value, &type); GetArrayType(value, 1, &value); test(RefLispDecl(value) == LISPDECL_NULL, "type_tablefunction_global9"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_make_tablefunction_stack(void) { int result; addr control, stack, value, call, check; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); make_tablefunction_stack(local, &value, stack, call); test(eval_tablefunction_p(value), "make_tablefunction_stack1"); result = find_tablefunction(stack, call, &check); test(result, "make_tablefunction_stack2"); test(check == value, "make_tablefunction_stack3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_push_tablefunction_alloc(void) { addr control, stack, call, value, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); push_tablefunction_alloc(ptr, local, stack, call, &value); test(getglobalp_tablefunction(value), "push_tablefunction_alloc1"); push_tablefunction_alloc(ptr, local, stack, call, &value); test(! getglobalp_tablefunction(value), "push_tablefunction_alloc2"); readstring_debug(&call, "bb"); parse_callname_local(local, &call, call); readstring_debug(&pos, "((dynamic-extent #'bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &pos); apply_declare_stack(local, stack, pos); push_tablefunction_alloc(ptr, local, stack, call, &value); test(getdynamic_tablefunction(value), "push_tablefunction_alloc3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_callname_global_tablefunction(void) { addr control, call, pos1, pos2; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); callname_global_tablefunction(ptr, &pos1, call); test(getglobalp_tablefunction(pos1), "callname_global_tablefunction1"); callname_global_tablefunction(ptr, &pos2, call); test(pos1 == pos2, "callname_global_tablefunction2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_push_closure_function(void) { int result; addr control, stack, call, value, check, table, key; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); readstring_debug(&value, "bb"); push_closure_function(stack, call, value); GetConstant(CONSTANT_SYSTEM_CLOSURE_FUNCTION, &key); GetEvalStackTable(stack, &table); result = getpplist_callname(table, key, call, &check); test(result == 0, "push_closure_function1"); test(check == value, "push_closure_function2"); readstring_debug(&check, "cc"); parse_callname_local(local, &call, call); push_closure_function(stack, call, check); GetEvalStackTable(stack, &table); result = getpplist_callname(table, key, call, &check); test(result == 0, "push_closure_function3"); test(check == value, "push_closure_function4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_callname_tablefunction(void) { int check; addr control, stack, call, pos, key, table, value, front; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); check = callname_tablefunction(ptr, Nil, call, &pos); test(check, "callname_tablefunction1"); test(eval_tablefunction_p(pos), "callname_tablefunction2"); check = callname_tablefunction(ptr, stack, call, &pos); test(check, "callname_tablefunction3"); make_tablefunction_stack(local, &value, stack, call); check = callname_tablefunction(ptr, stack, call, &pos); test(! check, "callname_tablefunction4"); stack = newstack_nil(ptr); check = callname_tablefunction(ptr, stack, call, &pos); test(! check, "callname_tablefunction5"); stack = newstack_lambda(ptr); newstack_nil(ptr); newstack_nil(ptr); newstack_nil(ptr); front = newstack_nil(ptr); check = callname_tablefunction(ptr, front, call, &pos); test(! check, "callname_tablefunction6"); GetConstant(CONSTANT_SYSTEM_CLOSURE_FUNCTION, &key); GetEvalStackTable(stack, &table); check = getpplist_callname(table, key, call, &pos); test(check == 0, "callname_tablefunction7"); readstring_debug(&call, "ee"); parse_callname_local(local, &call, call); check = callname_tablefunction(ptr, front, call, &pos); test(check, "callname_tablefunction8"); GetConstant(CONSTANT_SYSTEM_CLOSURE_FUNCTION, &key); GetEvalStackTable(stack, &table); check = getpplist_callname(table, key, call, &pos); test(check, "callname_tablefunction9"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_function(void) { addr control, pos, check, call; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); parse_eval_string(&pos, "(function hello)"); scope_function(ptr, &pos, pos); test(RefEvalScopeType(pos) == EVAL_PARSE_FUNCTION, "scope_function1"); GetEvalScopeValue(pos, &check); test(eval_tablefunction_p(check), "scope_function2"); test(getreference_tablefunction(check), "scope_function3"); getname_tablefunction(check, &check); readstring_debug(&call, "hello"); parse_callname_heap(&call, call); test(equal_callname(check, call), "scope_function4"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_FUNCTION, "scope_function5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * lambda */ static int test_lambda_init_var(void) { addr control, stack, args, decl, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); eval_declare_local(local, &decl); parse_eval_string(&args, "(lambda (aa bb))"); GetEvalParse(args, 0, &args); /* args */ getnth_abort(args, 0, &args); /* var */ lambda_init_var(ptr, stack, args, decl); readstring_debug(&pos, "aa"); test(find_tablevalue(stack, pos, &pos), "lambda_init_var1"); readstring_debug(&pos, "bb"); test(find_tablevalue(stack, pos, &pos), "lambda_init_var2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_init_opt(void) { addr control, stack, args, decl, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); eval_declare_local(local, &decl); parse_eval_string(&args, "(lambda (&optional (aa 10 bb) cc))"); GetEvalParse(args, 0, &args); /* args */ getnth_abort(args, 1, &args); /* optional */ lambda_init_opt(ptr, stack, args, decl, &args); test(length_list_unsafe(args) == 2, "lambda_init_opt1"); readstring_debug(&pos, "aa"); test(find_tablevalue(stack, pos, &pos), "lambda_init_opt2"); readstring_debug(&pos, "bb"); test(find_tablevalue(stack, pos, &pos), "lambda_init_opt3"); readstring_debug(&pos, "cc"); test(find_tablevalue(stack, pos, &pos), "lambda_init_opt4"); GetCons(args, &pos, &args); getnth_abort(pos, 1, &pos); test(eval_scope_p(pos), "lambda_init_opt5"); GetCons(args, &pos, &args); getnth_abort(pos, 2, &pos); test(pos == Nil, "lambda_init_opt6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_init_key(void) { addr control, stack, args, decl, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); eval_declare_local(local, &decl); parse_eval_string(&args, "(lambda (&key ((name aa) 10 bb) cc))"); GetEvalParse(args, 0, &args); /* args */ getnth_abort(args, 3, &args); /* key */ lambda_init_key(ptr, stack, args, decl, &args); test(length_list_unsafe(args) == 2, "lambda_init_key1"); readstring_debug(&pos, "aa"); test(find_tablevalue(stack, pos, &pos), "lambda_init_key2"); readstring_debug(&pos, "bb"); test(find_tablevalue(stack, pos, &pos), "lambda_init_key3"); readstring_debug(&pos, "cc"); test(find_tablevalue(stack, pos, &pos), "lambda_init_key4"); GetCons(args, &pos, &args); getnth_abort(pos, 1, &pos); test(symbolp(pos), "lambda_init_key5"); GetCons(args, &pos, &args); getnth_abort(pos, 3, &pos); test(pos == Nil, "lambda_init_key6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_init_aux(void) { addr control, stack, args, decl, pos; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); eval_declare_local(local, &decl); parse_eval_string(&args, "(lambda (&aux (aa 10) cc))"); GetEvalParse(args, 0, &args); /* args */ getnth_abort(args, 5, &args); /* aux */ lambda_init_aux(ptr, stack, args, decl, &args); test(length_list_unsafe(args) == 2, "lambda_init_aux1"); readstring_debug(&pos, "aa"); test(find_tablevalue(stack, pos, &pos), "lambda_init_aux2"); readstring_debug(&pos, "bb"); test(! find_tablevalue(stack, pos, &pos), "lambda_init_aux3"); readstring_debug(&pos, "cc"); test(find_tablevalue(stack, pos, &pos), "lambda_init_aux4"); GetCar(args, &args); getnth_abort(args, 0, &pos); test(symbolp(pos), "lambda_init_aux5"); getnth_abort(args, 1, &pos); test(eval_scope_p(pos), "lambda_init_aux6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_init(void) { addr control, pos; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); eval_declare_local(local, &str.decl); parse_eval_string(&pos, "(lambda (aa &optional bb &rest cc &key dd &allow-other-keys &aux ee))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); readstring_debug(&pos, "aa"); test(find_tablevalue(str.stack, pos, &pos), "lambda_init1"); readstring_debug(&pos, "bb"); test(find_tablevalue(str.stack, pos, &pos), "lambda_init2"); readstring_debug(&pos, "cc"); test(find_tablevalue(str.stack, pos, &pos), "lambda_init3"); readstring_debug(&pos, "dd"); test(find_tablevalue(str.stack, pos, &pos), "lambda_init4"); readstring_debug(&pos, "ee"); test(find_tablevalue(str.stack, pos, &pos), "lambda_init5"); getnth_abort(str.args, 1, &pos); /* optional */ getnth_abort(pos, 0, &pos); getnth_abort(pos, 1, &pos); /* init */ test(eval_scope_p(pos), "lambda_init6"); parse_eval_string(&pos, "(lambda ())"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); test(1, "lambda_init6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_tablevalue_var(void) { addr control, pos, args; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); eval_declare_local(local, &str.decl); parse_eval_string(&pos, "(lambda (aa bb))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); getnth_abort(str.args, 0, &args); /* var */ lambda_tablevalue_var(local, str.stack, args, &args); test(length_list_unsafe(args) == 2, "lambda_tablevalue_var1"); GetCons(args, &pos, &args); test(eval_tablevalue_p(pos), "lambda_tablevalue_var2"); GetCons(args, &pos, &args); test(eval_tablevalue_p(pos), "lambda_tablevalue_var3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_tablevalue_opt(void) { addr control, pos, args, check; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); eval_declare_local(local, &str.decl); parse_eval_string(&pos, "(lambda (&optional aa (bb 100 cc)))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); getnth_abort(str.args, 1, &args); /* optional */ lambda_tablevalue_opt(local, str.stack, args, &args); test(length_list_unsafe(args) == 2, "lambda_tablevalue_opt1"); GetCons(args, &pos, &args); test(length_list_unsafe(pos) == 3, "lambda_tablevalue_opt2"); getnth_abort(pos, 0, &check); test(eval_tablevalue_p(check), "lambda_tablevalue_opt3"); getnth_abort(pos, 2, &check); test(check == Nil, "lambda_tablevalue_opt4"); GetCons(args, &pos, &args); getnth_abort(pos, 0, &check); test(eval_tablevalue_p(check), "lambda_tablevalue_opt5"); getnth_abort(pos, 2, &check); test(eval_tablevalue_p(check), "lambda_tablevalue_opt6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_tablevalue_key(void) { addr control, pos, args, check; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); eval_declare_local(local, &str.decl); parse_eval_string(&pos, "(lambda (&key aa (bb 100 cc)))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); getnth_abort(str.args, 3, &args); /* key */ lambda_tablevalue_key(local, str.stack, args, &args); test(length_list_unsafe(args) == 2, "lambda_tablevalue_key1"); GetCons(args, &pos, &args); test(length_list_unsafe(pos) == 4, "lambda_tablevalue_key2"); getnth_abort(pos, 0, &check); test(eval_tablevalue_p(check), "lambda_tablevalue_key3"); getnth_abort(pos, 3, &check); test(check == Nil, "lambda_tablevalue_key4"); GetCons(args, &pos, &args); getnth_abort(pos, 0, &check); test(eval_tablevalue_p(check), "lambda_tablevalue_key5"); getnth_abort(pos, 3, &check); test(eval_tablevalue_p(check), "lambda_tablevalue_key6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_tablevalue_aux(void) { addr control, pos, args, check; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); eval_declare_local(local, &str.decl); parse_eval_string(&pos, "(lambda (&aux aa (bb 100)))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); getnth_abort(str.args, 5, &args); /* aux */ lambda_tablevalue_aux(local, str.stack, args, &args); test(length_list_unsafe(args) == 2, "lambda_tablevalue_aux1"); GetCons(args, &pos, &args); test(length_list_unsafe(pos) == 2, "lambda_tablevalue_aux2"); getnth_abort(pos, 0, &check); test(eval_tablevalue_p(check), "lambda_tablevalue_aux3"); GetCons(args, &pos, &args); getnth_abort(pos, 0, &check); test(eval_tablevalue_p(check), "lambda_tablevalue_aux4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_tablevalue(void) { addr control, pos; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); eval_declare_local(local, &str.decl); parse_eval_string(&pos, "(lambda (aa &optional bb &rest cc &key dd &allow-other-keys &aux ee))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); lambda_tablevalue(local, &str); getnth_abort(str.args, 2, &pos); /* aux */ test(eval_tablevalue_p(pos), "lambda_tablevalue1"); getnth_abort(str.args, 4, &pos); /* allow-other-keys */ test(pos == T, "lambda_tablevalue2"); parse_eval_string(&pos, "(lambda ())"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); lambda_tablevalue(local, &str); test(1, "lambda_tablevalue3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_ordinary_var(void) { int invalid; addr control, pos, args, check; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "((type integer aa) (type string bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &str.decl); parse_eval_string(&pos, "(lambda (aa bb))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); getnth_abort(str.args, 0, &args); /* var */ type_ordinary_var(local, args, &args); test(length_list_unsafe(args) == 2, "type_ordinary_var1"); GetCons(args, &pos, &args); readstring_debug(&check, "integer"); test_parse_type(&check, check); test(subtypep_clang(pos, check, &invalid), "type_ordinary_var2"); test(subtypep_clang(check, pos, &invalid), "type_ordinary_var3"); GetCons(args, &pos, &args); readstring_debug(&check, "string"); test_parse_type(&check, check); test(subtypep_clang(pos, check, &invalid), "type_ordinary_var4"); test(subtypep_clang(check, pos, &invalid), "type_ordinary_var5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_ordinary_opt(void) { int invalid; addr control, pos, args, check; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "((type integer aa) (type string bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &str.decl); parse_eval_string(&pos, "(lambda (&optional (aa 10) (bb \"Hello\")) :hello)"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); getnth_abort(str.args, 1, &args); /* optional */ type_ordinary_opt(local, args, &args); test(length_list_unsafe(args) == 2, "type_ordinary_opt1"); GetCons(args, &pos, &args); readstring_debug(&check, "integer"); test_parse_type(&check, check); test(subtypep_clang(pos, check, &invalid), "type_ordinary_opt2"); test(subtypep_clang(check, pos, &invalid), "type_ordinary_opt3"); GetCons(args, &pos, &args); readstring_debug(&check, "string"); test_parse_type(&check, check); test(subtypep_clang(pos, check, &invalid), "type_ordinary_opt4"); test(subtypep_clang(check, pos, &invalid), "type_ordinary_opt5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_type_ordinary_rest(void) { addr pos; pos = Nil; type_ordinary_rest(NULL, pos, &pos); test(pos == Nil, "type_ordinary_rest1"); pos = T; type_ordinary_rest(NULL, pos, &pos); test(RefLispDecl(pos) == LISPDECL_T, "type_ordinary_rest2"); RETURN; } static int test_type_ordinary_key(void) { int invalid; addr control, pos, args, check, key, value; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "((type integer aa) (type string bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &str.decl); parse_eval_string(&pos, "(lambda (&key ((hello aa) 10) (bb \"Hello\")))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); getnth_abort(str.args, 3, &args); /* optional */ type_ordinary_key(local, args, Nil, &args); test(length_list_unsafe(args) == 2, "type_ordinary_key1"); GetCons(args, &pos, &args); GetCons(pos, &key, &value); readstring_debug(&check, "hello"); test(key == check, "type_ordinary_key2"); readstring_debug(&check, "integer"); test_parse_type(&check, check); test(subtypep_clang(value, check, &invalid), "type_ordinary_key3"); test(subtypep_clang(check, value, &invalid), "type_ordinary_key4"); GetCons(args, &pos, &args); GetCons(pos, &key, &value); readstring_debug(&check, ":bb"); test(key == check, "type_ordinary_key5"); readstring_debug(&check, "string"); test_parse_type(&check, check); test(subtypep_clang(value, check, &invalid), "type_ordinary_key6"); test(subtypep_clang(check, value, &invalid), "type_ordinary_key7"); type_ordinary_key(local, Nil, T, &check); test(check == T, "type_ordinary_key8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_make_type_ordinary(void) { addr control, pos; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "((type integer aa) (type string bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &str.decl); parse_eval_string(&pos, "(lambda ())"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); make_type_ordinary(local, str.args, &pos); test(lenarrayr(pos) == 4, "make_type_ordinary1"); test(refarray(pos, 0) == Nil, "make_type_ordinary2"); test(refarray(pos, 1) == Nil, "make_type_ordinary3"); test(refarray(pos, 2) == Nil, "make_type_ordinary4"); test(refarray(pos, 3) == Nil, "make_type_ordinary5"); newstack_nil(ptr); parse_eval_string(&pos, "(lambda (aa bb &optional cc (dd 10) &rest ee " " &key ff &allow-other-keys &aux gg))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); make_type_ordinary(local, str.args, &pos); test(refarray(pos, 0) != Nil, "make_type_ordinary6"); test(refarray(pos, 1) != Nil, "make_type_ordinary7"); test(refarray(pos, 2) != Nil, "make_type_ordinary8"); test(refarray(pos, 3) != Nil, "make_type_ordinary9"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_type_incomplete(void) { addr control, pos, check; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "((type integer aa) (type string bb))"); parse_declare_heap(Execute_Thread, Nil, pos, &str.decl); parse_eval_string(&pos, "(lambda ())"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_type_incomplete(local, str.args, &pos); test(RefLispDecl(pos) == LISPDECL_FUNCTION, "lambda_type_incomplete1"); GetArrayType(pos, 0, &check); test(lenarrayr(check) == 4, "lambda_type_incomplete2"); GetArrayType(pos, 1, &check); test(type_asterisk_p(check), "lambda_type_incomplete3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_declare(void) { addr control, pos, check; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.call = Nil; str.table = Nil; str.the = Nil; str.stack = newstack_nil(ptr); eval_declare_alloc(local, &str.decl); parse_eval_string(&pos, "(lambda (aa))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_declare(local, &str); test(str.table == Nil, "lambda_declare1"); test(RefLispDecl(str.the) == LISPDECL_FUNCTION, "lambda_declare2"); readstring_debug(&pos, "hello"); parse_callname_local(local, &str.call, pos); str.table = Nil; str.the = Nil; str.globalp = 1; str.stack = newstack_nil(ptr); eval_declare_alloc(local, &str.decl); parse_eval_string(&pos, "(lambda (aa))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_declare(local, &str); test(str.table != Nil, "lambda_declare3"); test(! getglobalp_tablefunction(str.table), "lambda_declare4"); gettype_tablefunction(str.table, &pos); test(RefLispDecl(pos) == LISPDECL_FUNCTION, "lambda_declare5"); test(RefLispDecl(str.the) == LISPDECL_FUNCTION, "lambda_declare6"); GetArrayType(pos, 0, &check); test(! type_asterisk_p(check), "lambda_declare7"); GetArrayType(pos, 1, &check); test(type_asterisk_p(check), "lambda_declare8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_progn(void) { addr control, pos, check; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "hello"); parse_callname_local(local, &str.call, pos); str.table = Nil; str.the = Nil; str.globalp = 1; str.stack = newstack_nil(ptr); parse_eval_string(&pos, "(lambda (aa) 100)"); GetEvalParse(pos, 0, &str.args); /* args */ GetEvalParse(pos, 1, &str.decl); /* decl */ GetEvalParse(pos, 3, &str.cons); /* cons */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_declare(local, &str); lambda_progn(ptr, &str); pos = str.the; test(RefLispDecl(pos) == LISPDECL_FUNCTION, "lambda_progn1"); GetArrayType(pos, 0, &check); test(! type_asterisk_p(check), "lambda_progn2"); GetArrayType(pos, 1, &check); test(! type_asterisk_p(check), "lambda_progn3"); gettype_tablefunction(str.table, &pos); GetArrayType(pos, 1, &check); test(! type_asterisk_p(check), "lambda_progn4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_update_var(void) { addr control, pos; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.call = Nil; str.table = Nil; str.stack = newstack_nil(ptr); eval_declare_alloc(local, &str.decl); parse_eval_string(&pos, "(lambda (aa bb))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_declare(local, &str); getnth_abort(str.args, 0, &pos); /* var */ lambda_update_var(&pos, pos); test(! GetStatusDynamic(pos), "lambda_update_var1"); test(length_list_unsafe(pos) == 2, "lambda_update_var2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_update_opt(void) { addr control, pos; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.call = Nil; str.table = Nil; str.stack = newstack_nil(ptr); eval_declare_alloc(local, &str.decl); parse_eval_string(&pos, "(lambda (&optional aa (bb 10 cc)))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_declare(local, &str); getnth_abort(str.args, 1, &pos); /* optional */ lambda_update_opt(&pos, pos); test(! GetStatusDynamic(pos), "lambda_update_opt1"); test(length_list_unsafe(pos) == 2, "lambda_update_opt2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_update_key(void) { addr control, pos; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.call = Nil; str.table = Nil; str.stack = newstack_nil(ptr); eval_declare_alloc(local, &str.decl); parse_eval_string(&pos, "(lambda (&key aa ((hello bb) 10 cc)))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_declare(local, &str); getnth_abort(str.args, 3, &pos); /* key */ lambda_update_key(&pos, pos); test(! GetStatusDynamic(pos), "lambda_update_key1"); test(length_list_unsafe(pos) == 2, "lambda_update_key2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_update_aux(void) { addr control, pos; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.call = Nil; str.table = Nil; str.stack = newstack_nil(ptr); eval_declare_alloc(local, &str.decl); parse_eval_string(&pos, "(lambda (&aux aa (bb 10)))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_declare(local, &str); getnth_abort(str.args, 5, &pos); /* aux */ lambda_update_aux(&pos, pos); test(! GetStatusDynamic(pos), "lambda_update_aux1"); test(length_list_unsafe(pos) == 2, "lambda_update_aux2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_update(void) { addr control, pos; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "hello"); parse_callname_local(local, &str.call, pos); str.table = Nil; str.globalp = 1; str.stack = newstack_nil(ptr); eval_declare_alloc(local, &str.decl); parse_eval_string(&pos, "(lambda ())"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_declare(local, &str); lambda_update(&str); test(str.table != Nil, "lambda_update1"); test(! GetStatusDynamic(str.table), "lambda_update2"); str.call = Nil; str.table = Nil; str.globalp = 1; str.stack = newstack_nil(ptr); eval_declare_alloc(local, &str.decl); parse_eval_string(&pos, "(lambda (aa bb cc &optional dd " "&rest ee &key ff &allow-other-keys &aux gg hh))"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_declare(local, &str); lambda_update(&str); test(str.table == Nil, "lambda_update3"); test(! GetStatusDynamic(str.args), "lambda_update4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_closure(void) { addr control, pos, stack, table, current, check; Execute ptr; LocalRoot local; struct lambda_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "aa"); push_tablevalue_local(ptr, stack, pos, &table); str.call = Nil; str.table = Nil; str.globalp = 1; str.clos = Nil; str.stack = newstack_lambda(ptr); eval_declare_alloc(local, &str.decl); parse_eval_string(&pos, "(lambda ())"); GetEvalParse(pos, 0, &str.args); /* args */ lambda_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); lambda_tablevalue(local, &str); lambda_declare(local, &str); lambda_update(&str); current = newstack_nil(ptr); readstring_debug(&pos, "aa"); test(! find_symbol_scope(ptr, pos, &pos), "lambda_closure1"); freestack_eval(ptr, current); lambda_closure(ptr, &str); test(str.clos != Nil, "lambda_closure2"); GetArrayA2(str.clos, 0, &pos); GetCons(pos, &check, &pos); test(eval_tablevalue_p(check), "lambda_closure3"); test(pos == Nil, "lambda_closure4"); getname_tablevalue(check, &check); readstring_debug(&pos, "aa"); test(check == pos, "lambda_closure5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_lambda_execute(void) { addr control, pos; Execute ptr; struct lambda_struct str; init_lambda_struct(&str, EVAL_PARSE_LAMBDA, 0); ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_lambda(ptr); parse_eval_string(&pos, "(lambda (aa bb) (declare (integer aa)) aa bb :hello)"); GetEvalParse(pos, 0, &str.args); /* args */ GetEvalParse(pos, 1, &str.decl); /* decl */ GetEvalParse(pos, 3, &str.cons); /* cons */ lambda_execute(ptr, &str, &pos); test(eval_scope_p(pos), "lambda_execute1"); str.stack = newstack_lambda(ptr); parse_eval_string(&pos, "(lambda (aa bb) (declare (integer aa)) aa bb :hello)"); GetEvalParse(pos, 0, &str.args); /* args */ GetEvalParse(pos, 1, &str.decl); /* decl */ GetEvalParse(pos, 3, &str.cons); /* cons */ lambda_object(ptr, &str, &pos); test(eval_scope_p(pos), "lambda_object1"); parse_eval_string(&pos, "(lambda (aa bb) (declare (integer aa)) aa bb :hello)"); scope_lambda(ptr, &pos, pos); test(eval_scope_p(pos), "scope_lambda1"); test(RefEvalScopeType(pos) == EVAL_PARSE_LAMBDA, "scope_lambda2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * defun */ static int test_defun_update(void) { addr control, stack, call, pos, check; Execute ptr; LocalRoot local; struct lambda_struct str; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_lambda(ptr); parse_eval_string(&pos, "(defun name (aa bb) (declare (integer aa)) aa bb 10)"); init_lambda_struct(&str, EVAL_PARSE_DEFUN, 1); GetEvalParse(pos, 0, &str.call); GetEvalParse(pos, 1, &str.args); GetEvalParse(pos, 2, &str.decl); GetEvalParse(pos, 3, &str.doc); GetEvalParse(pos, 4, &str.cons); lambda_object(ptr, &str, &pos); defun_update(ptr, &str); getglobal_eval(ptr, &stack); readstring_debug(&call, "name"); parse_callname_local(local, &call, call); test(find_tablefunction(stack, call, &pos), "defun_update1"); getname_tablefunction(pos, &check); test(equal_callname(call, check), "defun_update2"); gettype_tablefunction(pos, &check); test(RefLispDecl(check) == LISPDECL_FUNCTION, "defun_update3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_defun_the(void) { addr pos, eval, type, car, cdr, check; struct lambda_struct str; begin_eval_stack(Execute_Thread); init_lambda_struct(&str, EVAL_PARSE_DEFUN, 1); readstring_debug(&pos, "hello"); parse_callname_heap(&pos, pos); str.call = pos; eval_scope_size(Execute_Thread, &eval, EvalLambda_Size, EVAL_PARSE_EMPTY, Nil, Nil); defun_the(eval, &str); GetEvalScopeThe(eval, &type); test(RefLispDecl(type) == LISPDECL_SYMBOL, "defun_the1"); init_lambda_struct(&str, EVAL_PARSE_DEFUN, 1); readstring_debug(&pos, "(setf hello)"); parse_callname_heap(&pos, pos); str.call = pos; eval_scope_size(Execute_Thread, &eval, EvalLambda_Size, EVAL_PARSE_EMPTY, Nil, Nil); defun_the(eval, &str); GetEvalScopeThe(eval, &type); /* (cons (eql setf) (cons (eql hello) null)) */ test(RefLispDecl(type) == LISPDECL_CONS, "defun_the2"); GetArrayType(type, 0, &car); GetArrayType(type, 1, &cdr); test(RefLispDecl(car) == LISPDECL_EQL, "defun_the3"); GetArrayType(car, 0, &car); GetConstant(CONSTANT_COMMON_SETF, &check); test(car == check, "defun_the4"); test(RefLispDecl(cdr) == LISPDECL_CONS, "defun_the5"); GetArrayType(cdr, 0, &car); GetArrayType(cdr, 1, &cdr); test(RefLispDecl(car) == LISPDECL_EQL, "defun_the6"); GetArrayType(car, 0, &car); readstring_debug(&check, "hello"); test(car == check, "defun_the7"); test(RefLispDecl(cdr) == LISPDECL_NULL, "defun_the8"); RETURN; } static int test_scope_defun(void) { addr control, pos; Execute ptr; struct lambda_struct str; init_lambda_struct(&str, EVAL_PARSE_LAMBDA, 0); ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); parse_eval_string(&pos, "(defun name (aa) (declare (integer aa)) aa :hello)"); scope_defun(ptr, &pos, pos); test(eval_scope_p(pos), "scope_defun1"); test(RefEvalScopeType(pos) == EVAL_PARSE_DEFUN, "scope_defun2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * macro-lambda */ static int test_macro_init_var(void) { addr args, control, stack, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&args, "(aa bb)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); test(length_list_unsafe(args) == 8, "macro_init_var1"); GetCar(args, &args); test(length_list_unsafe(args) == 2, "macro_init_var2"); GetCons(args, &pos, &args); test(pos == readr_debug("aa"), "macro_init_var3"); GetCons(args, &pos, &args); test(pos == readr_debug("bb"), "macro_init_var4"); readstring_debug(&args, "(aa (bb cc) dd)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); test(length_list_unsafe(args) == 8, "macro_init_var5"); GetCar(args, &args); test(length_list_unsafe(args) == 3, "macro_init_var6"); GetCons(args, &pos, &args); test(pos == readr_debug("aa"), "macro_init_var7"); GetCons(args, &pos, &args); GetCar(pos, &pos); test(length_list_unsafe(pos) == 2, "macro_init_var8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_macro_init_rest(void) { addr args, control, stack, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&args, "(&rest aa)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); lista_bind_(args, &pos, &pos, &pos, &args, NULL); test(consp(pos), "macro_init_rest1"); GetCar(pos, &pos); test(pos == readr_debug("aa"), "macro_init_rest2"); readstring_debug(&args, "(&body bb)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); lista_bind_(args, &pos, &pos, &pos, &args, NULL); test(consp(pos), "macro_init_rest3"); GetCar(pos, &pos); test(pos == readr_debug("bb"), "macro_init_rest4"); readstring_debug(&args, "(cc . dd)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); lista_bind_(args, &pos, &pos, &pos, &args, NULL); test(consp(pos), "macro_init_rest5"); GetCar(pos, &pos); test(pos == readr_debug("dd"), "macro_init_rest6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_macro_init_args(void) { addr args, control, stack; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&args, "(&whole whole &environment env aa (&rest bb))"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); test(length_list_unsafe(args) == 8, "macro_init_args1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_macro_tablevalue_var(void) { addr args, control, stack, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&args, "(aa bb)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); macro_tablevalue_args(ptr, stack, args, &args); test(length_list_unsafe(args) == 8, "macro_tablevalue_var1"); GetCar(args, &args); test(length_list_unsafe(args) == 2, "macro_tablevalue_var2"); GetCons(args, &pos, &args); test(eval_tablevalue_p(pos), "macro_tablevalue_var3"); getname_tablevalue(pos, &pos); test(pos == readr_debug("aa"), "macro_tablevalue_var4"); GetCons(args, &pos, &args); test(eval_tablevalue_p(pos), "macro_tablevalue_var5"); getname_tablevalue(pos, &pos); test(pos == readr_debug("bb"), "macro_tablevalue_var6"); readstring_debug(&args, "(aa (bb cc) dd)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); macro_tablevalue_args(ptr, stack, args, &args); test(length_list_unsafe(args) == 8, "macro_tablevalue_var7"); GetCar(args, &args); test(length_list_unsafe(args) == 3, "macro_tablevalue_var8"); GetCons(args, &pos, &args); test(eval_tablevalue_p(pos), "macro_tablevalue_var9"); getname_tablevalue(pos, &pos); test(pos == readr_debug("aa"), "macro_tablevalue_var10"); GetCons(args, &pos, &args); GetCar(pos, &pos); test(length_list_unsafe(pos) == 2, "macro_tablevalue_var11"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_macro_tablevalue_rest(void) { addr args, control, stack, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&args, "(&rest aa)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); macro_tablevalue_args(ptr, stack, args, &args); lista_bind_(args, &pos, &pos, &pos, &args, NULL); test(consp(pos), "macro_tablevalue_rest1"); GetCar(pos, &pos); test(eval_tablevalue_p(pos), "macro_tablevalue_rest2"); getname_tablevalue(pos, &pos); test(pos == readr_debug("aa"), "macro_tablevalue_rest3"); readstring_debug(&args, "(&body bb)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); macro_tablevalue_args(ptr, stack, args, &args); lista_bind_(args, &pos, &pos, &pos, &args, NULL); test(consp(pos), "macro_tablevalue_rest4"); GetCar(pos, &pos); test(eval_tablevalue_p(pos), "macro_tablevalue_rest5"); getname_tablevalue(pos, &pos); test(pos == readr_debug("bb"), "macro_tablevalue_rest6"); readstring_debug(&args, "(cc . dd)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); macro_tablevalue_args(ptr, stack, args, &args); lista_bind_(args, &pos, &pos, &pos, &args, NULL); test(consp(pos), "macro_tablevalue_rest7"); GetCar(pos, &pos); test(eval_tablevalue_p(pos), "macro_tablevalue_rest8"); getname_tablevalue(pos, &pos); test(pos == readr_debug("dd"), "macro_tablevalue_rest9"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_macro_tablevalue_args(void) { addr args, control, stack, pos, whole, env; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&args, "(&whole aa &environment bb cc (&rest dd))"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); macro_tablevalue_args(ptr, stack, args, &args); test(length_list_unsafe(args) == 8, "macro_tablevalue_args1"); list_bind(args, &pos, &pos, &pos, &pos, &pos, &pos, &whole, &env, NULL); test(eval_tablevalue_p(whole), "macro_tablevalue_args2"); getname_tablevalue(whole, &whole); test(whole == readr_debug("aa"), "macro_tablevalue_args3"); test(eval_tablevalue_p(env), "macro_tablevalue_args4"); getname_tablevalue(env, &env); test(env == readr_debug("bb"), "macro_tablevalue_args5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_macro_update_var(void) { addr args, control, stack, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&args, "(aa (bb cc) dd)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); macro_tablevalue_args(ptr, stack, args, &args); macro_update_args(&args, args); test(length_list_unsafe(args) == 8, "macro_update_var1"); GetCar(args, &args); test(length_list_unsafe(args) == 3, "macro_update_var2"); GetCons(args, &pos, &args); test(eval_tablevalue_p(pos), "macro_update_var3"); getname_tablevalue(pos, &pos); test(pos == readr_debug("aa"), "macro_update_var4"); GetCons(args, &pos, &args); GetCar(pos, &pos); test(length_list_unsafe(pos) == 2, "macro_update_var5"); test(! GetStatusDynamic(pos), "macro_update_var6"); GetCar(pos, &pos); test(eval_tablevalue_p(pos), "macro_update_var7"); test(! GetStatusDynamic(pos), "macro_update_var8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_macro_update_rest(void) { addr args, control, stack, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&args, "(&rest aa)"); stack = newstack_nil(ptr); lambda_macro(ptr->local, &args, args, Nil); parse_macro_lambda_list(ptr, &args, args); macro_init_args(ptr, stack, args, Nil, &args); macro_tablevalue_args(ptr, stack, args, &args); macro_update_args(&args, args); lista_bind_(args, &pos, &pos, &pos, &args, NULL); test(consp(pos), "macro_update_rest1"); test(! GetStatusDynamic(pos), "macro_update_rest2"); GetCar(pos, &pos); test(eval_tablevalue_p(pos), "macro_update_rest3"); test(! GetStatusDynamic(pos), "macro_update_rest4"); getname_tablevalue(pos, &pos); test(pos == readr_debug("aa"), "macro_update_rest5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_defmacro(void) { addr control, pos, name, lambda; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); parse_eval_string(&pos, "(defmacro aaa () :hello)"); GetEvalParse(pos, 0, &name); GetEvalParse(pos, 1, &lambda); test(symbolp(name), "scope_defmacro1"); test(name == readr_debug("aaa"), "scope_defmacro2"); test(macro_function_p(lambda), "scope_defmacro3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_push_symbol_macrolet(void) { addr control, stack, key, table, symbol, v1, v2, left, right; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); symbol = readr_debug("aaa"); fixnum_heap(&v1, 10); fixnum_heap(&v2, 20); push_symbol_macrolet(stack, symbol, v1, v2); GetConst(SYSTEM_SYMBOL_MACROLET, &key); GetEvalStackTable(stack, &table); test(getpplist(table, key, symbol, &right) == 0, "push_symbol_macrolet1"); test(consp(right), "push_symbol_macrolet2"); GetCons(right, &left, &right); test(left == v1, "push_symbol_macrolet3"); test(right == v2, "push_symbol_macrolet4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_define_symbol_macro(void) { addr control, pos, name, form; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); newstack_nil(ptr); parse_eval_string(&pos, "(define-symbol-macro aaa ''hello)"); GetEvalParse(pos, 0, &name); GetEvalParse(pos, 1, &form); test(symbolp(name), "scope_define_symbol_macro1"); test(name == readr_debug("aaa"), "scope_define_symbol_macro2"); test(eval_parse_p(form), "scope_define_symbol_macro3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_apply_symbol_macrolet(void) { addr control, stack, pos, key, table, left, right; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); parse_eval_string(&pos, "(symbol-macrolet " "((aaa ''hello1) (bbb ''hello2)) :hello)"); GetEvalParse(pos, 0, &pos); apply_symbol_macrolet(stack, pos); GetConst(SYSTEM_SYMBOL_MACROLET, &key); GetEvalStackTable(stack, &table); pos = readr_debug("aaa"); test(getpplist(table, key, pos, &right) == 0, "apply_symbol_macrolet1"); test(consp(right), "apply_symbol_macrolet2"); GetCons(right, &left, &right); test(eval_parse_p(left), "apply_symbol_macrolet3"); test(GetType(right) == LISPTYPE_ENVIRONMENT, "apply_symbol_macrolet4"); pos = readr_debug("bbb"); test(getpplist(table, key, pos, &right) == 0, "apply_symbol_macrolet5"); test(consp(right), "apply_symbol_macrolet6"); GetCons(right, &left, &right); test(eval_parse_p(left), "apply_symbol_macrolet7"); test(GetType(right) == LISPTYPE_ENVIRONMENT, "apply_symbol_macrolet8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_symbol_macrolet(void) { addr control, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); newstack_nil(ptr); parse_eval_string(&pos, "(symbol-macrolet " "((aaa ''hello1) (bbb ''hello2)) :hello)"); scope_symbol_macrolet(ptr, &pos, pos); test(RefEvalScopeType(pos) == EVAL_PARSE_LOCALLY, "scope_symbol_macrolet1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * flet */ static int test_flet_call(void) { addr control, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); parse_eval_string(&pos, "(flet ((aa () :hello)) :cons)"); GetEvalParse(pos, 0, &pos); /* args */ GetCar(pos, &pos); /* aa */ flet_call(ptr, &pos, pos); test(RefEvalScopeType(pos) == EVAL_PARSE_EMPTY, "flet_call1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_flet_init(void) { addr control, pos, args, eval, check; Execute ptr; LocalRoot local; struct let_struct str; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); memset(&str, 0, sizeoft(struct let_struct)); parse_eval_string(&pos, "(flet ((aa () :hello) (bb (c) c 10)) :cons)"); GetEvalParse(pos, 0, &str.args); flet_init(ptr, &str); args = str.args; test(length_list_unsafe(args) == 2, "flet_init1"); GetCons(args, &pos, &args); GetCons(pos, &pos, &eval); readstring_debug(&check, "aa"); parse_callname_local(local, &check, check); test(equal_callname(pos, check), "flet_init2"); test(eval_scope_p(eval), "flet_init3"); GetCons(args, &pos, &args); GetCons(pos, &pos, &eval); readstring_debug(&check, "bb"); parse_callname_local(local, &check, check); test(equal_callname(pos, check), "flet_init4"); test(eval_scope_p(eval), "flet_init5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_flet_maketable(void) { addr control, pos; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(flet ((a () 10) (b () (progn 20)) (c ())) :hello)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &pos); /* let-args */ str.args = pos; flet_init(ptr, &str); flet_maketable(local, &str); readstring_debug(&pos, "a"); parse_callname_local(local, &pos, pos); test(find_tablefunction(str.stack, pos, &pos), "flet_maketable1"); test(eval_tablefunction_p(pos), "flet_maketable2"); gettype_tablefunction(pos, &pos); test(type_function_aster_p(pos), "flet_maketable3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_checktype_function(void) { addr control, stack, call, table, type, init; Execute ptr; LocalRoot local; ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&call, "aa"); parse_callname_local(local, &call, call); push_tablefunction_alloc(ptr, local, stack, call, &table); readstring_debug(&type, "(function * *)"); test_parse_type(&type, type); settype_tablefunction(table, type); readstring_debug(&type, "(function * *)"); test_parse_type(&type, type); make_eval_scope(Execute_Thread, &init, EVAL_PARSE_EMPTY, type, Nil); checktype_function(table, init); test(1, "checktype_function1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_flet_applytable(void) { addr control, pos, table, type; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(flet ((aa () 10) (bb () 20)) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); /* let-args */ GetEvalParse(pos, 1, &str.decl); /* let-decl */ flet_init(ptr, &str); flet_maketable(local, &str); apply_declare(ptr, str.stack, str.decl, &str.free); flet_applytable(ptr, &str); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); test(find_tablefunction(str.stack, pos, &table), "flet_applytable1"); test(! getglobalp_tablefunction(table), "flet_applytable2"); readstring_debug(&pos, "bb"); parse_callname_local(local, &pos, pos); test(find_tablefunction(str.stack, pos, &table), "flet_applytable3"); test(! getglobalp_tablefunction(table), "flet_applytable4"); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); test(find_tablefunction(str.stack, pos, &table), "flet_applytable5"); readstring_debug(&type, "(function * *)"); test_parse_type(&type, type); settype_tablefunction(table, type); flet_applytable(ptr, &str); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); test(find_tablefunction(str.stack, pos, &table), "flet_applytable7"); test(! getglobalp_tablefunction(table), "flet_applytable8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_ignore_checkfunction(void) { addr control, pos, table; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(flet ((aa () 10) (bb () 20)) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); /* let-args */ GetEvalParse(pos, 1, &str.decl); /* let-decl */ flet_init(ptr, &str); flet_maketable(local, &str); apply_declare(ptr, str.stack, str.decl, &str.free); flet_applytable(ptr, &str); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); find_tablefunction(str.stack, pos, &table); setreference_tablefunction(table, 1); readstring_debug(&pos, "bb"); parse_callname_local(local, &pos, pos); find_tablefunction(str.stack, pos, &table); setreference_tablefunction(table, 1); ignore_checkfunction(str.stack); test(1, "ignore_checkfunction1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_flet_update(void) { int check; addr control, pos, cons; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(flet ((aa () 10) (bb () 20)) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); /* let-args */ GetEvalParse(pos, 1, &str.decl); /* let-decl */ flet_init(ptr, &str); flet_maketable(local, &str); apply_declare(ptr, str.stack, str.decl, &str.free); flet_applytable(ptr, &str); flet_update(&str); check = 1; for (cons = str.args; cons != Nil; ) { GetCons(cons, &pos, &cons); GetCar(pos, &pos); if (GetStatusDynamic(pos)) { check = 0; break; } } test(check, "flet_update1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_flet(void) { addr control, pos; Execute ptr; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(flet ((aa () 10) (bb () 20)) (aa) (bb) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); GetEvalParse(pos, 1, &str.decl); GetEvalParse(pos, 2, &str.cons); flet_execute(ptr, &str); test(RefLispDecl(str.the) == LISPDECL_KEYWORD, "flet_execute1"); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(flet ((aa () 10) (bb () 20)) (aa) (bb) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); GetEvalParse(pos, 1, &str.decl); GetEvalParse(pos, 2, &str.cons); flet_object(ptr, &str); test(RefLispDecl(str.the) == LISPDECL_KEYWORD, "flet_object1"); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(flet ((aa () 10) (bb () 20)) (aa) (bb) :aa)"); eval_parse_execute(&pos, pos); scope_flet(ptr, &pos, pos); test(eval_scope_p(pos), "scope_flet1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * labels */ static int test_ifdeclcall(void) { addr control, call, pos; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(labels ((aa () 10) (bb () 20)) " " (declare (inline aa bb cc)) " " (aa) (bb) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); GetEvalParse(pos, 1, &str.decl); readstring_debug(&call, "bb"); parse_callname_local(local, &call, call); ifdeclcall(ptr, str.stack, call, str.decl, &pos); test(eval_tablefunction_p(pos), "ifdeclcall1"); test(find_tablefunction(str.stack, call, NULL), "ifdeclcall2"); test(getinline_tablefunction(pos) == InlineType_Inline, "ifdeclcall3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_labels_init(void) { addr control, pos, args, eval, check, call; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(labels ((aa () 10) (bb () 20)) " " (declare (inline aa bb cc)) " " (aa) (bb) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); GetEvalParse(pos, 1, &str.decl); labels_init(ptr, &str); args = str.args; test(length_list_unsafe(args) == 2, "labels_init1"); GetCons(args, &pos, &args); GetCons(pos, &pos, &eval); readstring_debug(&check, "aa"); parse_callname_local(local, &check, check); test(equal_callname(pos, check), "labels_init2"); test(eval_scope_p(eval), "labels_init3"); GetCons(args, &pos, &args); GetCons(pos, &pos, &eval); readstring_debug(&check, "bb"); parse_callname_local(local, &check, check); test(equal_callname(pos, check), "labels_init4"); test(eval_scope_p(eval), "labels_init5"); readstring_debug(&call, "bb"); parse_callname_local(local, &call, call); test(find_tablefunction(str.stack, call, &pos), "labels_init6"); test(getinline_tablefunction(pos) == InlineType_Inline, "labels_init7"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_labels_checktype(void) { addr control, pos, table, type; Execute ptr; LocalRoot local; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; local = ptr->local; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(labels ((aa () 10) (bb () 20)) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); GetEvalParse(pos, 1, &str.decl); labels_init(ptr, &str); apply_declare(ptr, str.stack, str.decl, &str.free); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); test(find_tablefunction(str.stack, pos, &table), "labels_checktype1"); readstring_debug(&type, "(function * *)"); test_parse_type(&type, type); settype_tablefunction(table, type); labels_checktype(&str); readstring_debug(&pos, "aa"); parse_callname_local(local, &pos, pos); test(find_tablefunction(str.stack, pos, &table), "labels_checktype2"); test(! getglobalp_tablefunction(table), "labels_checktype3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_labels(void) { addr control, pos; Execute ptr; struct let_struct str; memset(&str, 0, sizeoft(str)); ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(labels ((aa () 10) (bb () 20)) (aa) (bb) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); GetEvalParse(pos, 1, &str.decl); GetEvalParse(pos, 2, &str.cons); labels_execute(ptr, &str); test(RefLispDecl(str.the) == LISPDECL_KEYWORD, "labels_execute1"); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(labels ((aa () 10) (bb () 20)) (aa) (bb) :aa)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &str.args); GetEvalParse(pos, 1, &str.decl); GetEvalParse(pos, 2, &str.cons); labels_object(ptr, &str); test(RefLispDecl(str.the) == LISPDECL_KEYWORD, "labels_object1"); str.stack = newstack_nil(ptr); readstring_debug(&pos, "(labels ((aa () 10) (bb () 20)) (aa) (bb) :aa)"); eval_parse_execute(&pos, pos); scope_labels(ptr, &pos, pos); test(eval_scope_p(pos), "scope_labels1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * call */ static int test_call_first(void) { addr control, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(hello 10 20 30)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &pos); call_first(ptr, &pos, pos); test(eval_scope_p(pos), "call_first1"); test(RefEvalScopeType(pos) == EVAL_PARSE_FUNCTION, "call_first2"); readstring_debug(&pos, "((lambda ()) 10 20 30)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &pos); call_first(ptr, &pos, pos); test(eval_scope_p(pos), "call_first3"); test(RefEvalScopeType(pos) == EVAL_PARSE_LAMBDA, "call_first4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_check_tablecall(void) { addr control, pos, type, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "100"); eval_parse_execute(&pos, pos); readstring_debug(&type, "integer"); test_parse_type(&type, type); check_tablecall(ptr, pos, type, &pos); test(eval_tablecall_p(pos), "check_tablecall1"); gettype_tablecall(pos, &check); test(RefLispDecl(check) == LISPDECL_INTEGER, "check_tablecall2"); getvalue_tablecall(pos, &check); test(eval_scope_p(check), "check_tablecall3"); test(! getcheck_tablecall(pos), "check_tablecall4"); readstring_debug(&pos, "100"); eval_parse_execute(&pos, pos); readstring_debug(&type, "(satisfies hello)"); test_parse_type(&type, type); check_tablecall(ptr, pos, type, &pos); test(getcheck_tablecall(pos), "check_tablecall5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_callargs_var(void) { addr control, pos, args, root, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(function (integer character))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call 10 #\\a)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ root = Nil; test(callargs_var(ptr, pos, &args, &root) == 0, "callargs_var1"); test(length_list_unsafe(root) == 2, "callargs_var2"); GetCons(root, &pos, &root); test(eval_tablecall_p(pos), "callargs_var3"); gettype_tablecall(pos, &check); test(RefLispDecl(check) == LISPDECL_CHARACTER, "callargs_var4"); getvalue_tablecall(pos, &check); test(RefEvalScopeType(check) == EVAL_PARSE_CHARACTER, "callargs_var5"); test(! getcheck_tablecall(pos), "callargs_var6"); readstring_debug(&pos, "(function (integer character real))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call 10 #\\a)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ root = Nil; test(callargs_var(ptr, pos, &args, &root), "callargs_var7"); readstring_debug(&pos, "(function ((satisfies hello)))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call 10)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ root = Nil; test(callargs_var(ptr, pos, &args, &root) == 0, "callargs_var8"); test(length_list_unsafe(root) == 1, "callargs_var9"); GetCons(root, &pos, &root); test(getcheck_tablecall(pos), "callargs_var10"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_callargs_opt(void) { addr control, pos, args, root, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(function (&optional integer character))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call 10 #\\a)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ root = Nil; callargs_opt(ptr, pos, &args, &root); test(length_list_unsafe(root) == 2, "callargs_opt1"); GetCons(root, &pos, &root); test(eval_tablecall_p(pos), "callargs_opt2"); gettype_tablecall(pos, &check); test(RefLispDecl(check) == LISPDECL_CHARACTER, "callargs_opt3"); getvalue_tablecall(pos, &check); test(RefEvalScopeType(check) == EVAL_PARSE_CHARACTER, "callargs_opt4"); test(! getcheck_tablecall(pos), "callargs_opt5"); readstring_debug(&pos, "(function (&optional (satisfies hello)))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call 10)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ root = Nil; callargs_opt(ptr, pos, &args, &root); test(length_list_unsafe(root) == 1, "callargs_opt6"); GetCons(root, &pos, &root); test(getcheck_tablecall(pos), "callargs_opt7"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_callargs_keyvalue(void) { addr cons, key, type, check; readstring_debug(&key, "hello"); GetTypeTable(&type, Atom); cons_heap(&cons, key, type); callargs_keyvalue(0, cons, &check); test(RefLispDecl(check) == LISPDECL_EQL, "callargs_keyvalue1"); GetArrayType(check, 0, &check); test(check == key, "callargs_keyvalue2"); callargs_keyvalue(1, cons, &check); test(RefLispDecl(check) == LISPDECL_ATOM, "callargs_keyvalue3"); RETURN; } static int test_callargs_key(void) { addr cons, key, type, check; callargs_key(0, T, &check); test(RefLispDecl(check) == LISPDECL_SYMBOL, "callargs_key1"); callargs_key(1, T, &check); test(RefLispDecl(check) == LISPDECL_T, "callargs_key2"); readstring_debug(&key, "hello"); GetTypeTable(&type, Atom); cons_heap(&cons, key, type); list_heap(&cons, cons, NULL); callargs_key(0, cons, &check); test(RefLispDecl(check) == LISPDECL_EQL, "callargs_key3"); callargs_key(1, cons, &check); test(RefLispDecl(check) == LISPDECL_ATOM, "callargs_key4"); cons_heap(&cons, key, type); list_heap(&cons, cons, cons, NULL); callargs_key(0, cons, &check); test(RefLispDecl(check) == LISPDECL_OR, "callargs_key5"); callargs_key(1, cons, &check); test(RefLispDecl(check) == LISPDECL_OR, "callargs_key6"); RETURN; } static int test_callargs_restkey(void) { int result; addr control, pos, args, root, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(function ())"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call 10 #\\a)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ root = Nil; callargs_restkey(ptr, pos, &args, &root, &result); test(result, "callargs_restkey1"); readstring_debug(&args, "(call)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ root = Nil; callargs_restkey(ptr, pos, &args, &root, &result); test(! result, "callargs_restkey2"); test(root == Nil, "callargs_restkey3"); readstring_debug(&pos, "(function (&rest integer))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call 10)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ root = Nil; callargs_restkey(ptr, pos, &args, &root, &result); test(! result, "callargs_restkey4"); test(singlep(root), "callargs_restkey5"); GetCar(root, &root); gettype_tablecall(root, &root); test(RefLispDecl(root) == LISPDECL_INTEGER, "callargs_restkey6"); readstring_debug(&pos, "(function (&key (aaa integer) (bbb real)))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call aaa 10)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ root = Nil; callargs_restkey(ptr, pos, &args, &root, &result); test(! result, "callargs_restkey7"); test(length_list_unsafe(root) == 2, "callargs_restkey8"); GetCar(root, &check); gettype_tablecall(check, &check); test(RefLispDecl(check) == LISPDECL_OR, "callargs_restkey9"); readstring_debug(&pos, "(function (&rest fixnum &key (aaa integer) (bbb real)))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call aaa 10 bbb 20)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ root = Nil; callargs_restkey(ptr, pos, &args, &root, &result); test(! result, "callargs_restkey10"); test(length_list_unsafe(root) == 4, "callargs_restkey11"); GetCar(root, &check); gettype_tablecall(check, &check); test(RefLispDecl(check) == LISPDECL_AND, "callargs_restkey12"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_callargs_check(void) { addr control, pos, args, root, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(function ())"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ callargs_check(ptr, pos, args, &root); test(root == Nil, "callargs_check1"); readstring_debug(&pos, "(function (integer))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call 10)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ callargs_check(ptr, pos, args, &root); test(length_list_unsafe(root) == 1, "callargs_check2"); readstring_debug(&pos, "(function (integer &optional real))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call 10 20)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ callargs_check(ptr, pos, args, &root); test(length_list_unsafe(root) == 2, "callargs_check3"); GetCar(root, &check); getvalue_tablecall(check, &check); GetEvalScopeValue(check, &check); test(RefFixnum(check) == 10, "callargs_check4"); readstring_debug(&pos, "(function (integer &rest real))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call 10 20 30 40 50)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ callargs_check(ptr, pos, args, &root); test(length_list_unsafe(root) == 5, "callargs_check5"); readstring_debug(&pos, "(function (&rest t &key (hello integer)))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ callargs_check(ptr, pos, args, &root); test(length_list_unsafe(root) == 0, "callargs_check6"); readstring_debug(&pos, "(function (&rest t &key (hello integer)))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call hello 20)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ callargs_check(ptr, pos, args, &root); test(length_list_unsafe(root) == 2, "callargs_check7"); readstring_debug(&pos, "(function (&key (hello integer)))"); test_parse_type(&pos, pos); GetArrayType(pos, 0, &pos); /* args */ readstring_debug(&args, "(call hello 100)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ callargs_check(ptr, pos, args, &root); test(length_list_unsafe(root) == 2, "callargs_check8"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_asterisk_function_argument(void) { addr pos; GetTypeTable(&pos, Asterisk); test(asterisk_function_argument(pos, &pos), "asterisk_function_argument1"); readstring_debug(&pos, "function"); test_parse_type(&pos, pos); test(asterisk_function_argument(pos, &pos), "asterisk_function_argument2"); readstring_debug(&pos, "(function * integer)"); test_parse_type(&pos, pos); test(asterisk_function_argument(pos, &pos), "asterisk_function_argument3"); readstring_debug(&pos, "(function ())"); test_parse_type(&pos, pos); test(! asterisk_function_argument(pos, &pos), "asterisk_function_argument4"); test(GetType(pos) == LISPTYPE_VECTOR, "asterisk_function_argument5"); RETURN; } static int test_callargs_nocheck(void) { addr control, args, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&args, "(call 10 20 30 40)"); eval_parse_execute(&args, args); GetEvalParse(args, 1, &args); /* args */ callargs_nocheck(ptr, args, &args); test(length_list_unsafe(args) == 4, "callargs_nocheck1"); GetCar(args, &check); test(eval_tablecall_p(check), "callargs_nocheck2"); gettype_tablecall(check, &check); test(type_asterisk_p(check), "callargs_nocheck3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_call_args(void) { addr control, pos, first, args, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(call 10 20 30 40)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &first); GetEvalParse(pos, 1, &args); call_first(ptr, &first, first); readstring_debug(&pos, "(function * *)"); test_parse_type(&pos, pos); SetEvalScopeThe(first, pos); call_args(ptr, &args, first, args); test(length_list_unsafe(args) == 4, "call_args1"); GetCar(args, &check); test(eval_tablecall_p(check), "call_args2"); gettype_tablecall(check, &check); test(type_asterisk_p(check), "call_args3"); readstring_debug(&pos, "(call 10 20 30 40)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &first); GetEvalParse(pos, 1, &args); call_first(ptr, &first, first); readstring_debug(&pos, "(function (&rest integer) *)"); test_parse_type(&pos, pos); SetEvalScopeThe(first, pos); call_args(ptr, &args, first, args); test(length_list_unsafe(args) == 4, "call_args4"); GetCar(args, &check); test(eval_tablecall_p(check), "call_args5"); gettype_tablecall(check, &check); test(RefLispDecl(check) == LISPDECL_INTEGER, "call_args6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_call_result(void) { addr control, pos, first, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(call 10 20 30 40)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &first); call_first(ptr, &first, first); GetTypeTable(&pos, Asterisk); SetEvalScopeThe(first, pos); call_result(&check, first); test(type_asterisk_p(check), "call_result1"); readstring_debug(&pos, "(function * *)"); test_parse_type(&pos, pos); SetEvalScopeThe(first, pos); call_result(&check, first); test(type_asterisk_p(check), "call_result2"); readstring_debug(&pos, "(function * integer)"); test_parse_type(&pos, pos); SetEvalScopeThe(first, pos); call_result(&check, first); test(RefLispDecl(check) == LISPDECL_INTEGER, "call_result3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_call(void) { addr control, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(call 10 20 30 40)"); eval_parse_execute(&pos, pos); scope_call(ptr, &pos, pos); test(eval_scope_p(pos), "scope_call1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * syntax operator */ static int test_values_args(void) { addr control, pos, cons, type; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(values 10 #\\A)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &pos); values_args(ptr, pos, &cons, &type); test(length_list_unsafe(cons) == 2, "values_args1"); GetCar(cons, &pos); GetEvalScopeValue(pos, &pos); test(RefFixnum(pos) == 10, "values_args2"); test(RefLispDecl(type) == LISPDECL_VALUES, "values_args3"); GetArrayType(type, 0, &pos); /* var */ test(length_list_unsafe(pos) == 2, "values_args4"); GetCar(pos, &pos); test(RefLispDecl(pos) == LISPDECL_INTEGER, "values_args5"); GetArrayType(type, 2, &pos); /* rest */ test(RefLispDecl(pos) == LISPDECL_NIL, "values_args6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_values(void) { addr control, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(values 10 #\\A)"); eval_parse_execute(&pos, pos); scope_values(ptr, &pos, pos); test(eval_scope_p(pos), "scope_values1"); GetEvalScopeValue(pos, &check); test(length_list_unsafe(check) == 2, "scope_values2"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_VALUES, "scope_values3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_the_check(void) { addr control, pos, eval, type, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(the integer 100)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &type); GetEvalParse(pos, 1, &eval); scope_eval(ptr, &eval, eval); the_check(eval, type, &check); test(check == Nil, "the_check1"); readstring_debug(&pos, "(the (satisfies hello) 100)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &type); GetEvalParse(pos, 1, &eval); scope_eval(ptr, &eval, eval); the_check(eval, type, &check); test(check == T, "the_check2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_the(void) { addr control, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(the (satisfies hello) 100)"); eval_parse_execute(&pos, pos); scope_the(ptr, &pos, pos); test(eval_scope_p(pos), "scope_the1"); GetEvalScopeValue(pos, &check); test(eval_scope_p(check), "scope_the2"); GetEvalScopeIndex(pos, 0, &check); test(check == T, "scope_the3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_locally_execute(void) { addr control, pos, decl, cons, free, type; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(locally (declare (type integer aaa)) 100 :hello)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &decl); GetEvalParse(pos, 1, &cons); locally_execute(ptr, decl, cons, &cons, &type, &free); test(length_list_unsafe(cons) == 2, "locally_execute1"); GetCar(cons, &cons); GetEvalScopeValue(cons, &cons); test(RefFixnum(cons) == 100, "locally_execute2"); test(RefLispDecl(type) == LISPDECL_KEYWORD, "locally_execute3"); test(length_list_unsafe(free) == 1, "locally_execute4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_locally(void) { addr control, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(locally (declare (type integer aaa)) 100 :hello)"); eval_parse_execute(&pos, pos); scope_locally(ptr, &pos, pos); test(eval_scope_p(pos), "scope_locally1"); test(RefEvalScopeType(pos) == EVAL_PARSE_LOCALLY, "scope_locally2"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_KEYWORD, "scope_locally3"); GetEvalScopeIndex(pos, 0, &check); test(eval_declare_p(check), "scope_locally4"); GetEvalScopeIndex(pos, 1, &check); test(length_list_unsafe(check) == 2, "scope_locally5"); GetEvalScopeIndex(pos, 2, &check); test(length_list_unsafe(check) == 1, "scope_locally6"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_if(void) { addr control, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(if 10 20 30)"); eval_parse_execute(&pos, pos); scope_if(ptr, &pos, pos); test(eval_scope_p(pos), "scope_if1"); test(RefEvalScopeType(pos) == EVAL_PARSE_IF, "scope_if2"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_OR, "scope_if3"); GetArrayType(check, 0, &check); test(lenarrayr(check) == 2, "scope_if4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_unwind_protect(void) { addr control, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(unwind-protect 10 20 :hello)"); eval_parse_execute(&pos, pos); scope_unwind_protect(ptr, &pos, pos); test(eval_scope_p(pos), "scope_unwind_protect1"); test(RefEvalScopeType(pos) == EVAL_PARSE_UNWIND_PROTECT, "scope_unwind_protect2"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_INTEGER, "scope_unwind_protect3"); GetEvalScopeIndex(pos, 0, &check); test(eval_scope_p(check), "scope_unwind_protect4"); GetEvalScopeIndex(pos, 1, &check); test(length_list_unsafe(check) == 2, "scope_unwind_protect5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * tagbody */ static int test_push_tabletagbody(void) { addr control, stack, table, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "hello"); push_tabletagbody(stack, pos); readstring_debug(&pos, "hello"); push_tabletagbody(stack, pos); make_fixnum_heap(&pos, 10); push_tabletagbody(stack, pos); make_fixnum_heap(&pos, 10); push_tabletagbody(stack, pos); readstring_debug(&pos, "aaa"); push_tabletagbody(stack, pos); GetConstant(CONSTANT_SYSTEM_TABLE_TAGBODY, &pos); GetEvalStackTable(stack, &table); getplist(table, pos, &table); test(length_list_unsafe(table) == 6, "push_tabletagbody1"); readstring_debug(&pos, "10"); test(getplist_eql(table, pos, &pos) == 0, "push_tabletagbody2"); test(eval_tabletagbody_p(pos), "push_tabletagbody3"); gettag_tabletagbody(pos, &pos); test(RefFixnum(pos) == 10, "push_tabletagbody4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_tagbody_push(void) { addr control, stack, table, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "(tagbody 10 20 hello 40 (call))"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &pos); /* tag */ tagbody_push(stack, pos); GetConstant(CONSTANT_SYSTEM_TABLE_TAGBODY, &pos); GetEvalStackTable(stack, &table); getplist(table, pos, &table); test(length_list_unsafe(table) == 8, "tagbody_push1"); readstring_debug(&pos, "10"); test(getplist_eql(table, pos, &pos) == 0, "tagbody_push2"); test(eval_tabletagbody_p(pos), "tagbody_push3"); gettag_tabletagbody(pos, &pos); test(RefFixnum(pos) == 10, "tagbody_push4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_tagbody_allcons(void) { addr control, stack, pos, tag, body; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "(tagbody 10 20 hello 40 (call))"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &tag); /* tag */ GetEvalParse(pos, 1, &body); /* body */ tagbody_push(stack, tag); tagbody_allcons(ptr, body, &body); test(length_list_unsafe(body) == 5, "tagbody_allcons1"); GetCar(body, &body); test(eval_scope_p(body), "tagbody_allcons2"); test(RefEvalScopeType(body) == EVAL_PARSE_TAG, "tagbody_allcons3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_tagbody_check(void) { addr control, stack, pos, tag, body; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "(tagbody 10 20 (go 10) (call) (go 20))"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &tag); /* tag */ GetEvalParse(pos, 1, &body); /* body */ tagbody_push(stack, tag); tagbody_allcons(ptr, body, &body); tagbody_check(stack); test(1, "tagbody_check1"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_tagbody(void) { addr control, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(tagbody 10 20 (go 10) (call) (go 20))"); eval_parse_execute(&pos, pos); scope_tagbody(ptr, &pos, pos); test(eval_scope_p(pos), "scope_tagbody1"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_NULL, "scope_tagbody2"); GetEvalScopeIndex(pos, 0, &check); test(length_list_unsafe(check) == 2, "scope_tagbody3"); GetEvalScopeIndex(pos, 1, &check); test(length_list_unsafe(check) == 5, "scope_tagbody4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_find_tabletagbody(void) { addr control, stack, pos, tag, body, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "(tagbody 10 20 (go 10) (call) (go 20))"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &tag); /* tag */ GetEvalParse(pos, 1, &body); /* body */ tagbody_push(stack, tag); readstring_debug(&pos, "20"); test(find_tabletagbody(stack, pos, &check), "find_tabletagbody1"); test(find_tabletagbody(stack, pos, NULL), "find_tabletagbody2"); test(eval_tabletagbody_p(check), "find_tabletagbody3"); readstring_debug(&pos, "hello"); test(! find_tabletagbody(stack, pos, &check), "find_tabletagbody4"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_push_closure_tagbody(void) { addr control, stack, pos, tag, body, check, key, table; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "(tagbody 10 20 (go 10) (call) (go 20))"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &tag); /* tag */ GetEvalParse(pos, 1, &body); /* body */ tagbody_push(stack, tag); readstring_debug(&pos, "20"); test(find_tabletagbody(stack, pos, &check), "push_closure_tagbody1"); push_closure_tagbody(stack, pos, check); readstring_debug(&pos, "10"); test(find_tabletagbody(stack, pos, &check), "push_closure_tagbody2"); push_closure_tagbody(stack, pos, check); GetConstant(CONSTANT_SYSTEM_CLOSURE_TAGBODY, &key); GetEvalStackTable(stack, &table); getplist(table, key, &pos); test(length_list_unsafe(pos) == 4, "push_closure_tagbody3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_go_tabletagbody(void) { addr control, tagbody, stack, pos, tag, body, check, key, table; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_tagbody(ptr); readstring_debug(&pos, "(tagbody 10 20 (go 10) (call) (go 20))"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &tag); /* tag */ GetEvalParse(pos, 1, &body); /* body */ tagbody_push(stack, tag); readstring_debug(&pos, "20"); test(find_tabletagbody(stack, pos, &check), "go_tabletagbody1"); stack = newstack_nil(ptr); tagbody = newstack_lambda(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "20"); test(go_tabletagbody(stack, pos, &pos), "go_tabletagbody2"); test(pos == check, "go_tabletagbody3"); GetConstant(CONSTANT_SYSTEM_CLOSURE_TAGBODY, &key); GetEvalStackTable(tagbody, &table); getplist(table, key, &pos); test(length_list_unsafe(pos) == 2, "go_tabletagbody4"); readstring_debug(&pos, "hello"); test(! go_tabletagbody(stack, pos, &pos), "go_tabletagbody5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_go_execute(void) { addr control, stack, pos, tag, body; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_tagbody(ptr); readstring_debug(&pos, "(tagbody 10 20 (go 10) (call) (go 20))"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &tag); /* tag */ GetEvalParse(pos, 1, &body); /* body */ tagbody_push(stack, tag); readstring_debug(&pos, "20"); go_execute(ptr, &pos, pos); test(eval_tabletagbody_p(pos), "go_execute1"); test(getreference_tabletagbody(pos), "go_execute2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_go(void) { addr control, stack, pos, tag, body; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_tagbody(ptr); readstring_debug(&pos, "(tagbody 10 20 (go 10) (call) (go 20))"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &tag); /* tag */ GetEvalParse(pos, 1, &body); /* body */ tagbody_push(stack, tag); readstring_debug(&pos, "(go 20)"); eval_parse_execute(&pos, pos); scope_go(ptr, &pos, pos); test(eval_scope_p(pos), "scope_go1"); test(RefEvalScopeType(pos) == EVAL_PARSE_GO, "scope_go2"); GetEvalScopeThe(pos, &pos); test(RefLispDecl(pos) == LISPDECL_NIL, "scope_go3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * block */ static int test_push_tableblock(void) { addr control, stack, pos, key, table, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_tagbody(ptr); readstring_debug(&pos, "aaa"); push_tableblock(stack, pos); GetConstant(CONSTANT_SYSTEM_TABLE_BLOCK, &key); GetEvalStackTable(stack, &table); test(getplist(table, key, &check) == 0, "push_tableblock1"); test(check == pos, "push_tableblock2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_block_execute(void) { addr control, pos, name, cons; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); newstack_tagbody(ptr); readstring_debug(&pos, "(block name 10 20 :hello)"); eval_parse_execute(&pos, pos); GetEvalParse(pos, 0, &name); GetEvalParse(pos, 1, &cons); block_execute(ptr, name, cons, &cons, &pos); test(length_list_unsafe(cons) == 3, "block_execute1"); test(RefLispDecl(pos) == LISPDECL_KEYWORD, "block_execute2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_block(void) { addr control, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); newstack_tagbody(ptr); readstring_debug(&pos, "(block name 10 20 :hello)"); eval_parse_execute(&pos, pos); scope_block(ptr, &pos, pos); test(eval_scope_p(pos), "scope_block1"); test(RefEvalScopeType(pos) == EVAL_PARSE_BLOCK, "scope_block2"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_push_closure_block(void) { addr control, stack, pos, key, table; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_tagbody(ptr); readstring_debug(&pos, "name"); push_closure_block(stack, pos); readstring_debug(&pos, "aaa"); push_closure_block(stack, pos); readstring_debug(&pos, "name"); push_closure_block(stack, pos); readstring_debug(&pos, "bbb"); push_closure_block(stack, pos); GetConstant(CONSTANT_SYSTEM_CLOSURE_BLOCK, &key); GetEvalStackTable(stack, &table); test(getplist(table, key, &table) == 0, "push_closure_block1"); test(length_list_unsafe(table) == 3, "push_closure_block2"); readstring_debug(&pos, "name"); test(find_list_eq_unsafe(pos, table), "push_closure_block3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_find_tableblock(void) { addr control, stack, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_tagbody(ptr); readstring_debug(&pos, "name"); test(! find_tableblock(stack, pos), "find_tableblock1"); readstring_debug(&pos, "name"); push_tableblock(stack, pos); readstring_debug(&pos, "name"); test(find_tableblock(stack, pos), "find_tableblock2"); readstring_debug(&pos, "bbb"); test(! find_tableblock(stack, pos), "find_tableblock3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_name_tableblock(void) { addr control, stack, pos, key, table, lambda; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "name"); test(! name_tableblock(Nil, pos), "name_tableblock1"); stack = newstack_nil(ptr); readstring_debug(&pos, "name"); push_tableblock(stack, pos); readstring_debug(&pos, "aaa"); test(! name_tableblock(stack, pos), "name_tableblock2"); readstring_debug(&pos, "name"); test(name_tableblock(stack, pos), "name_tableblock3"); stack = newstack_nil(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "aaa"); test(! name_tableblock(stack, pos), "name_tableblock4"); readstring_debug(&pos, "name"); test(name_tableblock(stack, pos), "name_tableblock5"); lambda = newstack_lambda(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "aaa"); test(! name_tableblock(stack, pos), "name_tableblock6"); readstring_debug(&pos, "name"); test(name_tableblock(stack, pos), "name_tableblock7"); GetConstant(CONSTANT_SYSTEM_CLOSURE_BLOCK, &key); GetEvalStackTable(lambda, &table); test(getplist(table, key, &table) == 0, "name_tableblock8"); test(singlep(table), "name_tableblock9"); GetCar(table, &table); test(table == pos, "name_tableblock10"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_return_from(void) { addr control, stack, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); stack = newstack_nil(ptr); readstring_debug(&pos, "name"); push_tableblock(stack, pos); readstring_debug(&pos, "(return-from name 100)"); eval_parse_execute(&pos, pos); scope_return_from(ptr, &pos, pos); test(eval_scope_p(pos), "scope_return_from1"); test(RefEvalScopeType(pos) == EVAL_PARSE_RETURN_FROM, "scope_return_from2"); GetEvalScopeThe(pos, &pos); test(RefLispDecl(pos) == LISPDECL_NIL, "scope_return_from3"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * catch */ static int test_scope_catch(void) { addr control, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(catch 'hello 20 30)"); eval_parse_execute(&pos, pos); scope_catch(ptr, &pos, pos); test(eval_scope_p(pos), "scope_catch1"); test(RefEvalScopeType(pos) == EVAL_PARSE_CATCH, "scope_catch2"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_ASTERISK, "scope_catch3"); GetEvalScopeIndex(pos, 0, &check); test(RefEvalScopeType(check) == EVAL_PARSE_QUOTE, "scope_catch4"); GetEvalScopeIndex(pos, 1, &check); test(lenarrayr(check) == 2, "scope_catch5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } static int test_scope_throw(void) { addr control, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(throw 'name 100)"); eval_parse_execute(&pos, pos); scope_throw(ptr, &pos, pos); test(eval_scope_p(pos), "scope_throw1"); test(RefEvalScopeType(pos) == EVAL_PARSE_THROW, "scope_throw2"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_NIL, "scope_throw3"); GetEvalScopeIndex(pos, 0, &check); test(RefEvalScopeType(check) == EVAL_PARSE_QUOTE, "scope_throw4"); GetEvalScopeIndex(pos, 1, &check); test(RefEvalScopeType(check) == EVAL_PARSE_INTEGER, "scope_throw5"); free_eval_stack(ptr); pop_control_(ptr, control); RETURN; } /* * eval-when */ static int test_eval_when_check(void) { addr control, symbol, value; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); symbol_toplevel_eval(&symbol); pushspecial_control(ptr, symbol, T); symbol_evalwhen_eval(&symbol); pushspecial_control(ptr, symbol, Nil); symbol_evalwhen_eval(&symbol); GetConst(COMMON_EVAL, &value); setspecial_local(ptr, symbol, value); test(! eval_when_check(ptr, T, T, Nil), "eval_when_check1"); test(eval_when_check(ptr, Nil, Nil, T), "eval_when_check2"); test(eval_when_check(ptr, T, Nil, T), "eval_when_check3"); GetConst(COMMON_LOAD, &value); setspecial_local(ptr, symbol, value); test(! eval_when_check(ptr, T, Nil, T), "eval_when_check4"); test(eval_when_check(ptr, Nil, T, Nil), "eval_when_check5"); GetConst(COMMON_COMPILE, &value); setspecial_local(ptr, symbol, value); test(! eval_when_check(ptr, Nil, T, T), "eval_when_check6"); test(eval_when_check(ptr, T, Nil, Nil), "eval_when_check7"); symbol_toplevel_eval(&symbol); setspecial_local(ptr, symbol, Nil); symbol_evalwhen_eval(&symbol); GetConst(COMMON_EVAL, &value); setspecial_local(ptr, symbol, value); test(! eval_when_check(ptr, T, T, Nil), "eval_when_check8"); test(eval_when_check(ptr, Nil, Nil, T), "eval_when_check9"); test(eval_when_check(ptr, T, Nil, T), "eval_when_check10"); GetConst(COMMON_LOAD, &value); setspecial_local(ptr, symbol, value); test(! eval_when_check(ptr, T, Nil, T), "eval_when_check11"); test(! eval_when_check(ptr, Nil, T, Nil), "eval_when_check12"); GetConst(COMMON_COMPILE, &value); setspecial_local(ptr, symbol, value); test(! eval_when_check(ptr, Nil, T, T), "eval_when_check13"); test(! eval_when_check(ptr, T, Nil, Nil), "eval_when_check14"); pop_control_(ptr, control); RETURN; } static int test_scope_eval_when(void) { addr control, pos; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(eval-when nil 100)"); eval_parse_execute(&pos, pos); scope_eval_when(ptr, &pos, pos); test(RefEvalScopeType(pos) == EVAL_PARSE_NIL, "scope_eval_when1"); readstring_debug(&pos, "(eval-when (:execute) 100)"); eval_parse_execute(&pos, pos); scope_eval_when(ptr, &pos, pos); test(RefEvalScopeType(pos) == EVAL_PARSE_PROGN, "scope_eval_when2"); pop_control_(ptr, control); RETURN; } /* * multiple-value-bind */ static int test_mvbind_maketable(void) { return 0; } /* * multiple-value-call */ static int test_function_result_type(void) { addr pos; Execute ptr; ptr = Execute_Thread; readstring_debug(&pos, "(progn 100)"); eval_parse_execute(&pos, pos); eval_scope(ptr, &pos, pos); test(function_result_type(pos, &pos), "function_result_type1"); readstring_debug(&pos, "(lambda () 100)"); eval_parse_execute(&pos, pos); eval_scope(ptr, &pos, pos); test(! function_result_type(pos, &pos), "function_result_type2"); test(RefLispDecl(pos) == LISPDECL_INTEGER, "function_result_type3"); RETURN; } static int test_scope_multiple_value_call(void) { addr control, pos, check; Execute ptr; ptr = Execute_Thread; push_control(ptr, &control); begin_eval_stack(ptr); readstring_debug(&pos, "(multiple-value-call (lambda () 100) (values 10 20 30) 40)"); eval_parse_execute(&pos, pos); scope_multiple_value_call(ptr, &pos, pos); test(eval_scope_p(pos), "scope_multiple_value_call1"); test(RefEvalScopeType(pos) == EVAL_PARSE_MULTIPLE_VALUE_CALL, "scope_multiple_value_call2"); GetEvalScopeThe(pos, &check); test(RefLispDecl(check) == LISPDECL_INTEGER, "scope_multiple_value_call3"); GetEvalScopeIndex(pos, 0, &check); test(RefEvalScopeType(check) == EVAL_PARSE_LAMBDA, "scope_multiple_value_call4"); GetEvalScopeIndex(pos, 1, &check); test(lenarrayr(check) == 2, "scope_multiple_value_call5"); pop_control_(ptr, control); RETURN; } /* * Main */ static int testcase_scope(void) { /* memory */ TestBreak(test_eval_scope_heap); TestBreak(test_eval_scope_size); TestBreak(test_make_eval_scope); TestBreak(test_StructEvalScope); /* scope constant */ TestBreak(test_scope_nil); TestBreak(test_scope_t); TestBreak(test_scope_integer); TestBreak(test_scope_rational); TestBreak(test_scope_character); TestBreak(test_scope_array); TestBreak(test_scope_vector); TestBreak(test_scope_string); TestBreak(test_scope_float); TestBreak(test_scope_quote); TestBreak(test_scope_allcons); TestBreak(test_scope_progn); TestBreak(test_scope_declaim); /* apply_declare */ TestBreak(test_find_tablevalue); TestBreak(test_find_tablefunction); TestBreak(test_check_value_declare); TestBreak(test_check_function_declare); TestBreak(test_check_declare_stack); TestBreak(test_apply_declare); /* let */ TestBreak(test_check_scope_variable); TestBreak(test_let_init); TestBreak(test_make_tablevalue_stack); TestBreak(test_let_maketable); TestBreak(test_specialp_stack_tablevalue); TestBreak(test_specialp_tablevalue); TestBreak(test_dynamic_stack_tablevalue); TestBreak(test_dynamic_tablevalue); TestBreak(test_ignore_stack_tablevalue); TestBreak(test_ignore_tablevalue); TestBreak(test_type_free_tablevalue); TestBreak(test_type_boundary_tablevalue); TestBreak(test_type_tablevalue_local); TestBreak(test_type_tablevalue_global); TestBreak(test_type_and_array); TestBreak(test_push_tablevalue_alloc); TestBreak(test_checktype_p); TestBreak(test_checktype_value); TestBreak(test_let_applytable); TestBreak(test_ignore_checkvalue); TestBreak(test_tablevalue_update); TestBreak(test_let_update); TestBreak(test_let_execute); TestBreak(test_scope_let); TestBreak(test_ifdeclvalue); TestBreak(test_leta_checktype); TestBreak(test_leta_execute); TestBreak(test_scope_leta); TestBreak(test_let_special); /* symbol */ TestBreak(test_symbol_global_tablevalue); TestBreak(test_push_closure_value); TestBreak(test_symbol_tablevalue); TestBreak(test_find_symbol_scope); TestBreak(test_make_scope_symbol); TestBreak(test_symbol_macrolet_global_p); TestBreak(test_symbol_macrolet_p); TestBreak(test_scope_symbol_replace); TestBreak(test_scope_symbol); TestBreak(test_scope_setq_cons); TestBreak(test_scope_setq); /* function */ TestBreak(test_globalp_stack_tablefunction); TestBreak(test_globalp_tablefunction); TestBreak(test_dynamic_stack_tablefunction); TestBreak(test_dynamic_tablefunction); TestBreak(test_ignore_stack_tablefunction); TestBreak(test_ignore_tablefunction); TestBreak(test_inline_stack_tablefunction); TestBreak(test_inline_tablefunction); TestBreak(test_gettype_global_callname); TestBreak(test_type_free_tablefunction); TestBreak(test_type_boundary_tablefunction); TestBreak(test_type_tablefunction_local); TestBreak(test_type_tablefunction_global); TestBreak(test_make_tablefunction_stack); TestBreak(test_push_tablefunction_alloc); TestBreak(test_callname_global_tablefunction); TestBreak(test_push_closure_function); TestBreak(test_callname_tablefunction); TestBreak(test_scope_function); /* lambda */ TestBreak(test_lambda_init_var); TestBreak(test_lambda_init_opt); TestBreak(test_lambda_init_key); TestBreak(test_lambda_init_aux); TestBreak(test_lambda_init); TestBreak(test_lambda_tablevalue_var); TestBreak(test_lambda_tablevalue_opt); TestBreak(test_lambda_tablevalue_key); TestBreak(test_lambda_tablevalue_aux); TestBreak(test_lambda_tablevalue); TestBreak(test_type_ordinary_var); TestBreak(test_type_ordinary_opt); TestBreak(test_type_ordinary_rest); TestBreak(test_type_ordinary_key); TestBreak(test_make_type_ordinary); TestBreak(test_lambda_type_incomplete); TestBreak(test_lambda_declare); TestBreak(test_lambda_progn); TestBreak(test_lambda_update_var); TestBreak(test_lambda_update_opt); TestBreak(test_lambda_update_key); TestBreak(test_lambda_update_aux); TestBreak(test_lambda_update); TestBreak(test_lambda_closure); TestBreak(test_lambda_execute); /* defun */ TestBreak(test_defun_update); TestBreak(test_defun_the); TestBreak(test_scope_defun); /* macro */ TestBreak(test_macro_init_var); TestBreak(test_macro_init_rest); TestBreak(test_macro_init_args); TestBreak(test_macro_tablevalue_var); TestBreak(test_macro_tablevalue_rest); TestBreak(test_macro_tablevalue_args); TestBreak(test_macro_update_var); TestBreak(test_macro_update_rest); TestBreak(test_scope_defmacro); TestBreak(test_push_symbol_macrolet); TestBreak(test_scope_define_symbol_macro); TestBreak(test_apply_symbol_macrolet); TestBreak(test_scope_symbol_macrolet); /* flet */ TestBreak(test_flet_call); TestBreak(test_flet_init); TestBreak(test_flet_maketable); TestBreak(test_checktype_function); TestBreak(test_flet_applytable); TestBreak(test_ignore_checkfunction); TestBreak(test_flet_update); TestBreak(test_scope_flet); /* labels */ TestBreak(test_ifdeclcall); TestBreak(test_labels_init); TestBreak(test_labels_checktype); TestBreak(test_scope_labels); /* call */ TestBreak(test_call_first); TestBreak(test_check_tablecall); TestBreak(test_callargs_var); TestBreak(test_callargs_opt); TestBreak(test_callargs_keyvalue); TestBreak(test_callargs_key); TestBreak(test_callargs_restkey); TestBreak(test_callargs_check); TestBreak(test_asterisk_function_argument); TestBreak(test_callargs_nocheck); TestBreak(test_call_args); TestBreak(test_call_result); TestBreak(test_scope_call); /* syntax operator */ TestBreak(test_values_args); TestBreak(test_scope_values); TestBreak(test_the_check); TestBreak(test_scope_the); TestBreak(test_locally_execute); TestBreak(test_scope_locally); TestBreak(test_scope_if); TestBreak(test_scope_unwind_protect); /* tagbody */ TestBreak(test_push_tabletagbody); TestBreak(test_tagbody_push); TestBreak(test_tagbody_allcons); TestBreak(test_tagbody_check); TestBreak(test_scope_tagbody); TestBreak(test_find_tabletagbody); TestBreak(test_push_closure_tagbody); TestBreak(test_go_tabletagbody); TestBreak(test_go_execute); TestBreak(test_scope_go); /* block */ TestBreak(test_push_tableblock); TestBreak(test_block_execute); TestBreak(test_scope_block); TestBreak(test_push_closure_block); TestBreak(test_find_tableblock); TestBreak(test_name_tableblock); TestBreak(test_scope_return_from); /* catch */ TestBreak(test_scope_catch); TestBreak(test_scope_throw); /* eval-when */ TestBreak(test_eval_when_check); TestBreak(test_scope_eval_when); /* multiple-value-bind */ TestBreak(test_mvbind_maketable); /* multiple-value-call */ TestBreak(test_function_result_type); TestBreak(test_scope_multiple_value_call); return 0; } static void test_build_scope(void) { addr pos, when; Execute ptr; ptr = Execute_Thread; push_control(ptr, &pos); GetConstant(CONSTANT_COMMON_EVAL, &when); push_toplevel_eval(ptr, T); push_evalwhen_eval(ptr); } static void testinit_scope(Execute ptr) { build_lisproot(ptr); build_constant(); build_object(); build_character(); build_package(); build_stream(); build_symbol(); build_clos(ptr); build_condition(ptr); build_type(); build_syscall(); build_common(); build_reader(); build_pathname(); build_declare(); build_code(); } #endif int test_scope(void) { #if 0 DegradeTitle; return DegradeCode(scope); #endif return 0; }
5117af54bce97745bca728e6f3e68a86ae619d4d
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/net/rdist6/files/patch-src_docmd.c
62580fbfe7661276324588f406009a96d02b3654
[ "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
2,593
c
patch-src_docmd.c
--- src/docmd.c.orig 1998-11-10 04:08:32 UTC +++ src/docmd.c @@ -102,7 +102,8 @@ static void notify(rhost, to, lmod) register struct namelist *to; time_t lmod; { - register int fd, len; + register int fd; + ssize_t len; FILE *pf, *popen(); struct stat stb; static char buf[BUFSIZ]; @@ -261,9 +262,7 @@ static int remotecmd(rhost, luser, ruser, cmd) char *cmd; { int desc; -#if defined(DIRECT_RCMD) static int port = -1; -#endif /* DIRECT_RCMD */ debugmsg(DM_MISC, "local user = %s remote user = %s\n", luser, ruser); debugmsg(DM_MISC, "Remote command = '%s'\n", cmd); @@ -290,11 +289,26 @@ static int remotecmd(rhost, luser, ruser, cmd) if (becomeuser() != 0) exit(1); #else /* !DIRECT_RCMD */ - debugmsg(DM_MISC, "Remote shell command = '%s'\n", path_remsh); - (void) signal(SIGPIPE, SIG_IGN); - desc = rshrcmd(&rhost, -1, luser, ruser, cmd, 0); - if (desc > 0) + if (geteuid() == 0 && strcmp(path_remsh, "/usr/bin/rsh") == 0) { + debugmsg(DM_MISC, "I am root, using rsh, therefore direct rcmd\n"); (void) signal(SIGPIPE, sighandler); + + if (port < 0) { + struct servent *sp; + + if ((sp = getservbyname("shell", "tcp")) == NULL) + fatalerr("shell/tcp: unknown service"); + port = sp->s_port; + } + + desc = rcmd(&rhost, port, luser, ruser, cmd, 0); + } else { + debugmsg(DM_MISC, "Remote shell command = '%s'\n", path_remsh); + (void) signal(SIGPIPE, SIG_IGN); + desc = rshrcmd(&rhost, -1, luser, ruser, cmd, 0); + if (desc > 0) + (void) signal(SIGPIPE, sighandler); + } #endif /* DIRECT_RCMD */ (void) alarm(0); @@ -312,7 +326,7 @@ static int makeconn(rhost) register char *ruser, *cp; static char *cur_host = NULL; extern char *locuser; - extern long min_freefiles, min_freespace; + extern int64_t min_freefiles, min_freespace; extern char *remotemsglist; char tuser[BUFSIZ], buf[BUFSIZ]; u_char respbuff[BUFSIZ]; @@ -403,13 +417,13 @@ static int makeconn(rhost) return(0); } if (min_freespace) { - (void) sendcmd(C_SETCONFIG, "%c%d", SC_FREESPACE, + (void) sendcmd(C_SETCONFIG, "%c%lld", SC_FREESPACE, min_freespace); if (response() < 0) return(0); } if (min_freefiles) { - (void) sendcmd(C_SETCONFIG, "%c%d", SC_FREEFILES, + (void) sendcmd(C_SETCONFIG, "%c%lld", SC_FREEFILES, min_freefiles); if (response() < 0) return(0); @@ -611,7 +625,7 @@ okname(name) c = *cp; if (c & 0200) isbad = TRUE; - if (!isalpha(c) && !isdigit(c) && c != '_' && c != '-') + if (!isalpha(c) && !isdigit(c) && c != '_' && c != '-' && c != '.' ) isbad = TRUE; }
c46496ee6932496056e23b764d2db081e3616e23
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/musl/compat/time32/difftime32.c
5950943a00345e02284eca55bae522781acca35a
[ "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-musl-exception", "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
115
c
difftime32.c
#include "time32.h" #include <time.h> double __difftime32(time32_t t1, time32_t t2) { return difftime(t1, t2); }
3066c10f0d174c09dddac495f75bae0555f7f769
342983ac4a4ddc27ffa33d48eae37bdd6237c618
/include/iface/rtmp_usb.h
7ce6f0bd422eaa5075c48c2566df0c2a4a044b12
[ "MIT" ]
permissive
chenhaiq/mt7610u_wifi_sta_v3002_dpo_20130916
9bbba99ecc921ce54e79038495a79b2df848956b
092d218723b8d50816b3bfb377675f5658a8ac4a
refs/heads/master
2022-08-10T15:47:25.607687
2017-08-18T16:37:02
2021-01-05T05:29:30
30,166,779
156
87
MIT
2022-07-27T03:52:36
2015-02-02T01:50:46
C
UTF-8
C
false
false
3,812
h
rtmp_usb.h
/* ************************************************************************* * Ralink Tech Inc. * 5F., No.36, Taiyuan St., Jhubei City, * Hsinchu County 302, * Taiwan, R.O.C. * * (c) Copyright 2002-2010, Ralink Technology, Inc. * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * * *************************************************************************/ #ifndef __RTMP_USB_H__ #define __RTMP_USB_H__ #include "rtusb_io.h" extern UCHAR EpToQueue[6]; #define RXBULKAGGRE_SIZE 12 #define MAX_TXBULK_LIMIT (LOCAL_TXBUF_SIZE*(BULKAGGRE_SIZE-1)) #define MAX_TXBULK_SIZE (LOCAL_TXBUF_SIZE*BULKAGGRE_SIZE) #define MAX_RXBULK_SIZE (LOCAL_TXBUF_SIZE*RXBULKAGGRE_SIZE) #define MAX_MLME_HANDLER_MEMORY 20 #define CMD_RSP_BULK_SIZE 1024 /*Power saving */ #define PowerWakeCID 3 #define CID0MASK 0x000000ff #define CID1MASK 0x0000ff00 #define CID2MASK 0x00ff0000 #define CID3MASK 0xff000000 /* Flags for Bulkflags control for bulk out data */ /* */ #define fRTUSB_BULK_OUT_DATA_NULL 0x00000001 #define fRTUSB_BULK_OUT_RTS 0x00000002 #define fRTUSB_BULK_OUT_MLME 0x00000004 #define fRTUSB_BULK_OUT_PSPOLL 0x00000010 #define fRTUSB_BULK_OUT_DATA_FRAG 0x00000020 #define fRTUSB_BULK_OUT_DATA_FRAG_2 0x00000040 #define fRTUSB_BULK_OUT_DATA_FRAG_3 0x00000080 #define fRTUSB_BULK_OUT_DATA_FRAG_4 0x00000100 #define fRTUSB_BULK_OUT_DATA_NORMAL 0x00010000 #define fRTUSB_BULK_OUT_DATA_NORMAL_2 0x00020000 #define fRTUSB_BULK_OUT_DATA_NORMAL_3 0x00040000 #define fRTUSB_BULK_OUT_DATA_NORMAL_4 0x00080000 /* TODO:move to ./ate/include/iface/ate_usb.h */ #ifdef RALINK_ATE #define fRTUSB_BULK_OUT_DATA_ATE 0x00100000 #endif /* RALINK_ATE */ #define FREE_HTTX_RING(_pCookie, _pipeId, _txContext) \ { \ if ((_txContext)->ENextBulkOutPosition == (_txContext)->CurWritePosition) \ { \ (_txContext)->bRingEmpty = TRUE; \ } \ /*NdisInterlockedDecrement(&(_p)->TxCount); */\ } #define NT_SUCCESS(status) (((status) >=0) ? (TRUE):(FALSE)) #define PIRP PVOID /*#define NDIS_OID UINT */ #ifndef USB_ST_NOERROR #define USB_ST_NOERROR 0 #endif /* vendor-specific control operations */ #define CONTROL_TIMEOUT_JIFFIES ( (300 * OS_HZ) / 1000) /*#define UNLINK_TIMEOUT_MS 3 // os abl move */ #define DEVICE_VENDOR_REQUEST_OUT 0x40 #define DEVICE_VENDOR_REQUEST_IN 0xc0 /*#define INTERFACE_VENDOR_REQUEST_OUT 0x41 */ /*#define INTERFACE_VENDOR_REQUEST_IN 0xc1 */ #define BULKOUT_MGMT_RESET_FLAG 0x80 #define RTUSB_SET_BULK_FLAG(_M, _F) ((_M)->BulkFlags |= (_F)) #define RTUSB_CLEAR_BULK_FLAG(_M, _F) ((_M)->BulkFlags &= ~(_F)) #define RTUSB_TEST_BULK_FLAG(_M, _F) (((_M)->BulkFlags & (_F)) != 0) #endif /* __RTMP_USB_H__ */
c4f11ae56455dd35198e761e79fb504906cee3e5
e100cedc265380fd666b08bd99ffdbeb4dfe0d3c
/include/SFML/Window/Joystick.h
cb0576872fc3cbff9498f2413ef79499b963d00c
[ "Zlib" ]
permissive
SFML/CSFML
50db0712f6f28c8958748df374a95a8c52a8063d
a80542d67d86dd37b9c6693e11ee666cbcfbe9f1
refs/heads/master
2023-08-19T00:21:35.753336
2023-08-06T22:12:44
2023-08-07T11:36:07
2,008,752
308
182
NOASSERTION
2023-09-09T21:36:25
2011-07-06T20:35:15
C
UTF-8
C
false
false
5,583
h
Joystick.h
//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.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. // //////////////////////////////////////////////////////////// #ifndef SFML_JOYSTICK_H #define SFML_JOYSTICK_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include <SFML/Window/Export.h> #include <SFML/Window/JoystickIdentification.h> //////////////////////////////////////////////////////////// /// \brief Global joysticks capabilities /// //////////////////////////////////////////////////////////// enum { sfJoystickCount = 8, ///< Maximum number of supported joysticks sfJoystickButtonCount = 32, ///< Maximum number of supported buttons sfJoystickAxisCount = 8 ///< Maximum number of supported axes }; //////////////////////////////////////////////////////////// /// \brief Axes supported by SFML joysticks /// //////////////////////////////////////////////////////////// typedef enum { sfJoystickX, ///< The X axis sfJoystickY, ///< The Y axis sfJoystickZ, ///< The Z axis sfJoystickR, ///< The R axis sfJoystickU, ///< The U axis sfJoystickV, ///< The V axis sfJoystickPovX, ///< The X axis of the point-of-view hat sfJoystickPovY ///< The Y axis of the point-of-view hat } sfJoystickAxis; //////////////////////////////////////////////////////////// /// \brief Check if a joystick is connected /// /// \param joystick Index of the joystick to check /// /// \return sfTrue if the joystick is connected, sfFalse otherwise /// //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfBool sfJoystick_isConnected(unsigned int joystick); //////////////////////////////////////////////////////////// /// \brief Return the number of buttons supported by a joystick /// /// If the joystick is not connected, this function returns 0. /// /// \param joystick Index of the joystick /// /// \return Number of buttons supported by the joystick /// //////////////////////////////////////////////////////////// CSFML_WINDOW_API unsigned int sfJoystick_getButtonCount(unsigned int joystick); //////////////////////////////////////////////////////////// /// \brief Check if a joystick supports a given axis /// /// If the joystick is not connected, this function returns false. /// /// \param joystick Index of the joystick /// \param axis Axis to check /// /// \return sfTrue if the joystick supports the axis, sfFalse otherwise /// //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfBool sfJoystick_hasAxis(unsigned int joystick, sfJoystickAxis axis); //////////////////////////////////////////////////////////// /// \brief Check if a joystick button is pressed /// /// If the joystick is not connected, this function returns false. /// /// \param joystick Index of the joystick /// \param button Button to check /// /// \return sfTrue if the button is pressed, sfFalse otherwise /// //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfBool sfJoystick_isButtonPressed(unsigned int joystick, unsigned int button); //////////////////////////////////////////////////////////// /// \brief Get the current position of a joystick axis /// /// If the joystick is not connected, this function returns 0. /// /// \param joystick Index of the joystick /// \param axis Axis to check /// /// \return Current position of the axis, in range [-100 .. 100] /// //////////////////////////////////////////////////////////// CSFML_WINDOW_API float sfJoystick_getAxisPosition(unsigned int joystick, sfJoystickAxis axis); //////////////////////////////////////////////////////////// /// \brief Get the joystick information /// /// The result of this function will only remain valid until /// the next time the function is called. /// /// \param joystick Index of the joystick /// /// \return Structure containing joystick information. /// //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfJoystickIdentification sfJoystick_getIdentification(unsigned int joystick); //////////////////////////////////////////////////////////// /// \brief Update the states of all joysticks /// /// This function is used internally by SFML, so you normally /// don't have to call it explicitely. However, you may need to /// call it if you have no window yet (or no window at all): /// in this case the joysticks states are not updated automatically. /// //////////////////////////////////////////////////////////// CSFML_WINDOW_API void sfJoystick_update(void); #endif // SFML_JOYSTICK_H
ca0b4231f5819e3aa0ec4cf791fb4599636e7140
f342990997706a962df8a42867fa1b46da2d2a0d
/Pods/Headers/Private/ComponentKit/CKComponentGestureActions.h
14c023cb0a608e9be05d684fb35d04e35d5d76f8
[ "MIT" ]
permissive
MarcoSero/HackerNews
11cd793a475fc6e875705035046f20dcce16b13a
92822de869c7eaaed751be98be9d0059391e5017
refs/heads/master
2021-01-21T01:59:36.492767
2016-03-05T10:51:02
2016-03-05T10:51:02
39,442,230
128
18
null
2016-03-05T10:51:05
2015-07-21T11:46:27
HTML
UTF-8
C
false
false
72
h
CKComponentGestureActions.h
../../../ComponentKit/ComponentKit/Utilities/CKComponentGestureActions.h
5a7673a320931309af51d4ed60cbe7d6ae382180
6f8f706e13170c840ce38712693cd9a11ca3ccc4
/Pods/Headers/Public/WBAppSize/WBAppSize/ASBaseFile.h
65cc3656e59d3fe3d4afbcc11ea8933b90e021ec
[]
permissive
wuba/WBBlades
80321e24414a9290f40512d809c79d8592b10439
c8af6d595fa4fa0aaa5d35447dd2fc048ec59705
refs/heads/master
2023-08-16T17:43:42.181515
2023-08-16T06:21:18
2023-08-16T06:21:18
247,865,662
1,353
207
BSD-3-Clause
2023-09-07T06:39:25
2020-03-17T02:56:07
Objective-C
UTF-8
C
false
false
64
h
ASBaseFile.h
../../../../../WBAppSize/ResourceCheck/Models/Files/ASBaseFile.h
6cee80be116833c3acc1e611d3b15469660280f2
f53d216dc2d8f54caeb71091117757c49d9afd30
/src/cpp/noderfc.h
70148d33356f1ab8bb4536092021ec97bef43cf1
[ "Apache-2.0" ]
permissive
SAP/node-rfc
38d916fec5d2689533067baaf094ca3f7042c185
25d67ab6b997b3c0f62521eaa9ef1743d39fcef5
refs/heads/main
2023-08-30T21:41:10.629615
2023-08-25T16:38:00
2023-08-25T16:38:00
22,616,677
257
90
Apache-2.0
2023-08-17T20:49:27
2014-08-04T19:18:18
C++
UTF-8
C
false
false
1,482
h
noderfc.h
// SPDX-FileCopyrightText: 2014 SAP SE Srdjan Boskovic <srdjan.boskovic@sap.com> // // SPDX-License-Identifier: Apache-2.0 #ifndef NodeRfc_Common_H #define NodeRfc_Common_H #include <napi.h> #include <sapnwrfc.h> // Error messages #define ERRMSG_LENGTH 255 #define ERROR_PATH_NAME_LEN 48 // Unsigned and pointer types #define uint_t uint32_t #define pointer_t uintptr_t // client binding version #define NODERFC_VERSION "3.3.0" // surpress unused parameter warnings #define UNUSED(x) (void)(x) // // Server options constants // #define SRV_OPTION_LOG_LEVEL "logLevel" #define SRV_OPTION_PORT "port" #define SRV_OPTION_AUTH "authHandler" // // Client options constants // #define CLIENT_OPTION_BCD "bcd" #define CLIENT_OPTION_DATE "date" #define CLIENT_OPTION_TIME "time" #define CLIENT_OPTION_FILTER "filter" #define CLIENT_OPTION_STATELESS "stateless" #define CLIENT_OPTION_TIMEOUT "timeout" #define CALL_OPTION_KEY_NOTREQUESTED "notRequested" #define CALL_OPTION_KEY_TIMEOUT CLIENT_OPTION_TIMEOUT #define CLIENT_OPTION_BCD_STRING 0 #define CLIENT_OPTION_BCD_NUMBER 1 #define CLIENT_OPTION_BCD_FUNCTION 2 // // Pool options constants // #define POOL_KEY_CONNECTION_PARAMS "connectionParameters" #define POOL_KEY_CLIENT_OPTIONS "clientOptions" #define POOL_KEY_POOL_OPTIONS "poolOptions" #define POOL_KEY_OPTION_LOW "low" #define POOL_KEY_OPTION_HIGH "high" #define POOL_READY_LOW 2 #define POOL_READY_HIGH 4 #define ENV_UNDEFINED node_rfc::__env.Undefined() #endif
ce87115e2717e889d49299bb65e1ad03a6960aa7
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/dawn/tools/golang/src/runtime/cgo/gcc_solaris_amd64.c
e89e844b1e0ad30ba76d3af59695391e7ceb0eff
[ "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference" ]
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
1,792
c
gcc_solaris_amd64.c
// Copyright 2015 The Go 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 <pthread.h> #include <string.h> #include <signal.h> #include <ucontext.h> #include "libcgo.h" #include "libcgo_unix.h" static void* threadentry(void*); static void (*setg_gcc)(void*); void x_cgo_init(G *g, void (*setg)(void*)) { ucontext_t ctx; setg_gcc = setg; if (getcontext(&ctx) != 0) perror("runtime/cgo: getcontext failed"); g->stacklo = (uintptr_t)ctx.uc_stack.ss_sp; // Solaris processes report a tiny stack when run with "ulimit -s unlimited". // Correct that as best we can: assume it's at least 1 MB. // See golang.org/issue/12210. if(ctx.uc_stack.ss_size < 1024*1024) g->stacklo -= 1024*1024 - ctx.uc_stack.ss_size; } void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; void *base; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); if (pthread_attr_getstack(&attr, &base, &size) != 0) perror("runtime/cgo: pthread_attr_getstack failed"); if (size == 0) { ts->g->stackhi = 2 << 20; if (pthread_attr_setstack(&attr, NULL, ts->g->stackhi) != 0) perror("runtime/cgo: pthread_attr_setstack failed"); } else { ts->g->stackhi = size; } pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err)); abort(); } } static void* threadentry(void *v) { ThreadStart ts; ts = *(ThreadStart*)v; free(v); crosscall_amd64(ts.fn, setg_gcc, (void*)ts.g); return nil; }
c11e00602e696d0a81701a1bc55e4acc06a0869d
f79dec3c4033ca3cbb55d8a51a748cc7b8b6fbab
/net/nagios-plugins/patches/patch-plugins__check_swap.c
4da178b3231a1c42366623370c165d05eb049584
[]
no_license
jsonn/pkgsrc
fb34c4a6a2d350e8e415f3c4955d4989fcd86881
c1514b5f4a3726d90e30aa16b0c209adbc276d17
refs/heads/trunk
2021-01-24T09:10:01.038867
2017-07-07T15:49:43
2017-07-07T15:49:43
2,095,004
106
47
null
2016-09-19T09:26:01
2011-07-23T23:49:04
Makefile
UTF-8
C
false
false
509
c
patch-plugins__check_swap.c
$NetBSD: patch-plugins__check_swap.c,v 1.3 2017/07/04 19:45:18 jperkin Exp $ Disable large file support when building 32bit on SunOS. --- plugins/check_swap.c.orig 2014-04-15 22:19:03.000000000 +0000 +++ plugins/check_swap.c @@ -35,6 +35,10 @@ const char *email = "devel@nagios-plugin #include "popen.h" #include "utils.h" +#if defined(__sun) && !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#undef _FILE_OFFSET_BITS +#endif + #ifdef HAVE_DECL_SWAPCTL # ifdef HAVE_SYS_PARAM_H # include <sys/param.h>
a1cafa025f05f665195927c30a5a8da077738e5a
3997bc3498e51eae394df0f71f8e15b64b9dc970
/src/streamvbyte_arm_encode.c
4b77cf52b7aeb1c7978372578a7b70269706d9a0
[ "Apache-2.0", "GPL-1.0-or-later", "MIT" ]
permissive
lemire/streamvbyte
7feff759567df86c9b6bc82ebbe1f27f127ca3e3
08c60644dc6956182c68c1b453ba5f2d42367823
refs/heads/master
2023-08-27T08:16:57.394402
2023-05-23T14:22:44
2023-05-23T14:22:44
56,248,127
346
33
Apache-2.0
2023-05-23T14:22:45
2016-04-14T15:19:32
C
UTF-8
C
false
false
2,169
c
streamvbyte_arm_encode.c
#include "streamvbyte_isadetection.h" #include "streamvbyte_shuffle_tables_encode.h" #ifdef STREAMVBYTE_ARM static const uint8_t pgatherlo[] = {12, 8, 4, 0, 12, 8, 4, 0}; // apparently only used in streamvbyte_encode4 #define concat (1 | 1 << 10 | 1 << 20 | 1 << 30) #define sum (1 | 1 << 8 | 1 << 16 | 1 << 24) static const uint32_t pAggregators[2] = {concat, sum}; // apparently only used in streamvbyte_encode4 static inline size_t streamvbyte_encode4(uint32x4_t data, uint8_t *__restrict__ outData, uint8_t *__restrict__ outCode) { const uint8x8_t gatherlo = vld1_u8(pgatherlo); const uint32x2_t Aggregators = vld1_u32(pAggregators); // lane code is 3 - (saturating sub) (clz(data)/8) uint32x4_t clzbytes = vshrq_n_u32(vclzq_u32(data), 3); uint32x4_t lanecodes = vqsubq_u32(vdupq_n_u32(3), clzbytes); // nops uint8x16_t lanebytes = vreinterpretq_u8_u32(lanecodes); #ifdef __aarch64__ uint8x8_t lobytes = vqtbl1_u8( lanebytes, gatherlo ); #else uint8x8x2_t twohalves = {{vget_low_u8(lanebytes), vget_high_u8(lanebytes)}}; // shuffle lsbytes into two copies of an int uint8x8_t lobytes = vtbl2_u8(twohalves, gatherlo); #endif uint32x2_t mulshift = vreinterpret_u32_u8(lobytes); uint32_t codeAndLength[2]; vst1_u32(codeAndLength, vmul_u32(mulshift, Aggregators)); uint32_t code = codeAndLength[0] >> 24; size_t length = 4 + (codeAndLength[1] >> 24); // shuffle in 8-byte chunks uint8x16_t databytes = vreinterpretq_u8_u32(data); uint8x16_t encodingShuffle = vld1q_u8((uint8_t *) &encodingShuffleTable[code]); #ifdef __aarch64__ vst1q_u8(outData, vqtbl1q_u8(databytes, encodingShuffle)); #else uint8x8x2_t datahalves = {{vget_low_u8(databytes), vget_high_u8(databytes)}}; vst1_u8(outData, vtbl2_u8(datahalves, vget_low_u8(encodingShuffle))); vst1_u8(outData + 8, vtbl2_u8(datahalves, vget_high_u8(encodingShuffle))); #endif *outCode = (uint8_t) code; return length; } static inline size_t streamvbyte_encode_quad(const uint32_t *__restrict__ in, uint8_t *__restrict__ outData, uint8_t *__restrict__ outCode) { uint32x4_t inq = vld1q_u32(in); return streamvbyte_encode4(inq, outData, outCode); } #endif
17d9383a7cb0d82dce331a9be0a91442dd5f29a4
af8fe84a9a43f5d7309cca301a791e9a1da6edf2
/test/unit-test/test_gestures.c
763da4d1ab3786619b5347a6d98dbf31f27ba0b4
[ "Apache-2.0" ]
permissive
digitalbitbox/bitbox02-firmware
c2581b02088009385d7c40066ad940a469eca761
12cfa59f05c200a72fa204961e3a5f8b3d3c0ba0
refs/heads/master
2023-08-31T22:14:19.307352
2023-08-31T09:29:16
2023-08-31T09:29:16
190,549,724
219
87
Apache-2.0
2023-09-14T07:10:09
2019-06-06T09:00:23
C
UTF-8
C
false
false
4,129
c
test_gestures.c
// Copyright 2019 Shift Cryptosecurity AG // // 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 <setjmp.h> #include <stdarg.h> #include <stdbool.h> #include <stddef.h> #include <cmocka.h> #include <touch/gestures.h> #include "mock_component.h" #include "mock_gestures.h" #include "mock_qtouch.h" // TODO: PR381 replaced callbacks with emitted events. // This test now has nothing to test. Need to check // instead that an event was emitted by `gestures.c`. static void reset_state(void) { // TODO: This was resetting callback 'called' boolean states, // but the callbacks were removed and replaced with events. // Therefore need to check that an event was emitted. } // TODO: SLIDE RELEASE // TODO: HOLD RELEASE // TODO: HOLD RELEASE + TAP RELEASE // TODO: TAP RELEASE + HOLD + TAP RELEASE // TODO: HOLD // TODO: TAP // TODO: SLIDE TAP /** * Tests whether a slide / tap-release / slide gesture is successfully detected. */ static void test_gestures_slide_tap_slide_detected(void** state) { component_t* mock_component = mock_component_create(); mock_gestures_touch_init(); // SLIDE: reset_state(); mock_gestures_touch(bottom_slider, 0); reset_state(); mock_gestures_touch(bottom_slider, 2); reset_state(); mock_gestures_touch(bottom_slider, 51); reset_state(); mock_gestures_touch_release(); // TAP RELEASE: reset_state(); mock_gestures_touch(bottom_slider, SCREEN_WIDTH); reset_state(); mock_gestures_touch(bottom_slider, SCREEN_WIDTH); reset_state(); mock_gestures_touch_release(); // SLIDE: reset_state(); mock_gestures_touch(bottom_slider, 0); reset_state(); mock_gestures_touch(bottom_slider, 2); reset_state(); mock_gestures_touch(bottom_slider, 51); reset_state(); mock_gestures_touch_release(); free(mock_component); } /** * Tests whether the slide gesture and a successive tap gesture is detected. */ static void test_gestures_slide_and_tap_detected(void** state) { component_t* mock_component = mock_component_create(); // SLIDE: mock_gestures_touch_init(); reset_state(); mock_gestures_touch(bottom_slider, 0); reset_state(); mock_gestures_touch(bottom_slider, 2); reset_state(); mock_gestures_touch(bottom_slider, 51); reset_state(); mock_gestures_touch_release(); // TAP RELEASE: reset_state(); mock_gestures_touch(bottom_slider, 0); reset_state(); mock_gestures_touch(bottom_slider, 0); reset_state(); mock_gestures_touch_release(); free(mock_component); } /** * Tests whether the slide gesture is detected. */ static void test_gestures_slide_left_to_right_detected(void** state) { component_t* mock_component = mock_component_create(); mock_gestures_touch_init(); reset_state(); mock_gestures_touch(bottom_slider, 0); reset_state(); mock_gestures_touch(bottom_slider, 51); reset_state(); mock_gestures_touch(bottom_slider, 51); reset_state(); mock_gestures_touch_release(); reset_state(); mock_gestures_touch(bottom_slider, 51); reset_state(); mock_gestures_touch(bottom_slider, 121); reset_state(); mock_gestures_touch_release(); free(mock_component); } int main(void) { const struct CMUnitTest tests[] = { cmocka_unit_test(test_gestures_slide_left_to_right_detected), cmocka_unit_test(test_gestures_slide_and_tap_detected), cmocka_unit_test(test_gestures_slide_tap_slide_detected), }; return cmocka_run_group_tests(tests, NULL, NULL); }
5f778fcea07a306701056d1496cee1afb8f92222
581bdcc078d282e388f1b655d4cfc4e08152d117
/tools/thirdparty/jsonc/json_visit.c
ee63d090911680612097b2ab6efa5a494fcc2452
[ "MIT", "BSD-3-Clause", "LGPL-2.0-or-later", "Zlib", "LGPL-2.1-or-later", "GPL-2.0-only", "LicenseRef-scancode-public-domain" ]
permissive
winsiderss/systeminformer
774928be871f0055263ac5e62ae0a598b098486b
5a6b442acd45d681f699a133d476a3211d072871
refs/heads/master
2023-08-28T15:43:41.074679
2023-08-27T20:59:20
2023-08-27T20:59:20
50,824,485
2,137
292
MIT
2023-09-10T22:35:12
2016-02-01T08:10:21
C
UTF-8
C
false
false
4,542
c
json_visit.c
/* * Copyright (c) 2016 Eric Haszlakiewicz * * This is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. */ #include <stdio.h> #include "config.h" #include "json_inttypes.h" #include "json_object.h" #include "json_visit.h" #include "linkhash.h" static int _json_c_visit(json_object *jso, json_object *parent_jso, const char *jso_key, size_t *jso_index, json_c_visit_userfunc *userfunc, void *userarg); int json_c_visit(json_object *jso, int future_flags, json_c_visit_userfunc *userfunc, void *userarg) { int ret = _json_c_visit(jso, NULL, NULL, NULL, userfunc, userarg); switch (ret) { case JSON_C_VISIT_RETURN_CONTINUE: case JSON_C_VISIT_RETURN_SKIP: case JSON_C_VISIT_RETURN_POP: case JSON_C_VISIT_RETURN_STOP: return 0; default: return JSON_C_VISIT_RETURN_ERROR; } } static int _json_c_visit(json_object *jso, json_object *parent_jso, const char *jso_key, size_t *jso_index, json_c_visit_userfunc *userfunc, void *userarg) { int userret = userfunc(jso, 0, parent_jso, jso_key, jso_index, userarg); switch (userret) { case JSON_C_VISIT_RETURN_CONTINUE: break; case JSON_C_VISIT_RETURN_SKIP: case JSON_C_VISIT_RETURN_POP: case JSON_C_VISIT_RETURN_STOP: case JSON_C_VISIT_RETURN_ERROR: return userret; default: fprintf(stderr, "ERROR: invalid return value from json_c_visit userfunc: %d\n", userret); return JSON_C_VISIT_RETURN_ERROR; } switch (json_object_get_type(jso)) { case json_type_null: case json_type_boolean: case json_type_double: case json_type_int: case json_type_string: // we already called userfunc above, move on to the next object return JSON_C_VISIT_RETURN_CONTINUE; case json_type_object: { json_object_object_foreach(jso, key, child) { userret = _json_c_visit(child, jso, key, NULL, userfunc, userarg); if (userret == JSON_C_VISIT_RETURN_POP) break; if (userret == JSON_C_VISIT_RETURN_STOP || userret == JSON_C_VISIT_RETURN_ERROR) return userret; if (userret != JSON_C_VISIT_RETURN_CONTINUE && userret != JSON_C_VISIT_RETURN_SKIP) { fprintf(stderr, "INTERNAL ERROR: _json_c_visit returned %d\n", userret); return JSON_C_VISIT_RETURN_ERROR; } } break; } case json_type_array: { size_t array_len = json_object_array_length(jso); size_t ii; for (ii = 0; ii < array_len; ii++) { json_object *child = json_object_array_get_idx(jso, ii); userret = _json_c_visit(child, jso, NULL, &ii, userfunc, userarg); if (userret == JSON_C_VISIT_RETURN_POP) break; if (userret == JSON_C_VISIT_RETURN_STOP || userret == JSON_C_VISIT_RETURN_ERROR) return userret; if (userret != JSON_C_VISIT_RETURN_CONTINUE && userret != JSON_C_VISIT_RETURN_SKIP) { fprintf(stderr, "INTERNAL ERROR: _json_c_visit returned %d\n", userret); return JSON_C_VISIT_RETURN_ERROR; } } break; } default: fprintf(stderr, "INTERNAL ERROR: _json_c_visit found object of unknown type: %d\n", json_object_get_type(jso)); return JSON_C_VISIT_RETURN_ERROR; } // Call userfunc for the second type on container types, after all // members of the container have been visited. // Non-container types will have already returned before this point. userret = userfunc(jso, JSON_C_VISIT_SECOND, parent_jso, jso_key, jso_index, userarg); switch (userret) { case JSON_C_VISIT_RETURN_SKIP: case JSON_C_VISIT_RETURN_POP: // These are not really sensible during JSON_C_VISIT_SECOND, // but map them to JSON_C_VISIT_CONTINUE anyway. // FALLTHROUGH case JSON_C_VISIT_RETURN_CONTINUE: return JSON_C_VISIT_RETURN_CONTINUE; case JSON_C_VISIT_RETURN_STOP: case JSON_C_VISIT_RETURN_ERROR: return userret; default: fprintf(stderr, "ERROR: invalid return value from json_c_visit userfunc: %d\n", userret); return JSON_C_VISIT_RETURN_ERROR; } // NOTREACHED }
93743db1f6df0a176e4ae6da02480434b6d67717
dfb59af794367d02891de53923aa3b67f7073472
/src/php/objects/php_priority_queue.h
e26434dffb342f9d2698eb3af531c8bac6a980b0
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
php-ds/ext-ds
b31df34b05ad14af53a0d23ba7a7a15437f4004a
d42750d69beb684ec3ef7b3da48fba769ce57ffc
refs/heads/master
2023-08-26T11:28:53.328205
2023-07-29T04:04:32
2023-07-29T04:04:32
50,824,235
625
40
MIT
2023-07-29T04:04:33
2016-02-01T08:05:07
C
UTF-8
C
false
false
1,640
h
php_priority_queue.h
#ifndef PHP_DS_PRIORITY_QUEUE_H #define PHP_DS_PRIORITY_QUEUE_H #include "../../ds/ds_priority_queue.h" typedef struct _php_ds_priority_queue_t { ds_priority_queue_t *queue; zval *gc_data; int gc_size; zend_object std; } php_ds_priority_queue_t; static inline php_ds_priority_queue_t *php_ds_priority_queue_fetch_object(zend_object *obj) { return (php_ds_priority_queue_t *)((char*)(obj) - XtOffsetOf(php_ds_priority_queue_t, std)); } #define Z_DS_PRIORITY_QUEUE(z) (php_ds_priority_queue_fetch_object(Z_OBJ(z))->queue) #define Z_DS_PRIORITY_QUEUE_P(z) Z_DS_PRIORITY_QUEUE(*z) #define THIS_DS_PRIORITY_QUEUE() Z_DS_PRIORITY_QUEUE_P(getThis()) #define ZVAL_DS_PRIORITY_QUEUE(z, queue) \ ZVAL_OBJ(z, (php_ds_priority_queue_create_object_ex(queue))) #define RETURN_DS_PRIORITY_QUEUE(queue) \ do { \ ds_priority_queue_t *_queue = queue; \ if (_queue) { \ ZVAL_DS_PRIORITY_QUEUE(return_value, _queue); \ } else { \ ZVAL_NULL(return_value); \ } \ return; \ } while(0) zend_object *php_ds_priority_queue_create_object_ex(ds_priority_queue_t *queue); zend_object *php_ds_priority_queue_create_object(zend_class_entry *ce); zend_object *php_ds_priority_queue_create_clone(ds_priority_queue_t *queue); PHP_DS_SERIALIZE_FUNCIONS(php_ds_priority_queue); #endif
cca8edd19494bf4f610347005e8237fcbb009069
dddb9237fb9ee58832488cb703c59bb5b9acec79
/Core/TomoP3DModelSino_core.c
e424fc716f1a09a96dd23532d7bef80175080b36
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "BSD-3-Clause", "GPL-3.0-only" ]
permissive
dkazanc/TomoPhantom
f9019e8e070f46c0e7575fc6696eca06c0cbfe11
6e3b949228ada2a549d1830c9bd79013552320cc
refs/heads/master
2022-11-07T19:07:29.467081
2022-10-12T08:34:47
2022-10-12T08:34:47
95,991,001
103
47
Apache-2.0
2022-10-12T08:34:48
2017-07-01T22:43:09
C
UTF-8
C
false
false
30,753
c
TomoP3DModelSino_core.c
/* * Copyright 2017 Daniil Kazantsev * * 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 "TomoP3DModelSino_core.h" #define M_PI 3.14159265358979323846 #define M_PI2 1.57079632679 #define EPS 0.000000001 #define MAXCHAR 1000 /* Function to create 3D analytical projection data (parallel beam geometry) for 3D models * * Input Parameters: * - ModelNo - the model number from Phantom3DLibrary file * - Horiz_det - the number of horizontal detectors * - Vert_det - - the number of vertical detectors * - N - the size of the Phantom (N x N x N), currently Vert_det must be set to N * - Theta_proj - a vector of projection anges in degrees * - C0 - intensity * - x0 - x0 position * - y0 - y0 position * - z0 - z0 position * - a - size object * - b - size object * - c - size object * - psi_gr1 - rotation angle1 * * Output: * 1. The analytical phantom size of [N1 x N2 x N3] or temporal 4D phantom (N1 x N2 x N3 x time-frames) * Note if Z1, Z2 indeces selected then the size can be [N1 x N2 x Z2-Z1] * */ float TomoP3DObjectSino_core(float *A, long Horiz_det, long Vert_det, long Z1, long Z2, long N, float *Theta_proj, int AngTot, char *Object, float C0, /* intensity */ float x0, /* x0 position */ float y0, /* y0 position */ float z0, /* z0 position */ float a, /* a - size object */ float b, /* b - size object */ float c, /* c - size object */ float psi_gr1, /* rotation angle1 */ float psi_gr2, /* rotation angle2 */ float psi_gr3, /* rotation angle3 */ long tt /*temporal index, 0 - for stationary */) { int ll; long long i, j, k, sub_vol_size; size_t index; float *DetectorRange_Horiz_ar=NULL, DetectorRange_Horiz_min, DetectorRange_Horiz_max, *DetectorRange_Vert_ar=NULL, DetectorRange_Vert_min, DetectorRange_Vert_max, U_step, V_step, a22, b22, c2, *Tomorange_Z_Ar = NULL, *Zdel = NULL; float *AnglesRad=NULL; float Tomorange_Xmin, Tomorange_Xmax, H_x, multiplier, x00, y00, z00, a2, b2; DetectorRange_Horiz_max = (float)(Horiz_det)/(float)(N+1); /* horizontal detector range */ DetectorRange_Horiz_min = -DetectorRange_Horiz_max; /* Here assuming that the size of the vertical detector array is always equal to Z-dim of the phantom */ DetectorRange_Vert_max = (float)(Vert_det)/(float)(N+1); /* vertical detector range */ DetectorRange_Vert_min = -DetectorRange_Vert_max; DetectorRange_Horiz_ar = malloc(Horiz_det*sizeof(float)); /* horizontal array */ DetectorRange_Vert_ar = malloc(Vert_det*sizeof(float)); /* vertical array */ U_step = (DetectorRange_Horiz_max - DetectorRange_Horiz_min)/(float)(Horiz_det-1); V_step = (DetectorRange_Vert_max - DetectorRange_Vert_min)/(float)(Vert_det-1); for(i=0; i<Horiz_det; i++) {DetectorRange_Horiz_ar[i] = (DetectorRange_Horiz_max) - (float)i*U_step;} for(i=0; i<Vert_det; i++) {DetectorRange_Vert_ar[i] = (DetectorRange_Vert_max) - (float)i*V_step;} sub_vol_size = Z2 - Z1; Tomorange_Xmin = -1.0f; Tomorange_Xmax = 1.0f; H_x = (Tomorange_Xmax - Tomorange_Xmin)/(float)(N); Tomorange_Z_Ar = malloc(N * sizeof(float)); for (i = 0; i<N; i++) { Tomorange_Z_Ar[i] = Tomorange_Xmin + (float)i*H_x; } Zdel = malloc(N * sizeof(float)); for (i = 0; i<N; i++) Zdel[i] = Tomorange_Z_Ar[i] - z0; /* convert to radians */ AnglesRad = malloc(AngTot*sizeof(float)); for(ll=0; ll<AngTot; ll++) AnglesRad[ll] = (Theta_proj[ll])*((float)M_PI/180.0f); float alog2 = logf(2.0f); multiplier = (C0*(N/2.0f)); float RS = 1.0f; /*Angles: TETA1, PSIs, FI1 ? */ float TETAs, TETA1, FIs, FI1, PSI1, PSIs; float psi1, psi2, psi3; psi_gr1 = psi_gr1 + 90.0f; psi_gr2 = psi_gr2 + 90.0f; psi1 = psi_gr1*((float)M_PI/180.0f); psi2 = psi_gr2*((float)M_PI/180.0f); psi3 = psi_gr3*((float)M_PI/180.0f); float xwid=0.0f,ywid=0.0f,p00,ksi00,ksi1=0.0f; /* cuboid-related */ float p,ksi,C,S,A2,B2,FI,CF,SF,P0,TF,PC,QM,DEL,XSYC,QP,SS,x11=0.0f,y11=0.0f; /* fix for centering */ x00 = x0 + 0.5f*H_x; y00 = y0 - 0.5f*H_x; z00 = z0 - 0.5f*H_x; /* parameters of an object have been extracted, now run the building module */ /************************************************/ if (strcmp("gaussian",Object) == 0) { a = 0.5f*a; b = 0.5f*b; c = 0.5f*c; } a22 = a*a; b22 = b*b; a2 = 1.0f/(a22); b2 = 1.0f/(b22); c2 = 1.0f/(c*c); float xh[3] = {0.0f, 0.0f, 0.0f}; float xh1[3] = {0.0f, 0.0f, 0.0f}; float vh1[3] = {0.0f, 0.0f, 0.0f}; float aa[3] = {0.0f, 0.0f, 0.0f}; float aa1[3] = {0.0f, 0.0f, 0.0f}; float al[3] = {0.0f, 0.0f, 0.0f}; float ai[3][3] = { {0.0f,0.0f,0.0f}, {0.0f,0.0f,0.0f}, {0.0f,0.0f,0.0f} }; float bs[3][3] = { {0.0f,0.0f,0.0f}, {0.0f,0.0f,0.0f}, {0.0f,0.0f,0.0f} }; float bsai[3][3] = { {0.0f,0.0f,0.0f}, {0.0f,0.0f,0.0f}, {0.0f,0.0f,0.0f} }; matrot3(bs,psi1,psi2,psi3); /* rotation of 3x3 matrix */ xh1[0] = x00; xh1[1] = y00; xh1[2] = z00; matvet3(bs,xh1,xh); /* matrix-vector multiplication */ float a_v, b_v, c_v, d_v, p1, p2, alh, bth, gmh; if (strcmp("cuboid",Object) == 0) { /* the object is a cuboid */ x11 = 2.0f*x0; y11 = 2.0f*y0 + 1.0f*H_x; xwid = b; ywid = a; c2 = 0.5f*c; if (psi3 < 0) {ksi1 = (float)M_PI + psi3;} else ksi1 = psi3; } float AA5, sin_2, cos_2, delta1, delta_sq, first_dr, AA2, AA3, AA6; AA5 = (N*C0*a*b); /*printf("%s %f %f %f %f %f %f %f %f %f %f %ld\n", Object, C0, x0, y0, z0, a, b, c, psi_gr1, psi_gr2, psi_gr3, tt);*/ #pragma omp parallel for shared(A) private(index,k,j,ll,TETAs,FIs,PSIs,aa1,aa,FI1,TETA1,PSI1,ai,bsai,vh1,al,a_v,b_v,c_v,d_v,p1,p2,alh,bth,gmh,sin_2, cos_2,delta1,delta_sq,first_dr, AA2, AA3, AA6, p00,ksi00,p,ksi,C,S,A2,B2,FI,CF,SF,P0,TF,PC,QM,DEL,XSYC,QP,SS) for(ll=0; ll<AngTot; ll++) { TETAs = AnglesRad[ll]; /* the variable projection angle (AnglesRad) */ TETA1 = TETAs - M_PI2; FIs = 0.0f; /* always zero for the fixed source? */ PSIs = 0.0f; /* always zero for the fixed source? */ aa1[0]=-RS*sinf(TETAs)*cosf(FIs); aa1[1]=-RS*sinf(TETAs)*sinf(FIs); aa1[2]=-RS*cosf(TETAs); matvet3(bs,aa1,aa); /* matrix-vector multiplication */ /* calculation of inverse matrix */ FI1=-FIs; TETA1=-TETA1; PSI1=-PSIs; matrot3(ai,PSI1,TETA1,FI1); /* rotation of 3x3 matrix */ /* A transform matrix from projection space to object space */ matmat3(bs,ai,bsai); vh1[0]=0.0f; /* the object is an ellipsoid */ for(j=0; j<Horiz_det; j++) { // for(k=0; k<Vert_det; k++) { for(k=Z1; k<Z2; k++) { //index = tt*Vert_det*Horiz_det*AngTot + ll*Vert_det*Horiz_det + k*Horiz_det + j; index = (size_t)tt*Horiz_det*AngTot*sub_vol_size + (size_t)ll*sub_vol_size*Horiz_det + (size_t)((k - Z1)*Horiz_det + j); vh1[2]=DetectorRange_Horiz_ar[j]; vh1[1]=DetectorRange_Vert_ar[k]; matvet3(bsai,vh1,al); /*matrix-vector multiplication */ if (strcmp("ellipsoid",Object) == 0) { a_v = powf((aa[0]/a),2) + powf((aa[1]/b),2) + powf((aa[2]/c),2); b_v = aa[0]*(al[0]-xh[0])*a2 + aa[1]*(al[1]-xh[1])*b2 + aa[2]*(al[2]-xh[2])*c2; c_v = powf(((al[0]-xh[0])/a),2) + powf(((al[1]-xh[1])/b), 2) + powf(((al[2]-xh[2])/c),2) - 1.0f; d_v = b_v*b_v - a_v*c_v; if(d_v > 0) { p1 = -(sqrtf(d_v)+b_v)/a_v; p2 = (sqrtf(d_v)-b_v)/a_v; A[index] += (p2-p1)*multiplier; } } if (strcmp("paraboloid",Object) == 0) { /* the object is a parabola Lambda = 1 */ a_v = powf((aa[0]/a),2) + powf((aa[1]/b),2) + powf((aa[2]/c),2); b_v = aa[0]*(al[0]-xh[0])*a2 + aa[1]*(al[1]-xh[1])*b2 + aa[2]*(al[2]-xh[2])*c2; c_v = powf(((al[0]-xh[0])/a),2) + powf(((al[1]-xh[1])/b), 2) + powf(((al[2]-xh[2])/c),2) - 1.0f; d_v = b_v*b_v - a_v*c_v; if(d_v > 0) { p1 = -(sqrtf(d_v)+b_v)/a_v; p2 = (sqrtf(d_v)-b_v)/a_v; A[index] += multiplier*(a_v/3.0f*(pow(p1,3.0f) - pow(p2,3.0f)) + b_v*(pow(p1,2.0f) - pow(p2,2.0f)) + c_v*(p1-p2)); } } if (strcmp("gaussian",Object) == 0) { /* The object is a volumetric gaussian */ alh=alog2*a2; bth=alog2*b2; gmh=alog2*c2; a_v = 1.0f/(alh*powf((aa[0]),2) + bth*powf((aa[1]),2) + gmh*powf((aa[2]),2)); b_v = aa[0]*alh*(al[0]-xh[0]) + aa[1]*bth*(al[1]-xh[1]) + aa[2]*gmh*(al[2]-xh[2]); c_v = alh*powf(((al[0]-xh[0])),2) + bth*powf(((al[1]-xh[1])),2) + gmh*powf(((al[2]-xh[2])),2); A[index] += multiplier*sqrtf(M_PI*a_v)*expf((pow(b_v,2))*a_v-c_v); } }} /*main for j-k loop*/ if (strcmp("elliptical_cylinder",Object) == 0) { sin_2 = powf((sinf(TETAs - psi3)),2); cos_2 = powf((cosf(TETAs - psi3)),2); delta1 = 1.0f/(a22*sin_2 + b22*cos_2); delta_sq = sqrtf(delta1); first_dr = AA5*delta_sq; AA2 = -x00*sinf(TETAs) + y00*cosf(TETAs); for(k=Z1; k<Z2; k++) { if (fabs(Zdel[k]) < c) { for(j=0; j<Horiz_det; j++) { AA3 = powf((DetectorRange_Horiz_ar[j] - AA2),2); AA6 = (AA3)*delta1; //index = tt*Vert_det*Horiz_det*AngTot + ll*Vert_det*Horiz_det + k*Horiz_det + j; index = tt*sub_vol_size*Horiz_det*AngTot + ll*sub_vol_size*Horiz_det + (k - Z1)*Horiz_det + j; if (AA6 < 1.0f) A[index] += first_dr*sqrtf(1.0f - AA6); } } } } if (strcmp("cuboid",Object) == 0) { /* the object is a cuboid */ ksi00 = AnglesRad[(AngTot-1)-ll]; for(k=Z1; k<Z2; k++) { if (fabs(Zdel[k]) < c2) { for(j=0; j< Horiz_det; j++) { p00 = DetectorRange_Horiz_ar[j]; index = tt*sub_vol_size*Horiz_det*AngTot + ll*sub_vol_size*Horiz_det + (k - Z1)*Horiz_det + j; p = p00; ksi=ksi00; if (ksi > (float)M_PI) { ksi = ksi - (float)M_PI; p = -p00; } C = cosf(ksi); S = sinf(ksi); XSYC = -x11*S + y11*C; A2 = xwid*0.5f; B2 = ywid*0.5f; if ((ksi - ksi1) < 0.0f) FI = (float)M_PI + ksi - ksi1; else FI = ksi - ksi1; if (FI > M_PI2) FI = (float)M_PI - FI; CF = cosf(FI); SF = sinf(FI); P0 = fabs(p-XSYC); SS = xwid/CF*C0; if (fabs(CF) <= (float)EPS) { SS = ywid*C0; if ((P0 - A2) > (float)EPS) SS=0.0f; } if (fabs(SF) <= (float)EPS) { SS = xwid*C0; if ((P0 - B2) > (float)EPS) SS=0.0f; } TF = SF/CF; PC = P0/CF; QP = B2+A2*TF; QM = QP+PC; if (QM > ywid) { DEL = P0+B2*CF; SS = ywid/SF*C0; if (DEL > (A2*SF)) SS = (QP-PC)/SF*C0; } if (QM > ywid) { DEL = P0+B2*CF; if (DEL > A2*SF) SS = (QP-PC)/SF*C0; else SS = ywid/SF*C0; } else SS = xwid/CF*C0; if (PC >= QP) SS=0.0f; A[index] += (N/2.0f)*SS; } /*j-loop*/ } } /*k-loop*/ } } /************************************************/ free(AnglesRad); free(DetectorRange_Horiz_ar); free(DetectorRange_Vert_ar); free(Tomorange_Z_Ar); free(Zdel); return *A; } /********************Core Function*****************************/ float TomoP3DModelSino_core(float *A, int ModelSelected, long Horiz_det, long Vert_det, long Z1, long Z2, long N, float *Angl_vector, int AngTot, char* ModelParametersFilename) { int Model = 0, Components = 0, steps = 0, counter = 0, ii; float C0 = 0.0f, x0 = 0.0f, y0 = 0.0f, z0 = 0.0f, a = 0.0f, b = 0.0f, c = 0.0f, psi_gr1 = 0.0f, psi_gr2 = 0.0f, psi_gr3 = 0.0f; FILE *fp = fopen(ModelParametersFilename, "r"); // read parameters file if (fp == NULL) { printf("%s \n", "Cannot open the file"); } else { char str[MAXCHAR]; char tmpstr1[16]; char tmpstr2[22]; char tmpstr3[16]; char tmpstr4[16]; char tmpstr5[16]; char tmpstr6[16]; char tmpstr7[16]; char tmpstr8[16]; char tmpstr9[16]; char tmpstr10[16]; char tmpstr11[16]; char tmpstr12[16]; while (fgets(str, MAXCHAR, fp) != NULL) { /* work with non-# commented lines */ if (str[0] != '#') { sscanf(str, "%15s : %21[^;];", tmpstr1, tmpstr2); if (strcmp(tmpstr1, "Model") == 0) { Model = atoi(tmpstr2); if ((ModelSelected == Model) && (counter == 0)) { /* check if we have a right model */ if (fgets(str, MAXCHAR, fp) != NULL) sscanf(str, "%15s : %21[^;];", tmpstr1, tmpstr2); else { break; } if (strcmp(tmpstr1, "Components") == 0) Components = atoi(tmpstr2); //printf("%s %i\n", "Components:", Components); if (Components <= 0) { printf("%s %i\n", "Components cannot be negative, the given value is", Components); break; } if (fgets(str, MAXCHAR, fp) != NULL) sscanf(str, "%15s : %21[^;];", tmpstr1, tmpstr2); else { break; } if (strcmp(tmpstr1, "TimeSteps") == 0) steps = atoi(tmpstr2); if (steps <= 0) { printf("%s %i\n", "TimeSteps cannot be negative, the given value is", steps); break; } //printf("%s %i\n", "TimeSteps:", steps); if (steps == 1) { /**************************************************/ //printf("\n %s %i %s \n", "Stationary 3D model", ModelSelected, " is selected"); /* loop over all components */ for (ii = 0; ii<Components; ii++) { if (fgets(str, MAXCHAR, fp) != NULL) sscanf(str, "%15s : %21s %15s %15s %15s %15s %15s %15s %15s %15s %15s %15[^;];", tmpstr1, tmpstr2, tmpstr3, tmpstr4, tmpstr5, tmpstr6, tmpstr7, tmpstr8, tmpstr9, tmpstr10, tmpstr11, tmpstr12); else { break; } if (strcmp(tmpstr1, "Object") == 0) { C0 = (float)atof(tmpstr3); /* intensity */ x0 = (float)atof(tmpstr4); /* x0 position */ y0 = (float)atof(tmpstr5); /* y0 position */ z0 = (float)atof(tmpstr6); /* z0 position */ a = (float)atof(tmpstr7); /* a - size object */ b = (float)atof(tmpstr8); /* b - size object */ c = (float)atof(tmpstr9); /* c - size object */ psi_gr1 = (float)atof(tmpstr10); /* rotation angle 1*/ psi_gr2 = (float)atof(tmpstr11); /* rotation angle 2*/ psi_gr3 = (float)atof(tmpstr12); /* rotation angle 3*/ } else { break; } // printf("\nObject : %s \nC0 : %f \nx0 : %f \ny0 : %f \nz0 : %f \na : %f \nb : %f \nc : %f \n", tmpstr2, C0, x0, y0, z0, a, b, c); if ((strcmp("gaussian",tmpstr2) == 0) || (strcmp("paraboloid",tmpstr2) == 0) || (strcmp("ellipsoid",tmpstr2) == 0)) { TomoP3DObjectSino_core(A, Horiz_det, Vert_det, Z1, Z2, N, Angl_vector, AngTot, tmpstr2, C0, y0, -z0, -x0, b, a, c, psi_gr3, psi_gr2, psi_gr1, 0l); //python } else if (strcmp("elliptical_cylinder",tmpstr2) == 0) { TomoP3DObjectSino_core(A, Horiz_det, Vert_det, Z1, Z2, N, Angl_vector, AngTot, tmpstr2, C0, x0, -y0, z0, b, a, c, psi_gr3, psi_gr2, psi_gr1, 0l); //python } else { TomoP3DObjectSino_core(A, Horiz_det, Vert_det, Z1, Z2, N, Angl_vector, AngTot, tmpstr2, C0, x0, y0, z0, a, b, c, psi_gr3, psi_gr2, -psi_gr1, 0l); //python } } } else { /**************************************************/ //printf("\n %s \n", "Temporal model is selected"); /* temporal phantom 3D + time (4D) */ float C1 = 0.0f, x1 = 0.0f, y1 = 0.0f, z1 = 0.0f, a1 = 0.0f, b1 = 0.0f, c1 = 0.0f, psi_gr1_1 = 0.0f, psi_gr2_1 = 0.0f, psi_gr3_1 = 0.0f; /* loop over all components */ for (ii = 0; ii<Components; ii++) { if (fgets(str, MAXCHAR, fp) != NULL) sscanf(str, "%15s : %21s %15s %15s %15s %15s %15s %15s %15s %15s %15s %15[^;];", tmpstr1, tmpstr2, tmpstr3, tmpstr4, tmpstr5, tmpstr6, tmpstr7, tmpstr8, tmpstr9, tmpstr10, tmpstr11, tmpstr12); else { break; } if (strcmp(tmpstr1, "Object") == 0) { C0 = (float)atof(tmpstr3); /* intensity */ x0 = (float)atof(tmpstr4); /* x0 position */ y0 = (float)atof(tmpstr5); /* y0 position */ z0 = (float)atof(tmpstr6); /* y0 position */ a = (float)atof(tmpstr7); /* a - size object */ b = (float)atof(tmpstr8); /* b - size object */ c = (float)atof(tmpstr9); /* b - size object */ psi_gr1 = (float)atof(tmpstr10); /* rotation angle 1*/ psi_gr2 = (float)atof(tmpstr11); /* rotation angle 2*/ psi_gr3 = (float)atof(tmpstr12); /* rotation angle 3*/ } else { break; } // printf("\nObject : %s \nC0 : %f \nx0 : %f \ny0 : %f \nz0 : %f \na : %f \nb : %f \n", tmpstr2, C0, x0, y0, z0, a, b, c); /* check Endvar relatedparameters */ if (fgets(str, MAXCHAR, fp) != NULL) sscanf(str, "%15s : %15s %15s %15s %15s %15s %15s %15s %15s %15s %15[^;];", tmpstr1, tmpstr3, tmpstr4, tmpstr5, tmpstr6, tmpstr7, tmpstr8, tmpstr9, tmpstr10, tmpstr11, tmpstr12); else break; if (strcmp(tmpstr1, "Endvar") == 0) { C1 = (float)atof(tmpstr3); /* intensity */ x1 = (float)atof(tmpstr4); /* x0 position */ y1 = (float)atof(tmpstr5); /* y0 position */ z1 = (float)atof(tmpstr6); /* z0 position */ a1 = (float)atof(tmpstr7); /* a - size object */ b1 = (float)atof(tmpstr8); /* b - size object */ c1 = (float)atof(tmpstr9); /* c - size object */ psi_gr1_1 = (float)atof(tmpstr10); /* rotation angle 1*/ psi_gr2_1 = (float)atof(tmpstr11); /* rotation angle 2*/ psi_gr3_1 = (float)atof(tmpstr12); /* rotation angle 3*/ } else { printf("%s\n", "Cannot find 'Endvar' string in parameters file"); break; } //printf("\nObject : %s \nC0 : %f \nx0 : %f \ny0 : %f \nz0 : %f \na : %f \nb : %f \nc : %f \n", tmpstr2, C0, x0, y0, z0, a1, b1, c1); /*now we know the initial parameters of the object and the final ones. We linearly extrapolate to establish steps and coordinates. */ /* calculating the full distance berween the start and the end points */ float distance = sqrtf(pow((x1 - x0), 2) + pow((y1 - y0), 2) + pow((z1 - z0), 2)); float d_dist = distance / (steps - 1); /*a step over line */ float C_step = (C1 - C0) / (steps - 1); float a_step = (a1 - a) / (steps - 1); float b_step = (b1 - b) / (steps - 1); float c_step = (c1 - c) / (steps - 1); float phi_rot_step1 = (psi_gr1_1 - psi_gr1) / (steps - 1); float phi_rot_step2 = (psi_gr2_1 - psi_gr2) / (steps - 1); float phi_rot_step3 = (psi_gr3_1 - psi_gr3) / (steps - 1); long tt; float x_t, y_t, z_t, a_t, b_t, c_t, C_t, phi1_t, phi2_t, phi3_t, d_step; /* initialize */ x_t = x0; y_t = y0; z_t = z0; a_t = a; b_t = b; c_t = c; C_t = C0; phi1_t = psi_gr1; phi2_t = psi_gr2; phi3_t = psi_gr3; d_step = d_dist; /*loop over time frames*/ for (tt = 0; tt < (long)steps; tt++) { if ((strcmp("gaussian",tmpstr2) == 0) || (strcmp("paraboloid",tmpstr2) == 0) || (strcmp("ellipsoid",tmpstr2) == 0)) { TomoP3DObjectSino_core(A, Horiz_det, Vert_det, Z1, Z2, N, Angl_vector, AngTot, tmpstr2, C_t, y_t, -z_t, -x_t, b_t, a_t, c_t, phi3_t, phi2_t, phi1_t, tt); //python } else if (strcmp("elliptical_cylinder",tmpstr2) == 0) { TomoP3DObjectSino_core(A, Horiz_det, Vert_det, Z1, Z2, N, Angl_vector, AngTot, tmpstr2, C_t, x_t, -y_t, z_t, b_t, a_t, c_t, phi3_t, phi2_t, phi1_t, tt); //python } else { TomoP3DObjectSino_core(A, Horiz_det, Vert_det, Z1, Z2, N, Angl_vector, AngTot, tmpstr2, C_t, x_t, y_t, z_t, a_t, b_t, c_t, phi3_t, phi2_t, -phi1_t, tt); //python } /* calculating new coordinates of an object */ if (distance != 0.0f) { float t = d_step / distance; x_t = (1 - t)*x0 + t*x1; y_t = (1 - t)*y0 + t*y1; z_t = (1 - t)*z0 + t*z1; } else { x_t = x0; y_t = y0; z_t = z0; } d_step += d_dist; a_t += a_step; b_t += b_step; c_t += c_step; C_t += C_step; phi1_t += phi_rot_step1; phi2_t += phi_rot_step2; phi3_t += phi_rot_step3; } /*time steps*/ } /*components loop*/ } counter++; } } } } } fclose(fp); return *A; }
c6867759180b040bed9772150a7f397c524f0424
36a92ec73c174daf7d1cd05d20dc7e1baa7ed831
/fast-models-examples/GICv3.x_GICv4.x_example/src/main_gicv31.c
a8cb6b228ae49048170acf20b5b632bde19efaba
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
ARM-software/Tool-Solutions
88d941367949c5f491ee73d3413d17cc8bc834ff
04545fbffcae472b7d880bb0453e118fb2885e95
refs/heads/main
2023-09-02T00:15:57.634633
2023-08-18T11:00:28
2023-08-18T12:33:44
155,524,900
241
149
Apache-2.0
2023-09-12T09:27:14
2018-10-31T08:39:51
C
WINDOWS-1258
C
false
false
4,885
c
main_gicv31.c
// Example of using the Generic Timer in AArch64 // // Copyright (C) Arm Limited, 2019 All rights reserved. // // The example code is provided to you as an aid to learning when working // with Arm-based technology, including but not limited to programming tutorials. // Arm hereby grants to you, subject to the terms and conditions of this Licence, // a non-exclusive, non-transferable, non-sub-licensable, free-of-charge licence, // to use and copy the Software solely for the purpose of demonstration and // evaluation. // // You accept that the Software has not been tested by Arm therefore the Software // is provided “as is”, without warranty of any kind, express or implied. In no // event shall the authors or copyright holders be liable for any claim, damages // or other liability, whether in action or contract, tort or otherwise, arising // from, out of or in connection with the Software or the use of Software. // // ------------------------------------------------------------ #include <stdio.h> #include "gicv3_basic.h" extern uint32_t getAffinity(void); uint32_t initGIC(void); uint32_t checkGICModel(void); volatile unsigned int flag; // -------------------------------------------------------- #define DIST_BASE_ADDR (0x2F000000) #define RD_BASE_ADDR (0x2F100000) // -------------------------------------------------------- int main(void) { uint64_t current_time; uint32_t rd, affinity; affinity = getAffinity(); // // Configure the interrupt controller // rd = initGIC(); // Check that the model has been launched with the correct configuration if (checkGICModel() != 0) return 1; // // Configure interrupt sources // // GICv3.1 Extended PPI range (INTID 1056) setIntPriority(1056, rd, 0); setIntGroup(1056, rd, GICV3_GROUP0); enableInt(1056, rd); // GICv3.1 Extended SPI range (INTID 4096) setIntPriority(4096, 0, 0); setIntGroup(4096, 0, GICV3_GROUP0); setIntRoute(4096, GICV3_ROUTE_MODE_COORDINATE, affinity); setIntType(4096, 0, GICV3_CONFIG_EDGE); enableInt(4096, 0); // // Trigger PPI in GICv3.1 extended range // // Setting the interrupt as pending manually, as the // Base Platform model does not have a peripheral // connected within this range setIntPending(1056, rd); // // Trigger SPI in GICv3.1 extended range // // Setting the interrupt as pending manually, as the // Base Platform model does not have a peripheral // connected within this range setIntPending(4096, 0); // NOTE: // This code assumes that the IRQ and FIQ exceptions // have been routed to the appropriate Exception level // and that the PSTATE masks are clear. In this example // this is done in the startup.s file // // Spin until interrupt // while(flag < 2) {} printf("Main(): Test end\n"); return 1; } // -------------------------------------------------------- void fiqHandler(void) { unsigned int ID; // Read the IAR to get the INTID of the interrupt taken ID = readIARGrp0(); printf("FIQ: Received INTID %d\n", ID); switch (ID) { case 1023: printf("FIQ: Interrupt was spurious\n"); return; case 1056: printf("FIQ: GICv3.1 extended PPI range interrupt\n"); break; case 4096: printf("FIQ: GICv3.1 extended SPI range interrupt\n"); // No need to clear the interrut, as we configured it as edge-triggered break; default: printf("FIQ: Panic, unexpected INTID\n"); } // Write EOIR to deactivate interrupt writeEOIGrp0(ID); flag++; return; } // -------------------------------------------------------- uint32_t initGIC(void) { uint32_t rd; // Set location of GIC setGICAddr((void*)DIST_BASE_ADDR, (void*)RD_BASE_ADDR); // Enable GIC enableGIC(); // Get the ID of the Redistributor connected to this PE rd = getRedistID(getAffinity()); // Mark this core as beign active wakeUpRedist(rd); // Configure the CPU interface // This assumes that the SRE bits are already set setPriorityMask(0xFF); enableGroup0Ints(); enableGroup1Ints(); enableNSGroup1Ints(); // This call only works as example runs at EL3 return rd; } // -------------------------------------------------------- uint32_t checkGICModel(void) { // Check that the GICv3.1 extended PPI range is implemented if (getExtPPI(0) == 32) { printf("checkGICModel() - GICR_TYPER.PPInum reports no extended PPI support.\n"); return 1; } // Check that the GICv3.1 extended SPI range is implemented if (getExtSPI() == 0) { printf("checkGICModel() - GICD_TYPER.ESPI reports no extended SPI support.\n"); return 1; } return 0; }
d57afb69130ec3ddf4dcd6006c46948cf7ac97eb
50dd46b8ece33f3cdd174284b15d1d51f89669d4
/third_party/edk2/OvmfPkg/XenBusDxe/XenStore.c
6812e1078cd88d2a7eda1c0a5da7392548160064
[ "MIT", "BSD-2-Clause", "LicenseRef-scancode-generic-cla", "Apache-2.0", "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
42,066
c
XenStore.c
/** @file Low-level kernel interface to the XenStore. The XenStore interface is a simple storage system that is a means of communicating state and configuration data between the Xen Domain 0 and the various guest domains. All configuration data other than a small amount of essential information required during the early boot process of launching a Xen aware guest, is managed using the XenStore. The XenStore is ASCII string based, and has a structure and semantics similar to a filesystem. There are files and directories, the directories able to contain files or other directories. The depth of the hierarchy is only limited by the XenStore's maximum path length. The communication channel between the XenStore service and other domains is via two, guest specific, ring buffers in a shared memory area. One ring buffer is used for communicating in each direction. The grant table references for this shared memory are given to the guest either via the xen_start_info structure for a fully para- virtualized guest, or via HVM hypercalls for a hardware virtualized guest. The XenStore communication relies on an event channel and thus interrupts. But under OVMF this XenStore client will pull the state of the event channel. Several Xen services depend on the XenStore, most notably the XenBus used to discover and manage Xen devices. Copyright (C) 2005 Rusty Russell, IBM Corporation Copyright (C) 2009,2010 Spectra Logic Corporation Copyright (C) 2014, Citrix Ltd. This file may be distributed separately from the Linux kernel, or incorporated into other software packages, subject to the following license: Permission is hereby granted, free of charge, to any person obtaining a copy of this source file (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 "XenStore.h" #include <Library/PrintLib.h> #include <IndustryStandard/Xen/hvm/params.h> #include "EventChannel.h" #include <Library/XenHypercallLib.h> // // Private Data Structures // typedef struct { CONST VOID *Data; UINT32 Len; } WRITE_REQUEST; /* Register callback to watch subtree (node) in the XenStore. */ #define XENSTORE_WATCH_SIGNATURE SIGNATURE_32 ('X','S','w','a') struct _XENSTORE_WATCH { UINT32 Signature; LIST_ENTRY Link; /* Path being watched. */ CHAR8 *Node; }; #define XENSTORE_WATCH_FROM_LINK(l) \ CR (l, XENSTORE_WATCH, Link, XENSTORE_WATCH_SIGNATURE) /** * Structure capturing messages received from the XenStore service. */ #define XENSTORE_MESSAGE_SIGNATURE SIGNATURE_32 ('X', 'S', 's', 'm') typedef struct { UINT32 Signature; LIST_ENTRY Link; struct xsd_sockmsg Header; union { /* Queued replies. */ struct { CHAR8 *Body; } Reply; /* Queued watch events. */ struct { XENSTORE_WATCH *Handle; CONST CHAR8 **Vector; UINT32 VectorSize; } Watch; } u; } XENSTORE_MESSAGE; #define XENSTORE_MESSAGE_FROM_LINK(r) \ CR (r, XENSTORE_MESSAGE, Link, XENSTORE_MESSAGE_SIGNATURE) /** * Container for all XenStore related state. */ typedef struct { /** * Pointer to shared memory communication structures allowing us * to communicate with the XenStore service. */ struct xenstore_domain_interface *XenStore; XENBUS_DEVICE *Dev; /** * A list of replies to our requests. * * The reply list is filled by xs_rcv_thread(). It * is consumed by the context that issued the request * to which a reply is made. The requester blocks in * XenStoreReadReply (). * * /note Only one requesting context can be active at a time. */ LIST_ENTRY ReplyList; /** Lock protecting the reply list. */ EFI_LOCK ReplyLock; /** * List of registered watches. */ LIST_ENTRY RegisteredWatches; /** Lock protecting the registered watches list. */ EFI_LOCK RegisteredWatchesLock; /** * List of pending watch callback events. */ LIST_ENTRY WatchEvents; /** Lock protecting the watch calback list. */ EFI_LOCK WatchEventsLock; /** * The event channel for communicating with the * XenStore service. */ evtchn_port_t EventChannel; /** Handle for XenStore events. */ EFI_EVENT EventChannelEvent; } XENSTORE_PRIVATE; // // Global Data // static XENSTORE_PRIVATE xs; // // Private Utility Functions // /** Count and optionally record pointers to a number of NUL terminated strings in a buffer. @param Strings A pointer to a contiguous buffer of NUL terminated strings. @param Len The length of the buffer pointed to by strings. @param Dst An array to store pointers to each string found in strings. @return A count of the number of strings found. **/ STATIC UINT32 ExtractStrings ( IN CONST CHAR8 *Strings, IN UINTN Len, OUT CONST CHAR8 **Dst OPTIONAL ) { UINT32 Num = 0; CONST CHAR8 *Ptr; for (Ptr = Strings; Ptr < Strings + Len; Ptr += AsciiStrSize (Ptr)) { if (Dst != NULL) { *Dst++ = Ptr; } Num++; } return Num; } /** Convert a contiguous buffer containing a series of NUL terminated strings into an array of pointers to strings. The returned pointer references the array of string pointers which is followed by the storage for the string data. It is the client's responsibility to free this storage. The storage addressed by Strings is free'd prior to Split returning. @param Strings A pointer to a contiguous buffer of NUL terminated strings. @param Len The length of the buffer pointed to by strings. @param NumPtr The number of strings found and returned in the strings array. @return An array of pointers to the strings found in the input buffer. **/ STATIC CONST CHAR8 ** Split ( IN CHAR8 *Strings, IN UINTN Len, OUT UINT32 *NumPtr ) { CONST CHAR8 **Dst; ASSERT(NumPtr != NULL); ASSERT(Strings != NULL); /* Protect against unterminated buffers. */ if (Len > 0) { Strings[Len - 1] = '\0'; } /* Count the Strings. */ *NumPtr = ExtractStrings (Strings, Len, NULL); /* Transfer to one big alloc for easy freeing by the caller. */ Dst = AllocatePool (*NumPtr * sizeof (CHAR8 *) + Len); CopyMem ((VOID*)&Dst[*NumPtr], Strings, Len); FreePool (Strings); /* Extract pointers to newly allocated array. */ Strings = (CHAR8 *) &Dst[*NumPtr]; ExtractStrings (Strings, Len, Dst); return (Dst); } /** Convert from watch token (unique identifier) to the associated internal tracking structure for this watch. @param Tocken The unique identifier for the watch to find. @return A pointer to the found watch structure or NULL. **/ STATIC XENSTORE_WATCH * XenStoreFindWatch ( IN CONST CHAR8 *Token ) { XENSTORE_WATCH *Watch, *WantedWatch; LIST_ENTRY *Entry; WantedWatch = (VOID *) AsciiStrHexToUintn (Token); if (IsListEmpty (&xs.RegisteredWatches)) { return NULL; } for (Entry = GetFirstNode (&xs.RegisteredWatches); !IsNull (&xs.RegisteredWatches, Entry); Entry = GetNextNode (&xs.RegisteredWatches, Entry)) { Watch = XENSTORE_WATCH_FROM_LINK (Entry); if (Watch == WantedWatch) return Watch; } return NULL; } // // Public Utility Functions // API comments for these methods can be found in XenStore.h // CHAR8 * XenStoreJoin ( IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node ) { CHAR8 *Buf; UINTN BufSize; /* +1 for '/' and +1 for '\0' */ BufSize = AsciiStrLen (DirectoryPath) + AsciiStrLen (Node) + 2; Buf = AllocatePool (BufSize); ASSERT (Buf != NULL); if (Node[0] == '\0') { AsciiSPrint (Buf, BufSize, "%a", DirectoryPath); } else { AsciiSPrint (Buf, BufSize, "%a/%a", DirectoryPath, Node); } return Buf; } // // Low Level Communication Management // /** Verify that the indexes for a ring are valid. The difference between the producer and consumer cannot exceed the size of the ring. @param Cons The consumer index for the ring to test. @param Prod The producer index for the ring to test. @retval TRUE If indexes are in range. @retval FALSE If the indexes are out of range. **/ STATIC BOOLEAN XenStoreCheckIndexes ( XENSTORE_RING_IDX Cons, XENSTORE_RING_IDX Prod ) { return ((Prod - Cons) <= XENSTORE_RING_SIZE); } /** Return a pointer to, and the length of, the contiguous free region available for output in a ring buffer. @param Cons The consumer index for the ring. @param Prod The producer index for the ring. @param Buffer The base address of the ring's storage. @param LenPtr The amount of contiguous storage available. @return A pointer to the start location of the free region. **/ STATIC VOID * XenStoreGetOutputChunk ( IN XENSTORE_RING_IDX Cons, IN XENSTORE_RING_IDX Prod, IN CHAR8 *Buffer, OUT UINT32 *LenPtr ) { UINT32 Len; Len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX (Prod); if ((XENSTORE_RING_SIZE - (Prod - Cons)) < Len) { Len = XENSTORE_RING_SIZE - (Prod - Cons); } *LenPtr = Len; return (Buffer + MASK_XENSTORE_IDX (Prod)); } /** Return a pointer to, and the length of, the contiguous data available to read from a ring buffer. @param Cons The consumer index for the ring. @param Prod The producer index for the ring. @param Buffer The base address of the ring's storage. @param LenPtr The amount of contiguous data available to read. @return A pointer to the start location of the available data. **/ STATIC CONST VOID * XenStoreGetInputChunk ( IN XENSTORE_RING_IDX Cons, IN XENSTORE_RING_IDX Prod, IN CONST CHAR8 *Buffer, OUT UINT32 *LenPtr ) { UINT32 Len; Len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX (Cons); if ((Prod - Cons) < Len) { Len = Prod - Cons; } *LenPtr = Len; return (Buffer + MASK_XENSTORE_IDX (Cons)); } /** Wait for an event or timeout. @param Event Event to wait for. @param Timeout A timeout value in 100ns units. @retval EFI_SUCCESS Event have been triggered or the current TPL is not TPL_APPLICATION. @retval EFI_TIMEOUT Timeout have expired. **/ STATIC EFI_STATUS XenStoreWaitForEvent ( IN EFI_EVENT Event, IN UINT64 Timeout ) { UINTN Index; EFI_STATUS Status; EFI_EVENT TimerEvent; EFI_EVENT WaitList[2]; gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent); gBS->SetTimer (TimerEvent, TimerRelative, Timeout); WaitList[0] = xs.EventChannelEvent; WaitList[1] = TimerEvent; Status = gBS->WaitForEvent (2, WaitList, &Index); ASSERT (Status != EFI_INVALID_PARAMETER); gBS->CloseEvent (TimerEvent); if (Status == EFI_UNSUPPORTED) { return EFI_SUCCESS; } if (Index == 1) { return EFI_TIMEOUT; } else { return EFI_SUCCESS; } } /** Transmit data to the XenStore service. The buffer pointed to by DataPtr is at least Len bytes in length. @param DataPtr A pointer to the contiguous data to send. @param Len The amount of data to send. @return On success 0, otherwise an errno value indicating the cause of failure. **/ STATIC XENSTORE_STATUS XenStoreWriteStore ( IN CONST VOID *DataPtr, IN UINT32 Len ) { XENSTORE_RING_IDX Cons, Prod; CONST CHAR8 *Data = (CONST CHAR8 *)DataPtr; while (Len != 0) { void *Dest; UINT32 Available; Cons = xs.XenStore->req_cons; Prod = xs.XenStore->req_prod; if ((Prod - Cons) == XENSTORE_RING_SIZE) { /* * Output ring is full. Wait for a ring event. * * Note that the events from both queues are combined, so being woken * does not guarantee that data exist in the read ring. */ EFI_STATUS Status; Status = XenStoreWaitForEvent (xs.EventChannelEvent, EFI_TIMER_PERIOD_SECONDS (1)); if (Status == EFI_TIMEOUT) { DEBUG ((EFI_D_WARN, "XenStore Write, waiting for a ring event.\n")); } continue; } /* Verify queue sanity. */ if (!XenStoreCheckIndexes (Cons, Prod)) { xs.XenStore->req_cons = xs.XenStore->req_prod = 0; return XENSTORE_STATUS_EIO; } Dest = XenStoreGetOutputChunk (Cons, Prod, xs.XenStore->req, &Available); if (Available > Len) { Available = Len; } CopyMem (Dest, Data, Available); Data += Available; Len -= Available; /* * The store to the producer index, which indicates * to the other side that new data has arrived, must * be visible only after our copy of the data into the * ring has completed. */ MemoryFence (); xs.XenStore->req_prod += Available; /* * The other side will see the change to req_prod at the time of the * interrupt. */ MemoryFence (); XenEventChannelNotify (xs.Dev, xs.EventChannel); } return XENSTORE_STATUS_SUCCESS; } /** Receive data from the XenStore service. The buffer pointed to by DataPtr is at least Len bytes in length. @param DataPtr A pointer to the contiguous buffer to receive the data. @param Len The amount of data to receive. @return On success 0, otherwise an errno value indicating the cause of failure. **/ STATIC XENSTORE_STATUS XenStoreReadStore ( OUT VOID *DataPtr, IN UINT32 Len ) { XENSTORE_RING_IDX Cons, Prod; CHAR8 *Data = (CHAR8 *) DataPtr; while (Len != 0) { UINT32 Available; CONST CHAR8 *Src; Cons = xs.XenStore->rsp_cons; Prod = xs.XenStore->rsp_prod; if (Cons == Prod) { /* * Nothing to read. Wait for a ring event. * * Note that the events from both queues are combined, so being woken * does not guarantee that data exist in the read ring. */ EFI_STATUS Status; Status = XenStoreWaitForEvent (xs.EventChannelEvent, EFI_TIMER_PERIOD_SECONDS (1)); if (Status == EFI_TIMEOUT) { DEBUG ((EFI_D_WARN, "XenStore Read, waiting for a ring event.\n")); } continue; } /* Verify queue sanity. */ if (!XenStoreCheckIndexes (Cons, Prod)) { xs.XenStore->rsp_cons = xs.XenStore->rsp_prod = 0; return XENSTORE_STATUS_EIO; } Src = XenStoreGetInputChunk (Cons, Prod, xs.XenStore->rsp, &Available); if (Available > Len) { Available = Len; } /* * Insure the data we read is related to the indexes * we read above. */ MemoryFence (); CopyMem (Data, Src, Available); Data += Available; Len -= Available; /* * Insure that the producer of this ring does not see * the ring space as free until after we have copied it * out. */ MemoryFence (); xs.XenStore->rsp_cons += Available; /* * The producer will see the updated consumer index when the event is * delivered. */ MemoryFence (); XenEventChannelNotify (xs.Dev, xs.EventChannel); } return XENSTORE_STATUS_SUCCESS; } // // Received Message Processing // /** Block reading the next message from the XenStore service and process the result. @return XENSTORE_STATUS_SUCCESS on success. Otherwise an errno value indicating the type of failure encountered. **/ STATIC XENSTORE_STATUS XenStoreProcessMessage ( VOID ) { XENSTORE_MESSAGE *Message; CHAR8 *Body; XENSTORE_STATUS Status; Message = AllocateZeroPool (sizeof (XENSTORE_MESSAGE)); Message->Signature = XENSTORE_MESSAGE_SIGNATURE; Status = XenStoreReadStore (&Message->Header, sizeof (Message->Header)); if (Status != XENSTORE_STATUS_SUCCESS) { FreePool (Message); DEBUG ((EFI_D_ERROR, "XenStore: Error read store (%d)\n", Status)); return Status; } Body = AllocatePool (Message->Header.len + 1); Status = XenStoreReadStore (Body, Message->Header.len); if (Status != XENSTORE_STATUS_SUCCESS) { FreePool (Body); FreePool (Message); DEBUG ((EFI_D_ERROR, "XenStore: Error read store (%d)\n", Status)); return Status; } Body[Message->Header.len] = '\0'; if (Message->Header.type == XS_WATCH_EVENT) { Message->u.Watch.Vector = Split(Body, Message->Header.len, &Message->u.Watch.VectorSize); EfiAcquireLock (&xs.RegisteredWatchesLock); Message->u.Watch.Handle = XenStoreFindWatch (Message->u.Watch.Vector[XS_WATCH_TOKEN]); DEBUG ((EFI_D_INFO, "XenStore: Watch event %a\n", Message->u.Watch.Vector[XS_WATCH_TOKEN])); if (Message->u.Watch.Handle != NULL) { EfiAcquireLock (&xs.WatchEventsLock); InsertHeadList (&xs.WatchEvents, &Message->Link); EfiReleaseLock (&xs.WatchEventsLock); } else { DEBUG ((EFI_D_WARN, "XenStore: Watch handle %a not found\n", Message->u.Watch.Vector[XS_WATCH_TOKEN])); FreePool((VOID*)Message->u.Watch.Vector); FreePool(Message); } EfiReleaseLock (&xs.RegisteredWatchesLock); } else { Message->u.Reply.Body = Body; EfiAcquireLock (&xs.ReplyLock); InsertTailList (&xs.ReplyList, &Message->Link); EfiReleaseLock (&xs.ReplyLock); } return XENSTORE_STATUS_SUCCESS; } // // XenStore Message Request/Reply Processing // /** Convert a XenStore error string into an errno number. Unknown error strings are converted to EINVAL. @param errorstring The error string to convert. @return The errno best matching the input string. **/ typedef struct { XENSTORE_STATUS Status; CONST CHAR8 *ErrorStr; } XenStoreErrors; static XenStoreErrors gXenStoreErrors[] = { { XENSTORE_STATUS_EINVAL, "EINVAL" }, { XENSTORE_STATUS_EACCES, "EACCES" }, { XENSTORE_STATUS_EEXIST, "EEXIST" }, { XENSTORE_STATUS_EISDIR, "EISDIR" }, { XENSTORE_STATUS_ENOENT, "ENOENT" }, { XENSTORE_STATUS_ENOMEM, "ENOMEM" }, { XENSTORE_STATUS_ENOSPC, "ENOSPC" }, { XENSTORE_STATUS_EIO, "EIO" }, { XENSTORE_STATUS_ENOTEMPTY, "ENOTEMPTY" }, { XENSTORE_STATUS_ENOSYS, "ENOSYS" }, { XENSTORE_STATUS_EROFS, "EROFS" }, { XENSTORE_STATUS_EBUSY, "EBUSY" }, { XENSTORE_STATUS_EAGAIN, "EAGAIN" }, { XENSTORE_STATUS_EISCONN, "EISCONN" }, { XENSTORE_STATUS_E2BIG, "E2BIG" } }; STATIC XENSTORE_STATUS XenStoreGetError ( CONST CHAR8 *ErrorStr ) { UINT32 Index; for (Index = 0; Index < ARRAY_SIZE(gXenStoreErrors); Index++) { if (!AsciiStrCmp (ErrorStr, gXenStoreErrors[Index].ErrorStr)) { return gXenStoreErrors[Index].Status; } } DEBUG ((EFI_D_WARN, "XenStore gave unknown error %a\n", ErrorStr)); return XENSTORE_STATUS_EINVAL; } /** Block waiting for a reply to a message request. @param TypePtr The returned type of the reply. @param LenPtr The returned body length of the reply. @param Result The returned body of the reply. **/ STATIC XENSTORE_STATUS XenStoreReadReply ( OUT enum xsd_sockmsg_type *TypePtr, OUT UINT32 *LenPtr OPTIONAL, OUT VOID **Result ) { XENSTORE_MESSAGE *Message; LIST_ENTRY *Entry; CHAR8 *Body; while (IsListEmpty (&xs.ReplyList)) { XENSTORE_STATUS Status; Status = XenStoreProcessMessage (); if (Status != XENSTORE_STATUS_SUCCESS && Status != XENSTORE_STATUS_EAGAIN) { DEBUG ((EFI_D_ERROR, "XenStore, error while reading the ring (%d).", Status)); return Status; } } EfiAcquireLock (&xs.ReplyLock); Entry = GetFirstNode (&xs.ReplyList); Message = XENSTORE_MESSAGE_FROM_LINK (Entry); RemoveEntryList (Entry); EfiReleaseLock (&xs.ReplyLock); *TypePtr = Message->Header.type; if (LenPtr != NULL) { *LenPtr = Message->Header.len; } Body = Message->u.Reply.Body; FreePool (Message); *Result = Body; return XENSTORE_STATUS_SUCCESS; } /** Send a message with an optionally muti-part body to the XenStore service. @param Transaction The transaction to use for this request. @param RequestType The type of message to send. @param WriteRequest Pointers to the body sections of the request. @param NumRequests The number of body sections in the request. @param LenPtr The returned length of the reply. @param ResultPtr The returned body of the reply. @return XENSTORE_STATUS_SUCCESS on success. Otherwise an errno indicating the cause of failure. **/ STATIC XENSTORE_STATUS XenStoreTalkv ( IN CONST XENSTORE_TRANSACTION *Transaction, IN enum xsd_sockmsg_type RequestType, IN CONST WRITE_REQUEST *WriteRequest, IN UINT32 NumRequests, OUT UINT32 *LenPtr OPTIONAL, OUT VOID **ResultPtr OPTIONAL ) { struct xsd_sockmsg Message; void *Return = NULL; UINT32 Index; XENSTORE_STATUS Status; if (Transaction == XST_NIL) { Message.tx_id = 0; } else { Message.tx_id = Transaction->Id; } Message.req_id = 0; Message.type = RequestType; Message.len = 0; for (Index = 0; Index < NumRequests; Index++) { Message.len += WriteRequest[Index].Len; } Status = XenStoreWriteStore (&Message, sizeof (Message)); if (Status != XENSTORE_STATUS_SUCCESS) { DEBUG ((EFI_D_ERROR, "XenStoreTalkv failed %d\n", Status)); goto Error; } for (Index = 0; Index < NumRequests; Index++) { Status = XenStoreWriteStore (WriteRequest[Index].Data, WriteRequest[Index].Len); if (Status != XENSTORE_STATUS_SUCCESS) { DEBUG ((EFI_D_ERROR, "XenStoreTalkv failed %d\n", Status)); goto Error; } } Status = XenStoreReadReply ((enum xsd_sockmsg_type *)&Message.type, LenPtr, &Return); Error: if (Status != XENSTORE_STATUS_SUCCESS) { return Status; } if (Message.type == XS_ERROR) { Status = XenStoreGetError (Return); FreePool (Return); return Status; } /* Reply is either error or an echo of our request message type. */ ASSERT ((enum xsd_sockmsg_type)Message.type == RequestType); if (ResultPtr) { *ResultPtr = Return; } else { FreePool (Return); } return XENSTORE_STATUS_SUCCESS; } /** Wrapper for XenStoreTalkv allowing easy transmission of a message with a single, contiguous, message body. The returned result is provided in malloced storage and thus must be free'd by the caller. @param Transaction The transaction to use for this request. @param RequestType The type of message to send. @param Body The body of the request. @param LenPtr The returned length of the reply. @param Result The returned body of the reply. @return 0 on success. Otherwise an errno indicating the cause of failure. **/ STATIC XENSTORE_STATUS XenStoreSingle ( IN CONST XENSTORE_TRANSACTION *Transaction, IN enum xsd_sockmsg_type RequestType, IN CONST CHAR8 *Body, OUT UINT32 *LenPtr OPTIONAL, OUT VOID **Result OPTIONAL ) { WRITE_REQUEST WriteRequest; WriteRequest.Data = (VOID *) Body; WriteRequest.Len = (UINT32)AsciiStrSize (Body); return XenStoreTalkv (Transaction, RequestType, &WriteRequest, 1, LenPtr, Result); } // // XenStore Watch Support // /** Transmit a watch request to the XenStore service. @param Path The path in the XenStore to watch. @param Tocken A unique identifier for this watch. @return XENSTORE_STATUS_SUCCESS on success. Otherwise an errno indicating the cause of failure. **/ STATIC XENSTORE_STATUS XenStoreWatch ( CONST CHAR8 *Path, CONST CHAR8 *Token ) { WRITE_REQUEST WriteRequest[2]; WriteRequest[0].Data = (VOID *) Path; WriteRequest[0].Len = (UINT32)AsciiStrSize (Path); WriteRequest[1].Data = (VOID *) Token; WriteRequest[1].Len = (UINT32)AsciiStrSize (Token); return XenStoreTalkv (XST_NIL, XS_WATCH, WriteRequest, 2, NULL, NULL); } /** Transmit an uwatch request to the XenStore service. @param Path The path in the XenStore to watch. @param Tocken A unique identifier for this watch. @return XENSTORE_STATUS_SUCCESS on success. Otherwise an errno indicating the cause of failure. **/ STATIC XENSTORE_STATUS XenStoreUnwatch ( CONST CHAR8 *Path, CONST CHAR8 *Token ) { WRITE_REQUEST WriteRequest[2]; WriteRequest[0].Data = (VOID *) Path; WriteRequest[0].Len = (UINT32)AsciiStrSize (Path); WriteRequest[1].Data = (VOID *) Token; WriteRequest[1].Len = (UINT32)AsciiStrSize (Token); return XenStoreTalkv (XST_NIL, XS_UNWATCH, WriteRequest, 2, NULL, NULL); } STATIC XENSTORE_STATUS XenStoreWaitWatch ( VOID *Token ) { XENSTORE_MESSAGE *Message; LIST_ENTRY *Entry = NULL; LIST_ENTRY *Last = NULL; XENSTORE_STATUS Status; while (TRUE) { EfiAcquireLock (&xs.WatchEventsLock); if (IsListEmpty (&xs.WatchEvents) || Last == GetFirstNode (&xs.WatchEvents)) { EfiReleaseLock (&xs.WatchEventsLock); Status = XenStoreProcessMessage (); if (Status != XENSTORE_STATUS_SUCCESS && Status != XENSTORE_STATUS_EAGAIN) { return Status; } continue; } for (Entry = GetFirstNode (&xs.WatchEvents); Entry != Last && !IsNull (&xs.WatchEvents, Entry); Entry = GetNextNode (&xs.WatchEvents, Entry)) { Message = XENSTORE_MESSAGE_FROM_LINK (Entry); if (Message->u.Watch.Handle == Token) { RemoveEntryList (Entry); EfiReleaseLock (&xs.WatchEventsLock); FreePool((VOID*)Message->u.Watch.Vector); FreePool(Message); return XENSTORE_STATUS_SUCCESS; } } Last = GetFirstNode (&xs.WatchEvents); EfiReleaseLock (&xs.WatchEventsLock); } } VOID EFIAPI NotifyEventChannelCheckForEvent ( IN EFI_EVENT Event, IN VOID *Context ) { XENSTORE_PRIVATE *xsp; xsp = (XENSTORE_PRIVATE *)Context; if (TestAndClearBit (xsp->EventChannel, xsp->Dev->SharedInfo->evtchn_pending)) { gBS->SignalEvent (Event); } } /** Setup communication channels with the XenStore service. @retval EFI_SUCCESS if everything went well. **/ STATIC EFI_STATUS XenStoreInitComms ( XENSTORE_PRIVATE *xsp ) { EFI_STATUS Status; EFI_EVENT TimerEvent; struct xenstore_domain_interface *XenStore = xsp->XenStore; Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent); Status = gBS->SetTimer (TimerEvent, TimerRelative, EFI_TIMER_PERIOD_SECONDS (5)); while (XenStore->rsp_prod != XenStore->rsp_cons) { Status = gBS->CheckEvent (TimerEvent); if (!EFI_ERROR (Status)) { DEBUG ((EFI_D_WARN, "XENSTORE response ring is not quiescent " "(%08x:%08x): fixing up\n", XenStore->rsp_cons, XenStore->rsp_prod)); XenStore->rsp_cons = XenStore->rsp_prod; } } gBS->CloseEvent (TimerEvent); Status = gBS->CreateEvent (EVT_NOTIFY_WAIT, TPL_NOTIFY, NotifyEventChannelCheckForEvent, xsp, &xsp->EventChannelEvent); ASSERT_EFI_ERROR (Status); return Status; } /** Initialize XenStore. @param Dev A XENBUS_DEVICE instance. @retval EFI_SUCCESS if everything went well. **/ EFI_STATUS XenStoreInit ( XENBUS_DEVICE *Dev ) { EFI_STATUS Status; /** * The HVM guest pseudo-physical frame number. This is Xen's mapping * of the true machine frame number into our "physical address space". */ UINTN XenStoreGpfn; xs.Dev = Dev; xs.EventChannel = (evtchn_port_t)XenHypercallHvmGetParam (HVM_PARAM_STORE_EVTCHN); XenStoreGpfn = (UINTN)XenHypercallHvmGetParam (HVM_PARAM_STORE_PFN); xs.XenStore = (VOID *) (XenStoreGpfn << EFI_PAGE_SHIFT); DEBUG ((EFI_D_INFO, "XenBusInit: XenBus rings @%p, event channel %x\n", xs.XenStore, xs.EventChannel)); InitializeListHead (&xs.ReplyList); InitializeListHead (&xs.WatchEvents); InitializeListHead (&xs.RegisteredWatches); EfiInitializeLock (&xs.ReplyLock, TPL_NOTIFY); EfiInitializeLock (&xs.RegisteredWatchesLock, TPL_NOTIFY); EfiInitializeLock (&xs.WatchEventsLock, TPL_NOTIFY); /* Initialize the shared memory rings to talk to xenstored */ Status = XenStoreInitComms (&xs); return Status; } VOID XenStoreDeinit ( IN XENBUS_DEVICE *Dev ) { // // Emptying the list RegisteredWatches, but this list should already be // empty. Every driver that is using Watches should unregister them when // it is stopped. // if (!IsListEmpty (&xs.RegisteredWatches)) { XENSTORE_WATCH *Watch; LIST_ENTRY *Entry; DEBUG ((EFI_D_WARN, "XenStore: RegisteredWatches is not empty, cleaning up...")); Entry = GetFirstNode (&xs.RegisteredWatches); while (!IsNull (&xs.RegisteredWatches, Entry)) { Watch = XENSTORE_WATCH_FROM_LINK (Entry); Entry = GetNextNode (&xs.RegisteredWatches, Entry); XenStoreUnregisterWatch (Watch); } } // // Emptying the list WatchEvents, but this list should already be empty after // having cleanup the list RegisteredWatches. // if (!IsListEmpty (&xs.WatchEvents)) { LIST_ENTRY *Entry; DEBUG ((EFI_D_WARN, "XenStore: WatchEvents is not empty, cleaning up...")); Entry = GetFirstNode (&xs.WatchEvents); while (!IsNull (&xs.WatchEvents, Entry)) { XENSTORE_MESSAGE *Message = XENSTORE_MESSAGE_FROM_LINK (Entry); Entry = GetNextNode (&xs.WatchEvents, Entry); RemoveEntryList (&Message->Link); FreePool ((VOID*)Message->u.Watch.Vector); FreePool (Message); } } if (!IsListEmpty (&xs.ReplyList)) { XENSTORE_MESSAGE *Message; LIST_ENTRY *Entry; Entry = GetFirstNode (&xs.ReplyList); while (!IsNull (&xs.ReplyList, Entry)) { Message = XENSTORE_MESSAGE_FROM_LINK (Entry); Entry = GetNextNode (&xs.ReplyList, Entry); RemoveEntryList (&Message->Link); FreePool (Message->u.Reply.Body); FreePool (Message); } } gBS->CloseEvent (xs.EventChannelEvent); if (xs.XenStore->server_features & XENSTORE_SERVER_FEATURE_RECONNECTION) { xs.XenStore->connection = XENSTORE_RECONNECT; XenEventChannelNotify (xs.Dev, xs.EventChannel); while (*(volatile UINT32*)&xs.XenStore->connection == XENSTORE_RECONNECT) { XenStoreWaitForEvent (xs.EventChannelEvent, EFI_TIMER_PERIOD_MILLISECONDS (100)); } } else { /* If the backend reads the state while we're erasing it then the * ring state will become corrupted, preventing guest frontends from * connecting. This is rare. To help diagnose the failure, we fill * the ring with XS_INVALID packets. */ SetMem (xs.XenStore->req, XENSTORE_RING_SIZE, 0xff); SetMem (xs.XenStore->rsp, XENSTORE_RING_SIZE, 0xff); xs.XenStore->req_cons = xs.XenStore->req_prod = 0; xs.XenStore->rsp_cons = xs.XenStore->rsp_prod = 0; } xs.XenStore = NULL; } // // Public API // API comments for these methods can be found in XenStore.h // XENSTORE_STATUS XenStoreListDirectory ( IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node, OUT UINT32 *DirectoryCountPtr, OUT CONST CHAR8 ***DirectoryListPtr ) { CHAR8 *Path; CHAR8 *TempStr; UINT32 Len = 0; XENSTORE_STATUS Status; Path = XenStoreJoin (DirectoryPath, Node); Status = XenStoreSingle (Transaction, XS_DIRECTORY, Path, &Len, (VOID **) &TempStr); FreePool (Path); if (Status != XENSTORE_STATUS_SUCCESS) { return Status; } *DirectoryListPtr = Split (TempStr, Len, DirectoryCountPtr); return XENSTORE_STATUS_SUCCESS; } BOOLEAN XenStorePathExists ( IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *Directory, IN CONST CHAR8 *Node ) { CONST CHAR8 **TempStr; XENSTORE_STATUS Status; UINT32 TempNum; Status = XenStoreListDirectory (Transaction, Directory, Node, &TempNum, &TempStr); if (Status != XENSTORE_STATUS_SUCCESS) { return FALSE; } FreePool ((VOID*)TempStr); return TRUE; } XENSTORE_STATUS XenStoreRead ( IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node, OUT UINT32 *LenPtr OPTIONAL, OUT VOID **Result ) { CHAR8 *Path; VOID *Value; XENSTORE_STATUS Status; Path = XenStoreJoin (DirectoryPath, Node); Status = XenStoreSingle (Transaction, XS_READ, Path, LenPtr, &Value); FreePool (Path); if (Status != XENSTORE_STATUS_SUCCESS) { return Status; } *Result = Value; return XENSTORE_STATUS_SUCCESS; } XENSTORE_STATUS XenStoreWrite ( IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node, IN CONST CHAR8 *Str ) { CHAR8 *Path; WRITE_REQUEST WriteRequest[2]; XENSTORE_STATUS Status; Path = XenStoreJoin (DirectoryPath, Node); WriteRequest[0].Data = (VOID *) Path; WriteRequest[0].Len = (UINT32)AsciiStrSize (Path); WriteRequest[1].Data = (VOID *) Str; WriteRequest[1].Len = (UINT32)AsciiStrLen (Str); Status = XenStoreTalkv (Transaction, XS_WRITE, WriteRequest, 2, NULL, NULL); FreePool (Path); return Status; } XENSTORE_STATUS XenStoreRemove ( IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node ) { CHAR8 *Path; XENSTORE_STATUS Status; Path = XenStoreJoin (DirectoryPath, Node); Status = XenStoreSingle (Transaction, XS_RM, Path, NULL, NULL); FreePool (Path); return Status; } XENSTORE_STATUS XenStoreTransactionStart ( OUT XENSTORE_TRANSACTION *Transaction ) { CHAR8 *IdStr; XENSTORE_STATUS Status; Status = XenStoreSingle (XST_NIL, XS_TRANSACTION_START, "", NULL, (VOID **) &IdStr); if (Status == XENSTORE_STATUS_SUCCESS) { Transaction->Id = (UINT32)AsciiStrDecimalToUintn (IdStr); FreePool (IdStr); } return Status; } XENSTORE_STATUS XenStoreTransactionEnd ( IN CONST XENSTORE_TRANSACTION *Transaction, IN BOOLEAN Abort ) { CHAR8 AbortStr[2]; AbortStr[0] = Abort ? 'F' : 'T'; AbortStr[1] = '\0'; return XenStoreSingle (Transaction, XS_TRANSACTION_END, AbortStr, NULL, NULL); } XENSTORE_STATUS EFIAPI XenStoreVSPrint ( IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node, IN CONST CHAR8 *FormatString, IN VA_LIST Marker ) { CHAR8 *Buf; XENSTORE_STATUS Status; UINTN BufSize; VA_LIST Marker2; VA_COPY (Marker2, Marker); BufSize = SPrintLengthAsciiFormat (FormatString, Marker2) + 1; VA_END (Marker2); Buf = AllocateZeroPool (BufSize); AsciiVSPrint (Buf, BufSize, FormatString, Marker); Status = XenStoreWrite (Transaction, DirectoryPath, Node, Buf); FreePool (Buf); return Status; } XENSTORE_STATUS EFIAPI XenStoreSPrint ( IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node, IN CONST CHAR8 *FormatString, ... ) { VA_LIST Marker; XENSTORE_STATUS Status; VA_START (Marker, FormatString); Status = XenStoreVSPrint (Transaction, DirectoryPath, Node, FormatString, Marker); VA_END (Marker); return Status; } XENSTORE_STATUS XenStoreRegisterWatch ( IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node, OUT XENSTORE_WATCH **WatchPtr ) { /* Pointer in ascii is the token. */ CHAR8 Token[sizeof (XENSTORE_WATCH) * 2 + 1]; XENSTORE_STATUS Status; XENSTORE_WATCH *Watch; Watch = AllocateZeroPool (sizeof (XENSTORE_WATCH)); Watch->Signature = XENSTORE_WATCH_SIGNATURE; Watch->Node = XenStoreJoin (DirectoryPath, Node); EfiAcquireLock (&xs.RegisteredWatchesLock); InsertTailList (&xs.RegisteredWatches, &Watch->Link); EfiReleaseLock (&xs.RegisteredWatchesLock); AsciiSPrint (Token, sizeof (Token), "%p", (VOID*) Watch); Status = XenStoreWatch (Watch->Node, Token); /* Ignore errors due to multiple registration. */ if (Status == XENSTORE_STATUS_EEXIST) { Status = XENSTORE_STATUS_SUCCESS; } if (Status == XENSTORE_STATUS_SUCCESS) { *WatchPtr = Watch; } else { EfiAcquireLock (&xs.RegisteredWatchesLock); RemoveEntryList (&Watch->Link); EfiReleaseLock (&xs.RegisteredWatchesLock); FreePool (Watch->Node); FreePool (Watch); } return Status; } VOID XenStoreUnregisterWatch ( IN XENSTORE_WATCH *Watch ) { CHAR8 Token[sizeof (Watch) * 2 + 1]; LIST_ENTRY *Entry; ASSERT (Watch->Signature == XENSTORE_WATCH_SIGNATURE); AsciiSPrint (Token, sizeof (Token), "%p", (VOID *) Watch); if (XenStoreFindWatch (Token) == NULL) { return; } EfiAcquireLock (&xs.RegisteredWatchesLock); RemoveEntryList (&Watch->Link); EfiReleaseLock (&xs.RegisteredWatchesLock); XenStoreUnwatch (Watch->Node, Token); /* Cancel pending watch events. */ EfiAcquireLock (&xs.WatchEventsLock); Entry = GetFirstNode (&xs.WatchEvents); while (!IsNull (&xs.WatchEvents, Entry)) { XENSTORE_MESSAGE *Message = XENSTORE_MESSAGE_FROM_LINK (Entry); Entry = GetNextNode (&xs.WatchEvents, Entry); if (Message->u.Watch.Handle == Watch) { RemoveEntryList (&Message->Link); FreePool ((VOID*)Message->u.Watch.Vector); FreePool (Message); } } EfiReleaseLock (&xs.WatchEventsLock); FreePool (Watch->Node); FreePool (Watch); } // // XENBUS protocol // XENSTORE_STATUS EFIAPI XenBusWaitForWatch ( IN XENBUS_PROTOCOL *This, IN VOID *Token ) { return XenStoreWaitWatch (Token); } XENSTORE_STATUS EFIAPI XenBusXenStoreRead ( IN XENBUS_PROTOCOL *This, IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *Node, OUT VOID **Value ) { return XenStoreRead (Transaction, This->Node, Node, NULL, Value); } XENSTORE_STATUS EFIAPI XenBusXenStoreBackendRead ( IN XENBUS_PROTOCOL *This, IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *Node, OUT VOID **Value ) { return XenStoreRead (Transaction, This->Backend, Node, NULL, Value); } XENSTORE_STATUS EFIAPI XenBusXenStoreRemove ( IN XENBUS_PROTOCOL *This, IN CONST XENSTORE_TRANSACTION *Transaction, IN const char *Node ) { return XenStoreRemove (Transaction, This->Node, Node); } XENSTORE_STATUS EFIAPI XenBusXenStoreTransactionStart ( IN XENBUS_PROTOCOL *This, OUT XENSTORE_TRANSACTION *Transaction ) { return XenStoreTransactionStart (Transaction); } XENSTORE_STATUS EFIAPI XenBusXenStoreTransactionEnd ( IN XENBUS_PROTOCOL *This, IN CONST XENSTORE_TRANSACTION *Transaction, IN BOOLEAN Abort ) { return XenStoreTransactionEnd (Transaction, Abort); } XENSTORE_STATUS EFIAPI XenBusXenStoreSPrint ( IN XENBUS_PROTOCOL *This, IN CONST XENSTORE_TRANSACTION *Transaction, IN CONST CHAR8 *DirectoryPath, IN CONST CHAR8 *Node, IN CONST CHAR8 *FormatString, ... ) { VA_LIST Marker; XENSTORE_STATUS Status; VA_START (Marker, FormatString); Status = XenStoreVSPrint (Transaction, DirectoryPath, Node, FormatString, Marker); VA_END (Marker); return Status; } XENSTORE_STATUS EFIAPI XenBusRegisterWatch ( IN XENBUS_PROTOCOL *This, IN CONST CHAR8 *Node, OUT VOID **Token ) { return XenStoreRegisterWatch (This->Node, Node, (XENSTORE_WATCH **) Token); } XENSTORE_STATUS EFIAPI XenBusRegisterWatchBackend ( IN XENBUS_PROTOCOL *This, IN CONST CHAR8 *Node, OUT VOID **Token ) { return XenStoreRegisterWatch (This->Backend, Node, (XENSTORE_WATCH **) Token); } VOID EFIAPI XenBusUnregisterWatch ( IN XENBUS_PROTOCOL *This, IN VOID *Token ) { XenStoreUnregisterWatch ((XENSTORE_WATCH *) Token); }
b8ae59070c6999ff8c3bdefa133dd4fd6f2c2584
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/lpc176x/drivers/spi.h
bad75d38b45d438fd6ed6aec96528da013cdce95
[ "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
1,085
h
spi.h
/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ #ifndef __LPC17XX_SPI_H__ #define __LPC17XX_SPI_H__ #include <stdint.h> #include <stdbool.h> // if not use FIFO, R: 600kB/s, W: 500kB/s // if use FIFO, R: 1.2MB/s, W: 800kB/s #define USE_FIFO 1 /* bit-frequency = PCLK / (CPSDVSR * [SCR+1]), here SCR=0, PCLK=72MHz, must be even */ #define SPI_SPEED_20MHz 4 /* => 18MHz */ #define SPI_SPEED_25MHz 4 /* => 18MHz */ #define SPI_SPEED_400kHz 180 /* => 400kHz */ /* external functions */ void LPC17xx_SPI_Init (void); void LPC17xx_SPI_DeInit( void ); void LPC17xx_SPI_Release (void); void LPC17xx_SPI_SetSpeed (uint8_t speed); void LPC17xx_SPI_Select (void); void LPC17xx_SPI_DeSelect (void); void LPC17xx_SPI_SendByte (uint8_t data); uint8_t LPC17xx_SPI_RecvByte (void); #if USE_FIFO void LPC17xx_SPI_RecvBlock_FIFO (uint8_t *buff, uint32_t btr); void LPC17xx_SPI_SendBlock_FIFO (const uint8_t *buff); #endif #endif // __LPC17XX_SPI_H__
6f1120be5985f12138c92843df4f5e234d1d33ed
057a475216e9beed41983481aafcaf109bbf58da
/contrib/openssl-cmake/der_ecx_gen.c
ba7bf14b5e156d581d164f31dd1814673a40bf70
[ "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
1,193
c
der_ecx_gen.c
/* * WARNING: do not edit! * Generated by Makefile from providers/common/der/der_ecx_gen.c.in * * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include "prov/der_ecx.h" /* Well known OIDs precompiled */ /* * id-X25519 OBJECT IDENTIFIER ::= { id-edwards-curve-algs 110 } */ const unsigned char ossl_der_oid_id_X25519[DER_OID_SZ_id_X25519] = { DER_OID_V_id_X25519 }; /* * id-X448 OBJECT IDENTIFIER ::= { id-edwards-curve-algs 111 } */ const unsigned char ossl_der_oid_id_X448[DER_OID_SZ_id_X448] = { DER_OID_V_id_X448 }; /* * id-Ed25519 OBJECT IDENTIFIER ::= { id-edwards-curve-algs 112 } */ const unsigned char ossl_der_oid_id_Ed25519[DER_OID_SZ_id_Ed25519] = { DER_OID_V_id_Ed25519 }; /* * id-Ed448 OBJECT IDENTIFIER ::= { id-edwards-curve-algs 113 } */ const unsigned char ossl_der_oid_id_Ed448[DER_OID_SZ_id_Ed448] = { DER_OID_V_id_Ed448 };
2becb71e8f238b9e64dfa2e7b31d89f41376802a
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
/Engine/Plugins/Editor/USDImporter/Source/ThirdParty/USD/include/pxr/base/arch/debugger.h
3736cf1589c23beef0de4eb90cfbed27bbe101c3
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
windystrife/UnrealEngine_NVIDIAGameWorks
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
b50e6338a7c5b26374d66306ebc7807541ff815e
refs/heads/4.18-GameWorks
2023-03-11T02:50:08.471040
2022-01-13T20:50:29
2022-01-13T20:50:29
124,100,479
262
179
MIT
2022-12-16T05:36:38
2018-03-06T15:44:09
C++
UTF-8
C
false
false
4,367
h
debugger.h
// // Copyright 2016 Pixar // // Licensed under the Apache License, Version 2.0 (the "Apache License") // with the following modification; you may not use this file except in // compliance with the Apache License and the following modification to it: // Section 6. Trademarks. is deleted and replaced with: // // 6. Trademarks. This License does not grant permission to use the trade // names, trademarks, service marks, or product names of the Licensor // and its affiliates, except as required to comply with Section 4(c) of // the License and to reproduce the content of the NOTICE file. // // You may obtain a copy of the Apache License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the Apache License with the above modification is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // #ifndef ARCH_DEBUGGER_H #define ARCH_DEBUGGER_H /// \file arch/debugger.h /// Routines for interacting with a debugger. #include "pxr/pxr.h" #include "pxr/base/arch/api.h" #include "pxr/base/arch/attributes.h" PXR_NAMESPACE_OPEN_SCOPE /// Stop in a debugger. /// /// This function will do one of the following: start a debugger /// attached to this process stopped on this function; stop in an /// already attached debugger; stop and wait for a debugger to /// attach, or nothing. /// /// On Linux this will start a debugger using \c ArchDebuggerAttach() /// if no debugger is attached. If a debugger is (or was) attached it /// will stop on this function due to \c SIGTRAP. Alternatively, users /// can configure the debugger to not stop on \c SIGTRAP and instead /// break on \c ArchDebuggerTrap(). /// /// If a debugger is not attached, \c ArchDebuggerAttach() does not /// attach one, and \c ArchDebuggerWait() has been most recently /// called with \c true then this will wait for a debugger to attach, /// otherwise it does nothing and the process does not stop. The user /// can continue the process from the debugger simply by issuing the /// continue command. The user can also continue the process from an /// attached terminal by putting the process into the foreground or /// background. /// ARCH_API void ArchDebuggerTrap() ARCH_NOINLINE; /// Cause debug traps to wait for the debugger or not. /// /// When \p wait is \c true the next call to \c ArchDebuggerTrap() /// will cause the process to wait for a signal. The user can attach /// a debugger to continue the process. The process will not wait /// again until another call to this function with \p wait \c true. /// ARCH_API void ArchDebuggerWait(bool wait); /// Attach a debugger. /// /// Attaches the debugger by running the contents of the enviroment variable /// ARCH_DEBUGGER using /bin/sh. Any '%p' in the contents of this variable /// will be replaced with the process id of the process launching the debugger. /// Any '%e' will be replaced with the path to the executable for the process. /// /// Returns true if ARCH_DEBUGGER is set and the debugger was successfully /// launched, otherwise returns false. ARCH_API bool ArchDebuggerAttach() ARCH_NOINLINE; /// Test if a debugger is attached /// /// Attempts to detect if a debugger is currently attached to the process. ARCH_API bool ArchDebuggerIsAttached() ARCH_NOINLINE; /// Abort. This will try to avoid the JIT debugger if any if ARCH_AVOID_JIT /// is in the environment and the debugger isn't already attached. In that /// case it will _exit(134). If \p logging is \c false then this will /// attempt to bypass any crash logging. ARCH_API void ArchAbort(bool logging = true); /// Stop in the debugger. /// /// This macro expands to \c ArchDebuggerTrap() and, if necessary and /// possible, code to prevent optimization so the caller appears in the /// debugger's stack trace. The calling functions should also use the /// \c ARCH_NOINLINE function attribute. #if defined(ARCH_COMPILER_GCC) || defined(ARCH_COMPILER_CLANG) #define ARCH_DEBUGGER_TRAP do { ArchDebuggerTrap(); asm(""); } while (0) #else #define ARCH_DEBUGGER_TRAP do { ArchDebuggerTrap(); } while (0) #endif PXR_NAMESPACE_CLOSE_SCOPE #endif // ARCH_DEBUGGER_H
0475dd240ea234a3c4970e10fa35799ce58ae7b7
baa9fffc817a2a993d4ecc774d3f277783308c20
/src/uct/tcp/tcp_listener.h
ffd64dbe73c1883261c1c3d882d71c678ca80954
[ "BSD-3-Clause" ]
permissive
openucx/ucx
9a0f2205295afbdf3cff14b5d24af781b123f5ea
73a48700badb7cbace64d94b82f408e2a26fca32
refs/heads/master
2023-09-01T16:51:26.913950
2023-09-01T13:02:25
2023-09-01T13:02:25
25,379,390
966
420
NOASSERTION
2023-09-14T12:29:35
2014-10-17T22:17:24
C
UTF-8
C
false
false
1,245
h
tcp_listener.h
/** * Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2019. ALL RIGHTS RESERVED. * * See file LICENSE for terms. */ #include "tcp_sockcm.h" /** * An TCP listener for incoming connections requests on the server side. */ typedef struct uct_tcp_listener { uct_listener_t super; int listen_fd; uct_tcp_sockcm_t *sockcm; /** Callback to invoke upon receiving a connection request from a client */ uct_cm_listener_conn_request_callback_t conn_request_cb; /** User's data to be passed as argument to the conn_request_cb */ void *user_data; } uct_tcp_listener_t; UCS_CLASS_DECLARE_NEW_FUNC(uct_tcp_listener_t, uct_listener_t, uct_cm_h , const struct sockaddr *, socklen_t , const uct_listener_params_t *); UCS_CLASS_DECLARE_DELETE_FUNC(uct_tcp_listener_t, uct_listener_t); ucs_status_t uct_tcp_listener_query(uct_listener_h listener, uct_listener_attr_t *listener_attr); ucs_status_t uct_tcp_listener_reject(uct_listener_h listener, uct_conn_request_h conn_request);
d38dea3a24ce444737d664558e7157e44ec6d497
a3e2d421f94a8adf2c41ff1d093b5a06de1448d6
/product/runtime/src/main/c/chaquopy_java_extra.h
ae2ffef7dfab761ea5c303e49c70efd80c297ef1
[ "MIT" ]
permissive
chaquo/chaquopy
09ef057015a756ce9b862732477b2549562720b4
e09bbe6ca5efd859d484b01e30131ccc944aa2b6
refs/heads/master
2023-08-31T22:09:22.230601
2023-08-31T13:07:57
2023-08-31T13:07:57
95,140,462
607
121
MIT
2023-09-13T19:17:29
2017-06-22T17:33:02
Python
UTF-8
C
false
false
675
h
chaquopy_java_extra.h
// Cython generates a chaquopy_java.h automatically, so we need to use a different name. #include "Python.h" // The chaquopy_java library isn't loaded like a normal Python module. Instead, it's loaded // from Java using System.loadLibrary. The Java code then calls Python.startNative, which calls // PyInit_chaquopy_java. This is all much easier if we use single-phase initialization. #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 // The module initialization function in the generated C file is further down the file than the // place from where it's called, so we need to provide a prototype. PyMODINIT_FUNC PyInit_chaquopy_java(void);
e506d57947c4165afdf21e0b458d8ea49c18220e
1c92d2c1fb2ed9a4bf6a9c9f1875bb5fff546086
/arch/x86_64/rsp/rsp.h
e5467afb68c2d507cae318221e1a2ad93fb555a3
[]
permissive
n64dev/cen64
83a5b77221408745a16c323b902c20ecdb00f146
1c1118462bd9d9b8ceb4c556a647718072477aab
refs/heads/master
2023-09-05T18:35:09.152950
2023-05-29T04:24:38
2023-05-29T04:24:38
9,182,531
435
65
BSD-3-Clause
2023-09-02T21:07:35
2013-04-02T23:17:08
C
UTF-8
C
false
false
7,908
h
rsp.h
// // arch/x86_64/rsp/rsp.h // // Extern declarations for host RSP functions. // // This file is subject to the terms and conditions defined in // 'LICENSE', which is part of this source code package. // #ifndef __arch_rsp_h__ #define __arch_rsp_h__ #include "common.h" #ifdef __SSE4_2__ #include <nmmintrin.h> #elif defined(__SSE4_1__) #include <smmintrin.h> #elif defined(__SSSE3__) #include <tmmintrin.h> #elif defined(__SSE3__) #include <pmmintrin.h> #else #include <emmintrin.h> #endif struct rsp; typedef __m128i rsp_vect_t; // Gives the architecture backend a chance to initialize the RSP. cen64_cold void arch_rsp_destroy(struct rsp *rsp); cen64_cold int arch_rsp_init(struct rsp *rsp); // Masks for AND/OR/XOR and NAND/NOR/NXOR. extern const uint16_t rsp_vlogic_mask[2][8]; // Loads and shuffles a 16x8 vector according to element. #ifdef __SSSE3__ extern const uint16_t shuffle_keys[16][8]; static inline __m128i rsp_vect_load_and_shuffle_operand( const uint16_t *src, unsigned element) { __m128i operand = _mm_load_si128((__m128i*) src); __m128i key = _mm_load_si128((__m128i*) shuffle_keys[element]); return _mm_shuffle_epi8(operand, key); } #else __m128i rsp_vect_load_and_shuffle_operand( const uint16_t *src, unsigned element); #endif // Loads a vector without shuffling its elements. static inline __m128i rsp_vect_load_unshuffled_operand(const uint16_t *src) { return _mm_load_si128((__m128i *) src); } // Writes an operand back to memory. static inline void rsp_vect_write_operand(uint16_t *dest, __m128i src) { _mm_store_si128((__m128i*) dest, src); } // Functions for reading/writing the accumulator. //#if ((defined(__GNUC__) && !(defined(__clang__) || defined(__INTEL_COMPILER))) && defined(__x86_64)) #if 0 #define REGISTER_CACHING register __m128i hr_acc_lo __asm__ ("xmm8"); register __m128i hr_acc_md __asm__ ("xmm9"); register __m128i hr_acc_hi __asm__ ("xmm10"); register __m128i hr_vcc_lo __asm__ ("xmm11"); register __m128i hr_vcc_hi __asm__ ("xmm12"); register __m128i hr_vco_lo __asm__ ("xmm13"); register __m128i hr_vco_hi __asm__ ("xmm14"); register __m128i hr_vce __asm__ ("xmm15"); static inline __m128i read_acc_lo(const uint16_t *acc) { return hr_acc_lo; } static inline __m128i read_acc_md(const uint16_t *acc) { return hr_acc_md; } static inline __m128i read_acc_hi(const uint16_t *acc) { return hr_acc_hi; } static inline __m128i read_vcc_lo(const uint16_t *vcc) { return hr_vcc_lo; } static inline __m128i read_vcc_hi(const uint16_t *vcc) { return hr_vcc_hi; } static inline __m128i read_vco_lo(const uint16_t *vco) { return hr_vco_lo; } static inline __m128i read_vco_hi(const uint16_t *vco) { return hr_vco_hi; } static inline __m128i read_vce(const uint16_t *vce) { return hr_vce; } static inline void write_acc_lo(uint16_t *acc, __m128i acc_lo) { __asm__ volatile("movdqa %1, %0\n\t" : "=x"(hr_acc_lo) : "x"(acc_lo)); } static inline void write_acc_md(uint16_t *acc, __m128i acc_md) { __asm__ volatile("movdqa %1, %0\n\t" : "=x"(hr_acc_md) : "x"(acc_md)); } static inline void write_acc_hi(uint16_t *acc, __m128i acc_hi) { __asm__ volatile("movdqa %1, %0\n\t" : "=x"(hr_acc_hi) : "x"(acc_hi)); } static inline void write_vcc_lo(uint16_t *vcc, __m128i vcc_lo) { __asm__ volatile("movdqa %1, %0\n\t" : "=x"(hr_vcc_lo) : "x"(vcc_lo)); } static inline void write_vcc_hi(uint16_t *vcc, __m128i vcc_hi) { __asm__ volatile("movdqa %1, %0\n\t" : "=x"(hr_vcc_hi) : "x"(vcc_hi)); } static inline void write_vco_lo(uint16_t *vco, __m128i vco_lo) { __asm__ volatile("movdqa %1, %0\n\t" : "=x"(hr_vco_lo) : "x"(vco_lo)); } static inline void write_vco_hi(uint16_t *vco, __m128i vco_hi) { __asm__ volatile("movdqa %1, %0\n\t" : "=x"(hr_vco_hi) : "x"(vco_hi)); } static inline void write_vce(uint16_t *vce, __m128i vce_r) { __asm__ volatile("movdqa %1, %0\n\t" : "=x"(hr_vce) : "x"(vce_r)); } #else static inline __m128i read_acc_lo(const uint16_t *acc) { return rsp_vect_load_unshuffled_operand(acc + 16); } static inline __m128i read_acc_md(const uint16_t *acc) { return rsp_vect_load_unshuffled_operand(acc + 8); } static inline __m128i read_acc_hi(const uint16_t *acc) { return rsp_vect_load_unshuffled_operand(acc); } static inline __m128i read_vcc_lo(const uint16_t *vcc) { return rsp_vect_load_unshuffled_operand(vcc + 8); } static inline __m128i read_vcc_hi(const uint16_t *vcc) { return rsp_vect_load_unshuffled_operand(vcc); } static inline __m128i read_vco_lo(const uint16_t *vco) { return rsp_vect_load_unshuffled_operand(vco + 8); } static inline __m128i read_vco_hi(const uint16_t *vco) { return rsp_vect_load_unshuffled_operand(vco); } static inline __m128i read_vce(const uint16_t *vce) { return rsp_vect_load_unshuffled_operand(vce + 8); } static inline void write_acc_lo(uint16_t *acc, __m128i acc_lo) { rsp_vect_write_operand(acc + 16, acc_lo); } static inline void write_acc_md(uint16_t *acc, __m128i acc_md) { rsp_vect_write_operand(acc + 8, acc_md); } static inline void write_acc_hi(uint16_t *acc, __m128i acc_hi) { rsp_vect_write_operand(acc, acc_hi); } static inline void write_vcc_lo(uint16_t *vcc, __m128i vcc_lo) { rsp_vect_write_operand(vcc + 8, vcc_lo); } static inline void write_vcc_hi(uint16_t *vcc, __m128i vcc_hi) { rsp_vect_write_operand(vcc, vcc_hi); } static inline void write_vco_lo(uint16_t *vco, __m128i vco_lo) { rsp_vect_write_operand(vco + 8, vco_lo); } static inline void write_vco_hi(uint16_t *vco, __m128i vco_hi) { rsp_vect_write_operand(vco, vco_hi); } static inline void write_vce(uint16_t *vce, __m128i vce_r) { rsp_vect_write_operand(vce + 8, vce_r); } #endif // Returns scalar bitmasks for VCO/VCC/VCE. static inline int16_t rsp_get_flags(const uint16_t *flags) { return (int16_t) _mm_movemask_epi8( _mm_packs_epi16( _mm_load_si128((__m128i *) (flags + 8)), _mm_load_si128((__m128i *) (flags + 0)) ) ); } void rsp_set_flags(uint16_t *flags, uint16_t rt); // Zeroes out a vector register. static inline __m128i rsp_vzero(void) { return _mm_setzero_si128(); } // Load and store functions. void rsp_vload_group1(struct rsp *rsp, uint32_t addr, unsigned element, uint16_t *regp, __m128i reg, __m128i dqm); void rsp_vload_group2(struct rsp *rsp, uint32_t addr, unsigned element, uint16_t *regp, __m128i reg, __m128i dqm); void rsp_vload_group4(struct rsp *rsp, uint32_t addr, unsigned element, uint16_t *regp, rsp_vect_t reg, rsp_vect_t dqm); void rsp_vstore_group1(struct rsp *rsp, uint32_t addr, unsigned element, uint16_t *regp, __m128i reg, __m128i dqm); void rsp_vstore_group2(struct rsp *rsp, uint32_t addr, unsigned element, uint16_t *regp, __m128i reg, __m128i dqm); void rsp_vstore_group4(struct rsp *rsp, uint32_t addr, unsigned element, uint16_t *regp, rsp_vect_t reg, rsp_vect_t dqm); #include "arch/x86_64/rsp/clamp.h" #include "arch/x86_64/rsp/transpose.h" #include "arch/x86_64/rsp/vabs.h" #include "arch/x86_64/rsp/vadd.h" #include "arch/x86_64/rsp/vaddc.h" #include "arch/x86_64/rsp/vand.h" #include "arch/x86_64/rsp/vch.h" #include "arch/x86_64/rsp/vcmp.h" #include "arch/x86_64/rsp/vcl.h" #include "arch/x86_64/rsp/vcr.h" #include "arch/x86_64/rsp/vmac.h" #include "arch/x86_64/rsp/vmrg.h" #include "arch/x86_64/rsp/vmul.h" #include "arch/x86_64/rsp/vmulh.h" #include "arch/x86_64/rsp/vmull.h" #include "arch/x86_64/rsp/vmulm.h" #include "arch/x86_64/rsp/vmuln.h" #include "arch/x86_64/rsp/vor.h" #include "arch/x86_64/rsp/vsub.h" #include "arch/x86_64/rsp/vsubc.h" #include "arch/x86_64/rsp/vxor.h" extern const uint16_t vdiv_mask_table[8][8]; __m128i rsp_vdivh(struct rsp *rsp, unsigned src, unsigned e, unsigned dest, unsigned de); __m128i rsp_vmov(struct rsp *rsp, unsigned src, unsigned e, unsigned dest, rsp_vect_t vt_shuffle); __m128i rsp_vrcp_vrsq(struct rsp *rsp, uint32_t iw, int dp, unsigned src, unsigned e, unsigned dest, unsigned de); #endif
8fd0d87744654360837c598aa9098ed5245b6a6b
72f6d3ad72b2a4a9b6c5f93c5d1b744e2940b884
/include/h2o/cache.h
4eae70c926815d560b236074b67c6d51cf363b00
[ "MIT" ]
permissive
h2o/h2o
70012b6527ceb54e9e2819c9c75242b18e381485
b165770ce704c782ddee7428ea4a0b23c8bb7894
refs/heads/master
2023-08-16T13:16:35.018003
2023-08-16T03:56:28
2023-08-16T03:56:28
23,029,617
9,377
983
MIT
2023-09-12T04:49:14
2014-08-16T23:59:03
C
UTF-8
C
false
false
3,738
h
cache.h
/* * Copyright (c) 2014-2016 DeNA Co., Ltd., Kazuho Oku * * 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 h2o__cache_h #define h2o__cache_h #include <stdint.h> #include "h2o/linklist.h" #include "h2o/memory.h" typedef struct st_h2o_cache_t h2o_cache_t; typedef uint32_t /* eq. khint_t */ h2o_cache_hashcode_t; typedef struct st_h2o_cache_key_t { h2o_iovec_t vec; h2o_cache_hashcode_t hash; } h2o_cache_key_t; typedef struct st_h2o_cache_ref_t { h2o_iovec_t key; h2o_cache_hashcode_t keyhash; uint64_t at; h2o_iovec_t value; int _requested_early_update; h2o_linklist_t _lru_link; h2o_linklist_t _age_link; size_t _refcnt; } h2o_cache_ref_t; /** * calculates the hash code of a key */ h2o_cache_hashcode_t h2o_cache_calchash(const char *s, size_t len); enum { /** * if set, the internals of the cache is protected by a mutex so that it can be accessed concurrently */ H2O_CACHE_FLAG_MULTITHREADED = 0x1, /** * if set, the cache triggers an early update */ H2O_CACHE_FLAG_EARLY_UPDATE = 0x2 }; /** * creates a new cache */ h2o_cache_t *h2o_cache_create(int flags, size_t capacity, uint64_t duration, void (*destroy_cb)(h2o_iovec_t value)); /** * destroys a cache */ void h2o_cache_destroy(h2o_cache_t *cache); /** * clears a cache */ void h2o_cache_clear(h2o_cache_t *cache); /** * returns a value named by key from the cache if found, or else returns NULL * @param cache * @param now * @param key * @param keyhash callers may optionally pass in the precalculated hash value (or should be set to 0) */ h2o_cache_ref_t *h2o_cache_fetch(h2o_cache_t *cache, uint64_t now, h2o_iovec_t key, h2o_cache_hashcode_t keyhash); /** * releases the reference returned by h2o_cache_fetch */ void h2o_cache_release(h2o_cache_t *cache, h2o_cache_ref_t *ref); /** * sets the value of the cache * @param cache * @param now * @param key * @param keyhash callers may optionally pass in the precalculated hash value (or should be set to 0) * @param value (when no longer needed, destroy_cb will be called) * @return if the specified value already existed */ int h2o_cache_set(h2o_cache_t *cache, uint64_t now, h2o_iovec_t key, h2o_cache_hashcode_t keyhash, h2o_iovec_t value); /** * deletes a named value from the cache * @param cache * @param now * @param key * @param keyhash callers may optionally pass in the precalculated hash value (or should be set to 0) */ void h2o_cache_delete(h2o_cache_t *cache, uint64_t now, h2o_iovec_t key, h2o_cache_hashcode_t keyhash); /** * getter functions */ size_t h2o_cache_get_capacity(h2o_cache_t *cache); uint64_t h2o_cache_get_duration(h2o_cache_t *cache); #endif
309d5d842f7f1622b1e6a1afc5d0ef6ace22f903
8447eb38a4fc71b32b6b82a99f7828a2c50621aa
/common/vectormath/ppu/c/quat_aos.h
e5202649bc1c928747093c32b1dacbd162d8a661
[ "MIT" ]
permissive
ps3dev/PSL1GHT
9ecc1f0a2996b39d35cc98303c58c79966b9388b
5bc0961c66a3615c74f15e0c29bbeaa33f867ab3
refs/heads/master
2023-08-04T06:50:55.256801
2023-07-30T13:34:19
2023-07-30T13:34:19
1,541,223
159
357
MIT
2023-07-23T07:26:09
2011-03-29T12:34:15
C
UTF-8
C
false
false
14,722
h
quat_aos.h
/* Copyright (C) 2006, 2007 Sony Computer Entertainment 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. * Neither the name of the Sony Computer Entertainment 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 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _VECTORMATH_QUAT_AOS_C_H #define _VECTORMATH_QUAT_AOS_C_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /*----------------------------------------------------------------------------- * Definitions */ #ifndef _VECTORMATH_INTERNAL_FUNCTIONS #define _VECTORMATH_INTERNAL_FUNCTIONS #endif static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ) { result->vec128 = quat->vec128; } static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w ) { if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & __builtin_constant_p(_z) & __builtin_constant_p(_w)) { result->vec128 = (vec_float4){_x, _y, _z, _w}; } else { float *pf = (float *)&result->vec128; pf[0] = _x; pf[1] = _y; pf[2] = _z; pf[3] = _w; } } static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w ) { result->vec128 = xyz->vec128; _vmathVfSetElement(result->vec128, _w, 3); } static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ) { result->vec128 = vec->vec128; } static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ) { result->vec128 = _vmathVfSplatScalar(scalar); } static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 ) { result->vec128 = vf4; } static inline void vmathQMakeIdentity( VmathQuat *result ) { result->vec128 = _VECTORMATH_UNIT_0001; } static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ) { VmathQuat tmpQ_0, tmpQ_1; vmathQSub( &tmpQ_0, quat1, quat0 ); vmathQScalarMul( &tmpQ_1, &tmpQ_0, t ); vmathQAdd( result, quat0, &tmpQ_1 ); } static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ) { VmathQuat start; vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; vec_uint4 selectMask; cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 ); cosAngle = vec_splat( cosAngle, 0 ); selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), cosAngle ); cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask ); start.vec128 = vec_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask ); selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); angle = acosf4( cosAngle ); tttt = _vmathVfSplatScalar(t); oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); angles = vec_mergeh( angles, oneMinusT ); angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); sines = sinf4( angles ); scales = divf4( sines, vec_splat( sines, 0 ) ); scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); result->vec128 = vec_madd( start.vec128, scale0, vec_madd( unitQuat1->vec128, scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); } static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ) { VmathQuat tmp0, tmp1; vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 ); } static inline vec_float4 vmathQGet128( const VmathQuat *quat ) { return quat->vec128; } static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ) { result->vec128 = vec_sel( vec->vec128, result->vec128, _VECTORMATH_MASK_0x000F ); } static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ) { result->vec128 = quat->vec128; } static inline void vmathQSetX( VmathQuat *result, float _x ) { _vmathVfSetElement(result->vec128, _x, 0); } static inline float vmathQGetX( const VmathQuat *quat ) { return _vmathVfGetElement(quat->vec128, 0); } static inline void vmathQSetY( VmathQuat *result, float _y ) { _vmathVfSetElement(result->vec128, _y, 1); } static inline float vmathQGetY( const VmathQuat *quat ) { return _vmathVfGetElement(quat->vec128, 1); } static inline void vmathQSetZ( VmathQuat *result, float _z ) { _vmathVfSetElement(result->vec128, _z, 2); } static inline float vmathQGetZ( const VmathQuat *quat ) { return _vmathVfGetElement(quat->vec128, 2); } static inline void vmathQSetW( VmathQuat *result, float _w ) { _vmathVfSetElement(result->vec128, _w, 3); } static inline float vmathQGetW( const VmathQuat *quat ) { return _vmathVfGetElement(quat->vec128, 3); } static inline void vmathQSetElem( VmathQuat *result, int idx, float value ) { _vmathVfSetElement(result->vec128, value, idx); } static inline float vmathQGetElem( const VmathQuat *quat, int idx ) { return _vmathVfGetElement(quat->vec128, idx); } static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) { result->vec128 = vec_add( quat0->vec128, quat1->vec128 ); } static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) { result->vec128 = vec_sub( quat0->vec128, quat1->vec128 ); } static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ) { result->vec128 = vec_madd( quat->vec128, _vmathVfSplatScalar(scalar), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); } static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ) { result->vec128 = divf4( quat->vec128, _vmathVfSplatScalar(scalar) ); } static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ) { result->vec128 = negatef4( quat->vec128 ); } static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ) { vec_float4 result = _vmathVfDot4( quat0->vec128, quat1->vec128 ); return _vmathVfGetElement(result, 0); } static inline float vmathQNorm( const VmathQuat *quat ) { vec_float4 result = _vmathVfDot4( quat->vec128, quat->vec128 ); return _vmathVfGetElement(result, 0); } static inline float vmathQLength( const VmathQuat *quat ) { return sqrtf( vmathQNorm( quat ) ); } static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ) { vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 ); result->vec128 = vec_madd( quat->vec128, rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); } static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) { VmathVector3 crossVec, tmpV3_0; vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res; cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 ); cosAngle = vec_splat( cosAngle, 0 ); cosAngleX2Plus2 = vec_madd( cosAngle, ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){2.0f,2.0f,2.0f,2.0f}) ); recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 ); cosHalfAngleX2 = vec_madd( recipCosHalfAngleX2, cosAngleX2Plus2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 ); crossVec = tmpV3_0; res = vec_madd( crossVec.vec128, recipCosHalfAngleX2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); res = vec_sel( res, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), _VECTORMATH_MASK_0x000F ); result->vec128 = res; } static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ) { vec_float4 s, c, angle, res; angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); sincosf4( angle, &s, &c ); res = vec_sel( vec_madd( unitVec->vec128, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c, _VECTORMATH_MASK_0x000F ); result->vec128 = res; } static inline void vmathQMakeRotationX( VmathQuat *result, float radians ) { vec_float4 s, c, angle, res; angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); sincosf4( angle, &s, &c ); res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0xF000 ); res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); result->vec128 = res; } static inline void vmathQMakeRotationY( VmathQuat *result, float radians ) { vec_float4 s, c, angle, res; angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); sincosf4( angle, &s, &c ); res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x0F00 ); res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); result->vec128 = res; } static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ) { vec_float4 s, c, angle, res; angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); sincosf4( angle, &s, &c ); res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x00F0 ); res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); result->vec128 = res; } static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) { vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; vec_float4 product, l_wxyz, r_wxyz, xy, qw; ldata = quat0->vec128; rdata = quat1->vec128; tmp0 = vec_perm( ldata, ldata, _VECTORMATH_PERM_YZXW ); tmp1 = vec_perm( rdata, rdata, _VECTORMATH_PERM_ZXYW ); tmp2 = vec_perm( ldata, ldata, _VECTORMATH_PERM_ZXYW ); tmp3 = vec_perm( rdata, rdata, _VECTORMATH_PERM_YZXW ); qv = vec_madd( vec_splat( ldata, 3 ), rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv ); qv = vec_madd( tmp0, tmp1, qv ); qv = vec_nmsub( tmp2, tmp3, qv ); product = vec_madd( ldata, rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); l_wxyz = vec_sld( ldata, ldata, 12 ); r_wxyz = vec_sld( rdata, rdata, 12 ); qw = vec_nmsub( l_wxyz, r_wxyz, product ); xy = vec_madd( l_wxyz, r_wxyz, product ); qw = vec_sub( qw, vec_sld( xy, xy, 8 ) ); result->vec128 = vec_sel( qv, qw, _VECTORMATH_MASK_0x000F ); } static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec ) { vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res; qdata = quat->vec128; vdata = vec->vec128; tmp0 = vec_perm( qdata, qdata, _VECTORMATH_PERM_YZXW ); tmp1 = vec_perm( vdata, vdata, _VECTORMATH_PERM_ZXYW ); tmp2 = vec_perm( qdata, qdata, _VECTORMATH_PERM_ZXYW ); tmp3 = vec_perm( vdata, vdata, _VECTORMATH_PERM_YZXW ); wwww = vec_splat( qdata, 3 ); qv = vec_madd( wwww, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); qv = vec_madd( tmp0, tmp1, qv ); qv = vec_nmsub( tmp2, tmp3, qv ); product = vec_madd( qdata, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product ); qw = vec_add( vec_sld( product, product, 8 ), qw ); tmp1 = vec_perm( qv, qv, _VECTORMATH_PERM_ZXYW ); tmp3 = vec_perm( qv, qv, _VECTORMATH_PERM_YZXW ); res = vec_madd( vec_splat( qw, 0 ), qdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); res = vec_madd( wwww, qv, res ); res = vec_madd( tmp0, tmp1, res ); res = vec_nmsub( tmp2, tmp3, res ); result->vec128 = res; } static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ) { result->vec128 = vec_xor( quat->vec128, ((vec_float4)(vec_uint4){0x80000000,0x80000000,0x80000000,0}) ); } static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ) { unsigned int tmp; tmp = (unsigned int)-(select1 > 0); result->vec128 = vec_sel( quat0->vec128, quat1->vec128, _vmathVuiSplatScalar(tmp) ); } #ifdef _VECTORMATH_DEBUG static inline void vmathQPrint( const VmathQuat *quat ) { union { vec_float4 v; float s[4]; } tmp; tmp.v = quat->vec128; printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); } static inline void vmathQPrints( const VmathQuat *quat, const char *name ) { union { vec_float4 v; float s[4]; } tmp; tmp.v = quat->vec128; printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); } #endif #ifdef __cplusplus } #endif /* __cplusplus */ #endif
5e826eb396661877e02105e7c2026eb67f940e9b
7c857119fe1505b1d80d6e62969661c06dc1a2f4
/FileSystems/GrubFS/grub/grub-core/lib/efi/datetime.c
0fd1b5fbd615cfec38fd96f34b384e0c48480eb8
[ "BSD-2-Clause", "GPL-3.0-only" ]
permissive
CloverHackyColor/CloverBootloader
7042ca7dd6b513d22be591a295e49071ae1482ee
2711170df4f60b2ae5aa20add3e00f35cf57b7e5
refs/heads/master
2023-08-30T22:14:34.590134
2023-08-27T19:14:02
2023-08-27T19:14:02
205,810,121
4,734
770
BSD-2-Clause
2023-09-03T12:41:33
2019-09-02T08:22:14
C
UTF-8
C
false
false
2,413
c
datetime.c
/* kern/efi/datetime.c - efi datetime function. * * GRUB -- GRand Unified Bootloader * Copyright (C) 2008 Free Software Foundation, Inc. * * GRUB 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 3 of the License, or * (at your option) any later version. * * GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>. */ #include <grub/types.h> #include <grub/symbol.h> #include <grub/efi/api.h> #include <grub/efi/efi.h> #include <grub/datetime.h> #include <grub/dl.h> GRUB_MOD_LICENSE ("GPLv3+"); grub_err_t grub_get_datetime (struct grub_datetime *datetime) { grub_efi_status_t status; struct grub_efi_time efi_time; status = efi_call_2 (grub_efi_system_table->runtime_services->get_time, &efi_time, 0); if (status) return grub_error (GRUB_ERR_INVALID_COMMAND, "can\'t get datetime using efi"); else { datetime->year = efi_time.year; datetime->month = efi_time.month; datetime->day = efi_time.day; datetime->hour = efi_time.hour; datetime->minute = efi_time.minute; datetime->second = efi_time.second; } return 0; } grub_err_t grub_set_datetime (struct grub_datetime *datetime) { grub_efi_status_t status; struct grub_efi_time efi_time; status = efi_call_2 (grub_efi_system_table->runtime_services->get_time, &efi_time, 0); if (status) return grub_error (GRUB_ERR_INVALID_COMMAND, "can\'t get datetime using efi"); efi_time.year = datetime->year; efi_time.month = datetime->month; efi_time.day = datetime->day; efi_time.hour = datetime->hour; efi_time.minute = datetime->minute; efi_time.second = datetime->second; status = efi_call_1 (grub_efi_system_table->runtime_services->set_time, &efi_time); if (status) return grub_error (GRUB_ERR_INVALID_COMMAND, "can\'t set datetime using efi"); return 0; }
f9606221a796e82bf6bccc1beda55e20ee5cf114
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/include/any-macos.11-any/xpc/activity.h
c48051f145878798b22f39e8506cc62b2a72f2a2
[ "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
16,010
h
activity.h
#ifndef __XPC_ACTIVITY_H__ #define __XPC_ACTIVITY_H__ #ifndef __XPC_INDIRECT__ #error "Please #include <xpc/xpc.h> instead of this file directly." // For HeaderDoc. #include <xpc/base.h> #endif // __XPC_INDIRECT__ #ifdef __BLOCKS__ XPC_ASSUME_NONNULL_BEGIN __BEGIN_DECLS /* * The following are a collection of keys and values used to set an activity's * execution criteria. */ /*! * @constant XPC_ACTIVITY_INTERVAL * An integer property indicating the desired time interval (in seconds) of the * activity. The activity will not be run more than once per time interval. * Due to the nature of XPC Activity finding an opportune time to run * the activity, any two occurrences may be more or less than 'interval' * seconds apart, but on average will be 'interval' seconds apart. * The presence of this key implies the following, unless overridden: * - XPC_ACTIVITY_REPEATING with a value of true * - XPC_ACTIVITY_DELAY with a value of half the 'interval' * The delay enforces a minimum distance between any two occurrences. * - XPC_ACTIVITY_GRACE_PERIOD with a value of half the 'interval'. * The grace period is the amount of time allowed to pass after the end of * the interval before more aggressive scheduling occurs. The grace period * does not increase the size of the interval. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const char * const XPC_ACTIVITY_INTERVAL; /*! * @constant XPC_ACTIVITY_REPEATING * A boolean property indicating whether this is a repeating activity. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const char * const XPC_ACTIVITY_REPEATING; /*! * @constant XPC_ACTIVITY_DELAY * An integer property indicating the number of seconds to delay before * beginning the activity. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const char * const XPC_ACTIVITY_DELAY; /*! * @constant XPC_ACTIVITY_GRACE_PERIOD * An integer property indicating the number of seconds to allow as a grace * period before the scheduling of the activity becomes more aggressive. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const char * const XPC_ACTIVITY_GRACE_PERIOD; __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const int64_t XPC_ACTIVITY_INTERVAL_1_MIN; __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const int64_t XPC_ACTIVITY_INTERVAL_5_MIN; __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const int64_t XPC_ACTIVITY_INTERVAL_15_MIN; __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const int64_t XPC_ACTIVITY_INTERVAL_30_MIN; __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const int64_t XPC_ACTIVITY_INTERVAL_1_HOUR; __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const int64_t XPC_ACTIVITY_INTERVAL_4_HOURS; __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const int64_t XPC_ACTIVITY_INTERVAL_8_HOURS; __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const int64_t XPC_ACTIVITY_INTERVAL_1_DAY; __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const int64_t XPC_ACTIVITY_INTERVAL_7_DAYS; /*! * @constant XPC_ACTIVITY_PRIORITY * A string property indicating the priority of the activity. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const char * const XPC_ACTIVITY_PRIORITY; /*! * @constant XPC_ACTIVITY_PRIORITY_MAINTENANCE * A string indicating activity is maintenance priority. * * Maintenance priority is intended for user-invisible maintenance tasks * such as garbage collection or optimization. * * Maintenance activities are not permitted to run if the device thermal * condition exceeds a nominal level or if the battery level is lower than 20%. * In Low Power Mode (on supported devices), maintenance activities are not * permitted to run while the device is on battery, or plugged in and the * battery level is lower than 30%. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const char * const XPC_ACTIVITY_PRIORITY_MAINTENANCE; /*! * @constant XPC_ACTIVITY_PRIORITY_UTILITY * A string indicating activity is utility priority. * * Utility priority is intended for user-visible tasks such as fetching data * from the network, copying files, or importing data. * * Utility activities are not permitted to run if the device thermal condition * exceeds a moderate level or if the battery level is less than 10%. In Low * Power Mode (on supported devices) when on battery power, utility activities * are only permitted when they are close to their deadline (90% of their time * window has elapsed). */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const char * const XPC_ACTIVITY_PRIORITY_UTILITY; /*! * @constant XPC_ACTIVITY_ALLOW_BATTERY * A Boolean value indicating whether the activity should be allowed to run * while the computer is on battery power. The default value is false for * maintenance priority activity and true for utility priority activity. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const char * const XPC_ACTIVITY_ALLOW_BATTERY; /*! * @constant XPC_ACTIVITY_REQUIRE_SCREEN_SLEEP * A Boolean value indicating whether the activity should only be performed * while device appears to be asleep. Note that the definition of screen sleep * may vary by platform and may include states where the device is known to be * idle despite the fact that the display itself is still powered. Defaults to * false. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const char * const XPC_ACTIVITY_REQUIRE_SCREEN_SLEEP; // bool /*! * @constant XPC_ACTIVITY_REQUIRE_BATTERY_LEVEL * An integer percentage of minimum battery charge required to allow the * activity to run. A default minimum battery level is determined by the * system. */ __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_9, __MAC_10_9, __IPHONE_7_0, __IPHONE_7_0, "REQUIRE_BATTERY_LEVEL is not implemented") XPC_EXPORT const char * const XPC_ACTIVITY_REQUIRE_BATTERY_LEVEL; // int (%) /*! * @constant XPC_ACTIVITY_REQUIRE_HDD_SPINNING * A Boolean value indicating whether the activity should only be performed * while the hard disk drive (HDD) is spinning. Computers with flash storage * are considered to be equivalent to HDD spinning. Defaults to false. */ __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_9, __MAC_10_9, __IPHONE_7_0, __IPHONE_7_0, "REQUIRE_HDD_SPINNING is not implemented") XPC_EXPORT const char * const XPC_ACTIVITY_REQUIRE_HDD_SPINNING; // bool /*! * @define XPC_TYPE_ACTIVITY * A type representing the XPC activity object. */ #define XPC_TYPE_ACTIVITY (&_xpc_type_activity) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT XPC_TYPE(_xpc_type_activity); /*! * @typedef xpc_activity_t * * @abstract * An XPC activity object. * * @discussion * This object represents a set of execution criteria and a current execution * state for background activity on the system. Once an activity is registered, * the system will evaluate its criteria to determine whether the activity is * eligible to run under current system conditions. When an activity becomes * eligible to run, its execution state will be updated and an invocation of * its handler block will be made. */ XPC_DECL(xpc_activity); /*! * @typedef xpc_activity_handler_t * * @abstract * A block that is called when an XPC activity becomes eligible to run. */ XPC_NONNULL1 typedef void (^xpc_activity_handler_t)(xpc_activity_t activity); /*! * @constant XPC_ACTIVITY_CHECK_IN * This constant may be passed to xpc_activity_register() as the criteria * dictionary in order to check in with the system for previously registered * activity using the same identifier (for example, an activity taken from a * launchd property list). */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT const xpc_object_t XPC_ACTIVITY_CHECK_IN; /*! * @function xpc_activity_register * * @abstract * Registers an activity with the system. * * @discussion * Registers a new activity with the system. The criteria of the activity are * described by the dictionary passed to this function. If an activity with the * same identifier already exists, the criteria provided override the existing * criteria unless the special dictionary XPC_ACTIVITY_CHECK_IN is used. The * XPC_ACTIVITY_CHECK_IN dictionary instructs the system to first look up an * existing activity without modifying its criteria. Once the existing activity * is found (or a new one is created with an empty set of criteria) the handler * will be called with an activity object in the XPC_ACTIVITY_STATE_CHECK_IN * state. * * @param identifier * A unique identifier for the activity. Each application has its own namespace. * The identifier should remain constant across registrations, relaunches of * the application, and reboots. It should identify the kind of work being done, * not a particular invocation of the work. * * @param criteria * A dictionary of criteria for the activity. * * @param handler * The handler block to be called when the activity changes state to one of the * following states: * - XPC_ACTIVITY_STATE_CHECK_IN (optional) * - XPC_ACTIVITY_STATE_RUN * * The handler block is never invoked reentrantly. It will be invoked on a * dispatch queue with an appropriate priority to perform the activity. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3 void xpc_activity_register(const char *identifier, xpc_object_t criteria, xpc_activity_handler_t handler); /*! * @function xpc_activity_copy_criteria * * @abstract * Returns an XPC dictionary describing the execution criteria of an activity. * This will return NULL in cases where the activity has already completed, e.g. * when checking in to an event that finished and was not rescheduled. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT XPC_WARN_RESULT XPC_RETURNS_RETAINED XPC_NONNULL1 xpc_object_t _Nullable xpc_activity_copy_criteria(xpc_activity_t activity); /*! * @function xpc_activity_set_criteria * * @abstract * Modifies the execution criteria of an activity. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 void xpc_activity_set_criteria(xpc_activity_t activity, xpc_object_t criteria); /*! * @enum xpc_activity_state_t * An activity is defined to be in one of the following states. Applications * may check the current state of the activity using xpc_activity_get_state() * in the handler block provided to xpc_activity_register(). * * The application can modify the state of the activity by calling * xpc_activity_set_state() with one of the following: * - XPC_ACTIVITY_STATE_DEFER * - XPC_ACTIVITY_STATE_CONTINUE * - XPC_ACTIVITY_STATE_DONE * * @constant XPC_ACTIVITY_STATE_CHECK_IN * An activity in this state has just completed a checkin with the system after * XPC_ACTIVITY_CHECK_IN was provided as the criteria dictionary to * xpc_activity_register. The state gives the application an opportunity to * inspect and modify the activity's criteria. * * @constant XPC_ACTIVITY_STATE_WAIT * An activity in this state is waiting for an opportunity to run. This value * is never returned within the activity's handler block, as the block is * invoked in response to XPC_ACTIVITY_STATE_CHECK_IN or XPC_ACTIVITY_STATE_RUN. * * Note: * A launchd job may idle exit while an activity is in the wait state and be * relaunched in response to the activity becoming runnable. The launchd job * simply needs to re-register for the activity on its next launch by passing * XPC_ACTIVITY_STATE_CHECK_IN to xpc_activity_register(). * * @constant XPC_ACTIVITY_STATE_RUN * An activity in this state is eligible to run based on its criteria. * * @constant XPC_ACTIVITY_STATE_DEFER * An application may pass this value to xpc_activity_set_state() to indicate * that the activity should be deferred (placed back into the WAIT state) until * a time when its criteria are met again. Deferring an activity does not reset * any of its time-based criteria (in other words, it will remain past due). * * IMPORTANT: * This should be done in response to observing xpc_activity_should_defer(). * It should not be done unilaterally. If you determine that conditions are bad * to do your activity's work for reasons you can't express in a criteria * dictionary, you should set the activity's state to XPC_ACTIVITY_STATE_DONE. * * * @constant XPC_ACTIVITY_STATE_CONTINUE * An application may pass this value to xpc_activity_set_state() to indicate * that the activity will continue its operation beyond the return of its * handler block. This can be used to extend an activity to include asynchronous * operations. The activity's handler block will not be invoked again until the * state has been updated to either XPC_ACTIVITY_STATE_DEFER or, in the case * of repeating activity, XPC_ACTIVITY_STATE_DONE. * * @constant XPC_ACTIVITY_STATE_DONE * An application may pass this value to xpc_activity_set_state() to indicate * that the activity has completed. For non-repeating activity, the resources * associated with the activity will be automatically released upon return from * the handler block. For repeating activity, timers present in the activity's * criteria will be reset. */ enum { XPC_ACTIVITY_STATE_CHECK_IN, XPC_ACTIVITY_STATE_WAIT, XPC_ACTIVITY_STATE_RUN, XPC_ACTIVITY_STATE_DEFER, XPC_ACTIVITY_STATE_CONTINUE, XPC_ACTIVITY_STATE_DONE, }; typedef long xpc_activity_state_t; /*! * @function xpc_activity_get_state * * @abstract * Returns the current state of an activity. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 xpc_activity_state_t xpc_activity_get_state(xpc_activity_t activity); /*! * @function xpc_activity_set_state * * @abstract * Updates the current state of an activity. * * @return * Returns true if the state was successfully updated; otherwise, returns * false if the requested state transition is not valid. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 bool xpc_activity_set_state(xpc_activity_t activity, xpc_activity_state_t state); /*! * @function xpc_activity_should_defer * * @abstract * Test whether an activity should be deferred. * * @discussion * This function may be used to test whether the criteria of a long-running * activity are still satisfied. If not, the system indicates that the * application should defer the activity. The application may acknowledge the * deferral by calling xpc_activity_set_state() with XPC_ACTIVITY_STATE_DEFER. * Once deferred, the system will place the activity back into the WAIT state * and re-invoke the handler block at the earliest opportunity when the criteria * are once again satisfied. * * @return * Returns true if the activity should be deferred. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 bool xpc_activity_should_defer(xpc_activity_t activity); /*! * @function xpc_activity_unregister * * @abstract * Unregisters an activity found by its identifier. * * @discussion * A dynamically registered activity will be deleted in response to this call. * Statically registered activity (from a launchd property list) will be * deleted until the job is next loaded (e.g. at next boot). * * Unregistering an activity has no effect on any outstanding xpc_activity_t * objects or any currently executing xpc_activity_handler_t blocks; however, * no new handler block invocations will be made after it is unregistered. * * @param identifier * The identifier of the activity to unregister. */ __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0) XPC_EXPORT XPC_NONNULL1 void xpc_activity_unregister(const char *identifier); __END_DECLS XPC_ASSUME_NONNULL_END #endif // __BLOCKS__ #endif // __XPC_ACTIVITY_H__
287fefb396a1570cd1f8310a8b37ef0336384da1
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/ffmpeg/libavcodec/h265_profile_level.h
cd30ac5c504aabbb1d3fc28bf14c69b7a6a07b00
[ "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "LGPL-2.1-only", "LGPL-3.0-only", "GPL-2.0-only", "LGPL-2.1-or-later", "GPL-3.0-or-later", "LGPL-3.0-or-later", "IJG", "LicenseRef-scancode-other-permissive", "GPL-2.0-or-later", "GPL-3.0-only" ]
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,738
h
h265_profile_level.h
/* * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg 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 FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_H265_PROFILE_LEVEL_H #define AVCODEC_H265_PROFILE_LEVEL_H #include <stdint.h> #include "cbs_h265.h" typedef struct H265LevelDescriptor { char name[4]; // Large enough for all current levels like "4.1" uint8_t level_idc; // Table A.6. uint32_t max_luma_ps; uint32_t max_cpb_main; uint32_t max_cpb_high; uint16_t max_slice_segments_per_picture; uint8_t max_tile_rows; uint8_t max_tile_cols; // Table A.7. uint32_t max_luma_sr; uint32_t max_br_main; uint32_t max_br_high; uint8_t min_cr_base_main; uint8_t min_cr_base_high; } H265LevelDescriptor; typedef struct H265ProfileDescriptor { const char *name; uint8_t profile_idc; uint8_t high_throughput; // Tables A.2, A.3 and A.5. uint8_t max_14bit; uint8_t max_12bit; uint8_t max_10bit; uint8_t max_8bit; uint8_t max_422chroma; uint8_t max_420chroma; uint8_t max_monochrome; uint8_t intra; uint8_t one_picture_only; uint8_t lower_bit_rate; // Table A.8. uint16_t cpb_vcl_factor; uint16_t cpb_nal_factor; float format_capability_factor; float min_cr_scale_factor; uint8_t max_dpb_pic_buf; } H265ProfileDescriptor; const H265ProfileDescriptor *ff_h265_get_profile(const H265RawProfileTierLevel *ptl); /** * Guess the level of a stream from some parameters. * * Unknown parameters may be zero, in which case they are ignored. */ const H265LevelDescriptor *ff_h265_guess_level(const H265RawProfileTierLevel *ptl, int64_t bitrate, int width, int height, int slice_segments, int tile_rows, int tile_cols, int max_dec_pic_buffering); #endif /* AVCODEC_H265_PROFILE_LEVEL_H */
e6e723c2b3d18c245cae98c331cd729669a2178d
7e6afb4986a53c420d40a2039240f8c5ed3f9549
/libs/math/src/CSparse/cs_gaxpy.c
c898120da4efbed9b1e92cce17aa1fd94f2e9af3
[ "LGPL-2.1-or-later", "LGPL-2.0-or-later", "DOC", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
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
601
c
cs_gaxpy.c
// CSparse/Source/cs_gaxpy: sparse matrix times dense vector // CSparse, Copyright (c) 2006-2023, Timothy A. Davis. All Rights Reserved. // SPDX-License-Identifier: LGPL-2.1+ #include "cs.h" /* y = A*x+y */ int cs_gaxpy (const cs *A, const double *x, double *y) { int p, j, n, *Ap, *Ai ; double *Ax ; if (!CS_CSC (A) || !x || !y) return (0) ; /* check inputs */ n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ; for (j = 0 ; j < n ; j++) { for (p = Ap [j] ; p < Ap [j+1] ; p++) { y [Ai [p]] += Ax [p] * x [j] ; } } return (1) ; }
089b77e7d476ed5875d04075a912b492f558f066
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/audio/jack/patches/patch-netbsd_JackNetBSDTime.c
7be45d94067de93b828c38616d9122b16c04cdb1
[]
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
2,372
c
patch-netbsd_JackNetBSDTime.c
$NetBSD: patch-netbsd_JackNetBSDTime.c,v 1.1 2021/09/08 19:19:20 nia Exp $ Add NetBSD support. --- netbsd/JackNetBSDTime.c.orig 2021-09-08 13:51:19.683998596 +0000 +++ netbsd/JackNetBSDTime.c @@ -0,0 +1,90 @@ +/* +Copyright (C) 2001-2003 Paul Davis +Copyright (C) 2005 Jussi Laako +Copyright (C) 2004-2008 Grame +Copyright (C) 2018 Greg V + +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 2.1 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 Lesser 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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "JackConstants.h" +#include "JackTime.h" +#include "JackTypes.h" +#include "JackError.h" + +#include <time.h> +#include <unistd.h> + +jack_time_t (*_jack_get_microseconds)(void) = 0; + +static jack_time_t jack_get_microseconds_from_system (void) +{ + jack_time_t jackTime; + struct timespec time; + + clock_gettime(CLOCK_MONOTONIC, &time); + jackTime = (jack_time_t) time.tv_sec * 1e6 + + (jack_time_t) time.tv_nsec / 1e3; + return jackTime; +} + + +SERVER_EXPORT void JackSleep(long usec) +{ + usleep(usec); +} + +SERVER_EXPORT void InitTime() +{ + /* nothing to do on a generic system - we use the system clock */ +} + +SERVER_EXPORT void EndTime() +{} + +void SetClockSource(jack_timer_type_t source) +{ + jack_log("Clock source : %s", ClockSourceName(source)); + + switch (source) + { + case JACK_TIMER_SYSTEM_CLOCK: + default: + _jack_get_microseconds = jack_get_microseconds_from_system; + break; + } +} + +const char* ClockSourceName(jack_timer_type_t source) +{ + switch (source) { + case JACK_TIMER_SYSTEM_CLOCK: + return "system clock via clock_gettime"; + } + + return "unknown"; +} + +SERVER_EXPORT jack_time_t GetMicroSeconds() +{ + return _jack_get_microseconds(); +} + +SERVER_EXPORT jack_time_t jack_get_microseconds() +{ + return _jack_get_microseconds(); +} +
0dd25d13f21351801bdc0f50a12f6dcd44c1df24
fbe68d84e97262d6d26dd65c704a7b50af2b3943
/third_party/virtualbox/src/VBox/Devices/EFI/Firmware/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
0d4ddbc0e45a6ab3c87ab1a4198e32fd2d702f2e
[ "MIT", "GPL-2.0-only", "LicenseRef-scancode-unknown-license-reference", "CDDL-1.0", "LicenseRef-scancode-warranty-disclaimer", "GPL-1.0-or-later", "LGPL-2.1-or-later", "GPL-2.0-or-later", "MPL-1.0", "LicenseRef-scancode-generic-exception", "Apache-2.0", "OpenSSL", "BSD-2-Clause" ]
permissive
thalium/icebox
c4e6573f2b4f0973b6c7bb0bf068fe9e795fdcfb
6f78952d58da52ea4f0e55b2ab297f28e80c1160
refs/heads/master
2022-08-14T00:19:36.984579
2022-02-22T13:10:31
2022-02-22T13:10:31
190,019,914
585
109
MIT
2022-01-13T20:58:15
2019-06-03T14:18:12
C++
UTF-8
C
false
false
17,811
h
Ps2Keyboard.h
/** @file PS/2 keyboard driver header file Copyright (c) 2006 - 2012, 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 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. **/ #ifndef _PS2KEYBOARD_H_ #define _PS2KEYBOARD_H_ #include <FrameworkDxe.h> #include <Protocol/SimpleTextIn.h> #include <Protocol/SimpleTextInEx.h> #include <Protocol/IsaIo.h> #include <Protocol/DevicePath.h> #include <Protocol/Ps2Policy.h> #include <Library/UefiDriverEntryPoint.h> #include <Library/UefiLib.h> #include <Library/UefiBootServicesTableLib.h> #include <Library/ReportStatusCodeLib.h> #include <Library/DebugLib.h> #include <Library/UefiRuntimeServicesTableLib.h> #include <Library/MemoryAllocationLib.h> #include <Library/BaseLib.h> #include <Library/BaseMemoryLib.h> #include <Library/TimerLib.h> #include <Library/PcdLib.h> // // Global Variables // extern EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver; extern EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName; extern EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2; // // Driver Private Data // #define KEYBOARD_CONSOLE_IN_DEV_SIGNATURE SIGNATURE_32 ('k', 'k', 'e', 'y') #define KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('k', 'c', 'e', 'n') typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY { UINTN Signature; EFI_KEY_DATA KeyData; EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn; LIST_ENTRY NotifyEntry; } KEYBOARD_CONSOLE_IN_EX_NOTIFY; #define KEYBOARD_SCAN_CODE_MAX_COUNT 32 typedef struct { UINT8 Buffer[KEYBOARD_SCAN_CODE_MAX_COUNT]; UINTN Head; UINTN Tail; } SCAN_CODE_QUEUE; #define KEYBOARD_EFI_KEY_MAX_COUNT 256 typedef struct { EFI_KEY_DATA Buffer[KEYBOARD_EFI_KEY_MAX_COUNT]; UINTN Head; UINTN Tail; } EFI_KEY_QUEUE; typedef struct { UINTN Signature; EFI_HANDLE Handle; EFI_SIMPLE_TEXT_INPUT_PROTOCOL ConIn; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL ConInEx; EFI_ISA_IO_PROTOCOL *IsaIo; EFI_EVENT TimerEvent; UINT32 DataRegisterAddress; UINT32 StatusRegisterAddress; UINT32 CommandRegisterAddress; BOOLEAN LeftCtrl; BOOLEAN RightCtrl; BOOLEAN LeftAlt; BOOLEAN RightAlt; BOOLEAN LeftShift; BOOLEAN RightShift; BOOLEAN LeftLogo; BOOLEAN RightLogo; BOOLEAN Menu; BOOLEAN SysReq; BOOLEAN CapsLock; BOOLEAN NumLock; BOOLEAN ScrollLock; BOOLEAN IsSupportPartialKey; // // Queue storing key scancodes // SCAN_CODE_QUEUE ScancodeQueue; EFI_KEY_QUEUE EfiKeyQueue; // // Error state // BOOLEAN KeyboardErr; EFI_UNICODE_STRING_TABLE *ControllerNameTable; EFI_DEVICE_PATH_PROTOCOL *DevicePath; // // Notification Function List // LIST_ENTRY NotifyList; } KEYBOARD_CONSOLE_IN_DEV; #define KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) CR (a, KEYBOARD_CONSOLE_IN_DEV, ConIn, KEYBOARD_CONSOLE_IN_DEV_SIGNATURE) #define TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) \ CR (a, \ KEYBOARD_CONSOLE_IN_DEV, \ ConInEx, \ KEYBOARD_CONSOLE_IN_DEV_SIGNATURE \ ) #define TABLE_END 0x0 // // Driver entry point // /** The user Entry Point for module Ps2Keyboard. The user code starts with this function. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. **/ EFI_STATUS EFIAPI InstallPs2KeyboardDriver ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ); #define KEYBOARD_8042_DATA_REGISTER 0x60 #define KEYBOARD_8042_STATUS_REGISTER 0x64 #define KEYBOARD_8042_COMMAND_REGISTER 0x64 #define KEYBOARD_KBEN 0xF4 #define KEYBOARD_CMDECHO_ACK 0xFA #define KEYBOARD_MAX_TRY 256 // 256 #define KEYBOARD_TIMEOUT 65536 // 0.07s #define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s #define KEYBOARD_BAT_TIMEOUT 4000000 // 4s #define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s #define SCANCODE_EXTENDED0 0xE0 #define SCANCODE_EXTENDED1 0xE1 #define SCANCODE_CTRL_MAKE 0x1D #define SCANCODE_CTRL_BREAK 0x9D #define SCANCODE_ALT_MAKE 0x38 #define SCANCODE_ALT_BREAK 0xB8 #define SCANCODE_LEFT_SHIFT_MAKE 0x2A #define SCANCODE_LEFT_SHIFT_BREAK 0xAA #define SCANCODE_RIGHT_SHIFT_MAKE 0x36 #define SCANCODE_RIGHT_SHIFT_BREAK 0xB6 #define SCANCODE_CAPS_LOCK_MAKE 0x3A #define SCANCODE_NUM_LOCK_MAKE 0x45 #define SCANCODE_SCROLL_LOCK_MAKE 0x46 #define SCANCODE_DELETE_MAKE 0x53 #define SCANCODE_LEFT_LOGO_MAKE 0x5B //GUI key defined in Keyboard scan code #define SCANCODE_LEFT_LOGO_BREAK 0xDB #define SCANCODE_RIGHT_LOGO_MAKE 0x5C #define SCANCODE_RIGHT_LOGO_BREAK 0xDC #define SCANCODE_MENU_MAKE 0x5D //APPS key defined in Keyboard scan code #define SCANCODE_MENU_BREAK 0xDD #define SCANCODE_SYS_REQ_MAKE 0x37 #define SCANCODE_SYS_REQ_BREAK 0xB7 #define SCANCODE_SYS_REQ_MAKE_WITH_ALT 0x54 #define SCANCODE_SYS_REQ_BREAK_WITH_ALT 0xD4 #define SCANCODE_MAX_MAKE 0x60 #define KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA BIT0 ///< 0 - Output register has no data; 1 - Output register has data #define KEYBOARD_STATUS_REGISTER_HAS_INPUT_DATA BIT1 ///< 0 - Input register has no data; 1 - Input register has data #define KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG BIT2 ///< Set to 0 after power on reset #define KEYBOARD_STATUS_REGISTER_INPUT_DATA_TYPE BIT3 ///< 0 - Data in input register is data; 1 - Data in input register is command #define KEYBOARD_STATUS_REGISTER_ENABLE_FLAG BIT4 ///< 0 - Keyboard is disable; 1 - Keyboard is enable #define KEYBOARD_STATUS_REGISTER_TRANSMIT_TIMEOUT BIT5 ///< 0 - Transmit is complete without timeout; 1 - Transmit is timeout without complete #define KEYBOARD_STATUS_REGISTER_RECEIVE_TIMEOUT BIT6 ///< 0 - Receive is complete without timeout; 1 - Receive is timeout without complete #define KEYBOARD_STATUS_REGISTER_PARITY BIT7 ///< 0 - Odd parity; 1 - Even parity #define KEYBOARD_8042_COMMAND_READ 0x20 #define KEYBOARD_8042_COMMAND_WRITE 0x60 #define KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE 0xA7 #define KEYBOARD_8042_COMMAND_ENABLE_MOUSE_INTERFACE 0xA8 #define KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST 0xAA #define KEYBOARD_8042_COMMAND_KEYBOARD_INTERFACE_SELF_TEST 0xAB #define KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE 0xAD #define KEYBOARD_8048_COMMAND_CLEAR_OUTPUT_DATA 0xF4 #define KEYBOARD_8048_COMMAND_RESET 0xFF #define KEYBOARD_8048_COMMAND_SELECT_SCAN_CODE_SET 0xF0 #define KEYBOARD_8048_RETURN_8042_BAT_SUCCESS 0xAA #define KEYBOARD_8048_RETURN_8042_BAT_ERROR 0xFC #define KEYBOARD_8048_RETURN_8042_ACK 0xFA // // Keyboard Controller Status // #define KBC_PARE 0x80 // Parity Error #define KBC_TIM 0x40 // General Time Out // // Other functions that are used among .c files // /** Show keyboard status lights according to indicators in ConsoleIn. @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV @return status **/ EFI_STATUS UpdateStatusLights ( IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn ); /** write key to keyboard. @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV @param Data value wanted to be written @retval EFI_TIMEOUT - GC_TODO: Add description for return value @retval EFI_SUCCESS - GC_TODO: Add description for return value **/ EFI_STATUS KeyboardRead ( IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, OUT UINT8 *Data ); /** Get scancode from scancode buffer and translate into EFI-scancode and unicode defined by EFI spec. The function is always called in TPL_NOTIFY. @param ConsoleIn KEYBOARD_CONSOLE_IN_DEV instance pointer **/ VOID KeyGetchar ( IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn ); /** Perform 8042 controller and keyboard Initialization. If ExtendedVerification is TRUE, do additional test for the keyboard interface @param ConsoleIn - KEYBOARD_CONSOLE_IN_DEV instance pointer @param ExtendedVerification - indicates a thorough initialization @retval EFI_DEVICE_ERROR Fail to init keyboard @retval EFI_SUCCESS Success to init keyboard **/ EFI_STATUS InitKeyboard ( IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, IN BOOLEAN ExtendedVerification ); /** Disable the keyboard interface of the 8042 controller. @param ConsoleIn - the device instance @return status of issuing disable command **/ EFI_STATUS DisableKeyboard ( IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn ); /** Timer event handler: read a series of scancodes from 8042 and put them into memory scancode buffer. it read as much scancodes to either fill the memory buffer or empty the keyboard buffer. It is registered as running under TPL_NOTIFY @param Event - The timer event @param Context - A KEYBOARD_CONSOLE_IN_DEV pointer **/ VOID EFIAPI KeyboardTimerHandler ( IN EFI_EVENT Event, IN VOID *Context ); /** logic reset keyboard Implement SIMPLE_TEXT_IN.Reset() Perform 8042 controller and keyboard initialization @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL @param ExtendedVerification Indicate that the driver may perform a more exhaustive verification operation of the device during reset, now this par is ignored in this driver **/ EFI_STATUS EFIAPI KeyboardEfiReset ( IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification ); /** Implement SIMPLE_TEXT_IN.ReadKeyStroke(). Retrieve key values for driver user. @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL @param Key The output buffer for key value @retval EFI_SUCCESS success to read key stroke **/ EFI_STATUS EFIAPI KeyboardReadKeyStroke ( IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, OUT EFI_INPUT_KEY *Key ); /** Event notification function for SIMPLE_TEXT_IN.WaitForKey event Signal the event if there is key available @param Event the event object @param Context waitting context **/ VOID EFIAPI KeyboardWaitForKey ( IN EFI_EVENT Event, IN VOID *Context ); /** Read status register. @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV @return value in status register **/ UINT8 KeyReadStatusRegister ( IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn ); /** Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device should not be in system. @param[in] ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV @retval TRUE Keyboard in System. @retval FALSE Keyboard not in System. **/ BOOLEAN EFIAPI CheckKeyboardConnect ( IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn ); /** Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event Signal the event if there is key available @param Event event object @param Context waiting context **/ VOID EFIAPI KeyboardWaitForKeyEx ( IN EFI_EVENT Event, IN VOID *Context ); // // Simple Text Input Ex protocol function prototypes // /** Reset the input device and optionaly run diagnostics @param This - Protocol instance pointer. @param ExtendedVerification - Driver may perform diagnostics on reset. @retval EFI_SUCCESS - The device was reset. @retval EFI_DEVICE_ERROR - The device is not functioning properly and could not be reset. **/ EFI_STATUS EFIAPI KeyboardEfiResetEx ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN BOOLEAN ExtendedVerification ); /** Reads the next keystroke from the input device. The WaitForKey Event can be used to test for existance of a keystroke via WaitForEvent () call. @param This - Protocol instance pointer. @param KeyData - A pointer to a buffer that is filled in with the keystroke state data for the key that was pressed. @retval EFI_SUCCESS - The keystroke information was returned. @retval EFI_NOT_READY - There was no keystroke data availiable. @retval EFI_DEVICE_ERROR - The keystroke information was not returned due to hardware errors. @retval EFI_INVALID_PARAMETER - KeyData is NULL. **/ EFI_STATUS EFIAPI KeyboardReadKeyStrokeEx ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, OUT EFI_KEY_DATA *KeyData ); /** Set certain state for the input device. @param This - Protocol instance pointer. @param KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the state for the input device. @retval EFI_SUCCESS - The device state was set successfully. @retval EFI_DEVICE_ERROR - The device is not functioning correctly and could not have the setting adjusted. @retval EFI_UNSUPPORTED - The device does not have the ability to set its state. @retval EFI_INVALID_PARAMETER - KeyToggleState is NULL. **/ EFI_STATUS EFIAPI KeyboardSetState ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_TOGGLE_STATE *KeyToggleState ); /** Register a notification function for a particular keystroke for the input device. @param This - Protocol instance pointer. @param KeyData - A pointer to a buffer that is filled in with the keystroke information data for the key that was pressed. @param KeyNotificationFunction - Points to the function to be called when the key sequence is typed specified by KeyData. @param NotifyHandle - Points to the unique handle assigned to the registered notification. @retval EFI_SUCCESS - The notification function was registered successfully. @retval EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures. @retval EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL. **/ EFI_STATUS EFIAPI KeyboardRegisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_DATA *KeyData, IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, OUT VOID **NotifyHandle ); /** Remove a registered notification function from a particular keystroke. @param This - Protocol instance pointer. @param NotificationHandle - The handle of the notification function being unregistered. @retval EFI_SUCCESS - The notification function was unregistered successfully. @retval EFI_INVALID_PARAMETER - The NotificationHandle is invalid. @retval EFI_NOT_FOUND - Can not find the matching entry in database. **/ EFI_STATUS EFIAPI KeyboardUnregisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN VOID *NotificationHandle ); /** Push one key data to the EFI key buffer. @param Queue Pointer to instance of EFI_KEY_QUEUE. @param KeyData The key data to push. **/ VOID PushEfikeyBufTail ( IN EFI_KEY_QUEUE *Queue, IN EFI_KEY_DATA *KeyData ); /** Judge whether is a registed key @param RegsiteredData A pointer to a buffer that is filled in with the keystroke state data for the key that was registered. @param InputData A pointer to a buffer that is filled in with the keystroke state data for the key that was pressed. @retval TRUE Key be pressed matches a registered key. @retval FLASE Match failed. **/ BOOLEAN IsKeyRegistered ( IN EFI_KEY_DATA *RegsiteredData, IN EFI_KEY_DATA *InputData ); #endif
89adb4df4e789e700edbd915528f73dbb9876af9
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/include/any-windows-any/msplog.h
d422d82543fb9f5d2820c417708dea60de04012b
[ "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-public-domain", "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
1,053
h
msplog.h
/** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the mingw-w64 runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #ifndef _MSPLOG_H_ #define _MSPLOG_H_ #ifdef MSPLOG #include <rtutils.h> #define MSP_ERROR ((DWORD)0x00010000 | TRACE_USE_MASK) #define MSP_WARN ((DWORD)0x00020000 | TRACE_USE_MASK) #define MSP_INFO ((DWORD)0x00040000 | TRACE_USE_MASK) #define MSP_TRACE ((DWORD)0x00080000 | TRACE_USE_MASK) #define MSP_EVENT ((DWORD)0x00100000 | TRACE_USE_MASK) WINBOOL NTAPI MSPLogRegister(LPCTSTR szName); void NTAPI MSPLogDeRegister(); void NTAPI LogPrint(DWORD dwDbgLevel,LPCSTR DbgMessage,...); #define MSPLOGREGISTER(arg) MSPLogRegister(arg) #define MSPLOGDEREGISTER() MSPLogDeRegister() extern WINBOOL g_bMSPBaseTracingOn; #define LOG(arg) g_bMSPBaseTracingOn?LogPrint arg:0 #else #define MSPLOGREGISTER(arg) #define MSPLOGDEREGISTER() #define LOG(arg) #endif #define DECLARE_LOG_ADDREF_RELEASE(x) #define CMSPComObject CComObject #endif
d89a9016915e3fe1844352078eaff14e17019713
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/grpc/src/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c
00774f610445670a5ef950920916d25f247db1c1
[ "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "BSD-3-Clause", "MPL-2.0" ]
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
10,784
c
listener.upb.c
/* This file was generated by upbc (the upb compiler) from the input * file: * * envoy/config/listener/v3/listener.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ #include <stddef.h> #include "upb/msg_internal.h" #include "envoy/config/listener/v3/listener.upb.h" #include "envoy/config/accesslog/v3/accesslog.upb.h" #include "envoy/config/core/v3/address.upb.h" #include "envoy/config/core/v3/base.upb.h" #include "envoy/config/core/v3/extension.upb.h" #include "envoy/config/core/v3/socket_option.upb.h" #include "envoy/config/listener/v3/api_listener.upb.h" #include "envoy/config/listener/v3/listener_components.upb.h" #include "envoy/config/listener/v3/udp_listener_config.upb.h" #include "google/protobuf/duration.upb.h" #include "google/protobuf/wrappers.upb.h" #include "xds/annotations/v3/status.upb.h" #include "xds/core/v3/collection_entry.upb.h" #include "xds/type/matcher/v3/matcher.upb.h" #include "envoy/annotations/deprecation.upb.h" #include "udpa/annotations/security.upb.h" #include "udpa/annotations/status.upb.h" #include "udpa/annotations/versioning.upb.h" #include "validate/validate.upb.h" #include "upb/port_def.inc" static const upb_MiniTable_Sub envoy_config_listener_v3_AdditionalAddress_submsgs[2] = { {.submsg = &envoy_config_core_v3_Address_msginit}, {.submsg = &envoy_config_core_v3_SocketOptionsOverride_msginit}, }; static const upb_MiniTable_Field envoy_config_listener_v3_AdditionalAddress__fields[2] = { {1, UPB_SIZE(4, 8), UPB_SIZE(1, 1), 0, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {2, UPB_SIZE(8, 16), UPB_SIZE(2, 2), 1, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, }; const upb_MiniTable envoy_config_listener_v3_AdditionalAddress_msginit = { &envoy_config_listener_v3_AdditionalAddress_submsgs[0], &envoy_config_listener_v3_AdditionalAddress__fields[0], UPB_SIZE(16, 24), 2, kUpb_ExtMode_NonExtendable, 2, 255, 0, }; static const upb_MiniTable_Sub envoy_config_listener_v3_ListenerCollection_submsgs[1] = { {.submsg = &xds_core_v3_CollectionEntry_msginit}, }; static const upb_MiniTable_Field envoy_config_listener_v3_ListenerCollection__fields[1] = { {1, UPB_SIZE(0, 0), UPB_SIZE(0, 0), 0, 11, kUpb_FieldMode_Array | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, }; const upb_MiniTable envoy_config_listener_v3_ListenerCollection_msginit = { &envoy_config_listener_v3_ListenerCollection_submsgs[0], &envoy_config_listener_v3_ListenerCollection__fields[0], UPB_SIZE(8, 8), 1, kUpb_ExtMode_NonExtendable, 1, 255, 0, }; static const upb_MiniTable_Sub envoy_config_listener_v3_Listener_submsgs[23] = { {.submsg = &envoy_config_core_v3_Address_msginit}, {.submsg = &envoy_config_listener_v3_FilterChain_msginit}, {.submsg = &google_protobuf_BoolValue_msginit}, {.submsg = &google_protobuf_UInt32Value_msginit}, {.submsg = &envoy_config_core_v3_Metadata_msginit}, {.submsg = &envoy_config_listener_v3_Listener_DeprecatedV1_msginit}, {.submsg = &envoy_config_listener_v3_ListenerFilter_msginit}, {.submsg = &google_protobuf_BoolValue_msginit}, {.submsg = &google_protobuf_BoolValue_msginit}, {.submsg = &google_protobuf_UInt32Value_msginit}, {.submsg = &envoy_config_core_v3_SocketOption_msginit}, {.submsg = &google_protobuf_Duration_msginit}, {.submsg = &envoy_config_listener_v3_UdpListenerConfig_msginit}, {.submsg = &envoy_config_listener_v3_ApiListener_msginit}, {.submsg = &envoy_config_listener_v3_Listener_ConnectionBalanceConfig_msginit}, {.submsg = &envoy_config_accesslog_v3_AccessLog_msginit}, {.submsg = &google_protobuf_UInt32Value_msginit}, {.submsg = &envoy_config_listener_v3_FilterChain_msginit}, {.submsg = &google_protobuf_BoolValue_msginit}, {.submsg = &envoy_config_listener_v3_Listener_InternalListenerConfig_msginit}, {.submsg = &google_protobuf_BoolValue_msginit}, {.submsg = &xds_type_matcher_v3_Matcher_msginit}, {.submsg = &envoy_config_listener_v3_AdditionalAddress_msginit}, }; static const upb_MiniTable_Field envoy_config_listener_v3_Listener__fields[31] = { {1, UPB_SIZE(24, 24), UPB_SIZE(0, 0), kUpb_NoSub, 9, kUpb_FieldMode_Scalar | (kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, {2, UPB_SIZE(32, 40), UPB_SIZE(1, 1), 0, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {3, UPB_SIZE(36, 48), UPB_SIZE(0, 0), 1, 11, kUpb_FieldMode_Array | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {4, UPB_SIZE(40, 56), UPB_SIZE(2, 2), 2, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {5, UPB_SIZE(44, 64), UPB_SIZE(3, 3), 3, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {6, UPB_SIZE(48, 72), UPB_SIZE(4, 4), 4, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {7, UPB_SIZE(52, 80), UPB_SIZE(5, 5), 5, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {8, UPB_SIZE(4, 4), UPB_SIZE(0, 0), kUpb_NoSub, 5, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, {9, UPB_SIZE(56, 88), UPB_SIZE(0, 0), 6, 11, kUpb_FieldMode_Array | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {10, UPB_SIZE(60, 96), UPB_SIZE(6, 6), 7, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {11, UPB_SIZE(64, 104), UPB_SIZE(7, 7), 8, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {12, UPB_SIZE(68, 112), UPB_SIZE(8, 8), 9, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {13, UPB_SIZE(72, 120), UPB_SIZE(0, 0), 10, 11, kUpb_FieldMode_Array | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {15, UPB_SIZE(76, 128), UPB_SIZE(9, 9), 11, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {16, UPB_SIZE(8, 8), UPB_SIZE(0, 0), kUpb_NoSub, 5, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}, {17, UPB_SIZE(12, 12), UPB_SIZE(0, 0), kUpb_NoSub, 8, kUpb_FieldMode_Scalar | (kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, {18, UPB_SIZE(80, 136), UPB_SIZE(10, 10), 12, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {19, UPB_SIZE(84, 144), UPB_SIZE(11, 11), 13, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {20, UPB_SIZE(88, 152), UPB_SIZE(12, 12), 14, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {21, UPB_SIZE(13, 13), UPB_SIZE(0, 0), kUpb_NoSub, 8, kUpb_FieldMode_Scalar | (kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, {22, UPB_SIZE(92, 160), UPB_SIZE(0, 0), 15, 11, kUpb_FieldMode_Array | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {24, UPB_SIZE(96, 168), UPB_SIZE(13, 13), 16, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {25, UPB_SIZE(100, 176), UPB_SIZE(14, 14), 17, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {26, UPB_SIZE(104, 184), UPB_SIZE(15, 15), 18, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {27, UPB_SIZE(128, 232), UPB_SIZE(-17, -17), 19, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {28, UPB_SIZE(108, 192), UPB_SIZE(0, 0), kUpb_NoSub, 9, kUpb_FieldMode_Scalar | (kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}, {29, UPB_SIZE(116, 208), UPB_SIZE(16, 16), 20, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {30, UPB_SIZE(20, 20), UPB_SIZE(0, 0), kUpb_NoSub, 8, kUpb_FieldMode_Scalar | (kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, {31, UPB_SIZE(21, 21), UPB_SIZE(0, 0), kUpb_NoSub, 8, kUpb_FieldMode_Scalar | (kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)}, {32, UPB_SIZE(120, 216), UPB_SIZE(17, 17), 21, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {33, UPB_SIZE(124, 224), UPB_SIZE(0, 0), 22, 11, kUpb_FieldMode_Array | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, }; const upb_MiniTable envoy_config_listener_v3_Listener_msginit = { &envoy_config_listener_v3_Listener_submsgs[0], &envoy_config_listener_v3_Listener__fields[0], UPB_SIZE(136, 240), 31, kUpb_ExtMode_NonExtendable, 13, 255, 0, }; static const upb_MiniTable_Sub envoy_config_listener_v3_Listener_DeprecatedV1_submsgs[1] = { {.submsg = &google_protobuf_BoolValue_msginit}, }; static const upb_MiniTable_Field envoy_config_listener_v3_Listener_DeprecatedV1__fields[1] = { {1, UPB_SIZE(4, 8), UPB_SIZE(1, 1), 0, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, }; const upb_MiniTable envoy_config_listener_v3_Listener_DeprecatedV1_msginit = { &envoy_config_listener_v3_Listener_DeprecatedV1_submsgs[0], &envoy_config_listener_v3_Listener_DeprecatedV1__fields[0], UPB_SIZE(8, 16), 1, kUpb_ExtMode_NonExtendable, 1, 255, 0, }; static const upb_MiniTable_Sub envoy_config_listener_v3_Listener_ConnectionBalanceConfig_submsgs[2] = { {.submsg = &envoy_config_listener_v3_Listener_ConnectionBalanceConfig_ExactBalance_msginit}, {.submsg = &envoy_config_core_v3_TypedExtensionConfig_msginit}, }; static const upb_MiniTable_Field envoy_config_listener_v3_Listener_ConnectionBalanceConfig__fields[2] = { {1, UPB_SIZE(4, 8), UPB_SIZE(-1, -1), 0, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, {2, UPB_SIZE(4, 8), UPB_SIZE(-1, -1), 1, 11, kUpb_FieldMode_Scalar | (kUpb_FieldRep_Pointer << kUpb_FieldRep_Shift)}, }; const upb_MiniTable envoy_config_listener_v3_Listener_ConnectionBalanceConfig_msginit = { &envoy_config_listener_v3_Listener_ConnectionBalanceConfig_submsgs[0], &envoy_config_listener_v3_Listener_ConnectionBalanceConfig__fields[0], UPB_SIZE(8, 16), 2, kUpb_ExtMode_NonExtendable, 2, 255, 0, }; const upb_MiniTable envoy_config_listener_v3_Listener_ConnectionBalanceConfig_ExactBalance_msginit = { NULL, NULL, UPB_SIZE(0, 0), 0, kUpb_ExtMode_NonExtendable, 0, 255, 0, }; const upb_MiniTable envoy_config_listener_v3_Listener_InternalListenerConfig_msginit = { NULL, NULL, UPB_SIZE(0, 0), 0, kUpb_ExtMode_NonExtendable, 0, 255, 0, }; static const upb_MiniTable *messages_layout[7] = { &envoy_config_listener_v3_AdditionalAddress_msginit, &envoy_config_listener_v3_ListenerCollection_msginit, &envoy_config_listener_v3_Listener_msginit, &envoy_config_listener_v3_Listener_DeprecatedV1_msginit, &envoy_config_listener_v3_Listener_ConnectionBalanceConfig_msginit, &envoy_config_listener_v3_Listener_ConnectionBalanceConfig_ExactBalance_msginit, &envoy_config_listener_v3_Listener_InternalListenerConfig_msginit, }; const upb_MiniTable_File envoy_config_listener_v3_listener_proto_upb_file_layout = { messages_layout, NULL, NULL, 7, 0, 0, }; #include "upb/port_undef.inc"
094ebc2ee87f6a03cd8e5178880cc8f8d5998dd8
bed3ac926beac0f4e0293303d7b2a6031ee476c9
/Modules/ThirdParty/VNL/src/vxl/v3p/netlib/linpack/dpoco.c
612693576c3c4b22d7483ecb5f2bb82f708093e3
[ "IJG", "Zlib", "LicenseRef-scancode-proprietary-license", "SMLNJ", "BSD-3-Clause", "BSD-4.3TAHOE", "LicenseRef-scancode-free-unknown", "Spencer-86", "LicenseRef-scancode-llnl", "FSFUL", "Libpng", "libtiff", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-hdf5", "MIT", "NTP", "LicenseRef-scancode-mit-old-style", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference", "MPL-2.0", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
InsightSoftwareConsortium/ITK
ed9dbbc5b8b3f7511f007c0fc0eebb3ad37b88eb
3eb8fd7cdfbc5ac2d0c2e5e776848a4cbab3d7e1
refs/heads/master
2023-08-31T17:21:47.754304
2023-08-31T00:58:51
2023-08-31T14:12:21
800,928
1,229
656
Apache-2.0
2023-09-14T17:54:00
2010-07-27T15:48:04
C++
UTF-8
C
false
false
12,641
c
dpoco.c
/* linpack/dpoco.f -- translated by f2c (version 20050501). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib; on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you install libf2c.a in a standard place, with -lf2c -lm -- in that order, at the end of the command line, as in cc *.o -lf2c -lm Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */ #ifdef __cplusplus extern "C" { #endif #include "v3p_netlib.h" /* Table of constant values */ static integer c__1 = 1; /*< subroutine dpoco(a,lda,n,rcond,z,info) >*/ /* Subroutine */ int dpoco_(doublereal *a, integer *lda, integer *n, doublereal *rcond, doublereal *z__, integer *info) { /* System generated locals */ integer a_dim1, a_offset, i__1, i__2; doublereal d__1, d__2; /* Builtin functions */ double d_sign(doublereal *, doublereal *); /* Local variables */ integer i__, j, k; doublereal s, t; integer kb; doublereal ek, sm, wk; integer jm1, kp1; doublereal wkm; extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *, integer *); extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, integer *), dpofa_(doublereal *, integer *, integer *, integer *); extern doublereal dasum_(integer *, doublereal *, integer *); doublereal anorm; extern /* Subroutine */ int daxpy_(integer *, doublereal *, doublereal *, integer *, doublereal *, integer *); doublereal ynorm; /*< integer lda,n,info >*/ /*< double precision a(lda,1),z(1) >*/ /*< double precision rcond >*/ /* dpoco factors a double precision symmetric positive definite */ /* matrix and estimates the condition of the matrix. */ /* if rcond is not needed, dpofa is slightly faster. */ /* to solve a*x = b , follow dpoco by dposl. */ /* to compute inverse(a)*c , follow dpoco by dposl. */ /* to compute determinant(a) , follow dpoco by dpodi. */ /* to compute inverse(a) , follow dpoco by dpodi. */ /* on entry */ /* a double precision(lda, n) */ /* the symmetric matrix to be factored. only the */ /* diagonal and upper triangle are used. */ /* lda integer */ /* the leading dimension of the array a . */ /* n integer */ /* the order of the matrix a . */ /* on return */ /* a an upper triangular matrix r so that a = trans(r)*r */ /* where trans(r) is the transpose. */ /* the strict lower triangle is unaltered. */ /* if info .ne. 0 , the factorization is not complete. */ /* rcond double precision */ /* an estimate of the reciprocal condition of a . */ /* for the system a*x = b , relative perturbations */ /* in a and b of size epsilon may cause */ /* relative perturbations in x of size epsilon/rcond . */ /* if rcond is so small that the logical expression */ /* 1.0 + rcond .eq. 1.0 */ /* is true, then a may be singular to working */ /* precision. in particular, rcond is zero if */ /* exact singularity is detected or the estimate */ /* underflows. if info .ne. 0 , rcond is unchanged. */ /* z double precision(n) */ /* a work vector whose contents are usually unimportant. */ /* if a is close to a singular matrix, then z is */ /* an approximate null vector in the sense that */ /* norm(a*z) = rcond*norm(a)*norm(z) . */ /* if info .ne. 0 , z is unchanged. */ /* info integer */ /* = 0 for normal return. */ /* = k signals an error condition. the leading minor */ /* of order k is not positive definite. */ /* linpack. this version dated 08/14/78 . */ /* cleve moler, university of new mexico, argonne national lab. */ /* subroutines and functions */ /* linpack dpofa */ /* blas daxpy,ddot,dscal,dasum */ /* fortran dabs,dmax1,dreal,dsign */ /* internal variables */ /*< double precision ddot,ek,t,wk,wkm >*/ /*< double precision anorm,s,dasum,sm,ynorm >*/ /*< integer i,j,jm1,k,kb,kp1 >*/ /* find norm of a using only upper half */ /*< do 30 j = 1, n >*/ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; --z__; /* Function Body */ i__1 = *n; for (j = 1; j <= i__1; ++j) { /*< z(j) = dasum(j,a(1,j),1) >*/ z__[j] = dasum_(&j, &a[j * a_dim1 + 1], &c__1); /*< jm1 = j - 1 >*/ jm1 = j - 1; /*< if (jm1 .lt. 1) go to 20 >*/ if (jm1 < 1) { goto L20; } /*< do 10 i = 1, jm1 >*/ i__2 = jm1; for (i__ = 1; i__ <= i__2; ++i__) { /*< z(i) = z(i) + dabs(a(i,j)) >*/ z__[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1)); /*< 10 continue >*/ /* L10: */ } /*< 20 continue >*/ L20: /*< 30 continue >*/ /* L30: */ ; } /*< anorm = 0.0d0 >*/ anorm = 0.; /*< do 40 j = 1, n >*/ i__1 = *n; for (j = 1; j <= i__1; ++j) { /*< anorm = dmax1(anorm,z(j)) >*/ /* Computing MAX */ d__1 = anorm, d__2 = z__[j]; anorm = max(d__1,d__2); /*< 40 continue >*/ /* L40: */ } /* factor */ /*< call dpofa(a,lda,n,info) >*/ dpofa_(&a[a_offset], lda, n, info); /*< if (info .ne. 0) go to 180 >*/ if (*info != 0) { goto L180; } /* rcond = 1/(norm(a)*(estimate of norm(inverse(a)))) . */ /* estimate = norm(z)/norm(y) where a*z = y and a*y = e . */ /* the components of e are chosen to cause maximum local */ /* growth in the elements of w where trans(r)*w = e . */ /* the vectors are frequently rescaled to avoid overflow. */ /* solve trans(r)*w = e */ /*< ek = 1.0d0 >*/ ek = 1.; /*< do 50 j = 1, n >*/ i__1 = *n; for (j = 1; j <= i__1; ++j) { /*< z(j) = 0.0d0 >*/ z__[j] = 0.; /*< 50 continue >*/ /* L50: */ } /*< do 110 k = 1, n >*/ i__1 = *n; for (k = 1; k <= i__1; ++k) { /*< if (z(k) .ne. 0.0d0) ek = dsign(ek,-z(k)) >*/ if (z__[k] != 0.) { d__1 = -z__[k]; ek = d_sign(&ek, &d__1); } /*< if (dabs(ek-z(k)) .le. a(k,k)) go to 60 >*/ if ((d__1 = ek - z__[k], abs(d__1)) <= a[k + k * a_dim1]) { goto L60; } /*< s = a(k,k)/dabs(ek-z(k)) >*/ s = a[k + k * a_dim1] / (d__1 = ek - z__[k], abs(d__1)); /*< call dscal(n,s,z,1) >*/ dscal_(n, &s, &z__[1], &c__1); /*< ek = s*ek >*/ ek = s * ek; /*< 60 continue >*/ L60: /*< wk = ek - z(k) >*/ wk = ek - z__[k]; /*< wkm = -ek - z(k) >*/ wkm = -ek - z__[k]; /*< s = dabs(wk) >*/ s = abs(wk); /*< sm = dabs(wkm) >*/ sm = abs(wkm); /*< wk = wk/a(k,k) >*/ wk /= a[k + k * a_dim1]; /*< wkm = wkm/a(k,k) >*/ wkm /= a[k + k * a_dim1]; /*< kp1 = k + 1 >*/ kp1 = k + 1; /*< if (kp1 .gt. n) go to 100 >*/ if (kp1 > *n) { goto L100; } /*< do 70 j = kp1, n >*/ i__2 = *n; for (j = kp1; j <= i__2; ++j) { /*< sm = sm + dabs(z(j)+wkm*a(k,j)) >*/ sm += (d__1 = z__[j] + wkm * a[k + j * a_dim1], abs(d__1)); /*< z(j) = z(j) + wk*a(k,j) >*/ z__[j] += wk * a[k + j * a_dim1]; /*< s = s + dabs(z(j)) >*/ s += (d__1 = z__[j], abs(d__1)); /*< 70 continue >*/ /* L70: */ } /*< if (s .ge. sm) go to 90 >*/ if (s >= sm) { goto L90; } /*< t = wkm - wk >*/ t = wkm - wk; /*< wk = wkm >*/ wk = wkm; /*< do 80 j = kp1, n >*/ i__2 = *n; for (j = kp1; j <= i__2; ++j) { /*< z(j) = z(j) + t*a(k,j) >*/ z__[j] += t * a[k + j * a_dim1]; /*< 80 continue >*/ /* L80: */ } /*< 90 continue >*/ L90: /*< 100 continue >*/ L100: /*< z(k) = wk >*/ z__[k] = wk; /*< 110 continue >*/ /* L110: */ } /*< s = 1.0d0/dasum(n,z,1) >*/ s = 1. / dasum_(n, &z__[1], &c__1); /*< call dscal(n,s,z,1) >*/ dscal_(n, &s, &z__[1], &c__1); /* solve r*y = w */ /*< do 130 kb = 1, n >*/ i__1 = *n; for (kb = 1; kb <= i__1; ++kb) { /*< k = n + 1 - kb >*/ k = *n + 1 - kb; /*< if (dabs(z(k)) .le. a(k,k)) go to 120 >*/ if ((d__1 = z__[k], abs(d__1)) <= a[k + k * a_dim1]) { goto L120; } /*< s = a(k,k)/dabs(z(k)) >*/ s = a[k + k * a_dim1] / (d__1 = z__[k], abs(d__1)); /*< call dscal(n,s,z,1) >*/ dscal_(n, &s, &z__[1], &c__1); /*< 120 continue >*/ L120: /*< z(k) = z(k)/a(k,k) >*/ z__[k] /= a[k + k * a_dim1]; /*< t = -z(k) >*/ t = -z__[k]; /*< call daxpy(k-1,t,a(1,k),1,z(1),1) >*/ i__2 = k - 1; daxpy_(&i__2, &t, &a[k * a_dim1 + 1], &c__1, &z__[1], &c__1); /*< 130 continue >*/ /* L130: */ } /*< s = 1.0d0/dasum(n,z,1) >*/ s = 1. / dasum_(n, &z__[1], &c__1); /*< call dscal(n,s,z,1) >*/ dscal_(n, &s, &z__[1], &c__1); /*< ynorm = 1.0d0 >*/ ynorm = 1.; /* solve trans(r)*v = y */ /*< do 150 k = 1, n >*/ i__1 = *n; for (k = 1; k <= i__1; ++k) { /*< z(k) = z(k) - ddot(k-1,a(1,k),1,z(1),1) >*/ i__2 = k - 1; z__[k] -= ddot_(&i__2, &a[k * a_dim1 + 1], &c__1, &z__[1], &c__1); /*< if (dabs(z(k)) .le. a(k,k)) go to 140 >*/ if ((d__1 = z__[k], abs(d__1)) <= a[k + k * a_dim1]) { goto L140; } /*< s = a(k,k)/dabs(z(k)) >*/ s = a[k + k * a_dim1] / (d__1 = z__[k], abs(d__1)); /*< call dscal(n,s,z,1) >*/ dscal_(n, &s, &z__[1], &c__1); /*< ynorm = s*ynorm >*/ ynorm = s * ynorm; /*< 140 continue >*/ L140: /*< z(k) = z(k)/a(k,k) >*/ z__[k] /= a[k + k * a_dim1]; /*< 150 continue >*/ /* L150: */ } /*< s = 1.0d0/dasum(n,z,1) >*/ s = 1. / dasum_(n, &z__[1], &c__1); /*< call dscal(n,s,z,1) >*/ dscal_(n, &s, &z__[1], &c__1); /*< ynorm = s*ynorm >*/ ynorm = s * ynorm; /* solve r*z = v */ /*< do 170 kb = 1, n >*/ i__1 = *n; for (kb = 1; kb <= i__1; ++kb) { /*< k = n + 1 - kb >*/ k = *n + 1 - kb; /*< if (dabs(z(k)) .le. a(k,k)) go to 160 >*/ if ((d__1 = z__[k], abs(d__1)) <= a[k + k * a_dim1]) { goto L160; } /*< s = a(k,k)/dabs(z(k)) >*/ s = a[k + k * a_dim1] / (d__1 = z__[k], abs(d__1)); /*< call dscal(n,s,z,1) >*/ dscal_(n, &s, &z__[1], &c__1); /*< ynorm = s*ynorm >*/ ynorm = s * ynorm; /*< 160 continue >*/ L160: /*< z(k) = z(k)/a(k,k) >*/ z__[k] /= a[k + k * a_dim1]; /*< t = -z(k) >*/ t = -z__[k]; /*< call daxpy(k-1,t,a(1,k),1,z(1),1) >*/ i__2 = k - 1; daxpy_(&i__2, &t, &a[k * a_dim1 + 1], &c__1, &z__[1], &c__1); /*< 170 continue >*/ /* L170: */ } /* make znorm = 1.0 */ /*< s = 1.0d0/dasum(n,z,1) >*/ s = 1. / dasum_(n, &z__[1], &c__1); /*< call dscal(n,s,z,1) >*/ dscal_(n, &s, &z__[1], &c__1); /*< ynorm = s*ynorm >*/ ynorm = s * ynorm; /*< if (anorm .ne. 0.0d0) rcond = ynorm/anorm >*/ if (anorm != 0.) { *rcond = ynorm / anorm; } /*< if (anorm .eq. 0.0d0) rcond = 0.0d0 >*/ if (anorm == 0.) { *rcond = 0.; } /*< 180 continue >*/ L180: /*< return >*/ return 0; /*< end >*/ } /* dpoco_ */ #ifdef __cplusplus } #endif
9f564dc1fe4d3ab508e7d22014da714c15b1ca5b
73b0f9c30d07993ad74f7f2bcbc0fe61f1d1a3ce
/native/iosTest/Pods/Headers/Public/folly/RCT-Folly-umbrella.h
b0220742f4f2e7f04b37ae10a8ddffaae2e5ef80
[ "MIT" ]
permissive
Nozbe/WatermelonDB
84771a637e2c93474220fadee442e5c4ade40f7e
fd41fe279e229e9b5013b1dddf777cd7919e1d2d
refs/heads/master
2023-08-16T18:24:04.893973
2023-08-11T11:44:46
2023-08-11T11:44:46
146,468,829
9,358
670
MIT
2023-09-10T08:04:55
2018-08-28T15:32:05
JavaScript
UTF-8
C
false
false
60
h
RCT-Folly-umbrella.h
../../../Target Support Files/RCT-Folly/RCT-Folly-umbrella.h
c1eb8c578c2235e4b58ca0858ed852e6a0c09dbe
5eff7a36d9a9917dce9111f0c3074375fe6f7656
/driver/xf86-input-synaptics/src/eventcomm.h
4cd283ddc85db37977c1a3814a50516605c14ce5
[ "MIT" ]
permissive
openbsd/xenocara
cb392d02ebba06f6ff7d826fd8a89aa3b8401779
a012b5de33ea0b977095d77316a521195b26cc6b
refs/heads/master
2023-08-25T12:16:58.862008
2023-08-12T16:16:25
2023-08-12T16:16:25
66,967,384
177
66
null
2023-07-22T18:12:37
2016-08-30T18:36:01
C
UTF-8
C
false
false
1,877
h
eventcomm.h
/* * Copyright © 2004 Peter Osterlund * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice * appear in supporting documentation, and that the name of Red Hat * not be used in advertising or publicity pertaining to distribution * of the software without specific, written prior permission. Red * Hat makes no representations about the suitability of this software * for any purpose. It is provided "as is" without express or implied * warranty. * * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, 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. * * Authors: * Peter Osterlund (petero2@telia.com) */ #ifndef _EVENTCOMM_H_ #define _EVENTCOMM_H_ #include <xorg-server.h> #include <linux/input.h> #include <linux/version.h> #include <xf86Xinput.h> #include "synproto.h" #ifndef input_event_sec #define input_event_sec time.tv_sec #endif #ifndef input_event_usec #define input_event_usec time.tv_usec #endif /* for auto-dev: */ #define DEV_INPUT_EVENT "/dev/input" #define EVENT_DEV_NAME "event" struct eventcomm_proto_data; extern struct eventcomm_proto_data *EventProtoDataAlloc(int fd); extern Bool EventReadHwState(InputInfoPtr pInfo, struct CommData *comm, struct SynapticsHwState *hwRet); #endif /* _EVENTCOMM_H_ */
83d8f1dc7134fabb4e5cf4514bda9f9ea5ba55da
ea401c3e792a50364fe11f7cea0f35f99e8f4bde
/released_plugins/v3d_plugins/bigneuron_siqi_stalker_v3d/lib/ITK_include/vcl_climits.h
37cac12ce25a07613b2a205e751b9301136fe802
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
Vaa3D/vaa3d_tools
edb696aa3b9b59acaf83d6d27c6ae0a14bf75fe9
e6974d5223ae70474efaa85e1253f5df1814fae8
refs/heads/master
2023-08-03T06:12:01.013752
2023-08-02T07:26:01
2023-08-02T07:26:01
50,527,925
107
86
MIT
2023-05-22T23:43:48
2016-01-27T18:19:17
C++
UTF-8
C
false
false
305
h
vcl_climits.h
#ifndef vcl_climits_h_ #define vcl_climits_h_ /* fsm */ #include "vcl_compiler.h" #if !VCL_CXX_HAS_HEADER_CLIMITS # include <limits.h> #elif defined(VCL_SUNPRO_CC_5) # include <limits.h> // <climits> is broken -- mismatched braces. #else # include "iso/vcl_climits.h" #endif #endif // vcl_climits_h_
1cb2aa45d74cf728137ea167be16297f0d095f38
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/sh/boards/mach-hp6xx/pm.c
8b50cf763c065010666d9598bed8c1a3f59043f0
[ "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
3,198
c
pm.c
/* * hp6x0 Power Management Routines * * Copyright (c) 2006 Andriy Skulysh <askulsyh@gmail.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License. */ #include <linux/init.h> #include <linux/suspend.h> #include <linux/errno.h> #include <linux/time.h> #include <linux/delay.h> #include <linux/gfp.h> #include <asm/io.h> #include <asm/hd64461.h> #include <asm/bl_bit.h> #include <mach/hp6xx.h> #include <cpu/dac.h> #include <asm/freq.h> #include <asm/watchdog.h> #define INTR_OFFSET 0x600 #define STBCR 0xffffff82 #define STBCR2 0xffffff88 #define STBCR_STBY 0x80 #define STBCR_MSTP2 0x04 #define MCR 0xffffff68 #define RTCNT 0xffffff70 #define MCR_RMODE 2 #define MCR_RFSH 4 extern u8 wakeup_start; extern u8 wakeup_end; static void pm_enter(void) { u8 stbcr, csr; u16 frqcr, mcr; u32 vbr_new, vbr_old; set_bl_bit(); /* set wdt */ csr = sh_wdt_read_csr(); csr &= ~WTCSR_TME; csr |= WTCSR_CKS_4096; sh_wdt_write_csr(csr); csr = sh_wdt_read_csr(); sh_wdt_write_cnt(0); /* disable PLL1 */ frqcr = __raw_readw(FRQCR); frqcr &= ~(FRQCR_PLLEN | FRQCR_PSTBY); __raw_writew(frqcr, FRQCR); /* enable standby */ stbcr = __raw_readb(STBCR); __raw_writeb(stbcr | STBCR_STBY | STBCR_MSTP2, STBCR); /* set self-refresh */ mcr = __raw_readw(MCR); __raw_writew(mcr & ~MCR_RFSH, MCR); /* set interrupt handler */ asm volatile("stc vbr, %0" : "=r" (vbr_old)); vbr_new = get_zeroed_page(GFP_ATOMIC); udelay(50); memcpy((void*)(vbr_new + INTR_OFFSET), &wakeup_start, &wakeup_end - &wakeup_start); asm volatile("ldc %0, vbr" : : "r" (vbr_new)); __raw_writew(0, RTCNT); __raw_writew(mcr | MCR_RFSH | MCR_RMODE, MCR); cpu_sleep(); asm volatile("ldc %0, vbr" : : "r" (vbr_old)); free_page(vbr_new); /* enable PLL1 */ frqcr = __raw_readw(FRQCR); frqcr |= FRQCR_PSTBY; __raw_writew(frqcr, FRQCR); udelay(50); frqcr |= FRQCR_PLLEN; __raw_writew(frqcr, FRQCR); __raw_writeb(stbcr, STBCR); clear_bl_bit(); } static int hp6x0_pm_enter(suspend_state_t state) { u8 stbcr, stbcr2; #ifdef CONFIG_HD64461_ENABLER u8 scr; u16 hd64461_stbcr; #endif #ifdef CONFIG_HD64461_ENABLER outb(0, HD64461_PCC1CSCIER); scr = inb(HD64461_PCC1SCR); scr |= HD64461_PCCSCR_VCC1; outb(scr, HD64461_PCC1SCR); hd64461_stbcr = inw(HD64461_STBCR); hd64461_stbcr |= HD64461_STBCR_SPC1ST; outw(hd64461_stbcr, HD64461_STBCR); #endif __raw_writeb(0x1f, DACR); stbcr = __raw_readb(STBCR); __raw_writeb(0x01, STBCR); stbcr2 = __raw_readb(STBCR2); __raw_writeb(0x7f , STBCR2); outw(0xf07f, HD64461_SCPUCR); pm_enter(); outw(0, HD64461_SCPUCR); __raw_writeb(stbcr, STBCR); __raw_writeb(stbcr2, STBCR2); #ifdef CONFIG_HD64461_ENABLER hd64461_stbcr = inw(HD64461_STBCR); hd64461_stbcr &= ~HD64461_STBCR_SPC1ST; outw(hd64461_stbcr, HD64461_STBCR); outb(0x4c, HD64461_PCC1CSCIER); outb(0x00, HD64461_PCC1CSCR); #endif return 0; } static const struct platform_suspend_ops hp6x0_pm_ops = { .enter = hp6x0_pm_enter, .valid = suspend_valid_only_mem, }; static int __init hp6x0_pm_init(void) { suspend_set_ops(&hp6x0_pm_ops); return 0; } late_initcall(hp6x0_pm_init);
d774515f18d0856d104d3d63eea8ebc483cf9a69
eecd5e4c50d8b78a769bcc2675250576bed34066
/include/petscfeceed.h
26c0733a2dc97e8f9cddcf10258a890412ead87c
[ "BSD-2-Clause" ]
permissive
petsc/petsc
3b1a04fea71858e0292f9fd4d04ea11618c50969
9c5460f9064ca60dd71a234a1f6faf93e7a6b0c9
refs/heads/main
2023-08-17T20:51:16.507070
2023-08-17T16:08:06
2023-08-17T16:08:06
8,691,401
341
169
NOASSERTION
2023-03-29T11:02:58
2013-03-10T20:55:21
C
UTF-8
C
false
false
265
h
petscfeceed.h
#ifndef PETSCFECEED_H #define PETSCFECEED_H #include <petscfe.h> #if defined(PETSC_HAVE_LIBCEED) #include <ceed.h> PETSC_EXTERN PetscErrorCode PetscFEGetCeedBasis(PetscFE, CeedBasis *); PETSC_EXTERN PetscErrorCode PetscFESetCeed(PetscFE, Ceed); #endif #endif
5fadd80955211dd07a388af8b6e6accab42cf28f
971b2cea2d1c3001aadc8ca1a48110b7db1ed5f2
/deps/abc/src/misc/util/utilSignal.c
03af81d13d5304375e95001159040659d15da786
[ "LicenseRef-scancode-warranty-disclaimer", "MIT", "MIT-Modern-Variant" ]
permissive
emsec/hal
70ad2921739967d914dd458984bd7d6d497d3b0a
e4fae37bec9168a61100eacfda37a1f291b4d0be
refs/heads/master
2023-09-02T20:27:32.909426
2023-09-01T13:03:24
2023-09-01T13:03:24
169,076,171
510
72
MIT
2023-09-01T13:03:26
2019-02-04T12:37:20
C++
UTF-8
C
false
false
1,749
c
utilSignal.c
/**CFile**************************************************************** FileName [utilSignal.c] SystemName [ABC: Logic synthesis and verification system.] PackageName [] Synopsis [] Author [Baruch Sterin] Affiliation [UC Berkeley] Date [Ver. 1.0. Started - February 1, 2011.] Revision [$Id: utilSignal.c,v 1.00 2011/02/01 00:00:00 alanmi Exp $] ***********************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "abc_global.h" #include "utilSignal.h" #ifdef _MSC_VER #define unlink _unlink #else #include <unistd.h> #endif ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// int Util_SignalSystem(const char* cmd) { return system(cmd); } int tmpFile(const char* prefix, const char* suffix, char** out_name); int Util_SignalTmpFile(const char* prefix, const char* suffix, char** out_name) { return tmpFile(prefix, suffix, out_name); } void Util_SignalTmpFileRemove(const char* fname, int fLeave) { if (! fLeave) { unlink(fname); } } ABC_NAMESPACE_IMPL_END //////////////////////////////////////////////////////////////////////// /// END OF FILE /// ////////////////////////////////////////////////////////////////////////
0d023202e89c89ff62e30406025ff02bf0b2b3ce
fbef550c1f0206aac0582a58f7e3db945f442a9a
/Pods/Headers/Private/CocoaLumberjack/DDAssertMacros.h
756b2c0158243ac08d8a135c70b5451a0a55c89e
[ "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
49
h
DDAssertMacros.h
../../../CocoaLumberjack/Classes/DDAssertMacros.h
5e554e01aef918c39e7d340bd3fe42365ccea570
b801d688e01ca0ea993c1a84e1bc164967258aff
/LTP/LTP_05/read03.c
f11507ff3bcbc27f1ceb637fc5f5c6090fb84cc2
[ "Apache-2.0" ]
permissive
jitwxs/blog-sample
1a1e4152b48939baa5b09a2704dd089dfbe520ed
5123346e01a1ec94cc56b5afbd45732487d7ecb8
refs/heads/master
2022-02-24T06:04:26.341746
2022-02-16T14:11:26
2022-02-16T14:11:26
131,931,262
339
243
Apache-2.0
2021-09-20T15:25:44
2018-05-03T02:32:58
Java
UTF-8
C
false
false
1,867
c
read03.c
/* * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write the Free Software Foundation, Inc. * */ /********************************************************** * * TEST IDENTIFIER : read03 * * TEST TITLE : Basic tests for read(2) * * TEST CASE TOTAL : 1 * * AUTHOR : jitwxs * <jitwxs@foxmail.com> * * DESCRIPTION * Testcase to check that read() sets errno to EAGAIN. * * ALGORITHM * Create a named pipe (fifo), open it in O_NONBLOCK mode, and * attempt to read from it, without writing to it. read() should fail * with EAGAIN. * **********************************************************/ #include <errno.h> #include "tst_test.h" #define FIFONAME "tmpFIFO" int rfd, wfd; static void my_test(void) { int c; TEST(read(rfd, &c, 1)); if (TEST_RETURN != -1) tst_res(TFAIL, "read() failed"); if (TEST_ERRNO != EAGAIN) tst_res(TFAIL, "read set bad errno, expected EAGAIN, got %d", TEST_ERRNO); else tst_res(TPASS, "read() succeded in setting errno to EAGAIN"); } static void setup(void) { SAFE_MKFIFO(FIFONAME, 0777); rfd = SAFE_OPEN(FIFONAME, O_RDONLY | O_NONBLOCK); wfd = SAFE_OPEN(FIFONAME, O_WRONLY | O_NONBLOCK); } static void cleanup(void) { if (rfd > 0) SAFE_CLOSE(rfd); if (wfd > 0) SAFE_CLOSE(wfd); } static struct tst_test test = { .test_all = my_test, .setup = setup, .cleanup = cleanup, .needs_tmpdir = 1 };
04d982e676e7a5c81ed2fb3f024ffe0ee75d6d90
86b305c99df1d3f68d653a893fcd7e5eda407b4f
/modules/nginx-toolkit-module/t/ngx_dynamic_conf_test_module.c
ec24ad39c95d653e206e9b161af4620be404e399
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
pingostack/pingos
ea0de3a497d54790494768cce442722ae00a785b
8ba2ea109a39c53daf135aac381a488d7a8c5681
refs/heads/master
2022-12-21T22:10:06.449046
2022-11-21T02:24:41
2022-11-21T02:24:41
215,240,897
895
249
BSD-3-Clause
2022-12-20T02:27:08
2019-10-15T07:59:48
C
UTF-8
C
false
false
5,812
c
ngx_dynamic_conf_test_module.c
#include <ngx_config.h> #include <ngx_core.h> #include <ngx_http.h> #include "ngx_dynamic_conf.h" /******************************************************************************/ static void *ngx_dynamic_core_test_create_conf(ngx_conf_t *cf); static char *ngx_dynamic_core_test_init_conf(ngx_conf_t *cf, void *conf); typedef struct { ngx_uint_t i; ngx_str_t s; } ngx_dynamic_core_test_conf_t; ngx_core_module_t ngx_dynamic_core_test_module_ctx = { ngx_string("dynamic_core_test"), NULL, NULL }; static ngx_command_t ngx_dynamic_core_test_dcommands[] = { { ngx_string("dynamic_test_i"), NGX_MAIN_CONF|NGX_CONF_TAKE1, ngx_conf_set_num_slot, 0, offsetof(ngx_dynamic_core_test_conf_t, i), NULL }, { ngx_string("dynamic_test_s"), NGX_MAIN_CONF|NGX_CONF_TAKE1, ngx_conf_set_str_slot, 0, offsetof(ngx_dynamic_core_test_conf_t, s), NULL }, ngx_null_command }; static ngx_dynamic_core_module_t ngx_dynamic_core_test_module_dctx = { ngx_string("dynamic_core_test"), ngx_dynamic_core_test_create_conf, ngx_dynamic_core_test_init_conf }; ngx_module_t ngx_dynamic_core_test_module = { NGX_MODULE_V1, &ngx_dynamic_core_test_module_ctx, /* module context */ NULL, /* module directives */ NGX_CORE_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ NULL, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ NULL, /* exit process */ NULL, /* exit master */ (uintptr_t) &ngx_dynamic_core_test_module_dctx, /* module dynamic context */ (uintptr_t) ngx_dynamic_core_test_dcommands, /* module dynamic directives */ NGX_MODULE_V1_DYNAMIC_PADDING }; static void * ngx_dynamic_core_test_create_conf(ngx_conf_t *cf) { ngx_dynamic_core_test_conf_t *conf; conf = ngx_pcalloc(cf->pool, sizeof(ngx_dynamic_core_test_conf_t)); if (conf == NULL) { return NULL; } conf->i = NGX_CONF_UNSET_UINT; return conf; } static char * ngx_dynamic_core_test_init_conf(ngx_conf_t *cf, void *conf) { ngx_dynamic_core_test_conf_t *dctcf; dctcf = conf; ngx_conf_init_uint_value(dctcf->i, 1000); return NGX_CONF_OK; } /******************************************************************************/ static char *ngx_dynamic_conf_test(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); #define MAXBUFSIZE 4096 static ngx_command_t ngx_dynamic_conf_test_commands[] = { { ngx_string("dynamic_conf_test"), NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS, ngx_dynamic_conf_test, 0, 0, NULL }, ngx_null_command }; static ngx_http_module_t ngx_dynamic_conf_test_module_ctx = { NULL, /* preconfiguration */ NULL, /* postconfiguration */ NULL, /* create main configuration */ NULL, /* init main configuration */ NULL, /* create server configuration */ NULL, /* merge server configuration */ NULL, /* create location configuration */ NULL /* merge location configuration */ }; ngx_module_t ngx_dynamic_conf_test_module = { NGX_MODULE_V1, &ngx_dynamic_conf_test_module_ctx, /* module context */ ngx_dynamic_conf_test_commands, /* module directives */ NGX_HTTP_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ NULL, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ NULL, /* exit process */ NULL, /* exit master */ NGX_MODULE_V1_PADDING }; static ngx_int_t ngx_dynamic_conf_test_handler(ngx_http_request_t *r) { ngx_chain_t cl; ngx_buf_t *b; ngx_dynamic_core_test_conf_t *dctcf; ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "dynamic conf test handler"); b = ngx_create_temp_buf(r->pool, MAXBUFSIZE); if (b == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } dctcf = (ngx_dynamic_core_test_conf_t *) ngx_get_dconf(&ngx_dynamic_core_test_module); if (dctcf == NULL) { ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "dynamic conf test handler, dynamic conf not configured"); return NGX_HTTP_INTERNAL_SERVER_ERROR; } r->headers_out.status = NGX_HTTP_OK; ngx_http_send_header(r); b->last = ngx_snprintf(b->last, MAXBUFSIZE, "dynamic core test %ui [%V]\n", dctcf->i, &dctcf->s); b->last_buf = 1; b->last_in_chain = 1; cl.buf = b; cl.next = NULL; ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "send body"); return ngx_http_output_filter(r, &cl); } static char * ngx_dynamic_conf_test(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_core_loc_conf_t *clcf; clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); clcf->handler = ngx_dynamic_conf_test_handler; return NGX_CONF_OK; }
38c7957df447fe76f520532ec2a27c36daca859a
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/CME_M7/StdPeriph_Driver/src/cmem7_dma.c
061b907dd9bea2ecab617c2fb584ac03453d1145
[ "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
7,521
c
cmem7_dma.c
/** ***************************************************************************** * @file cmem7_dma.c * * @brief CMEM7 DMA source file * * * @version V1.0 * @date 3. September 2013 * * @note * ***************************************************************************** * @attention * * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE * TIME. AS A RESULT, CAPITAL-MICRO SHALL NOT BE HELD LIABLE FOR ANY DIRECT, * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. * * <h2><center>&copy; COPYRIGHT 2013 Capital-micro </center></h2> ***************************************************************************** */ #include "cmem7_dma.h" typedef struct { union { uint32_t CTL_LOW; struct { uint32_t INT_EN : 1; uint32_t DST_TR_WIDTH: 3; uint32_t SRC_TR_WIDTH: 3; uint32_t DINC : 2; uint32_t SINC : 2; uint32_t DEST_MSIZE : 3; uint32_t SRC_MSIZE : 3; uint32_t SRC_GATHER_EN: 1; uint32_t DST_SCATTER_EN: 1; uint32_t : 1; uint32_t TT_FC : 3; uint32_t DMS : 2; uint32_t SMS : 2; uint32_t LLP_DST_EN : 1; uint32_t LLP_SRC_EN : 1; } CTL_LOW_b; } INNER; } INNER_CTL_LOW; typedef struct { union { uint32_t CTL_HI; struct { uint32_t BLOCK_TS : 12; uint32_t DONE : 1; } CTL_HI_b; } INNER; } INNER_CTL_HIGH; typedef struct { uint32_t srcAddr; uint32_t dstAddr; uint32_t nextBlock; INNER_CTL_LOW low; INNER_CTL_HIGH high; } INNER_BLOCK_DESC; #define DMA_MAX_CHANNEL_NUM 8 #define DMA_TR_WIDTH_8_BIT 0 #define DMA_TR_WIDTH_16_BIT 1 #define DMA_TR_WIDTH_32_BIT 2 #define DMA_TR_WIDTH_64_BIT 3 #define DMA_TR_WIDTH_128_BIT 4 #define DMA_TR_WIDTH_256_BIT 5 #define DMA_INC_INCREMENT 0 #define DMA_INC_DECREMENT 1 #define DMA_INC_NO_CHANGE 2 #define DMA_LOCK_DMA_TRANSFER 0 #define DMA_LOCK_DMA_BLOCK_TRANSFER 1 #define DMA_LOCK_DMA_BLOCK_TRANSACTION 2 void DMA_Init() { DMA->DMA_EN_b.EN = TRUE; // only open channel 0 DMA->CH_EN = (0xFF << DMA_MAX_CHANNEL_NUM) | 0x0; DMA_ClearInt(DMA_Int_All); DMA_EnableInt(DMA_Int_All, FALSE); DMA->SAR0 = 0x0; DMA->DAR0 = 0x0; DMA->CTL_HI0_b.BLOCK_TS = 0; DMA->CTL_LOW0_b.INT_EN = FALSE; DMA->CTL_LOW0_b.DST_TR_WIDTH = DMA_TR_WIDTH_32_BIT; DMA->CTL_LOW0_b.SRC_TR_WIDTH = DMA_TR_WIDTH_32_BIT; DMA->CTL_LOW0_b.DINC = DMA_INC_INCREMENT; DMA->CTL_LOW0_b.SINC = DMA_INC_INCREMENT; DMA->CTL_LOW0_b.DEST_MSIZE = 0; DMA->CTL_LOW0_b.SRC_MSIZE = 0; DMA->CTL_LOW0_b.SRC_GATHER_EN = FALSE; DMA->CTL_LOW0_b.DST_SCATTER_EN = FALSE; DMA->CTL_LOW0_b.TT_FC = 0; DMA->CTL_LOW0_b.DMS = 0; DMA->CTL_LOW0_b.SMS = 0; DMA->CTL_LOW0_b.LLP_DST_EN = FALSE; DMA->CTL_LOW0_b.LLP_SRC_EN = FALSE; DMA->LLP0_b.LOC = 0; DMA->LLP0_b.LMS = 0; DMA->SGR0_b.SGC = 0x1; DMA->SGR0_b.SGI = 0x0; DMA->DSR0_b.DSC = 0x0; DMA->DSR0_b.DSI = 0x0; DMA->SSTATAR0 = 0x0; DMA->DSTATAR0 = 0x0; DMA->CFG_HI0 = 0x0; DMA->CFG_LOW0_b.CH_PRIOR = 0; DMA->CFG_LOW0_b.CH_SUSP = 0; DMA->CFG_LOW0_b.HS_SEL_DST = 0; DMA->CFG_LOW0_b.LOCK_B_L = 0; DMA->CFG_LOW0_b.HS_SEL_SRC = 0; DMA->CFG_LOW0_b.LOCK_CH_L = DMA_LOCK_DMA_TRANSFER; DMA->CFG_LOW0_b.LOCK_B_L = DMA_LOCK_DMA_TRANSFER; DMA->CFG_LOW0_b.LOCK_CH = TRUE; DMA->CFG_LOW0_b.LOCK_B = TRUE; DMA->CFG_LOW0_b.DST_HS_POL = 0; DMA->CFG_LOW0_b.SRC_HS_POL = 0; DMA->CFG_LOW0_b.RELOAD_SRC = FALSE; DMA->CFG_LOW0_b.RELOAD_DST = FALSE; } void DMA_EnableInt(uint32_t Int, BOOL enable) { assert_param(IS_DMA_INT(Int)); if (enable) { if (Int & DMA_Int_TfrComplete) { DMA->INT_EN_TFR = (0x1 << DMA_MAX_CHANNEL_NUM) | 0x1; } if (Int & DMA_Int_Err) { DMA->INT_EN_ERR = (0x1 << DMA_MAX_CHANNEL_NUM) | 0x1; } } else { if (Int & DMA_Int_TfrComplete) { DMA->INT_EN_TFR = (0x1 << DMA_MAX_CHANNEL_NUM) | 0x0; } if (Int & DMA_Int_Err) { DMA->INT_EN_ERR = (0x1 << DMA_MAX_CHANNEL_NUM) | 0x0; } } } BOOL DMA_GetIntStatus(uint32_t Int) { assert_param(IS_DMA_INT(Int)); if (Int & DMA_Int_TfrComplete) { if (DMA->INT_TFR) { return TRUE; } } if (Int & DMA_Int_Err) { if (DMA->INT_ERR) { return TRUE; } } return FALSE; } void DMA_ClearInt(uint32_t Int) { assert_param(IS_DMA_INT(Int)); if (Int & DMA_Int_TfrComplete) { DMA->INT_CLEAR_TFR = 0x1; } if (Int & DMA_Int_Err) { DMA->INT_CLEAR_ERR = 0x1; } } BOOL DMA_IsBusy() { return (DMA->CH_EN_b.EN) ? TRUE : FALSE; } BOOL DMA_Transfer(BLOCK_DESC *blockList) { BLOCK_DESC *p; if (!blockList) { return FALSE; } if (DMA_IsBusy()) { return FALSE; } p = blockList; while (p) { BOOL llp = FALSE; INNER_BLOCK_DESC *inner = (INNER_BLOCK_DESC *)p; if (p->nextBlock) { llp = TRUE; } inner->high.INNER.CTL_HI = 0; inner->high.INNER.CTL_HI_b.BLOCK_TS = (p->number >> DMA_TR_WIDTH_32_BIT); inner->high.INNER.CTL_HI_b.DONE = 0; inner->nextBlock = p->nextBlock; inner->low.INNER.CTL_LOW = 0; inner->low.INNER.CTL_LOW_b.INT_EN = TRUE; inner->low.INNER.CTL_LOW_b.DST_TR_WIDTH = DMA_TR_WIDTH_32_BIT; inner->low.INNER.CTL_LOW_b.SRC_TR_WIDTH = DMA_TR_WIDTH_32_BIT; inner->low.INNER.CTL_LOW_b.DINC = DMA_INC_INCREMENT; inner->low.INNER.CTL_LOW_b.SINC = DMA_INC_INCREMENT; inner->low.INNER.CTL_LOW_b.DEST_MSIZE = 0; inner->low.INNER.CTL_LOW_b.SRC_MSIZE = 0; inner->low.INNER.CTL_LOW_b.SRC_GATHER_EN = FALSE; inner->low.INNER.CTL_LOW_b.DST_SCATTER_EN = FALSE; inner->low.INNER.CTL_LOW_b.TT_FC = 0; inner->low.INNER.CTL_LOW_b.DMS = 0; inner->low.INNER.CTL_LOW_b.SMS = 0; inner->low.INNER.CTL_LOW_b.LLP_DST_EN = llp; inner->low.INNER.CTL_LOW_b.LLP_SRC_EN = llp; if ((uint32_t)inner == (uint32_t)blockList) { // copy to DMA DMA->SAR0 = llp ? 0x0 : inner->srcAddr ; DMA->DAR0 = llp ? 0x0 : inner->dstAddr ; DMA->CTL_HI0 = llp ? 0x0 : inner->high.INNER.CTL_HI; DMA->CTL_LOW0 = inner->low.INNER.CTL_LOW; DMA->LLP0 = llp ? (uint32_t)inner : 0x0; } p = (BLOCK_DESC *)inner->nextBlock; } // open channel 0 DMA->CH_EN = (0x1 << DMA_MAX_CHANNEL_NUM) | 0x1; return TRUE; }
ff6656fcf6d5bdab080ff9b137d2e975e0400ef8
9de0cec678bc4a3bec2b4adabef9f39ff5b4afac
/PWGCF/EBYE/macros/AddTaskFluctuations.C
a2ba931208816c53fa785035b658a4da1ea2b23c
[]
permissive
alisw/AliPhysics
91bf1bd01ab2af656a25ff10b25e618a63667d3e
5df28b2b415e78e81273b0d9bf5c1b99feda3348
refs/heads/master
2023-08-31T20:41:44.927176
2023-08-31T14:51:12
2023-08-31T14:51:12
61,661,378
129
1,150
BSD-3-Clause
2023-09-14T18:48:45
2016-06-21T19:31:29
C++
UTF-8
C
false
false
2,745
c
AddTaskFluctuations.C
//=============================================// const char* centralityEstimator = "TRK"; //=============================================// //_________________________________________________________// AliEbyEFluctuationAnalysisTask *AddTaskFluctuations(const char* analysisType = "ESD", const char *analysisMode = "TPC") { // Creates a fluctuations analysis task and adds it to the analysis manager. // Get the pointer to the existing analysis manager via the static access method. //=========================================================================== AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); if (!mgr) { ::Error("AddTaskFluctuations", "No analysis manager to connect to."); return NULL; } // Check the analysis type using the event handlers connected to the analysis manager. //=========================================================================== if (!mgr->GetInputEventHandler()) { ::Error("AddTaskFluctuations", "This task requires an input event handler"); return NULL; } TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD" // Create the task, add it to manager and configure it. //=========================================================================== AliEbyEFluctuationAnalysisTask *taskFluctuations = new AliEbyEFluctuationAnalysisTask("FluctuationsTask"); mgr->AddTask(taskFluctuations); taskFluctuations->SetAnalysisType(analysisType); if(analysisType == "ESD") { taskFluctuations->SetAnalysisMode(analysisMode); taskFluctuations->SetVertexDiamond(3.,3.,10.); taskFluctuations->SetCentralityEstimator(centralityEstimator); taskFluctuations->SetCentralityBins20(); taskFluctuations->SelectCollisionCandidates(AliVEvent::kMB); } TString type = analysisType; if (analysisType=="ESD") { gROOT->LoadMacro("configFluctuationsAnalysis.C"); AliESDtrackCuts *trackCuts = GetTrackCutsObject(); taskFluctuations->SetAnalysisCutObject(trackCuts); } // Create ONLY the output containers for the data produced by the task. // Get and connect other common input/output containers via the manager as below //============================================================================== TString outputFileName = AliAnalysisManager::GetCommonFileName(); outputFileName += ":outputFluctuationAnalysis.root"; AliAnalysisDataContainer *coutFA = mgr->CreateContainer("fluctuationsOutput", TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data()); mgr->ConnectInput(taskFluctuations, 0, mgr->GetCommonInputContainer()); mgr->ConnectOutput(taskFluctuations, 1, coutFA); // Return task pointer at the end return taskFluctuations; }
2bc12b24dfeb923b17225a8b00e7222985f63a9e
a6e90e48ced58e5fdd162d9c111679fcaac57b06
/loglib/csv.h
7f98e08329a56bcb3c82aca54d95615340911049
[ "MIT" ]
permissive
private-octopus/picoquic
0355964aa79e4292178d57a57bec084d6e3e99da
1e2979e8db0957c8ee798940091c4d0ef13bf8af
refs/heads/master
2023-08-20T08:18:46.538002
2023-08-16T03:41:36
2023-08-16T03:41:36
95,480,304
466
142
MIT
2023-09-06T16:56:25
2017-06-26T19:08:37
C
UTF-8
C
false
false
1,568
h
csv.h
/* * Author: Christian Huitema * Copyright (c) 2019, Private Octopus, Inc. * All rights reserved. * * 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. * * 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 Private Octopus, Inc. 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 <inttypes.h> #ifdef __cplusplus extern "C" { #endif FILE * picoquic_open_cc_log_file_for_read(char const * bin_cc_log_name, uint16_t * flags, uint64_t * log_time); /* Extract all picoquic_log_event_cc_update events from the binary log file and write them into an csv file. */ int picoquic_cc_log_file_to_csv(char const* bin_cc_log_name, char const* csv_cc_log_name); int picoquic_cc_bin_to_csv(FILE * f_binlog, FILE * f_csvlog); #ifdef __cplusplus } #endif
a2ed0f5efaf9b2a7ac34ad49fc4ea13bc352bd94
5a5328c0ad39230779aa52c9ae57ec193b88941e
/tesseract4android/src/main/cpp/leptonica/src/prog/recogtest3.c
c54be397a36000196e944457b302e84575f3e0e1
[ "BSD-2-Clause", "CC-BY-2.5", "Apache-2.0" ]
permissive
adaptech-cz/Tesseract4Android
66978579ccc80587b8a0ae3eebe79f152fa382cd
8ae584f54502d5457c8b9d62401eaa99551352c3
refs/heads/master
2023-07-21T16:49:39.617935
2023-07-18T12:13:29
2023-07-18T12:13:29
168,021,668
517
101
Apache-2.0
2021-03-29T11:52:21
2019-01-28T19:21:34
C
UTF-8
C
false
false
6,993
c
recogtest3.c
/*====================================================================* - Copyright (C) 2001 Leptonica. 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 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 ANY - 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. *====================================================================*/ /* * recogtest3.c * * Test padding of book-adapted recognizer (BAR) using templates * from a bootstrap recognizer (BSR) to identify unlabeled samples * from the book. * * Terminology note: * templates: labeled character images that can be inserted * into a recognizer. * samples: unlabeled character images that must be labeled by * a recognizer before they can be used as templates. * * This demonstrates the following operations: * (1) Making a BAR from labeled book templates (as a pixa). * (2) Making a hybrid BAR/BSR from scaled templates in the BAR, * supplemented with similarly scaled bootstrap templates for those * classes where the BAR templates are either missing or not * of sufficient quantity. * (3) Using the BAR/BSR to label unlabeled book sampless. * (4) Adding the pixa of the original set of labeled book * templates to the pixa of the newly labeled templates, and * making a BAR from the joined pixa. The BAR would then * work to identify unscaled samples from the book. * (5) Removing outliers from the BAR. * * Note that if this final BAR were not to have a sufficient number * of templates in each class, it can again be augmented with BSR * templates, and the hybrid BAR/BSR would be the final recognizer * that is used to identify unknown (scaled) samples. */ #ifdef HAVE_CONFIG_H #include <config_auto.h> #endif /* HAVE_CONFIG_H */ #include "string.h" #include "allheaders.h" l_int32 main(int argc, char **argv) { char *text; l_int32 histo[10]; l_int32 i, n, ival, same; PIX *pix1, *pix2; PIXA *pixa1, *pixa2, *pixa3, *pixa4; L_RECOG *recog1, *recog2, *recog3; if (argc != 1) { lept_stderr(" Syntax: recogtest3\n"); return 1; } setLeptDebugOK(1); lept_mkdir("lept/recog"); /* Read templates and split them into two sets. Use one to * make a BAR recog that needs padding; use the other with a * hybrid BAR/BSR to make more labeled templates to augment * the BAR */ pixa1 = pixaRead("recog/sets/train05.pa"); pixa2 = pixaCreate(0); /* to generate a small BAR */ pixa3 = pixaCreate(0); /* for templates to be labeled and * added to the BAR */ n = pixaGetCount(pixa1); for (i = 0; i < 10; i++) histo[i] = 0; for (i = 0; i < n; i++) { pix1 = pixaGetPix(pixa1, i, L_COPY); text = pixGetText(pix1); ival = text[0] - '0'; /* remove all 4's, and all but 2 7's and 9's */ if (ival == 4 || (ival == 7 && histo[7] == 2) || (ival == 9 && histo[9] == 2)) { pixaAddPix(pixa3, pix1, L_INSERT); } else { pixaAddPix(pixa2, pix1, L_INSERT); histo[ival]++; } } pix1 = pixaDisplayTiledWithText(pixa3, 1500, 1.0, 15, 2, 6, 0xff000000); pixDisplay(pix1, 500, 0); pixDestroy(&pix1); /* Make a BAR from the small set */ recog1 = recogCreateFromPixa(pixa2, 0, 40, 0, 128, 1); recogShowContent(stderr, recog1, 0, 1); /* Pad with BSR templates to make a hybrid BAR/BSR */ recogPadDigitTrainingSet(&recog1, 40, 0); recogShowContent(stderr, recog1, 1, 1); /* Use the BAR/BSR to label the left-over templates from the book */ pixa4 = recogTrainFromBoot(recog1, pixa3, 0.75, 128, 1); /* Join the two sets */ pixaJoin(pixa1, pixa4, 0, 0); pixaDestroy(&pixa4); /* Make a new BAR that uses unscaled templates. * This now has all the templates from pixa1, before deletions */ recog2 = recogCreateFromPixa(pixa1, 0, 0, 5, 128, 1); recogShowContent(stderr, recog2, 2, 1); /* Test recog serialization */ recogWrite("/tmp/lept/recog/recog2.rec", recog2); recog3 = recogRead("/tmp/lept/recog/recog2.rec"); recogWrite("/tmp/lept/recog/recog3.rec", recog3); filesAreIdentical("/tmp/lept/recog/recog2.rec", "/tmp/lept/recog/recog3.rec", &same); if (!same) lept_stderr("Error in serialization!\n"); recogDestroy(&recog3); /* Remove outliers: method 1 */ pixa4 = pixaRemoveOutliers1(pixa1, 0.8, 4, 3, &pix1, &pix2); pixDisplay(pix1, 500, 0); pixDisplay(pix2, 500, 500); pixDestroy(&pix1); pixDestroy(&pix2); recog3 = recogCreateFromPixa(pixa4, 0, 0, 0, 128, 1); recogShowContent(stderr, recog3, 3, 1); pixaDestroy(&pixa4); recogDestroy(&recog3); /* Relabel a few templates to put them in the wrong classes */ pix1 = pixaGetPix(pixa1, 7, L_CLONE); pixSetText(pix1, "4"); pixDestroy(&pix1); pix1 = pixaGetPix(pixa1, 38, L_CLONE); pixSetText(pix1, "9"); pixDestroy(&pix1); pix1 = pixaGetPix(pixa1, 61, L_CLONE); pixSetText(pix1, "2"); pixDestroy(&pix1); /* Remove outliers: method 2 */ pixa4 = pixaRemoveOutliers2(pixa1, 0.65, 3, &pix1, &pix2); pixDisplay(pix1, 900, 0); pixDisplay(pix2, 900, 500); pixDestroy(&pix1); pixDestroy(&pix2); recog3 = recogCreateFromPixa(pixa4, 0, 0, 0, 128, 1); recogShowContent(stderr, recog3, 3, 1); pixaDestroy(&pixa4); recogDestroy(&recog3); recogDestroy(&recog1); recogDestroy(&recog2); pixaDestroy(&pixa1); pixaDestroy(&pixa2); pixaDestroy(&pixa3); return 0; }
c7eadbad4ffee93759278cf2facf7ea78f45de73
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
/AKWF-c/AKWF_overtone/AKWF_overtone_0008.h
2eb41fa1af62e1c93bae10bcde653de78eaae091
[ "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,690
h
AKWF_overtone_0008.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_overtone_0008 256 samples +-----------------------------------------------------------------------------------------------------------------+ | ********* * ******* | | ********** * * ******* | | ******* * * ****** | | ******* * * ******* | |** * * ******** *****| | * * ***************************** | | * * | | * * | | * * | | * * | | * * | | * * | | * * | | * * | | * ******** | +-----------------------------------------------------------------------------------------------------------------+ */ const uint16_t AKWF_overtone_0008 [] = { 32800, 32972, 33154, 33339, 33525, 33711, 33900, 34091, 34283, 34474, 34672, 34861, 35063, 35253, 35457, 35646, 35855, 36041, 36252, 36435, 36651, 36830, 37047, 37222, 37439, 37615, 37829, 38005, 38213, 38394, 38590, 38779, 38958, 39160, 39317, 39537, 39668, 39906, 40008, 40269, 40341, 40622, 40664, 40961, 40980, 41286, 41291, 41592, 41598, 41877, 41899, 42139, 42200, 42376, 42500, 42585, 42799, 42767, 43094, 42923, 43384, 43054, 43668, 43161, 43940, 43248, 44199, 43315, 44444, 43361, 44683, 43361, 44971, 43182, 45780, 39110, 3260, 0, 916, 16, 1102, 417, 1318, 797, 1503, 1173, 1657, 1538, 1782, 1886, 1884, 2212, 1970, 2507, 2045, 2767, 2110, 2989, 2155, 3233, 1929, 5809, 41550, 48614, 45907, 47645, 45969, 47222, 45837, 46843, 45654, 46453, 45443, 46050, 45209, 45627, 44951, 45194, 44668, 44752, 44359, 44306, 44021, 43855, 43659, 43404, 43270, 42954, 42858, 42502, 42424, 42050, 41972, 41597, 41506, 41142, 41027, 40681, 40542, 40218, 40050, 39750, 39556, 39278, 39061, 38802, 38567, 38323, 38074, 37842, 37585, 37362, 37101, 36881, 36623, 36405, 36148, 35932, 35681, 35464, 35222, 35005, 34770, 34553, 34325, 34112, 33892, 33681, 33469, 33262, 33057, 32855, 32659, 32463, 32274, 32084, 31903, 31720, 31544, 31373, 31206, 31041, 30882, 30726, 30578, 30431, 30290, 30152, 30020, 29894, 29771, 29654, 29541, 29434, 29330, 29235, 29143, 29056, 28975, 28897, 28827, 28761, 28700, 28647, 28596, 28552, 28514, 28481, 28452, 28431, 28413, 28402, 28395, 28395, 28399, 28410, 28426, 28445, 28471, 28502, 28538, 28581, 28627, 28678, 28735, 28798, 28865, 28936, 29012, 29094, 29178, 29270, 29365, 29464, 29568, 29678, 29789, 29906, 30027, 30152, 30281, 30414, 30549, 30690, 30833, 30980, 31130, 31285, 31440, 31601, 31762, 31928, 32094, 32269, 32438, 32621, };
c384153f92583f43eb98844fa3718448fc2bc3e0
983f60b258028ccacd9d0637d430f6e39ca19f44
/src/sfizz/import/sfizz_import.h
7ae1184b1e73ec0c271cbacd2aa88cf411e6d77c
[ "LGPL-2.0-or-later", "BSD-3-Clause", "MIT-0", "BSL-1.0", "Apache-2.0", "BSD-2-Clause", "LGPL-2.1-only", "WTFPL", "MIT" ]
permissive
sfztools/sfizz
98a1136ffa0fea547aa3560c31309b0be42e2b10
c2783f1853067af933cdc8cc6e523d12a296b59d
refs/heads/develop
2023-08-28T14:13:44.790032
2023-08-26T13:29:49
2023-08-26T13:29:49
199,350,095
362
72
BSD-2-Clause
2023-08-30T02:33:41
2019-07-29T00:12:15
C++
UTF-8
C
false
false
1,303
h
sfizz_import.h
// SPDX-License-Identifier: BSD-2-Clause // This code is part of the sfizz library and is licensed under a BSD 2-clause // license. You should have receive a LICENSE.md file along with the code. // If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz #pragma once #include <sfizz.h> #ifdef __cplusplus extern "C" { #endif /** * @brief Loads or imports an instrument file. * * The file path can be absolute or relative. * @since 1.0.1 * * @param synth The synth. * @param path A null-terminated string representing a path to an instrument * in SFZ format, or another format which can be imported. * @param format An optional pointer to a string pointer, which receives the * null-terminated name of the format if the file was imported, * or null if the file was loaded directly as SFZ. * * @return @true when file loading went OK, * @false if some error occured while loading. * * @par Thread-safety constraints * - @b CT: the function must be invoked from the Control thread * - @b OFF: the function cannot be invoked while a thread is calling @b RT functions */ bool sfizz_load_or_import_file(sfizz_synth_t* synth, const char* path, const char** format); #ifdef __cplusplus } // extern "C" #endif
7a831d3039cbbc089d79b9193245751415409c6d
52c8ed39b32ccc7c0673278c1adea3638797c9ff
/src/arch/arm32/mach-trimui/include/f1c200s-irq.h
ede30c4009578fa50c542c1e1b3816d82287174f
[ "MIT" ]
permissive
xboot/xboot
0cab7b440b612aa0a4c366025598a53a7ec3adf1
6d6b93947b7fcb8c3924fedb0715c23877eedd5e
refs/heads/master
2023-08-20T05:56:25.149388
2023-07-12T07:38:29
2023-07-12T07:38:29
471,539
765
296
MIT
2023-05-25T09:39:01
2010-01-14T08:25:12
C
UTF-8
C
false
false
2,599
h
f1c200s-irq.h
#ifndef __F1C200S_IRQ_H__ #define __F1C200S_IRQ_H__ #ifdef __cplusplus extern "C" { #endif #define F1C200S_IRQ_NMI (0) #define F1C200S_IRQ_UART0 (1) #define F1C200S_IRQ_UART1 (2) #define F1C200S_IRQ_UART2 (3) #define F1C200S_IRQ_SPDIF (5) #define F1C200S_IRQ_CIR (6) #define F1C200S_IRQ_I2C0 (7) #define F1C200S_IRQ_I2C1 (8) #define F1C200S_IRQ_I2C2 (9) #define F1C200S_IRQ_SPI0 (10) #define F1C200S_IRQ_SPI1 (11) #define F1C200S_IRQ_TIMER0 (13) #define F1C200S_IRQ_TIMER1 (14) #define F1C200S_IRQ_TIMER2 (15) #define F1C200S_IRQ_WDOG (16) #define F1C200S_IRQ_RSB (17) #define F1C200S_IRQ_DMA (18) #define F1C200S_IRQ_TP (20) #define F1C200S_IRQ_AUDIO (21) #define F1C200S_IRQ_LRADC (22) #define F1C200S_IRQ_MMC0 (23) #define F1C200S_IRQ_MMC1 (24) #define F1C200S_IRQ_USBOTG (26) #define F1C200S_IRQ_TVD (27) #define F1C200S_IRQ_TVE (28) #define F1C200S_IRQ_LCD (29) #define F1C200S_IRQ_DEFE (30) #define F1C200S_IRQ_DEBE (31) #define F1C200S_IRQ_CSI (32) #define F1C200S_IRQ_DEITLA (33) #define F1C200S_IRQ_VE (34) #define F1C200S_IRQ_I2S (35) #define F1C200S_IRQ_GPIOD (38) #define F1C200S_IRQ_GPIOE (39) #define F1C200S_IRQ_GPIOF (40) #define F1C200S_IRQ_GPIOD0 (64) #define F1C200S_IRQ_GPIOD1 (65) #define F1C200S_IRQ_GPIOD2 (66) #define F1C200S_IRQ_GPIOD3 (67) #define F1C200S_IRQ_GPIOD4 (68) #define F1C200S_IRQ_GPIOD5 (69) #define F1C200S_IRQ_GPIOD6 (70) #define F1C200S_IRQ_GPIOD7 (71) #define F1C200S_IRQ_GPIOD8 (72) #define F1C200S_IRQ_GPIOD9 (73) #define F1C200S_IRQ_GPIOD10 (74) #define F1C200S_IRQ_GPIOD11 (75) #define F1C200S_IRQ_GPIOD12 (76) #define F1C200S_IRQ_GPIOD13 (77) #define F1C200S_IRQ_GPIOD14 (78) #define F1C200S_IRQ_GPIOD15 (79) #define F1C200S_IRQ_GPIOD17 (80) #define F1C200S_IRQ_GPIOD18 (81) #define F1C200S_IRQ_GPIOD19 (82) #define F1C200S_IRQ_GPIOD20 (83) #define F1C200S_IRQ_GPIOD21 (84) #define F1C200S_IRQ_GPIOE0 (96) #define F1C200S_IRQ_GPIOE1 (97) #define F1C200S_IRQ_GPIOE2 (98) #define F1C200S_IRQ_GPIOE3 (99) #define F1C200S_IRQ_GPIOE4 (100) #define F1C200S_IRQ_GPIOE5 (101) #define F1C200S_IRQ_GPIOE6 (102) #define F1C200S_IRQ_GPIOE7 (103) #define F1C200S_IRQ_GPIOE8 (104) #define F1C200S_IRQ_GPIOE9 (105) #define F1C200S_IRQ_GPIOE10 (106) #define F1C200S_IRQ_GPIOE11 (107) #define F1C200S_IRQ_GPIOE12 (108) #define F1C200S_IRQ_GPIOF0 (128) #define F1C200S_IRQ_GPIOF1 (129) #define F1C200S_IRQ_GPIOF2 (130) #define F1C200S_IRQ_GPIOF3 (131) #define F1C200S_IRQ_GPIOF4 (132) #define F1C200S_IRQ_GPIOF5 (133) #ifdef __cplusplus } #endif #endif /* __F1C200S_IRQ_H__ */
dbad120a611323e527341afc9ef760e65779de3f
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/cross/z80asm/patches/patch-z80asm.c
9b74f499eba09766b255f55a9fa085dd100660f8
[]
no_license
NetBSD/pkgsrc
a0732c023519650ef821ab89c23ab6ab59e25bdb
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
refs/heads/trunk
2023-09-01T07:40:12.138283
2023-09-01T05:25:19
2023-09-01T05:25:19
88,439,572
321
138
null
2023-07-12T22:34:14
2017-04-16T20:04:15
null
UTF-8
C
false
false
1,196
c
patch-z80asm.c
$NetBSD: patch-z80asm.c,v 1.1 2023/01/20 21:43:56 thorpej Exp $ Cast arguments to ctype(3) functions to (unsigned char). Remove a set-but-not-used variable. --- z80asm.c.orig 2023-01-20 20:33:15.390493731 +0000 +++ z80asm.c 2023-01-20 20:37:05.963725354 +0000 @@ -123,7 +123,7 @@ printerr (int error, const char *fmt, .. const char * delspc (const char *ptr) { - while (*ptr && isspace (*ptr)) + while (*ptr && isspace ((unsigned char)*ptr)) ptr++; if (*ptr == ';') ptr = ""; @@ -440,7 +440,7 @@ parse_commandline (int argc, char **argv static int indx (const char **ptr, const char **list, int error, const char **expr) { - int i, l; + int i; *ptr = delspc (*ptr); if (!**ptr) { @@ -461,7 +461,6 @@ indx (const char **ptr, const char **lis int had_expr = 0; if (!list[i][0]) continue; - l = strlen (list[i]); while (*check) { if (*check == ' ') @@ -492,7 +491,7 @@ indx (const char **ptr, const char **lis ++check; } - if (*check || (isalnum (check[-1]) && isalnum (input[0]))) + if (*check || (isalnum ((unsigned char)check[-1]) && isalnum ((unsigned char)input[0]))) continue; if (had_expr) {
76f90c8edb4c5f9fc2edeb421180a2be98b75cb8
f7dc806f341ef5dbb0e11252a4693003a66853d5
/thirdparty/freetype/src/psaux/pshints.c
6f44d0adbb728447915e7e116eaa59cfae8d1c77
[ "LicenseRef-scancode-free-unknown", "MIT", "CC-BY-4.0", "OFL-1.1", "Bison-exception-2.2", "CC0-1.0", "LicenseRef-scancode-nvidia-2002", "LicenseRef-scancode-other-permissive", "GPL-3.0-only", "LicenseRef-scancode-unknown-license-reference", "Unlicense", "BSL-1.0", "Apache-2.0", "BSD-3-Clause", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unicode", "BSD-2-Clause", "FTL", "GPL-3.0-or-later", "Bitstream-Vera", "Zlib", "MPL-2.0", "MIT-Modern-Variant", "JSON", "Libpng", "GPL-2.0-only", "LicenseRef-scancode-unknown", "GPL-1.0-or-later", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
godotengine/godot
8a2419750f4851d1426a8f3bcb52cac5c86f23c2
970be7afdc111ccc7459d7ef3560de70e6d08c80
refs/heads/master
2023-08-21T14:37:00.262883
2023-08-21T06:26:15
2023-08-21T06:26:15
15,634,981
68,852
18,388
MIT
2023-09-14T21:42:16
2014-01-04T16:05:36
C++
UTF-8
C
false
false
66,109
c
pshints.c
/**************************************************************************** * * pshints.c * * Adobe's code for handling CFF hints (body). * * Copyright 2007-2014 Adobe Systems Incorporated. * * This software, and all works of authorship, whether in source or * object code form as indicated by the copyright notice(s) included * herein (collectively, the "Work") is made available, and may only be * used, modified, and distributed under the FreeType Project License, * LICENSE.TXT. Additionally, subject to the terms and conditions of the * FreeType Project License, each contributor to the Work hereby grants * to any individual or legal entity exercising permissions granted by * the FreeType Project License and this section (hereafter, "You" or * "Your") a perpetual, worldwide, non-exclusive, no-charge, * royalty-free, irrevocable (except as stated in this section) patent * license to make, have made, use, offer to sell, sell, import, and * otherwise transfer the Work, where such license applies only to those * patent claims licensable by such contributor that are necessarily * infringed by their contribution(s) alone or by combination of their * contribution(s) with the Work to which such contribution(s) was * submitted. If You institute patent litigation against any entity * (including a cross-claim or counterclaim in a lawsuit) alleging that * the Work or a contribution incorporated within the Work constitutes * direct or contributory patent infringement, then any patent licenses * granted to You under this License for that Work shall terminate as of * the date such litigation is filed. * * By using, modifying, or distributing the Work you indicate that you * have read and understood the terms and conditions of the * FreeType Project License as well as those provided in this section, * and you accept them fully. * */ #include "psft.h" #include <freetype/internal/ftdebug.h> #include "psglue.h" #include "psfont.h" #include "pshints.h" #include "psintrp.h" /************************************************************************** * * The macro FT_COMPONENT is used in trace mode. It is an implicit * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log * messages during execution. */ #undef FT_COMPONENT #define FT_COMPONENT cf2hints typedef struct CF2_HintMoveRec_ { size_t j; /* index of upper hint map edge */ CF2_Fixed moveUp; /* adjustment to optimum position */ } CF2_HintMoveRec, *CF2_HintMove; /* Compute angular momentum for winding order detection. It is called */ /* for all lines and curves, but not necessarily in element order. */ static CF2_Int cf2_getWindingMomentum( CF2_Fixed x1, CF2_Fixed y1, CF2_Fixed x2, CF2_Fixed y2 ) { /* cross product of pt1 position from origin with pt2 position from */ /* pt1; we reduce the precision so that the result fits into 32 bits */ return ( x1 >> 16 ) * ( SUB_INT32( y2, y1 ) >> 16 ) - ( y1 >> 16 ) * ( SUB_INT32( x2, x1 ) >> 16 ); } /* * Construct from a StemHint; this is used as a parameter to * `cf2_blues_capture'. * `hintOrigin' is the character space displacement of a seac accent. * Adjust stem hint for darkening here. * */ static void cf2_hint_init( CF2_Hint hint, const CF2_ArrStack stemHintArray, size_t indexStemHint, const CF2_Font font, CF2_Fixed hintOrigin, CF2_Fixed scale, FT_Bool bottom ) { CF2_Fixed width; const CF2_StemHintRec* stemHint; FT_ZERO( hint ); stemHint = (const CF2_StemHintRec*)cf2_arrstack_getPointer( stemHintArray, indexStemHint ); width = SUB_INT32( stemHint->max, stemHint->min ); if ( width == cf2_intToFixed( -21 ) ) { /* ghost bottom */ if ( bottom ) { hint->csCoord = stemHint->max; hint->flags = CF2_GhostBottom; } else hint->flags = 0; } else if ( width == cf2_intToFixed( -20 ) ) { /* ghost top */ if ( bottom ) hint->flags = 0; else { hint->csCoord = stemHint->min; hint->flags = CF2_GhostTop; } } else if ( width < 0 ) { /* inverted pair */ /* * Hints with negative widths were produced by an early version of a * non-Adobe font tool. The Type 2 spec allows edge (ghost) hints * with negative widths, but says * * All other negative widths have undefined meaning. * * CoolType has a silent workaround that negates the hint width; for * permissive mode, we do the same here. * * Note: Such fonts cannot use ghost hints, but should otherwise work. * Note: Some poor hints in our faux fonts can produce negative * widths at some blends. For example, see a light weight of * `u' in ASerifMM. * */ if ( bottom ) { hint->csCoord = stemHint->max; hint->flags = CF2_PairBottom; } else { hint->csCoord = stemHint->min; hint->flags = CF2_PairTop; } } else { /* normal pair */ if ( bottom ) { hint->csCoord = stemHint->min; hint->flags = CF2_PairBottom; } else { hint->csCoord = stemHint->max; hint->flags = CF2_PairTop; } } /* Now that ghost hints have been detected, adjust this edge for */ /* darkening. Bottoms are not changed; tops are incremented by twice */ /* `darkenY'. */ if ( cf2_hint_isTop( hint ) ) hint->csCoord = ADD_INT32( hint->csCoord, 2 * font->darkenY ); hint->csCoord = ADD_INT32( hint->csCoord, hintOrigin ); hint->scale = scale; hint->index = indexStemHint; /* index in original stem hint array */ /* if original stem hint has been used, use the same position */ if ( hint->flags != 0 && stemHint->used ) { if ( cf2_hint_isTop( hint ) ) hint->dsCoord = stemHint->maxDS; else hint->dsCoord = stemHint->minDS; cf2_hint_lock( hint ); } else hint->dsCoord = FT_MulFix( hint->csCoord, scale ); } /* initialize an invalid hint map element */ static void cf2_hint_initZero( CF2_Hint hint ) { FT_ZERO( hint ); } FT_LOCAL_DEF( FT_Bool ) cf2_hint_isValid( const CF2_Hint hint ) { return FT_BOOL( hint->flags ); } static FT_Bool cf2_hint_isPair( const CF2_Hint hint ) { return FT_BOOL( hint->flags & ( CF2_PairBottom | CF2_PairTop ) ); } static FT_Bool cf2_hint_isPairTop( const CF2_Hint hint ) { return FT_BOOL( hint->flags & CF2_PairTop ); } FT_LOCAL_DEF( FT_Bool ) cf2_hint_isTop( const CF2_Hint hint ) { return FT_BOOL( hint->flags & ( CF2_PairTop | CF2_GhostTop ) ); } FT_LOCAL_DEF( FT_Bool ) cf2_hint_isBottom( const CF2_Hint hint ) { return FT_BOOL( hint->flags & ( CF2_PairBottom | CF2_GhostBottom ) ); } static FT_Bool cf2_hint_isLocked( const CF2_Hint hint ) { return FT_BOOL( hint->flags & CF2_Locked ); } static FT_Bool cf2_hint_isSynthetic( const CF2_Hint hint ) { return FT_BOOL( hint->flags & CF2_Synthetic ); } FT_LOCAL_DEF( void ) cf2_hint_lock( CF2_Hint hint ) { hint->flags |= CF2_Locked; } FT_LOCAL_DEF( void ) cf2_hintmap_init( CF2_HintMap hintmap, CF2_Font font, CF2_HintMap initialMap, CF2_ArrStack hintMoves, CF2_Fixed scale ) { FT_ZERO( hintmap ); /* copy parameters from font instance */ hintmap->hinted = font->hinted; hintmap->scale = scale; hintmap->font = font; hintmap->initialHintMap = initialMap; /* will clear in `cf2_hintmap_adjustHints' */ hintmap->hintMoves = hintMoves; } static FT_Bool cf2_hintmap_isValid( const CF2_HintMap hintmap ) { return hintmap->isValid; } static void cf2_hintmap_dump( CF2_HintMap hintmap ) { #ifdef FT_DEBUG_LEVEL_TRACE CF2_UInt i; FT_TRACE6(( " index csCoord dsCoord scale flags\n" )); for ( i = 0; i < hintmap->count; i++ ) { CF2_Hint hint = &hintmap->edge[i]; FT_TRACE6(( " %3ld %7.2f %7.2f %5d %s%s%s%s\n", hint->index, hint->csCoord / 65536.0, hint->dsCoord / ( hint->scale * 1.0 ), hint->scale, ( cf2_hint_isPair( hint ) ? "p" : "g" ), ( cf2_hint_isTop( hint ) ? "t" : "b" ), ( cf2_hint_isLocked( hint ) ? "L" : ""), ( cf2_hint_isSynthetic( hint ) ? "S" : "" ) )); } #else FT_UNUSED( hintmap ); #endif } /* transform character space coordinate to device space using hint map */ static CF2_Fixed cf2_hintmap_map( CF2_HintMap hintmap, CF2_Fixed csCoord ) { if ( hintmap->count == 0 || !hintmap->hinted ) { /* there are no hints; use uniform scale and zero offset */ return FT_MulFix( csCoord, hintmap->scale ); } else { /* start linear search from last hit */ CF2_UInt i = hintmap->lastIndex; FT_ASSERT( hintmap->lastIndex < CF2_MAX_HINT_EDGES ); /* search up */ while ( i < hintmap->count - 1 && csCoord >= hintmap->edge[i + 1].csCoord ) i += 1; /* search down */ while ( i > 0 && csCoord < hintmap->edge[i].csCoord ) i -= 1; hintmap->lastIndex = i; if ( i == 0 && csCoord < hintmap->edge[0].csCoord ) { /* special case for points below first edge: use uniform scale */ return ADD_INT32( FT_MulFix( SUB_INT32( csCoord, hintmap->edge[0].csCoord ), hintmap->scale ), hintmap->edge[0].dsCoord ); } else { /* * Note: entries with duplicate csCoord are allowed. * Use edge[i], the highest entry where csCoord >= entry[i].csCoord */ return ADD_INT32( FT_MulFix( SUB_INT32( csCoord, hintmap->edge[i].csCoord ), hintmap->edge[i].scale ), hintmap->edge[i].dsCoord ); } } } /* * This hinting policy moves a hint pair in device space so that one of * its two edges is on a device pixel boundary (its fractional part is * zero). `cf2_hintmap_insertHint' guarantees no overlap in CS * space. Ensure here that there is no overlap in DS. * * In the first pass, edges are adjusted relative to adjacent hints. * Those that are below have already been adjusted. Those that are * above have not yet been adjusted. If a hint above blocks an * adjustment to an optimal position, we will try again in a second * pass. The second pass is top-down. * */ static void cf2_hintmap_adjustHints( CF2_HintMap hintmap ) { size_t i, j; cf2_arrstack_clear( hintmap->hintMoves ); /* working storage */ /* * First pass is bottom-up (font hint order) without look-ahead. * Locked edges are already adjusted. * Unlocked edges begin with dsCoord from `initialHintMap'. * Save edges that are not optimally adjusted in `hintMoves' array, * and process them in second pass. */ for ( i = 0; i < hintmap->count; i++ ) { FT_Bool isPair = cf2_hint_isPair( &hintmap->edge[i] ); /* final amount to move edge or edge pair */ CF2_Fixed move = 0; CF2_Fixed dsCoord_i; CF2_Fixed dsCoord_j; /* index of upper edge (same value for ghost hint) */ j = isPair ? i + 1 : i; FT_ASSERT( j < hintmap->count ); FT_ASSERT( cf2_hint_isValid( &hintmap->edge[i] ) ); FT_ASSERT( cf2_hint_isValid( &hintmap->edge[j] ) ); FT_ASSERT( cf2_hint_isLocked( &hintmap->edge[i] ) == cf2_hint_isLocked( &hintmap->edge[j] ) ); dsCoord_i = hintmap->edge[i].dsCoord; dsCoord_j = hintmap->edge[j].dsCoord; if ( !cf2_hint_isLocked( &hintmap->edge[i] ) ) { /* hint edge is not locked, we can adjust it */ CF2_Fixed fracDown = cf2_fixedFraction( dsCoord_i ); CF2_Fixed fracUp = cf2_fixedFraction( dsCoord_j ); /* calculate all four possibilities; moves down are negative */ CF2_Fixed downMoveDown = 0 - fracDown; CF2_Fixed upMoveDown = 0 - fracUp; CF2_Fixed downMoveUp = ( fracDown == 0 ) ? 0 : cf2_intToFixed( 1 ) - fracDown; CF2_Fixed upMoveUp = ( fracUp == 0 ) ? 0 : cf2_intToFixed( 1 ) - fracUp; /* smallest move up */ CF2_Fixed moveUp = FT_MIN( downMoveUp, upMoveUp ); /* smallest move down */ CF2_Fixed moveDown = FT_MAX( downMoveDown, upMoveDown ); CF2_Fixed downMinCounter = CF2_MIN_COUNTER; CF2_Fixed upMinCounter = CF2_MIN_COUNTER; FT_Bool saveEdge = FALSE; /* minimum counter constraint doesn't apply when adjacent edges */ /* are synthetic */ /* TODO: doesn't seem a big effect; for now, reduce the code */ #if 0 if ( i == 0 || cf2_hint_isSynthetic( &hintmap->edge[i - 1] ) ) downMinCounter = 0; if ( j >= hintmap->count - 1 || cf2_hint_isSynthetic( &hintmap->edge[j + 1] ) ) upMinCounter = 0; #endif /* is there room to move up? */ /* there is if we are at top of array or the next edge is at or */ /* beyond proposed move up? */ if ( j >= hintmap->count - 1 || hintmap->edge[j + 1].dsCoord >= ADD_INT32( dsCoord_j, moveUp + upMinCounter ) ) { /* there is room to move up; is there also room to move down? */ if ( i == 0 || hintmap->edge[i - 1].dsCoord <= ADD_INT32( dsCoord_i, moveDown - downMinCounter ) ) { /* move smaller absolute amount */ move = ( -moveDown < moveUp ) ? moveDown : moveUp; /* optimum */ } else move = moveUp; } else { /* is there room to move down? */ if ( i == 0 || hintmap->edge[i - 1].dsCoord <= ADD_INT32( dsCoord_i, moveDown - downMinCounter ) ) { move = moveDown; /* true if non-optimum move */ saveEdge = FT_BOOL( moveUp < -moveDown ); } else { /* no room to move either way without overlapping or reducing */ /* the counter too much */ move = 0; saveEdge = TRUE; } } /* Identify non-moves and moves down that aren't optimal, and save */ /* them for second pass. */ /* Do this only if there is an unlocked edge above (which could */ /* possibly move). */ if ( saveEdge && j < hintmap->count - 1 && !cf2_hint_isLocked( &hintmap->edge[j + 1] ) ) { CF2_HintMoveRec savedMove; savedMove.j = j; /* desired adjustment in second pass */ savedMove.moveUp = moveUp - move; cf2_arrstack_push( hintmap->hintMoves, &savedMove ); } /* move the edge(s) */ hintmap->edge[i].dsCoord = ADD_INT32( dsCoord_i, move ); if ( isPair ) hintmap->edge[j].dsCoord = ADD_INT32( dsCoord_j, move ); } /* assert there are no overlaps in device space; */ /* ignore tests if there was overflow (that is, if */ /* operands have the same sign but the sum does not) */ FT_ASSERT( i == 0 || ( ( dsCoord_i ^ move ) >= 0 && ( dsCoord_i ^ hintmap->edge[i].dsCoord ) < 0 ) || hintmap->edge[i - 1].dsCoord <= hintmap->edge[i].dsCoord ); FT_ASSERT( i < j || ( ( dsCoord_j ^ move ) >= 0 && ( dsCoord_j ^ hintmap->edge[j].dsCoord ) < 0 ) || hintmap->edge[i].dsCoord <= hintmap->edge[j].dsCoord ); /* adjust the scales, avoiding divide by zero */ if ( i > 0 ) { if ( hintmap->edge[i].csCoord != hintmap->edge[i - 1].csCoord ) hintmap->edge[i - 1].scale = FT_DivFix( SUB_INT32( hintmap->edge[i].dsCoord, hintmap->edge[i - 1].dsCoord ), SUB_INT32( hintmap->edge[i].csCoord, hintmap->edge[i - 1].csCoord ) ); } if ( isPair ) { if ( hintmap->edge[j].csCoord != hintmap->edge[j - 1].csCoord ) hintmap->edge[j - 1].scale = FT_DivFix( SUB_INT32( hintmap->edge[j].dsCoord, hintmap->edge[j - 1].dsCoord ), SUB_INT32( hintmap->edge[j].csCoord, hintmap->edge[j - 1].csCoord ) ); i += 1; /* skip upper edge on next loop */ } } /* second pass tries to move non-optimal hints up, in case there is */ /* room now */ for ( i = cf2_arrstack_size( hintmap->hintMoves ); i > 0; i-- ) { CF2_HintMove hintMove = (CF2_HintMove) cf2_arrstack_getPointer( hintmap->hintMoves, i - 1 ); j = hintMove->j; /* this was tested before the push, above */ FT_ASSERT( j < hintmap->count - 1 ); /* is there room to move up? */ if ( hintmap->edge[j + 1].dsCoord >= ADD_INT32( hintmap->edge[j].dsCoord, hintMove->moveUp + CF2_MIN_COUNTER ) ) { /* there is more room now, move edge up */ hintmap->edge[j].dsCoord = ADD_INT32( hintmap->edge[j].dsCoord, hintMove->moveUp ); if ( cf2_hint_isPair( &hintmap->edge[j] ) ) { FT_ASSERT( j > 0 ); hintmap->edge[j - 1].dsCoord = ADD_INT32( hintmap->edge[j - 1].dsCoord, hintMove->moveUp ); } } } } /* insert hint edges into map, sorted by csCoord */ static void cf2_hintmap_insertHint( CF2_HintMap hintmap, CF2_Hint bottomHintEdge, CF2_Hint topHintEdge ) { CF2_UInt indexInsert; /* set default values, then check for edge hints */ FT_Bool isPair = TRUE; CF2_Hint firstHintEdge = bottomHintEdge; CF2_Hint secondHintEdge = topHintEdge; /* one or none of the input params may be invalid when dealing with */ /* edge hints; at least one edge must be valid */ FT_ASSERT( cf2_hint_isValid( bottomHintEdge ) || cf2_hint_isValid( topHintEdge ) ); /* determine how many and which edges to insert */ if ( !cf2_hint_isValid( bottomHintEdge ) ) { /* insert only the top edge */ firstHintEdge = topHintEdge; isPair = FALSE; } else if ( !cf2_hint_isValid( topHintEdge ) ) { /* insert only the bottom edge */ isPair = FALSE; } /* paired edges must be in proper order */ if ( isPair && topHintEdge->csCoord < bottomHintEdge->csCoord ) return; /* linear search to find index value of insertion point */ indexInsert = 0; for ( ; indexInsert < hintmap->count; indexInsert++ ) { if ( hintmap->edge[indexInsert].csCoord >= firstHintEdge->csCoord ) break; } FT_TRACE7(( " Got hint at %.2f (%.2f)\n", firstHintEdge->csCoord / 65536.0, firstHintEdge->dsCoord / 65536.0 )); if ( isPair ) FT_TRACE7(( " Got hint at %.2f (%.2f)\n", secondHintEdge->csCoord / 65536.0, secondHintEdge->dsCoord / 65536.0 )); /* * Discard any hints that overlap in character space. Most often, this * is while building the initial map, where captured hints from all * zones are combined. Define overlap to include hints that `touch' * (overlap zero). Hiragino Sans/Gothic fonts have numerous hints that * touch. Some fonts have non-ideographic glyphs that overlap our * synthetic hints. * * Overlap also occurs when darkening stem hints that are close. * */ if ( indexInsert < hintmap->count ) { /* we are inserting before an existing edge: */ /* verify that an existing edge is not the same */ if ( hintmap->edge[indexInsert].csCoord == firstHintEdge->csCoord ) return; /* ignore overlapping stem hint */ /* verify that a new pair does not straddle the next edge */ if ( isPair && hintmap->edge[indexInsert].csCoord <= secondHintEdge->csCoord ) return; /* ignore overlapping stem hint */ /* verify that we are not inserting between paired edges */ if ( cf2_hint_isPairTop( &hintmap->edge[indexInsert] ) ) return; /* ignore overlapping stem hint */ } /* recompute device space locations using initial hint map */ if ( cf2_hintmap_isValid( hintmap->initialHintMap ) && !cf2_hint_isLocked( firstHintEdge ) ) { if ( isPair ) { /* Use hint map to position the center of stem, and nominal scale */ /* to position the two edges. This preserves the stem width. */ CF2_Fixed midpoint = cf2_hintmap_map( hintmap->initialHintMap, ADD_INT32( firstHintEdge->csCoord, SUB_INT32 ( secondHintEdge->csCoord, firstHintEdge->csCoord ) / 2 ) ); CF2_Fixed halfWidth = FT_MulFix( SUB_INT32( secondHintEdge->csCoord, firstHintEdge->csCoord ) / 2, hintmap->scale ); firstHintEdge->dsCoord = SUB_INT32( midpoint, halfWidth ); secondHintEdge->dsCoord = ADD_INT32( midpoint, halfWidth ); } else firstHintEdge->dsCoord = cf2_hintmap_map( hintmap->initialHintMap, firstHintEdge->csCoord ); } /* * Discard any hints that overlap in device space; this can occur * because locked hints have been moved to align with blue zones. * * TODO: Although we might correct this later during adjustment, we * don't currently have a way to delete a conflicting hint once it has * been inserted. See v2.030 MinionPro-Regular, 12 ppem darkened, * initial hint map for second path, glyph 945 (the perispomeni (tilde) * in U+1F6E, Greek omega with psili and perispomeni). Darkening is * 25. Pair 667,747 initially conflicts in design space with top edge * 660. This is because 667 maps to 7.87, and the top edge was * captured by a zone at 8.0. The pair is later successfully inserted * in a zone without the top edge. In this zone it is adjusted to 8.0, * and no longer conflicts with the top edge in design space. This * means it can be included in yet a later zone which does have the top * edge hint. This produces a small mismatch between the first and * last points of this path, even though the hint masks are the same. * The density map difference is tiny (1/256). * */ if ( indexInsert > 0 ) { /* we are inserting after an existing edge */ if ( firstHintEdge->dsCoord < hintmap->edge[indexInsert - 1].dsCoord ) return; } if ( indexInsert < hintmap->count ) { /* we are inserting before an existing edge */ if ( isPair ) { if ( secondHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord ) return; } else { if ( firstHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord ) return; } } /* make room to insert */ { CF2_UInt iSrc = hintmap->count - 1; CF2_UInt iDst = isPair ? hintmap->count + 1 : hintmap->count; CF2_UInt count = hintmap->count - indexInsert; if ( iDst >= CF2_MAX_HINT_EDGES ) { FT_TRACE4(( "cf2_hintmap_insertHint: too many hintmaps\n" )); return; } while ( count-- ) hintmap->edge[iDst--] = hintmap->edge[iSrc--]; /* insert first edge */ hintmap->edge[indexInsert] = *firstHintEdge; /* copy struct */ hintmap->count += 1; FT_TRACE7(( " Inserting hint %.2f (%.2f)\n", firstHintEdge->csCoord / 65536.0, firstHintEdge->dsCoord / 65536.0 )); if ( isPair ) { /* insert second edge */ hintmap->edge[indexInsert + 1] = *secondHintEdge; /* copy struct */ hintmap->count += 1; FT_TRACE7(( " Inserting hint %.2f (%.2f)\n", secondHintEdge->csCoord / 65536.0, secondHintEdge->dsCoord / 65536.0 )); } } return; } /* * Build a map from hints and mask. * * This function may recur one level if `hintmap->initialHintMap' is not yet * valid. * If `initialMap' is true, simply build initial map. * * Synthetic hints are used in two ways. A hint at zero is inserted, if * needed, in the initial hint map, to prevent translations from * propagating across the origin. If synthetic em box hints are enabled * for ideographic dictionaries, then they are inserted in all hint * maps, including the initial one. * */ FT_LOCAL_DEF( void ) cf2_hintmap_build( CF2_HintMap hintmap, CF2_ArrStack hStemHintArray, CF2_ArrStack vStemHintArray, CF2_HintMask hintMask, CF2_Fixed hintOrigin, FT_Bool initialMap ) { FT_Byte* maskPtr; CF2_Font font = hintmap->font; CF2_HintMaskRec tempHintMask; size_t bitCount, i; FT_Byte maskByte; /* check whether initial map is constructed */ if ( !initialMap && !cf2_hintmap_isValid( hintmap->initialHintMap ) ) { /* make recursive call with initialHintMap and temporary mask; */ /* temporary mask will get all bits set, below */ cf2_hintmask_init( &tempHintMask, hintMask->error ); cf2_hintmap_build( hintmap->initialHintMap, hStemHintArray, vStemHintArray, &tempHintMask, hintOrigin, TRUE ); } if ( !cf2_hintmask_isValid( hintMask ) ) { /* without a hint mask, assume all hints are active */ cf2_hintmask_setAll( hintMask, cf2_arrstack_size( hStemHintArray ) + cf2_arrstack_size( vStemHintArray ) ); if ( !cf2_hintmask_isValid( hintMask ) ) { if ( font->isT1 ) { /* no error, just continue unhinted */ *hintMask->error = FT_Err_Ok; hintmap->hinted = FALSE; } return; /* too many stem hints */ } } /* begin by clearing the map */ hintmap->count = 0; hintmap->lastIndex = 0; /* make a copy of the hint mask so we can modify it */ tempHintMask = *hintMask; maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask ); /* use the hStem hints only, which are first in the mask */ bitCount = cf2_arrstack_size( hStemHintArray ); /* Defense-in-depth. Should never return here. */ if ( bitCount > hintMask->bitCount ) return; /* synthetic embox hints get highest priority */ if ( font->blues.doEmBoxHints ) { CF2_HintRec dummy; cf2_hint_initZero( &dummy ); /* invalid hint map element */ /* ghost bottom */ cf2_hintmap_insertHint( hintmap, &font->blues.emBoxBottomEdge, &dummy ); /* ghost top */ cf2_hintmap_insertHint( hintmap, &dummy, &font->blues.emBoxTopEdge ); } /* insert hints captured by a blue zone or already locked (higher */ /* priority) */ for ( i = 0, maskByte = 0x80; i < bitCount; i++ ) { if ( maskByte & *maskPtr ) { /* expand StemHint into two `CF2_Hint' elements */ CF2_HintRec bottomHintEdge, topHintEdge; cf2_hint_init( &bottomHintEdge, hStemHintArray, i, font, hintOrigin, hintmap->scale, TRUE /* bottom */ ); cf2_hint_init( &topHintEdge, hStemHintArray, i, font, hintOrigin, hintmap->scale, FALSE /* top */ ); if ( cf2_hint_isLocked( &bottomHintEdge ) || cf2_hint_isLocked( &topHintEdge ) || cf2_blues_capture( &font->blues, &bottomHintEdge, &topHintEdge ) ) { /* insert captured hint into map */ cf2_hintmap_insertHint( hintmap, &bottomHintEdge, &topHintEdge ); *maskPtr &= ~maskByte; /* turn off the bit for this hint */ } } if ( ( i & 7 ) == 7 ) { /* move to next mask byte */ maskPtr++; maskByte = 0x80; } else maskByte >>= 1; } /* initial hint map includes only captured hints plus maybe one at 0 */ /* * TODO: There is a problem here because we are trying to build a * single hint map containing all captured hints. It is * possible for there to be conflicts between captured hints, * either because of darkening or because the hints are in * separate hint zones (we are ignoring hint zones for the * initial map). An example of the latter is MinionPro-Regular * v2.030 glyph 883 (Greek Capital Alpha with Psili) at 15ppem. * A stem hint for the psili conflicts with the top edge hint * for the base character. The stem hint gets priority because * of its sort order. In glyph 884 (Greek Capital Alpha with * Psili and Oxia), the top of the base character gets a stem * hint, and the psili does not. This creates different initial * maps for the two glyphs resulting in different renderings of * the base character. Will probably defer this either as not * worth the cost or as a font bug. I don't think there is any * good reason for an accent to be captured by an alignment * zone. -darnold 2/12/10 */ if ( initialMap ) { /* Apply a heuristic that inserts a point for (0,0), unless it's */ /* already covered by a mapping. This locks the baseline for glyphs */ /* that have no baseline hints. */ if ( hintmap->count == 0 || hintmap->edge[0].csCoord > 0 || hintmap->edge[hintmap->count - 1].csCoord < 0 ) { /* all edges are above 0 or all edges are below 0; */ /* construct a locked edge hint at 0 */ CF2_HintRec edge, invalid; cf2_hint_initZero( &edge ); edge.flags = CF2_GhostBottom | CF2_Locked | CF2_Synthetic; edge.scale = hintmap->scale; cf2_hint_initZero( &invalid ); cf2_hintmap_insertHint( hintmap, &edge, &invalid ); } } else { /* insert remaining hints */ maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask ); for ( i = 0, maskByte = 0x80; i < bitCount; i++ ) { if ( maskByte & *maskPtr ) { CF2_HintRec bottomHintEdge, topHintEdge; cf2_hint_init( &bottomHintEdge, hStemHintArray, i, font, hintOrigin, hintmap->scale, TRUE /* bottom */ ); cf2_hint_init( &topHintEdge, hStemHintArray, i, font, hintOrigin, hintmap->scale, FALSE /* top */ ); cf2_hintmap_insertHint( hintmap, &bottomHintEdge, &topHintEdge ); } if ( ( i & 7 ) == 7 ) { /* move to next mask byte */ maskPtr++; maskByte = 0x80; } else maskByte >>= 1; } } #ifdef FT_DEBUG_LEVEL_TRACE if ( initialMap ) { FT_TRACE6(( "flags: [p]air [g]host [t]op" " [b]ottom [L]ocked [S]ynthetic\n" )); FT_TRACE6(( "Initial hintmap:\n" )); } else FT_TRACE6(( "Hints:\n" )); #endif cf2_hintmap_dump( hintmap ); /* * Note: The following line is a convenient place to break when * debugging hinting. Examine `hintmap->edge' for the list of * enabled hints, then step over the call to see the effect of * adjustment. We stop here first on the recursive call that * creates the initial map, and then on each counter group and * hint zone. */ /* adjust positions of hint edges that are not locked to blue zones */ cf2_hintmap_adjustHints( hintmap ); FT_TRACE6(( "Hints adjusted:\n" )); cf2_hintmap_dump( hintmap ); /* save the position of all hints that were used in this hint map; */ /* if we use them again, we'll locate them in the same position */ if ( !initialMap ) { for ( i = 0; i < hintmap->count; i++ ) { if ( !cf2_hint_isSynthetic( &hintmap->edge[i] ) ) { /* Note: include both valid and invalid edges */ /* Note: top and bottom edges are copied back separately */ CF2_StemHint stemhint = (CF2_StemHint) cf2_arrstack_getPointer( hStemHintArray, hintmap->edge[i].index ); if ( cf2_hint_isTop( &hintmap->edge[i] ) ) stemhint->maxDS = hintmap->edge[i].dsCoord; else stemhint->minDS = hintmap->edge[i].dsCoord; stemhint->used = TRUE; } } } /* hint map is ready to use */ hintmap->isValid = TRUE; /* remember this mask has been used */ cf2_hintmask_setNew( hintMask, FALSE ); } FT_LOCAL_DEF( void ) cf2_glyphpath_init( CF2_GlyphPath glyphpath, CF2_Font font, CF2_OutlineCallbacks callbacks, CF2_Fixed scaleY, /* CF2_Fixed hShift, */ CF2_ArrStack hStemHintArray, CF2_ArrStack vStemHintArray, CF2_HintMask hintMask, CF2_Fixed hintOriginY, const CF2_Blues blues, const FT_Vector* fractionalTranslation ) { FT_ZERO( glyphpath ); glyphpath->font = font; glyphpath->callbacks = callbacks; cf2_arrstack_init( &glyphpath->hintMoves, font->memory, &font->error, sizeof ( CF2_HintMoveRec ) ); cf2_hintmap_init( &glyphpath->initialHintMap, font, &glyphpath->initialHintMap, &glyphpath->hintMoves, scaleY ); cf2_hintmap_init( &glyphpath->firstHintMap, font, &glyphpath->initialHintMap, &glyphpath->hintMoves, scaleY ); cf2_hintmap_init( &glyphpath->hintMap, font, &glyphpath->initialHintMap, &glyphpath->hintMoves, scaleY ); glyphpath->scaleX = font->innerTransform.a; glyphpath->scaleC = font->innerTransform.c; glyphpath->scaleY = font->innerTransform.d; glyphpath->fractionalTranslation = *fractionalTranslation; #if 0 glyphpath->hShift = hShift; /* for fauxing */ #endif glyphpath->hStemHintArray = hStemHintArray; glyphpath->vStemHintArray = vStemHintArray; glyphpath->hintMask = hintMask; /* ptr to current mask */ glyphpath->hintOriginY = hintOriginY; glyphpath->blues = blues; glyphpath->darken = font->darkened; /* TODO: should we make copies? */ glyphpath->xOffset = font->darkenX; glyphpath->yOffset = font->darkenY; glyphpath->miterLimit = 2 * FT_MAX( cf2_fixedAbs( glyphpath->xOffset ), cf2_fixedAbs( glyphpath->yOffset ) ); /* .1 character space unit */ glyphpath->snapThreshold = cf2_doubleToFixed( 0.1 ); glyphpath->moveIsPending = TRUE; glyphpath->pathIsOpen = FALSE; glyphpath->pathIsClosing = FALSE; glyphpath->elemIsQueued = FALSE; } FT_LOCAL_DEF( void ) cf2_glyphpath_finalize( CF2_GlyphPath glyphpath ) { cf2_arrstack_finalize( &glyphpath->hintMoves ); } /* * Hint point in y-direction and apply outerTransform. * Input `current' hint map (which is actually delayed by one element). * Input x,y point in Character Space. * Output x,y point in Device Space, including translation. */ static void cf2_glyphpath_hintPoint( CF2_GlyphPath glyphpath, CF2_HintMap hintmap, FT_Vector* ppt, CF2_Fixed x, CF2_Fixed y ) { FT_Vector pt; /* hinted point in upright DS */ pt.x = ADD_INT32( FT_MulFix( glyphpath->scaleX, x ), FT_MulFix( glyphpath->scaleC, y ) ); pt.y = cf2_hintmap_map( hintmap, y ); ppt->x = ADD_INT32( FT_MulFix( glyphpath->font->outerTransform.a, pt.x ), ADD_INT32( FT_MulFix( glyphpath->font->outerTransform.c, pt.y ), glyphpath->fractionalTranslation.x ) ); ppt->y = ADD_INT32( FT_MulFix( glyphpath->font->outerTransform.b, pt.x ), ADD_INT32( FT_MulFix( glyphpath->font->outerTransform.d, pt.y ), glyphpath->fractionalTranslation.y ) ); } /* * From two line segments, (u1,u2) and (v1,v2), compute a point of * intersection on the corresponding lines. * Return false if no intersection is found, or if the intersection is * too far away from the ends of the line segments, u2 and v1. * */ static FT_Bool cf2_glyphpath_computeIntersection( CF2_GlyphPath glyphpath, const FT_Vector* u1, const FT_Vector* u2, const FT_Vector* v1, const FT_Vector* v2, FT_Vector* intersection ) { /* * Let `u' be a zero-based vector from the first segment, `v' from the * second segment. * Let `w 'be the zero-based vector from `u1' to `v1'. * `perp' is the `perpendicular dot product'; see * https://mathworld.wolfram.com/PerpDotProduct.html. * `s' is the parameter for the parametric line for the first segment * (`u'). * * See notation in * http://geomalgorithms.com/a05-_intersect-1.html. * Calculations are done in 16.16, but must handle the squaring of * line lengths in character space. We scale all vectors by 1/32 to * avoid overflow. This allows values up to 4095 to be squared. The * scale factor cancels in the divide. * * TODO: the scale factor could be computed from UnitsPerEm. * */ #define cf2_perp( a, b ) \ ( FT_MulFix( a.x, b.y ) - FT_MulFix( a.y, b.x ) ) /* round and divide by 32 */ #define CF2_CS_SCALE( x ) \ ( ( (x) + 0x10 ) >> 5 ) FT_Vector u, v, w; /* scaled vectors */ CF2_Fixed denominator, s; u.x = CF2_CS_SCALE( SUB_INT32( u2->x, u1->x ) ); u.y = CF2_CS_SCALE( SUB_INT32( u2->y, u1->y ) ); v.x = CF2_CS_SCALE( SUB_INT32( v2->x, v1->x ) ); v.y = CF2_CS_SCALE( SUB_INT32( v2->y, v1->y ) ); w.x = CF2_CS_SCALE( SUB_INT32( v1->x, u1->x ) ); w.y = CF2_CS_SCALE( SUB_INT32( v1->y, u1->y ) ); denominator = cf2_perp( u, v ); if ( denominator == 0 ) return FALSE; /* parallel or coincident lines */ s = FT_DivFix( cf2_perp( w, v ), denominator ); intersection->x = ADD_INT32( u1->x, FT_MulFix( s, SUB_INT32( u2->x, u1->x ) ) ); intersection->y = ADD_INT32( u1->y, FT_MulFix( s, SUB_INT32( u2->y, u1->y ) ) ); /* * Special case snapping for horizontal and vertical lines. * This cleans up intersections and reduces problems with winding * order detection. * Sample case is sbc cd KozGoPr6N-Medium.otf 20 16685. * Note: these calculations are in character space. * */ if ( u1->x == u2->x && cf2_fixedAbs( SUB_INT32( intersection->x, u1->x ) ) < glyphpath->snapThreshold ) intersection->x = u1->x; if ( u1->y == u2->y && cf2_fixedAbs( SUB_INT32( intersection->y, u1->y ) ) < glyphpath->snapThreshold ) intersection->y = u1->y; if ( v1->x == v2->x && cf2_fixedAbs( SUB_INT32( intersection->x, v1->x ) ) < glyphpath->snapThreshold ) intersection->x = v1->x; if ( v1->y == v2->y && cf2_fixedAbs( SUB_INT32( intersection->y, v1->y ) ) < glyphpath->snapThreshold ) intersection->y = v1->y; /* limit the intersection distance from midpoint of u2 and v1 */ if ( cf2_fixedAbs( intersection->x - ADD_INT32( u2->x, v1->x ) / 2 ) > glyphpath->miterLimit || cf2_fixedAbs( intersection->y - ADD_INT32( u2->y, v1->y ) / 2 ) > glyphpath->miterLimit ) return FALSE; return TRUE; } /* * Push the cached element (glyphpath->prevElem*) to the outline * consumer. When a darkening offset is used, the end point of the * cached element may be adjusted to an intersection point or we may * synthesize a connecting line to the current element. If we are * closing a subpath, we may also generate a connecting line to the start * point. * * This is where Character Space (CS) is converted to Device Space (DS) * using a hint map. This calculation must use a HintMap that was valid * at the time the element was saved. For the first point in a subpath, * that is a saved HintMap. For most elements, it just means the caller * has delayed building a HintMap from the current HintMask. * * Transform each point with outerTransform and call the outline * callbacks. This is a general 3x3 transform: * * x' = a*x + c*y + tx, y' = b*x + d*y + ty * * but it uses 4 elements from CF2_Font and the translation part * from CF2_GlyphPath. * */ static void cf2_glyphpath_pushPrevElem( CF2_GlyphPath glyphpath, CF2_HintMap hintmap, FT_Vector* nextP0, FT_Vector nextP1, FT_Bool close ) { CF2_CallbackParamsRec params; FT_Vector* prevP0; FT_Vector* prevP1; FT_Vector intersection = { 0, 0 }; FT_Bool useIntersection = FALSE; FT_ASSERT( glyphpath->prevElemOp == CF2_PathOpLineTo || glyphpath->prevElemOp == CF2_PathOpCubeTo ); if ( glyphpath->prevElemOp == CF2_PathOpLineTo ) { prevP0 = &glyphpath->prevElemP0; prevP1 = &glyphpath->prevElemP1; } else { prevP0 = &glyphpath->prevElemP2; prevP1 = &glyphpath->prevElemP3; } /* optimization: if previous and next elements are offset by the same */ /* amount, then there will be no gap, and no need to compute an */ /* intersection. */ if ( prevP1->x != nextP0->x || prevP1->y != nextP0->y ) { /* previous element does not join next element: */ /* adjust end point of previous element to the intersection */ useIntersection = cf2_glyphpath_computeIntersection( glyphpath, prevP0, prevP1, nextP0, &nextP1, &intersection ); if ( useIntersection ) { /* modify the last point of the cached element (either line or */ /* curve) */ *prevP1 = intersection; } } params.pt0 = glyphpath->currentDS; switch( glyphpath->prevElemOp ) { case CF2_PathOpLineTo: params.op = CF2_PathOpLineTo; /* note: pt2 and pt3 are unused */ if ( close ) { /* use first hint map if closing */ cf2_glyphpath_hintPoint( glyphpath, &glyphpath->firstHintMap, &params.pt1, glyphpath->prevElemP1.x, glyphpath->prevElemP1.y ); } else { cf2_glyphpath_hintPoint( glyphpath, hintmap, &params.pt1, glyphpath->prevElemP1.x, glyphpath->prevElemP1.y ); } /* output only non-zero length lines */ if ( params.pt0.x != params.pt1.x || params.pt0.y != params.pt1.y ) { glyphpath->callbacks->lineTo( glyphpath->callbacks, &params ); glyphpath->currentDS = params.pt1; } break; case CF2_PathOpCubeTo: params.op = CF2_PathOpCubeTo; /* TODO: should we intersect the interior joins (p1-p2 and p2-p3)? */ cf2_glyphpath_hintPoint( glyphpath, hintmap, &params.pt1, glyphpath->prevElemP1.x, glyphpath->prevElemP1.y ); cf2_glyphpath_hintPoint( glyphpath, hintmap, &params.pt2, glyphpath->prevElemP2.x, glyphpath->prevElemP2.y ); cf2_glyphpath_hintPoint( glyphpath, hintmap, &params.pt3, glyphpath->prevElemP3.x, glyphpath->prevElemP3.y ); glyphpath->callbacks->cubeTo( glyphpath->callbacks, &params ); glyphpath->currentDS = params.pt3; break; } if ( !useIntersection || close ) { /* insert connecting line between end of previous element and start */ /* of current one */ /* note: at the end of a subpath, we might do both, so use `nextP0' */ /* before we change it, below */ if ( close ) { /* if we are closing the subpath, then nextP0 is in the first */ /* hint zone */ cf2_glyphpath_hintPoint( glyphpath, &glyphpath->firstHintMap, &params.pt1, nextP0->x, nextP0->y ); } else { cf2_glyphpath_hintPoint( glyphpath, hintmap, &params.pt1, nextP0->x, nextP0->y ); } if ( params.pt1.x != glyphpath->currentDS.x || params.pt1.y != glyphpath->currentDS.y ) { /* length is nonzero */ params.op = CF2_PathOpLineTo; params.pt0 = glyphpath->currentDS; /* note: pt2 and pt3 are unused */ glyphpath->callbacks->lineTo( glyphpath->callbacks, &params ); glyphpath->currentDS = params.pt1; } } if ( useIntersection ) { /* return intersection point to caller */ *nextP0 = intersection; } } /* push a MoveTo element based on current point and offset of current */ /* element */ static void cf2_glyphpath_pushMove( CF2_GlyphPath glyphpath, FT_Vector start ) { CF2_CallbackParamsRec params; params.op = CF2_PathOpMoveTo; params.pt0 = glyphpath->currentDS; /* Test if move has really happened yet; it would have called */ /* `cf2_hintmap_build' to set `isValid'. */ if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) ) { /* we are here iff first subpath is missing a moveto operator: */ /* synthesize first moveTo to finish initialization of hintMap */ cf2_glyphpath_moveTo( glyphpath, glyphpath->start.x, glyphpath->start.y ); } cf2_glyphpath_hintPoint( glyphpath, &glyphpath->hintMap, &params.pt1, start.x, start.y ); /* note: pt2 and pt3 are unused */ glyphpath->callbacks->moveTo( glyphpath->callbacks, &params ); glyphpath->currentDS = params.pt1; glyphpath->offsetStart0 = start; } /* * All coordinates are in character space. * On input, (x1, y1) and (x2, y2) give line segment. * On output, (x, y) give offset vector. * We use a piecewise approximation to trig functions. * * TODO: Offset true perpendicular and proper length * supply the y-translation for hinting here, too, * that adds yOffset unconditionally to *y. */ static void cf2_glyphpath_computeOffset( CF2_GlyphPath glyphpath, CF2_Fixed x1, CF2_Fixed y1, CF2_Fixed x2, CF2_Fixed y2, CF2_Fixed* x, CF2_Fixed* y ) { CF2_Fixed dx = SUB_INT32( x2, x1 ); CF2_Fixed dy = SUB_INT32( y2, y1 ); /* note: negative offsets don't work here; negate deltas to change */ /* quadrants, below */ if ( glyphpath->font->reverseWinding ) { dx = NEG_INT32( dx ); dy = NEG_INT32( dy ); } *x = *y = 0; if ( !glyphpath->darken ) return; /* add momentum for this path element */ glyphpath->callbacks->windingMomentum = ADD_INT32( glyphpath->callbacks->windingMomentum, cf2_getWindingMomentum( x1, y1, x2, y2 ) ); /* note: allow mixed integer and fixed multiplication here */ if ( dx >= 0 ) { if ( dy >= 0 ) { /* first quadrant, +x +y */ if ( dx > MUL_INT32( 2, dy ) ) { /* +x */ *x = 0; *y = 0; } else if ( dy > MUL_INT32( 2, dx ) ) { /* +y */ *x = glyphpath->xOffset; *y = glyphpath->yOffset; } else { /* +x +y */ *x = FT_MulFix( cf2_doubleToFixed( 0.7 ), glyphpath->xOffset ); *y = FT_MulFix( cf2_doubleToFixed( 1.0 - 0.7 ), glyphpath->yOffset ); } } else { /* fourth quadrant, +x -y */ if ( dx > MUL_INT32( -2, dy ) ) { /* +x */ *x = 0; *y = 0; } else if ( NEG_INT32( dy ) > MUL_INT32( 2, dx ) ) { /* -y */ *x = NEG_INT32( glyphpath->xOffset ); *y = glyphpath->yOffset; } else { /* +x -y */ *x = FT_MulFix( cf2_doubleToFixed( -0.7 ), glyphpath->xOffset ); *y = FT_MulFix( cf2_doubleToFixed( 1.0 - 0.7 ), glyphpath->yOffset ); } } } else { if ( dy >= 0 ) { /* second quadrant, -x +y */ if ( NEG_INT32( dx ) > MUL_INT32( 2, dy ) ) { /* -x */ *x = 0; *y = MUL_INT32( 2, glyphpath->yOffset ); } else if ( dy > MUL_INT32( -2, dx ) ) { /* +y */ *x = glyphpath->xOffset; *y = glyphpath->yOffset; } else { /* -x +y */ *x = FT_MulFix( cf2_doubleToFixed( 0.7 ), glyphpath->xOffset ); *y = FT_MulFix( cf2_doubleToFixed( 1.0 + 0.7 ), glyphpath->yOffset ); } } else { /* third quadrant, -x -y */ if ( NEG_INT32( dx ) > MUL_INT32( -2, dy ) ) { /* -x */ *x = 0; *y = MUL_INT32( 2, glyphpath->yOffset ); } else if ( NEG_INT32( dy ) > MUL_INT32( -2, dx ) ) { /* -y */ *x = NEG_INT32( glyphpath->xOffset ); *y = glyphpath->yOffset; } else { /* -x -y */ *x = FT_MulFix( cf2_doubleToFixed( -0.7 ), glyphpath->xOffset ); *y = FT_MulFix( cf2_doubleToFixed( 1.0 + 0.7 ), glyphpath->yOffset ); } } } } /* * The functions cf2_glyphpath_{moveTo,lineTo,curveTo,closeOpenPath} are * called by the interpreter with Character Space (CS) coordinates. Each * path element is placed into a queue of length one to await the * calculation of the following element. At that time, the darkening * offset of the following element is known and joins can be computed, * including possible modification of this element, before mapping to * Device Space (DS) and passing it on to the outline consumer. * */ FT_LOCAL_DEF( void ) cf2_glyphpath_moveTo( CF2_GlyphPath glyphpath, CF2_Fixed x, CF2_Fixed y ) { cf2_glyphpath_closeOpenPath( glyphpath ); /* save the parameters of the move for later, when we'll know how to */ /* offset it; */ /* also save last move point */ glyphpath->currentCS.x = glyphpath->start.x = x; glyphpath->currentCS.y = glyphpath->start.y = y; glyphpath->moveIsPending = TRUE; /* ensure we have a valid map with current mask */ if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) || cf2_hintmask_isNew( glyphpath->hintMask ) ) cf2_hintmap_build( &glyphpath->hintMap, glyphpath->hStemHintArray, glyphpath->vStemHintArray, glyphpath->hintMask, glyphpath->hintOriginY, FALSE ); /* save a copy of current HintMap to use when drawing initial point */ glyphpath->firstHintMap = glyphpath->hintMap; /* structure copy */ } FT_LOCAL_DEF( void ) cf2_glyphpath_lineTo( CF2_GlyphPath glyphpath, CF2_Fixed x, CF2_Fixed y ) { CF2_Fixed xOffset, yOffset; FT_Vector P0, P1; FT_Bool newHintMap; /* * New hints will be applied after cf2_glyphpath_pushPrevElem has run. * In case this is a synthesized closing line, any new hints should be * delayed until this path is closed (`cf2_hintmask_isNew' will be * called again before the next line or curve). */ /* true if new hint map not on close */ newHintMap = cf2_hintmask_isNew( glyphpath->hintMask ) && !glyphpath->pathIsClosing; /* * Zero-length lines may occur in the charstring. Because we cannot * compute darkening offsets or intersections from zero-length lines, * it is best to remove them and avoid artifacts. However, zero-length * lines in CS at the start of a new hint map can generate non-zero * lines in DS due to hint substitution. We detect a change in hint * map here and pass those zero-length lines along. */ /* * Note: Find explicitly closed paths here with a conditional * breakpoint using * * !gp->pathIsClosing && gp->start.x == x && gp->start.y == y * */ if ( glyphpath->currentCS.x == x && glyphpath->currentCS.y == y && !newHintMap ) /* * Ignore zero-length lines in CS where the hint map is the same * because the line in DS will also be zero length. * * Ignore zero-length lines when we synthesize a closing line because * the close will be handled in cf2_glyphPath_pushPrevElem. */ return; cf2_glyphpath_computeOffset( glyphpath, glyphpath->currentCS.x, glyphpath->currentCS.y, x, y, &xOffset, &yOffset ); /* construct offset points */ P0.x = ADD_INT32( glyphpath->currentCS.x, xOffset ); P0.y = ADD_INT32( glyphpath->currentCS.y, yOffset ); P1.x = ADD_INT32( x, xOffset ); P1.y = ADD_INT32( y, yOffset ); if ( glyphpath->moveIsPending ) { /* emit offset 1st point as MoveTo */ cf2_glyphpath_pushMove( glyphpath, P0 ); glyphpath->moveIsPending = FALSE; /* adjust state machine */ glyphpath->pathIsOpen = TRUE; glyphpath->offsetStart1 = P1; /* record second point */ } if ( glyphpath->elemIsQueued ) { FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) || glyphpath->hintMap.count == 0 ); cf2_glyphpath_pushPrevElem( glyphpath, &glyphpath->hintMap, &P0, P1, FALSE ); } /* queue the current element with offset points */ glyphpath->elemIsQueued = TRUE; glyphpath->prevElemOp = CF2_PathOpLineTo; glyphpath->prevElemP0 = P0; glyphpath->prevElemP1 = P1; /* update current map */ if ( newHintMap ) cf2_hintmap_build( &glyphpath->hintMap, glyphpath->hStemHintArray, glyphpath->vStemHintArray, glyphpath->hintMask, glyphpath->hintOriginY, FALSE ); glyphpath->currentCS.x = x; /* pre-offset current point */ glyphpath->currentCS.y = y; } FT_LOCAL_DEF( void ) cf2_glyphpath_curveTo( CF2_GlyphPath glyphpath, CF2_Fixed x1, CF2_Fixed y1, CF2_Fixed x2, CF2_Fixed y2, CF2_Fixed x3, CF2_Fixed y3 ) { CF2_Fixed xOffset1, yOffset1, xOffset3, yOffset3; FT_Vector P0, P1, P2, P3; /* TODO: ignore zero length portions of curve?? */ cf2_glyphpath_computeOffset( glyphpath, glyphpath->currentCS.x, glyphpath->currentCS.y, x1, y1, &xOffset1, &yOffset1 ); cf2_glyphpath_computeOffset( glyphpath, x2, y2, x3, y3, &xOffset3, &yOffset3 ); /* add momentum from the middle segment */ glyphpath->callbacks->windingMomentum = ADD_INT32( glyphpath->callbacks->windingMomentum, cf2_getWindingMomentum( x1, y1, x2, y2 ) ); /* construct offset points */ P0.x = ADD_INT32( glyphpath->currentCS.x, xOffset1 ); P0.y = ADD_INT32( glyphpath->currentCS.y, yOffset1 ); P1.x = ADD_INT32( x1, xOffset1 ); P1.y = ADD_INT32( y1, yOffset1 ); /* note: preserve angle of final segment by using offset3 at both ends */ P2.x = ADD_INT32( x2, xOffset3 ); P2.y = ADD_INT32( y2, yOffset3 ); P3.x = ADD_INT32( x3, xOffset3 ); P3.y = ADD_INT32( y3, yOffset3 ); if ( glyphpath->moveIsPending ) { /* emit offset 1st point as MoveTo */ cf2_glyphpath_pushMove( glyphpath, P0 ); glyphpath->moveIsPending = FALSE; glyphpath->pathIsOpen = TRUE; glyphpath->offsetStart1 = P1; /* record second point */ } if ( glyphpath->elemIsQueued ) { FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) || glyphpath->hintMap.count == 0 ); cf2_glyphpath_pushPrevElem( glyphpath, &glyphpath->hintMap, &P0, P1, FALSE ); } /* queue the current element with offset points */ glyphpath->elemIsQueued = TRUE; glyphpath->prevElemOp = CF2_PathOpCubeTo; glyphpath->prevElemP0 = P0; glyphpath->prevElemP1 = P1; glyphpath->prevElemP2 = P2; glyphpath->prevElemP3 = P3; /* update current map */ if ( cf2_hintmask_isNew( glyphpath->hintMask ) ) cf2_hintmap_build( &glyphpath->hintMap, glyphpath->hStemHintArray, glyphpath->vStemHintArray, glyphpath->hintMask, glyphpath->hintOriginY, FALSE ); glyphpath->currentCS.x = x3; /* pre-offset current point */ glyphpath->currentCS.y = y3; } FT_LOCAL_DEF( void ) cf2_glyphpath_closeOpenPath( CF2_GlyphPath glyphpath ) { if ( glyphpath->pathIsOpen ) { /* * A closing line in Character Space line is always generated below * with `cf2_glyphPath_lineTo'. It may be ignored later if it turns * out to be zero length in Device Space. */ glyphpath->pathIsClosing = TRUE; cf2_glyphpath_lineTo( glyphpath, glyphpath->start.x, glyphpath->start.y ); /* empty the final element from the queue and close the path */ if ( glyphpath->elemIsQueued ) cf2_glyphpath_pushPrevElem( glyphpath, &glyphpath->hintMap, &glyphpath->offsetStart0, glyphpath->offsetStart1, TRUE ); /* reset state machine */ glyphpath->moveIsPending = TRUE; glyphpath->pathIsOpen = FALSE; glyphpath->pathIsClosing = FALSE; glyphpath->elemIsQueued = FALSE; } } /* END */
1054beb692a312ba4d77a452f330a5aa07deda40
aa3befea459382dc5c01c925653d54f435b3fb0f
/libs/libc/locale/lib_catalog.c
0dbb1a099e0ba49e8281534229f552c180b5d062
[ "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
10,730
c
lib_catalog.c
/**************************************************************************** * libs/libc/locale/lib_catalog.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 <endian.h> #include <errno.h> #include <fcntl.h> #include <nl_types.h> #include <stdlib.h> #include <string.h> #include <sys/mman.h> #include <sys/stat.h> #include <unistd.h> #ifdef CONFIG_LIBC_LOCALE_CATALOG /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ #define CAT_MAGIC 0xff88ff89 /**************************************************************************** * Private Type Definitions ****************************************************************************/ begin_packed_struct struct cathdr_s { uint32_t magic; uint32_t nsets; uint32_t size; uint32_t msg_offset; uint32_t txt_offset; } end_packed_struct; begin_packed_struct struct catset_s { uint32_t setno; uint32_t nmsgs; uint32_t index; } end_packed_struct; begin_packed_struct struct catmsg_s { uint32_t msgno; uint32_t msglen; uint32_t offset; } end_packed_struct; /**************************************************************************** * Private Functions ****************************************************************************/ static nl_catd catmap(FAR const char *path) { FAR const struct cathdr_s *hdr; nl_catd catd = MAP_FAILED; struct stat st; int fd; fd = open(path, O_RDONLY | O_CLOEXEC); if (fd < 0) { return catd; } if (fstat(fd, &st) >= 0) { catd = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); if (catd != MAP_FAILED) { hdr = (FAR const struct cathdr_s *)catd; if (CAT_MAGIC != be32toh(hdr->magic) || st.st_size != sizeof(*hdr) + be32toh(hdr->size)) { munmap(catd, st.st_size); catd = MAP_FAILED; set_errno(ENOENT); } } } close(fd); return catd; } static int setcmp(FAR const void *a, FAR const void *b) { FAR const int *set_id = a; FAR const struct catset_s *set = b; return *set_id - be32toh(set->setno); } static int msgcmp(FAR const void *a, FAR const void *b) { FAR const int *msg_id = a; FAR const struct catmsg_s *msg = b; return *msg_id - be32toh(msg->msgno); } /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: catopen * * Description: * The catopen() function shall open a message catalog and return a * message catalog descriptor. The name argument specifies the name of * the message catalog to be opened. If name contains a '/', then name * specifies a pathname for the message catalog. Otherwise, the environment * variable NLSPATH is used with name substituted for the %N conversion * specification (see XBD Environment Variables); if NLSPATH exists in the * environment when the process starts, then if the process has appropriate * privileges, the behavior of catopen() is undefined. If NLSPATH does not * exist in the environment, or if a message catalog cannot be found in any * of the components specified by NLSPATH, then an implementation-defined * default path shall be used. This default may be affected by the setting * of LC_MESSAGES if the value of oflag is NL_CAT_LOCALE, or the LANG * environment variable if oflag is 0. * * A message catalog descriptor shall remain valid in a process until that * process closes it, or a successful call to one of the exec functions. * A change in the setting of the LC_MESSAGES category may invalidate * existing open catalogs. * * If a file descriptor is used to implement message catalog descriptors, * the FD_CLOEXEC flag shall be set; see <fcntl.h>. * * If the value of the oflag argument is 0, the LANG environment variable * is used to locate the catalog without regard to the LC_MESSAGES * category. If the oflag argument is NL_CAT_LOCALE, the LC_MESSAGES * category is used to locate the message catalog (see XBD * Internationalization Variables ). * * Returned Value: * Upon successful completion, catopen() shall return a message catalog * descriptor for use on subsequent calls to catgets() and catclose(). * Otherwise, catopen() shall return (nl_catd) -1 and set errno to * indicate the error. * ****************************************************************************/ nl_catd catopen(FAR const char *name, int oflag) { FAR const char *path; FAR const char *lang; FAR const char *p; FAR const char *z; if (strchr(name, '/')) { return catmap(name); } path = getenv("NLSPATH"); if (path == NULL) { path = CONFIG_LIBC_LOCALE_PATH; } lang = oflag ? NULL : getenv("LANG"); if (lang == NULL) { lang = ""; } for (p = path; *p; p = z) { char buf[PATH_MAX]; nl_catd catd; size_t i; z = strchr(p, ':'); if (z == NULL) { z = p + strlen(p); } for (i = 0; p < z; p++) { FAR const char *v; size_t l; if (*p == '%') { switch (*++p) { case 'N': v = name; l = strlen(v); break; case 'L': v = lang; l = strlen(v); break; case 'l': v = lang; l = strcspn(v, "_.@"); break; case 't': v = strchr(lang, '_'); if (v == NULL) { v = "\0"; } l = strcspn(++v, ".@"); break; case 'c': v = "UTF-8"; l = 5; break; case '%': v = "%"; l = 1; break; default: v = NULL; } } else { v = p; l = 1; } if (v == NULL || i + l >= sizeof(buf)) { break; } memcpy(buf + i, v, l); i += l; } if (*z) { z++; } if (*p != ':' && *p != '\0') { continue; } /* Leading : or :: in NLSPATH is same as %N */ buf[i] = 0; catd = catmap(i ? buf : name); if (catd != MAP_FAILED) { return catd; } } set_errno(ENOENT); return MAP_FAILED; } /**************************************************************************** * Name: catgets * * Description: * The catgets() function shall attempt to read message msg_id, in set * set_id, from the message catalog identified by catd. The catd argument * is a message catalog descriptor returned from an earlier call to * catopen(). The results are undefined if catd is not a value returned * by catopen() for a message catalog still open in the process. The s * argument points to a default message string which shall be returned by * catgets() if it cannot retrieve the identified message. * * The catgets() function need not be thread-safe. * * Returned Value: * If the identified message is retrieved successfully, catgets() shall * return a pointer to an internal buffer area containing the null- * terminated message string. If the call is unsuccessful for any reason, * s shall be returned and errno shall be set to indicate the error. * ****************************************************************************/ FAR char *catgets(nl_catd catd, int set_id, int msg_id, FAR const char *s) { FAR const struct cathdr_s *hdr = (FAR const struct cathdr_s *)catd; FAR const struct catset_s *set = (FAR const struct catset_s *)(hdr + 1); FAR const struct catmsg_s *msg = (FAR const struct catmsg_s *) ((FAR const char *)(hdr + 1) + be32toh(hdr->msg_offset)); FAR const char *string = ((FAR const char *)(hdr + 1) + be32toh(hdr->txt_offset)); set = bsearch(&set_id, set, be32toh(hdr->nsets), sizeof(*set), setcmp); if (set == NULL) { set_errno(ENOMSG); return (FAR char *)s; } msg += be32toh(set->index); msg = bsearch(&msg_id, msg, be32toh(set->nmsgs), sizeof(*msg), msgcmp); if (msg == NULL) { set_errno(ENOMSG); return (FAR char *)s; } return (FAR char *)(string + be32toh(msg->offset)); } /**************************************************************************** * Name: catclose * * Description: * The catclose() function shall close the message catalog identified by * catd. If a file descriptor is used to implement the type nl_catd, that * file descriptor shall be closed. * * Returned Value: * Upon successful completion, catclose() shall return 0; otherwise, * -1 shall be returned, and errno set to indicate the error. * ****************************************************************************/ int catclose(nl_catd catd) { FAR const struct cathdr_s *hdr = (FAR const struct cathdr_s *)catd; return munmap(catd, sizeof(*hdr) + be32toh(hdr->size)); } #endif
227a751063f7202e2d20967a4c7a20d795e23ba1
4692f28f86ee84a76abfac8cc8a0dd41fcd402e4
/pkg/security/ebpf/c/include/tests/discarders_test.h
abae3e90cc1ebb90d01ee0bb47f8f7d8ceb5c06a
[ "GPL-2.0-only", "CC0-1.0", "BSD-3-Clause", "Apache-2.0", "GPL-1.0-or-later", "MIT", "0BSD", "Unlicense", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "BSD-2-Clause-Views", "MPL-2.0" ]
permissive
DataDog/datadog-agent
cc4b89839d6031903bf23aa12eccc2a3f3c7f213
d960cdb7de8fa5d1c7138cfe58e754af80cb796a
refs/heads/main
2023-09-04T10:45:08.138748
2023-09-04T09:13:43
2023-09-04T09:13:43
49,970,739
2,388
1,288
Apache-2.0
2023-09-14T20:06:34
2016-01-19T17:40:41
Go
UTF-8
C
false
false
6,381
h
discarders_test.h
#ifndef _DISCARDERS_TEST_H #define _DISCARDERS_TEST_H #include "helpers/discarders.h" #include "baloum.h" int __attribute__((always_inline)) _is_discarded_by_inode(u64 event_type, u32 mount_id, u64 inode) { struct is_discarded_by_inode_t params = { .discarder_type = event_type, .discarder = { .path_key.ino = inode, .path_key.mount_id = mount_id, } }; return is_discarded_by_inode(&params); } SEC("test/discarders_event_mask") int test_discarders_event_mask() { u32 mount_id = 123; u64 inode = 456; int ret = discard_inode(EVENT_OPEN, mount_id, inode, 0, 0); assert_zero(ret, "failed to discard the inode"); struct inode_discarder_params_t *inode_params = get_inode_discarder_params(mount_id, inode, 0); assert_not_null(inode_params, "unable to find the inode discarder entry"); ret = mask_has_event(inode_params->params.event_mask, EVENT_OPEN); assert_not_zero(ret, "event not found in mask"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id, inode); assert_not_zero(ret, "inode should be discarded"); // add another event type ret = discard_inode(EVENT_CHMOD, mount_id, inode, 0, 0); assert_zero(ret, "failed to discard the inode"); // check that we have now both open and chmod event discarded inode_params = get_inode_discarder_params(mount_id, inode, 0); assert_not_null(inode_params, "unable to find the inode discarder entry"); ret = mask_has_event(inode_params->params.event_mask, EVENT_OPEN); assert_not_zero(ret, "event not found in mask"); ret = mask_has_event(inode_params->params.event_mask, EVENT_CHMOD); assert_not_zero(ret, "event not found in mask"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id, inode); assert_not_zero(ret, "inode should be discarded"); ret = _is_discarded_by_inode(EVENT_CHMOD, mount_id, inode); assert_not_zero(ret, "inode should be discarded"); return 0; } SEC("test/discarders_retention") int test_discarders_retention() { u32 mount_id = 123; u64 inode = 456; int ret = discard_inode(EVENT_OPEN, mount_id, inode, 0, 0); assert_zero(ret, "failed to discard the inode"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id, inode); assert_not_zero(ret, "inode should be discarded"); // expire the discarder expire_inode_discarders(mount_id, inode); // shouldn't be discarded anymore ret = _is_discarded_by_inode(EVENT_OPEN, mount_id, inode); assert_zero(ret, "inode shouldn't be discarded"); // we shouldn't be able to add a new discarder for the same inode during the retention period // TODO(safchain) should return an error value ret = discard_inode(EVENT_OPEN, mount_id, inode, 0, 0); assert_zero(ret, "able to discard the inode"); // shouldn't still be discarded ret = _is_discarded_by_inode(EVENT_CHMOD, mount_id, inode); assert_zero(ret, "inode shouldn't be discarded"); // wait the retention period baloum_sleep(get_discarder_retention() + 1); // the retention period is now over, we should be able to add a discarder ret = discard_inode(EVENT_OPEN, mount_id, inode, 0, 0); assert_zero(ret, "failed to discard the inode"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id, inode); assert_not_zero(ret, "inode should be discarded"); return 0; } SEC("test/discarders_revision") int test_discarders_revision() { u32 mount_id1 = 123; u64 inode1 = 456; u32 mount_id2 = 456; u64 inode2 = 789; int ret = discard_inode(EVENT_OPEN, mount_id1, inode1, 0, 0); assert_zero(ret, "failed to discard the inode"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id1, inode1); assert_not_zero(ret, "inode should be discarded"); ret = discard_inode(EVENT_OPEN, mount_id2, inode2, 0, 0); assert_zero(ret, "failed to discard the inode"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id2, inode2); assert_not_zero(ret, "inode should be discarded"); // expire the discarders bump_discarders_revision(); // now all the discarders whatever their mount id should be discarded ret = _is_discarded_by_inode(EVENT_OPEN, mount_id1, inode1); assert_zero(ret, "inode shouldn't be discarded"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id2, inode2); assert_zero(ret, "inode shouldn't be discarded"); // check that we added a retention period ret = discard_inode(EVENT_OPEN, mount_id1, inode1, 0, 0); assert_zero(ret, "able to discard the inode"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id1, inode1); assert_zero(ret, "inode shouldn't be discarded"); // wait the retention period baloum_sleep(get_discarder_retention() + 1); ret = discard_inode(EVENT_OPEN, mount_id1, inode1, 0, 0); assert_zero(ret, "able to discard the inode"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id1, inode1); assert_not_zero(ret, "inode should be discarded"); return 0; } SEC("test/discarders_mount_revision") int test_discarders_mount_revision() { u32 mount_id1 = 123; u64 inode1 = 456; u32 mount_id2 = 456; u64 inode2 = 789; int ret = discard_inode(EVENT_OPEN, mount_id1, inode1, 0, 0); assert_zero(ret, "failed to discard the inode"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id1, inode1); assert_not_zero(ret, "inode should be discarded"); ret = discard_inode(EVENT_OPEN, mount_id2, inode2, 0, 0); assert_zero(ret, "failed to discard the inode"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id2, inode2); assert_not_zero(ret, "inode should be discarded"); // bump the revision bump_mount_discarder_revision(mount_id1); // now the inode1 shouldn't be discarded anymore ret = _is_discarded_by_inode(EVENT_OPEN, mount_id1, inode1); assert_zero(ret, "inode shouldn't be discarded"); // while node2 should still be ret = _is_discarded_by_inode(EVENT_OPEN, mount_id2, inode2); assert_not_zero(ret, "inode should be discarded"); // we are allowed to re-add inode1 right away ret = discard_inode(EVENT_OPEN, mount_id1, inode1, 0, 0); assert_zero(ret, "failed to discard the inode"); ret = _is_discarded_by_inode(EVENT_OPEN, mount_id1, inode1); assert_not_zero(ret, "inode should be discarded"); return 0; } #endif
b0f822ec7e00fea8c3ec72e109244907a6d4a0a1
540c04254075b9fb22685a73487531f4c0b3e3ac
/lib-h3/src/h3_gpio_int_cfg.c
3c180a031d55477bb8e6e212823a552e0448fd0b
[ "MIT" ]
permissive
vanvught/rpidmx512
197573217fc2c0c3673d6727d199c10e528a9fac
f27ae141d14c1d1cb9e0b62a291356ae0780c99f
refs/heads/master
2023-08-08T02:06:52.200184
2023-05-19T12:44:48
2023-05-19T12:44:48
15,496,962
380
125
MIT
2023-05-19T12:47:24
2013-12-28T18:27:20
C++
UTF-8
C
false
false
2,077
c
h3_gpio_int_cfg.c
/** * @file h3_gpio_int_cfg.c * */ /* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl * * 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 <stdint.h> #ifndef NDEBUG #include <stdio.h> #endif #include "h3_gpio.h" #include "h3.h" void h3_gpio_int_cfg(uint32_t gpio, gpio_int_cfg_t int_cfg) { const uint32_t number = H3_GPIO_TO_NUMBER(gpio); const uint32_t shift = (number & 0x7) * 4; uint32_t value; switch (H3_GPIO_TO_PORT(gpio)) { case H3_GPIO_PORTA: value = H3_PIO_PA_INT->CFG0; value &= ~((uint32_t) GPIO_INT_CFG_MASK << shift); value |= ((uint32_t) int_cfg << shift); H3_PIO_PA_INT->CFG0 = value; break; case H3_GPIO_PORTG: value = H3_PIO_PG_INT->CFG0; value &= ~((uint32_t) GPIO_INT_CFG_MASK << shift); value |= ((uint32_t) int_cfg << shift); H3_PIO_PG_INT->CFG0 = value; break; default: break; } #ifndef NDEBUG printf("%s gpio=%d, int_cfg=%d : port=%d[%c], number=%d, shift=%d\n", __func__, gpio, int_cfg, H3_GPIO_TO_PORT(gpio), 'A' + H3_GPIO_TO_PORT(gpio), number, shift); #endif }
e44f8d0c7b5f786b6081bb2ff3bc440d58f8a835
50e95229b9a1161ac294137120aaba94c9eb06bc
/sources/ippcp/crypto_mb/src/rsa/ifma_rsa_ssl_prv5_layer_mb8.c
4e7db9ad66880feab120a776e49e5314056c97cc
[ "Apache-2.0", "Intel" ]
permissive
intel/ipp-crypto
f0f05b87203705e82603db67bed5f8def13a5ee8
36e76e2388f3dd10cc440e213dfcf6ef59a0dfb8
refs/heads/develop
2023-09-04T08:15:06.851373
2023-07-27T12:47:12
2023-07-27T12:47:12
140,034,345
304
81
Apache-2.0
2023-08-30T17:18:36
2018-07-06T22:16:28
C
UTF-8
C
false
false
19,095
c
ifma_rsa_ssl_prv5_layer_mb8.c
typedef int to_avoid_translation_unit_is_empty_warning; #ifndef BN_OPENSSL_DISABLE /******************************************************************************* * Copyright (C) 2019 Intel Corporation * * 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 <openssl/bn.h> #include <internal/common/ifma_defs.h> #include <internal/common/ifma_cvt52.h> #include <internal/rsa/ifma_rsa_arith.h> #define EXP_WIN_SIZE (5) //(4) #define EXP_WIN_MASK ((1<<EXP_WIN_SIZE) -1) /* // y = x^d mod n (crt) */ void ifma_ssl_rsa1K_prv5_layer_mb8(const int8u* const from_pa[8], int8u* const to_pa[8], const BIGNUM* const p_pa[8], const BIGNUM* const q_pa[8], const BIGNUM* const dp_pa[8], const BIGNUM* const dq_pa[8], const BIGNUM* const iq_pa[8]) { #define RSA_BITLEN (RSA_1K) #define FACTOR_BITLEN (RSA_BITLEN/2) #define LEN52 (NUMBER_OF_DIGITS(FACTOR_BITLEN, DIGIT_SIZE)) #define LEN64 (NUMBER_OF_DIGITS(FACTOR_BITLEN, 64)) /* allocate mb8 buffers */ __ALIGN64 int64u k0_mb8[8]; __ALIGN64 int64u p_mb8[LEN52][8]; __ALIGN64 int64u q_mb8[LEN52][8]; __ALIGN64 int64u d_mb8[LEN64][8]; __ALIGN64 int64u rr_mb8[LEN52][8]; __ALIGN64 int64u xp_mb8[LEN52][8]; __ALIGN64 int64u xq_mb8[LEN52][8]; __ALIGN64 int64u inp_mb8[LEN52*2][8]; /* allocate stack for red(undant) result, multiplier, for exponent X and for pre-computed table of base powers */ __ALIGN64 int64u work_buffer[LEN52*2 + 1 + (LEN64 + 1) + (1 << EXP_WIN_SIZE)*LEN52][8]; /* convert input to ifma fmt */ zero_mb8(inp_mb8, LEN52*2); ifma_HexStr8_to_mb8(inp_mb8, from_pa, RSA_BITLEN); /* // q exponentiation */ /* convert modulus to ifma fmt */ ifma_BN_to_mb8(q_mb8, q_pa, FACTOR_BITLEN); /* compute k0[] */ ifma_montFactor52_mb8(k0_mb8, q_mb8[0]); /* compute to_Montgomery domain converters */ ifma_montRR52x_mb8(rr_mb8, q_mb8, FACTOR_BITLEN); /* xq = x mod q */ ifma_amred52x10_mb8(xq_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])q_mb8, k0_mb8); ifma_amm52x10_mb8((int64u*)xq_mb8, (int64u*)xq_mb8, (int64u*)rr_mb8, (int64u*)q_mb8, k0_mb8); ifma_modsub52x10_mb8(xq_mb8, (const int64u(*)[8])xq_mb8, (const int64u(*)[8])q_mb8, (const int64u(*)[8])q_mb8); // ?? /* re-arrange exps to ifma */ ifma_BN_transpose_copy(d_mb8, dq_pa, FACTOR_BITLEN); EXP52x10_mb8(xq_mb8, (const int64u(*)[8])xq_mb8, (const int64u(*)[8])d_mb8, (const int64u(*)[8])q_mb8, (const int64u(*)[8])rr_mb8, k0_mb8, (int64u(*)[8])work_buffer); /* // p exponentiation */ /* convert modulus to ifma fmt */ ifma_BN_to_mb8(p_mb8, p_pa, FACTOR_BITLEN); /* compute k0[] */ ifma_montFactor52_mb8(k0_mb8, p_mb8[0]); /* compute to_Montgomery domain converters */ ifma_montRR52x_mb8(rr_mb8, p_mb8, FACTOR_BITLEN); /* xp = x mod p */ ifma_amred52x10_mb8(xp_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])p_mb8, k0_mb8); ifma_amm52x10_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)rr_mb8, (int64u*)p_mb8, k0_mb8); ifma_modsub52x10_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8); // ?? /* re-arrange exps to ifma */ ifma_BN_transpose_copy(d_mb8, dp_pa, FACTOR_BITLEN); EXP52x10_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])d_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])rr_mb8, k0_mb8, (int64u(*)[8])work_buffer); /* // crt recombination */ /* xp = (xp-xq) mod p */ ifma_modsub52x10_mb8(inp_mb8,(const int64u(*)[8])xq_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8); /* for specific case p<q */ ifma_modsub52x10_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])p_mb8); /* xp = (xp*coef) mod p */ ifma_BN_to_mb8(inp_mb8, iq_pa, FACTOR_BITLEN); /* coef */ ifma_amm52x10_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)rr_mb8, (int64u*)p_mb8, k0_mb8); /* -> mont domain */ ifma_amm52x10_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)inp_mb8, (int64u*)p_mb8, k0_mb8); /* mmul */ ifma_modsub52x10_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8);/* correction */ /* xp = (xp*q + xq) */ zero_mb8(inp_mb8, LEN52*2); copy_mb8(inp_mb8, (const int64u(*)[8])xq_mb8, LEN52); ifma_addmul52x10_mb8(inp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])q_mb8); /* convert result from ifma fmt */ ifma_mb8_to_HexStr8(to_pa, (const int64u(*)[8])inp_mb8, RSA_BITLEN); /* clear exponents, p, q */ zero_mb8(d_mb8, LEN64); zero_mb8(q_mb8, LEN52); zero_mb8(p_mb8, LEN52); #undef RSA_BITLEN #undef FACTOR_BITLEN #undef LEN52 #undef LEN64 } void ifma_ssl_rsa2K_prv5_layer_mb8(const int8u* const from_pa[8], int8u* const to_pa[8], const BIGNUM* const p_pa[8], const BIGNUM* const q_pa[8], const BIGNUM* const dp_pa[8], const BIGNUM* const dq_pa[8], const BIGNUM* const iq_pa[8]) { #define RSA_BITLEN (RSA_2K) #define FACTOR_BITLEN (RSA_BITLEN/2) #define LEN52 (NUMBER_OF_DIGITS(FACTOR_BITLEN, DIGIT_SIZE)) #define LEN64 (NUMBER_OF_DIGITS(FACTOR_BITLEN, 64)) /* allocate mb8 buffers */ __ALIGN64 int64u k0_mb8[8]; __ALIGN64 int64u p_mb8[LEN52][8]; __ALIGN64 int64u q_mb8[LEN52][8]; __ALIGN64 int64u d_mb8[LEN64][8]; __ALIGN64 int64u rr_mb8[LEN52][8]; __ALIGN64 int64u xp_mb8[LEN52][8]; __ALIGN64 int64u xq_mb8[LEN52][8]; __ALIGN64 int64u inp_mb8[LEN52*2][8]; /* allocate stack for red(undant) result, multiplier, for exponent X and for pre-computed table of base powers */ __ALIGN64 int64u work_buffer[LEN52*2 + 1 + (LEN64 + 1) + (1 << EXP_WIN_SIZE)*LEN52][8]; /* convert input to ifma fmt */ zero_mb8(inp_mb8, LEN52*2); ifma_HexStr8_to_mb8(inp_mb8, from_pa, RSA_BITLEN); /* // q exponentiation */ /* convert modulus to ifma fmt */ ifma_BN_to_mb8(q_mb8, q_pa, FACTOR_BITLEN); /* compute k0[] */ ifma_montFactor52_mb8(k0_mb8, q_mb8[0]); /* compute to_Montgomery domain converters */ ifma_montRR52x_mb8(rr_mb8, q_mb8, FACTOR_BITLEN); /* xq = x mod q */ ifma_amred52x20_mb8(xq_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])q_mb8, k0_mb8); ifma_amm52x20_mb8((int64u*)xq_mb8, (int64u*)xq_mb8, (int64u*)rr_mb8, (int64u*)q_mb8, k0_mb8); ifma_modsub52x20_mb8(xq_mb8, (const int64u(*)[8])xq_mb8, (const int64u(*)[8])q_mb8, (const int64u(*)[8])q_mb8); // ?? /* re-arrange exps to ifma */ ifma_BN_transpose_copy(d_mb8, dq_pa, FACTOR_BITLEN); EXP52x20_mb8(xq_mb8, (const int64u(*)[8])xq_mb8, (const int64u(*)[8])d_mb8, (const int64u(*)[8])q_mb8, (const int64u(*)[8])rr_mb8, k0_mb8, (int64u(*)[8])work_buffer); /* // p exponentiation */ /* convert modulus to ifma fmt */ ifma_BN_to_mb8(p_mb8, p_pa, FACTOR_BITLEN); /* compute k0[] */ ifma_montFactor52_mb8(k0_mb8, p_mb8[0]); /* compute to_Montgomery domain converters */ ifma_montRR52x_mb8(rr_mb8, p_mb8, FACTOR_BITLEN); /* xp = x mod p */ ifma_amred52x20_mb8(xp_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])p_mb8, k0_mb8); ifma_amm52x20_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)rr_mb8, (int64u*)p_mb8, k0_mb8); ifma_modsub52x20_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8); // ?? /* re-arrange exps to ifma */ ifma_BN_transpose_copy(d_mb8, dp_pa, FACTOR_BITLEN); EXP52x20_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])d_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])rr_mb8, k0_mb8, (int64u(*)[8])work_buffer); /* // crt recombination */ /* xp = (xp-xq) mod p */ ifma_modsub52x20_mb8(inp_mb8,(const int64u(*)[8])xq_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8); /* for specific case p<q */ ifma_modsub52x20_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])p_mb8); /* xp = (xp*coef) mod p */ ifma_BN_to_mb8(inp_mb8, iq_pa, FACTOR_BITLEN); /* coef */ ifma_amm52x20_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)rr_mb8, (int64u*)p_mb8, k0_mb8); /* -> mont domain */ ifma_amm52x20_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)inp_mb8, (int64u*)p_mb8, k0_mb8); /* mmul */ ifma_modsub52x20_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8);/* correction */ /* xp = (xp*q + xq) */ zero_mb8(inp_mb8, LEN52*2); copy_mb8(inp_mb8, (const int64u(*)[8])xq_mb8, LEN52); ifma_addmul52x20_mb8(inp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])q_mb8); /* convert result from ifma fmt */ ifma_mb8_to_HexStr8(to_pa, (const int64u(*)[8])inp_mb8, RSA_BITLEN); /* clear exponents, p, q */ zero_mb8(d_mb8, LEN64); zero_mb8(q_mb8, LEN52); zero_mb8(p_mb8, LEN52); #undef RSA_BITLEN #undef FACTOR_BITLEN #undef LEN52 #undef LEN64 } void ifma_ssl_rsa3K_prv5_layer_mb8(const int8u* const from_pa[8], int8u* const to_pa[8], const BIGNUM* const p_pa[8], const BIGNUM* const q_pa[8], const BIGNUM* const dp_pa[8], const BIGNUM* const dq_pa[8], const BIGNUM* const iq_pa[8]) { #define RSA_BITLEN (RSA_3K) #define FACTOR_BITLEN (RSA_BITLEN/2) #define LEN52 (NUMBER_OF_DIGITS(FACTOR_BITLEN, DIGIT_SIZE)) #define LEN64 (NUMBER_OF_DIGITS(FACTOR_BITLEN, 64)) /* allocate mb8 buffers */ __ALIGN64 int64u k0_mb8[8]; __ALIGN64 int64u p_mb8[LEN52][8]; __ALIGN64 int64u q_mb8[LEN52][8]; __ALIGN64 int64u d_mb8[LEN64][8]; __ALIGN64 int64u rr_mb8[LEN52][8]; __ALIGN64 int64u xp_mb8[LEN52][8]; __ALIGN64 int64u xq_mb8[LEN52][8]; __ALIGN64 int64u inp_mb8[LEN52 * 2][8]; /* allocate stack for red(undant) result, multiplier, for exponent X and for pre-computed table of base powers */ __ALIGN64 int64u work_buffer[LEN52*2 + 1 + (LEN64 + 1) + (1 << EXP_WIN_SIZE)*LEN52][8]; /* convert input to ifma fmt */ zero_mb8(inp_mb8, LEN52 * 2); ifma_HexStr8_to_mb8(inp_mb8, from_pa, RSA_BITLEN); /* // q exponentiation */ /* convert modulus to ifma fmt */ ifma_BN_to_mb8(q_mb8, q_pa, FACTOR_BITLEN); /* compute k0[] */ ifma_montFactor52_mb8(k0_mb8, q_mb8[0]); /* compute to_Montgomery domain converters */ ifma_montRR52x_mb8(rr_mb8, q_mb8, FACTOR_BITLEN); /* xq = x mod q */ ifma_amred52x30_mb8(xq_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])q_mb8, k0_mb8); ifma_amm52x30_mb8((int64u*)xq_mb8, (int64u*)xq_mb8, (int64u*)rr_mb8, (int64u*)q_mb8, k0_mb8); ifma_modsub52x30_mb8(xq_mb8, (const int64u(*)[8])xq_mb8, (const int64u(*)[8])q_mb8, (const int64u(*)[8])q_mb8); // ?? /* re-arrange exps to ifma */ ifma_BN_transpose_copy(d_mb8, dq_pa, FACTOR_BITLEN); EXP52x30_mb8(xq_mb8, (const int64u(*)[8])xq_mb8, (const int64u(*)[8])d_mb8, (const int64u(*)[8])q_mb8, (const int64u(*)[8])rr_mb8, k0_mb8, (int64u(*)[8])work_buffer); /* // p exponentiation */ /* convert modulus to ifma fmt */ ifma_BN_to_mb8(p_mb8, p_pa, FACTOR_BITLEN); /* compute k0[] */ ifma_montFactor52_mb8(k0_mb8, p_mb8[0]); /* compute to_Montgomery domain converters */ ifma_montRR52x_mb8(rr_mb8, p_mb8, FACTOR_BITLEN); /* xp = x mod p */ ifma_amred52x30_mb8(xp_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])p_mb8, k0_mb8); ifma_amm52x30_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)rr_mb8, (int64u*)p_mb8, k0_mb8); ifma_modsub52x30_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8); // ?? /* re-arrange exps to ifma */ ifma_BN_transpose_copy(d_mb8, dp_pa, FACTOR_BITLEN); EXP52x30_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])d_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])rr_mb8, k0_mb8, (int64u(*)[8])work_buffer); /* // crt recombination */ /* xp = (xp-xq) mod p */ ifma_modsub52x30_mb8(inp_mb8,(const int64u(*)[8])xq_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8); /* for specific case p<q */ ifma_modsub52x30_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])p_mb8); /* xp = (xp*coef) mod p */ ifma_BN_to_mb8(inp_mb8, iq_pa, FACTOR_BITLEN); /* coef */ ifma_amm52x30_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)rr_mb8, (int64u*)p_mb8, k0_mb8); /* -> mont domain */ ifma_amm52x30_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)inp_mb8, (int64u*)p_mb8, k0_mb8); /* mmul */ ifma_modsub52x30_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8);/* correction */ /* xp = (xp*q + xq) */ zero_mb8(inp_mb8, LEN52 * 2); copy_mb8(inp_mb8, (const int64u(*)[8])xq_mb8, LEN52); ifma_addmul52x30_mb8(inp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])q_mb8); /* convert result from ifma fmt */ ifma_mb8_to_HexStr8(to_pa, (const int64u(*)[8])inp_mb8, RSA_BITLEN); /* clear exponents, p, q */ zero_mb8(d_mb8, LEN64); zero_mb8(q_mb8, LEN52); zero_mb8(p_mb8, LEN52); #undef RSA_BITLEN #undef FACTOR_BITLEN #undef LEN52 #undef LEN64 } void ifma_ssl_rsa4K_prv5_layer_mb8(const int8u* const from_pa[8], int8u* const to_pa[8], const BIGNUM* const p_pa[8], const BIGNUM* const q_pa[8], const BIGNUM* const dp_pa[8], const BIGNUM* const dq_pa[8], const BIGNUM* const iq_pa[8]) { #define RSA_BITLEN (RSA_4K) #define FACTOR_BITLEN (RSA_BITLEN/2) #define LEN52 (NUMBER_OF_DIGITS(FACTOR_BITLEN, DIGIT_SIZE)) #define LEN64 (NUMBER_OF_DIGITS(FACTOR_BITLEN, 64)) /* allocate mb8 buffers */ __ALIGN64 int64u k0_mb8[8]; __ALIGN64 int64u p_mb8[LEN52][8]; __ALIGN64 int64u q_mb8[LEN52][8]; __ALIGN64 int64u d_mb8[LEN64][8]; __ALIGN64 int64u rr_mb8[LEN52][8]; __ALIGN64 int64u xp_mb8[LEN52][8]; __ALIGN64 int64u xq_mb8[LEN52][8]; __ALIGN64 int64u inp_mb8[LEN52*2][8]; /* allocate stack for red(undant) result, multiplier, for exponent X and for pre-computed table of base powers */ __ALIGN64 int64u work_buffer[LEN52*2 + 1 + (LEN64 + 1) + (1 << EXP_WIN_SIZE)*LEN52][8]; /* convert input to ifma fmt */ zero_mb8(inp_mb8, LEN52 * 2); ifma_HexStr8_to_mb8(inp_mb8, from_pa, RSA_BITLEN); /* // q exponentiation */ /* convert modulus to ifma fmt */ ifma_BN_to_mb8(q_mb8, q_pa, FACTOR_BITLEN); /* compute k0[] */ ifma_montFactor52_mb8(k0_mb8, q_mb8[0]); /* compute to_Montgomery domain converters */ ifma_montRR52x_mb8(rr_mb8, q_mb8, FACTOR_BITLEN); /* xq = x mod q */ ifma_amred52x40_mb8(xq_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])q_mb8, k0_mb8); ifma_amm52x40_mb8((int64u*)xq_mb8, (int64u*)xq_mb8, (int64u*)rr_mb8, (int64u*)q_mb8, k0_mb8); ifma_modsub52x40_mb8(xq_mb8, (const int64u(*)[8])xq_mb8, (const int64u(*)[8])q_mb8, (const int64u(*)[8])q_mb8); // ?? /* re-arrange exps to ifma */ ifma_BN_transpose_copy(d_mb8, dq_pa, FACTOR_BITLEN); EXP52x40_mb8(xq_mb8, (const int64u(*)[8])xq_mb8, (const int64u(*)[8])d_mb8, (const int64u(*)[8])q_mb8, (const int64u(*)[8])rr_mb8, k0_mb8, (int64u(*)[8])work_buffer); /* // p exponentiation */ /* convert modulus to ifma fmt */ ifma_BN_to_mb8(p_mb8, p_pa, FACTOR_BITLEN); /* compute k0[] */ ifma_montFactor52_mb8(k0_mb8, p_mb8[0]); /* compute to_Montgomery domain converters */ ifma_montRR52x_mb8(rr_mb8, p_mb8, FACTOR_BITLEN); /* xp = x mod p */ ifma_amred52x40_mb8(xp_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])p_mb8, k0_mb8); ifma_amm52x40_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)rr_mb8, (int64u*)p_mb8, k0_mb8); ifma_modsub52x40_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8); // ?? /* re-arrange exps to ifma */ ifma_BN_transpose_copy(d_mb8, dp_pa, FACTOR_BITLEN); EXP52x40_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])d_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])rr_mb8, k0_mb8, (int64u(*)[8])work_buffer); /* // crt recombination */ /* xp = (xp-xq) mod p */ ifma_modsub52x40_mb8(inp_mb8,(const int64u(*)[8])xq_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8); /* for specific case p<q */ ifma_modsub52x40_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])inp_mb8, (const int64u(*)[8])p_mb8); /* xp = (xp*coef) mod p */ ifma_BN_to_mb8(inp_mb8, iq_pa, FACTOR_BITLEN); /* coef */ ifma_amm52x40_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)rr_mb8, (int64u*)p_mb8, k0_mb8); /* -> mont domain */ ifma_amm52x40_mb8((int64u*)xp_mb8, (int64u*)xp_mb8, (int64u*)inp_mb8, (int64u*)p_mb8, k0_mb8); /* mmul */ ifma_modsub52x40_mb8(xp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])p_mb8, (const int64u(*)[8])p_mb8);/* correction */ /* xp = (xp*q + xq) */ zero_mb8(inp_mb8, LEN52 * 2); copy_mb8(inp_mb8, (const int64u(*)[8])xq_mb8, LEN52); ifma_addmul52x40_mb8(inp_mb8, (const int64u(*)[8])xp_mb8, (const int64u(*)[8])q_mb8); /* convert result from ifma fmt */ ifma_mb8_to_HexStr8(to_pa, (const int64u(*)[8])inp_mb8, RSA_BITLEN); /* clear exponents, p, q */ zero_mb8(d_mb8, LEN64); zero_mb8(q_mb8, LEN52); zero_mb8(p_mb8, LEN52); #undef RSA_BITLEN #undef FACTOR_BITLEN #undef LEN52 #undef LEN64 } #endif /* BN_OPENSSL_DISABLE */
0eaa8c6baa7477f8ff3ec9e43ed2f527871decb5
78297bc868d588dd7a16cfea059ef7365ba18622
/lib/core/include/irods/cpUtil.h
d76588a8a9c12408f130c8ff8b7ae71a280aca29
[ "BSD-3-Clause" ]
permissive
irods/irods
ab72a41fdf05a4a905c3e3a97bb7ba3c2a6ae52d
f3ccaa842218e477395ebcf553639134433b63ee
refs/heads/main
2023-09-01T20:12:33.322002
2023-08-23T18:22:59
2023-08-31T13:41:31
14,724,975
381
167
NOASSERTION
2023-09-11T18:18:14
2013-11-26T18:10:18
C++
UTF-8
C
false
false
1,065
h
cpUtil.h
/*** Copyright (c), The Regents of the University of California *** *** For more information please refer to files in the COPYRIGHT directory ***/ /* getUtil.h - Header for for getUtil.c */ #ifndef CP_UTIL_H__ #define CP_UTIL_H__ #include <stdio.h> #include "irods/rodsClient.h" #include "irods/parseCommandLine.h" #include "irods/rodsPath.h" #ifdef __cplusplus extern "C" { #endif int cpUtil( rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp ); int cpFileUtil( rcComm_t *conn, char *srcPath, char *targPath, rodsLong_t srcSize, rodsArguments_t *rodsArgs, dataObjCopyInp_t *dataObjCopyInp ); int initCondForCp( rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjCopyInp_t *dataObjCopyInp, rodsRestart_t *rodsRestart ); int cpCollUtil( rcComm_t *conn, char *srcColl, char *targColl, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjCopyInp_t *dataObjCopyInp, rodsRestart_t *rodsRestart ); #ifdef __cplusplus } #endif #endif // CP_UTIL_H__
eb29e4caf6a03ac6d56de14e53bbb8dd2c1b471a
76f9898ff7a555f4a729d725056a317af818375d
/assets/scenes/misc/fairy_fountain/fairy_fountain_scene.c
5e5dcf69a614f2441d00ed8c0ed15d94022ee8e0
[]
no_license
z64proto/sw97
0b65837ab2f2a4073faca5670761d7fe0e74d29d
f571505ade2cefd4a5b5d19da06d33e7c6b02c60
refs/heads/master
2023-08-01T02:47:42.895871
2022-05-15T20:29:08
2022-05-15T20:29:08
430,216,978
208
29
null
2021-11-22T12:23:50
2021-11-20T21:52:59
C
UTF-8
C
false
false
44,210
c
fairy_fountain_scene.c
#include "ultra64.h" #include "z64.h" #include "macros.h" #include "fairy_fountain_scene.h" #include "segment_symbols.h" #include "command_macros_base.h" #include "z64cutscene_commands.h" #include "variables.h" #include "fairy_fountain_scene.h" static SCmdRoomList fairy_fountain_sceneSet0000Cmd00; static SCmdColHeader fairy_fountain_sceneSet0000Cmd01; static SCmdEntranceList fairy_fountain_sceneSet0000Cmd02; static SCmdSpawnList fairy_fountain_sceneSet0000Cmd03; static SCmdSkyboxSettings fairy_fountain_sceneSet0000Cmd04; static SCmdLightSettingList fairy_fountain_sceneSet0000Cmd05; static SCmdEndMarker fairy_fountain_sceneSet0000Cmd06; static SCmdRoomList fairy_fountain_sceneSet0000Cmd00 = { 0x04, 0x01, (u32)&fairy_fountain_sceneRoomList0x000048 }; // 0x0000 static SCmdColHeader fairy_fountain_sceneSet0000Cmd01 = { 0x03, 0x00, (u32)&fairy_fountain_sceneCollisionHeader0x001D6C }; // 0x0008 static SCmdEntranceList fairy_fountain_sceneSet0000Cmd02 = { 0x06, 0x00, (u32)&fairy_fountain_sceneEntranceList0x000050 }; // 0x0010 static SCmdSpawnList fairy_fountain_sceneSet0000Cmd03 = { 0x00, 0x01, (u32)&fairy_fountain_sceneStartPositionList0x000038 }; // 0x0018 static SCmdSkyboxSettings fairy_fountain_sceneSet0000Cmd04 = { 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; // 0x0020 static SCmdLightSettingList fairy_fountain_sceneSet0000Cmd05 = { 0x0F, 4, (u32)&fairy_fountain_sceneLightSettings0x000054 }; // 0x0028 static SCmdEndMarker fairy_fountain_sceneSet0000Cmd06 = { 0x14, 0x00, 0x00 }; // 0x0030 ActorEntry fairy_fountain_sceneStartPositionList0x000038[] = { { ACTOR_PLAYER, -26, 20, 274, 0, 32767, 0, 0x0FFF }, }; RomFile fairy_fountain_sceneRoomList0x000048[] = { { (u32)_fairy_fountain_room_00SegmentRomStart, (u32)_fairy_fountain_room_00SegmentRomEnd }, }; EntranceEntry fairy_fountain_sceneEntranceList0x000050[2] = { { 0x00, 0x00 }, //0x000050 { 0x00, 0x00 }, //0x000052 }; LightSettings fairy_fountain_sceneLightSettings0x000054[4] = { { 0x1E, 0x1E, 0x3C, 0x00, 0x46, 0x88, 0xC8, 0xC8, 0xFF, 0x00, 0xBA, 0x78, 0x28, 0x28, 0x46, 0x00, 0x00, 0x00, 0x03DB, 0x3200 }, // 0x000054 { 0x46, 0x46, 0x64, 0x00, 0x5A, 0xEC, 0x96, 0x96, 0x96, 0x00, 0xA6, 0x14, 0xC8, 0xFF, 0xFF, 0x64, 0x64, 0x7D, 0x03DB, 0x3200 }, // 0x00006A { 0x78, 0x5A, 0x00, 0x50, 0x50, 0x50, 0xFA, 0x87, 0x32, 0xB0, 0xB0, 0xB0, 0x1E, 0x1E, 0x3C, 0x1C, 0x14, 0x00, 0x03E1, 0x3200 }, // 0x000080 { 0x28, 0x28, 0x46, 0x50, 0x50, 0x50, 0x14, 0x14, 0x23, 0xB0, 0xB0, 0xB0, 0x32, 0x32, 0x64, 0x00, 0x00, 0x1E, 0x03E0, 0x3200 }, // 0x000096 }; static u8 unaccounted_0000AC[4] = { 0x00, 0x00, 0x00, 0x00, }; CamData fairy_fountain_sceneCollisionHeader0x001D6C_camDataList_000000B0[1] = { { 0x0000, 0, 0x00000000 }, }; u32 fairy_fountain_sceneCollisionHeader0x001D6C_polygonTypes_000000B8[] = { 0x00000000, 0x00000040, 0x00000000, 0x00000000, }; CollisionPoly fairy_fountain_sceneCollisionHeader0x001D6C_polygons_000000C8[] = { { 0x0000, 0x00B6, 0x00B4, 0x00B2, 0x0000, 0x7FFF, 0x0000, 0xFFD1 }, // 0x000000C8 { 0x0000, 0x00B6, 0x00B2, 0x00B0, 0x0000, 0x7FFF, 0x0000, 0xFFD1 }, // 0x000000D8 { 0x0000, 0x00B6, 0x00B0, 0x00AC, 0x0000, 0x7FFF, 0x0000, 0xFFD1 }, // 0x000000E8 { 0x0000, 0x00B6, 0x00AC, 0x00AF, 0x0000, 0x7FFF, 0x0000, 0xFFD1 }, // 0x000000F8 { 0x0000, 0x0000, 0x0001, 0x0002, 0x0000, 0x0000, 0x8001, 0x01A5 }, // 0x00000108 { 0x0000, 0x0000, 0x0002, 0x0003, 0x0000, 0x0000, 0x8001, 0x01A5 }, // 0x00000118 { 0x0000, 0x0003, 0x0004, 0x0005, 0x0000, 0x0000, 0x8001, 0x01A5 }, // 0x00000128 { 0x0000, 0x0003, 0x0005, 0x0006, 0x0000, 0x0000, 0x8001, 0x01A5 }, // 0x00000138 { 0x0000, 0x0007, 0x0008, 0x0009, 0x0000, 0x0000, 0x8001, 0x01A5 }, // 0x00000148 { 0x0000, 0x0007, 0x0009, 0x0006, 0x0000, 0x0000, 0x8001, 0x01A5 }, // 0x00000158 { 0x0001, 0x0002, 0x0007, 0x000A, 0x0000, 0x7FFF, 0x0000, 0xFFEC }, // 0x00000168 { 0x0001, 0x0002, 0x000A, 0x000B, 0x0000, 0x7FFF, 0x0000, 0xFFEC }, // 0x00000178 { 0x0001, 0x000A, 0x000C, 0x000D, 0x0000, 0x7FFF, 0x0000, 0xFFEC }, // 0x00000188 { 0x0001, 0x000A, 0x000D, 0x000B, 0x0000, 0x7FFF, 0x0000, 0xFFEC }, // 0x00000198 { 0x0000, 0x000E, 0x0004, 0x0002, 0x7FFF, 0x0000, 0x0000, 0x007A }, // 0x000001A8 { 0x0000, 0x000E, 0x0002, 0x000B, 0x7FFF, 0x0000, 0x0000, 0x007A }, // 0x000001B8 { 0x0000, 0x000D, 0x000F, 0x000E, 0x7FFF, 0x0000, 0x0000, 0x007A }, // 0x000001C8 { 0x0000, 0x000D, 0x000E, 0x000B, 0x7FFF, 0x0000, 0x0000, 0x007A }, // 0x000001D8 { 0x0000, 0x0007, 0x0005, 0x0010, 0x8001, 0x0000, 0x0000, 0x004E }, // 0x000001E8 { 0x0000, 0x0007, 0x0010, 0x000A, 0x8001, 0x0000, 0x0000, 0x004E }, // 0x000001F8 { 0x0000, 0x0010, 0x0011, 0x000C, 0x8001, 0x0000, 0x0000, 0x004E }, // 0x00000208 { 0x0000, 0x0010, 0x000C, 0x000A, 0x8001, 0x0000, 0x0000, 0x004E }, // 0x00000218 { 0x0000, 0x0010, 0x0005, 0x0004, 0x0000, 0x8001, 0x0000, 0x00B4 }, // 0x00000228 { 0x0000, 0x0010, 0x0004, 0x000E, 0x0000, 0x8001, 0x0000, 0x00B4 }, // 0x00000238 { 0x0000, 0x000F, 0x0011, 0x0010, 0x0000, 0x8001, 0x0000, 0x00B4 }, // 0x00000248 { 0x0000, 0x000F, 0x0010, 0x000E, 0x0000, 0x8001, 0x0000, 0x00B4 }, // 0x00000258 { 0x0000, 0x0012, 0x0013, 0x0014, 0x0000, 0x7FFF, 0x0000, 0x0028 }, // 0x00000268 { 0x0000, 0x0012, 0x0014, 0x0015, 0x0000, 0x7FFF, 0x0000, 0x0028 }, // 0x00000278 { 0x0000, 0x0012, 0x0015, 0x0016, 0x0000, 0x7FFF, 0x0000, 0x0028 }, // 0x00000288 { 0x0000, 0x0012, 0x0016, 0x0017, 0x0000, 0x7FFF, 0x0000, 0x0028 }, // 0x00000298 { 0x0000, 0x0012, 0x0017, 0x0018, 0x0000, 0x7FFF, 0x0000, 0x0028 }, // 0x000002A8 { 0x0000, 0x0012, 0x0018, 0x0019, 0x0000, 0x7FFF, 0x0000, 0x0028 }, // 0x000002B8 { 0x0000, 0x0012, 0x0019, 0x001A, 0x0000, 0x7FFF, 0x0000, 0x0028 }, // 0x000002C8 { 0x0000, 0x0012, 0x001A, 0x001B, 0x0000, 0x7FFF, 0x0000, 0x0028 }, // 0x000002D8 { 0x0000, 0x0012, 0x001B, 0x001C, 0x0000, 0x7FFF, 0x0000, 0x0028 }, // 0x000002E8 { 0x0000, 0x0012, 0x001C, 0x001D, 0x0000, 0x7FFF, 0x0000, 0x0028 }, // 0x000002F8 { 0x0000, 0x001D, 0x001E, 0x001F, 0xFAED, 0x7F95, 0xF710, 0xFFFC }, // 0x00000308 { 0x0000, 0x001D, 0x001F, 0x0012, 0xFAE6, 0x7F96, 0xF71E, 0xFFFC }, // 0x00000318 { 0x0000, 0x001C, 0x0020, 0x001E, 0x0000, 0x7F96, 0xF5C2, 0xFFF5 }, // 0x00000328 { 0x0000, 0x001C, 0x001E, 0x001D, 0x002B, 0x7F93, 0xF5A3, 0xFFF5 }, // 0x00000338 { 0x0000, 0x001B, 0x0021, 0x0020, 0x0525, 0x7F96, 0xF726, 0xFFFE }, // 0x00000348 { 0x0000, 0x001B, 0x0020, 0x001C, 0x0541, 0x7F95, 0xF723, 0xFFFE }, // 0x00000358 { 0x0000, 0x001A, 0x0022, 0x0021, 0x08F0, 0x7F95, 0xFAED, 0x0015 }, // 0x00000368 { 0x0000, 0x001A, 0x0021, 0x001B, 0x090C, 0x7F94, 0xFAF9, 0x0015 }, // 0x00000378 { 0x0000, 0x0019, 0x0023, 0x0022, 0x0A3E, 0x7F96, 0x0000, 0x0033 }, // 0x00000388 { 0x0000, 0x0019, 0x0022, 0x001A, 0x0A5D, 0x7F93, 0x002B, 0x0034 }, // 0x00000398 { 0x0000, 0x0018, 0x0024, 0x0023, 0x08E9, 0x7F95, 0x052D, 0x0051 }, // 0x000003A8 { 0x0000, 0x0018, 0x0023, 0x0019, 0x08E7, 0x7F95, 0x051C, 0x0051 }, // 0x000003B8 { 0x0000, 0x0017, 0x0025, 0x0024, 0x0518, 0x7F96, 0x08E5, 0x0066 }, // 0x000003C8 { 0x0000, 0x0017, 0x0024, 0x0018, 0x04FC, 0x7F92, 0x0924, 0x0068 }, // 0x000003D8 { 0x0000, 0x0016, 0x0026, 0x0025, 0x0000, 0x7F96, 0x0A3E, 0x006D }, // 0x000003E8 { 0x0000, 0x0016, 0x0025, 0x0017, 0xFFD5, 0x7F93, 0x0A5E, 0x006E }, // 0x000003F8 { 0x0000, 0x0015, 0x0027, 0x0026, 0xFAE0, 0x7F97, 0x08D2, 0x0064 }, // 0x00000408 { 0x0000, 0x0015, 0x0026, 0x0016, 0xFAA9, 0x7F94, 0x08D7, 0x0064 }, // 0x00000418 { 0x0000, 0x0014, 0x0028, 0x0027, 0xF710, 0x7F95, 0x0513, 0x004D }, // 0x00000428 { 0x0000, 0x0014, 0x0027, 0x0015, 0xF71E, 0x7F96, 0x051A, 0x004E }, // 0x00000438 { 0x0000, 0x0013, 0x0029, 0x0028, 0xF5B3, 0x7F95, 0xFFEC, 0x002F }, // 0x00000448 { 0x0000, 0x0013, 0x0028, 0x0014, 0xF5A3, 0x7F93, 0xFFD5, 0x002F }, // 0x00000458 { 0x0000, 0x0012, 0x001F, 0x0029, 0xF722, 0x7F96, 0xFAEC, 0x0012 }, // 0x00000468 { 0x0000, 0x0012, 0x0029, 0x0013, 0xF71A, 0x7F93, 0xFAA1, 0x0010 }, // 0x00000478 { 0x0000, 0x002A, 0x000D, 0x000C, 0x0000, 0x0000, 0x8001, 0xFE85 }, // 0x00000488 { 0x0000, 0x002A, 0x000C, 0x002B, 0x0000, 0x0000, 0x8001, 0xFE85 }, // 0x00000498 { 0x0000, 0x002C, 0x002D, 0x002E, 0xC07F, 0x0000, 0x90DE, 0xFDEF }, // 0x000004A8 { 0x0000, 0x002C, 0x002E, 0x002F, 0xC07F, 0x0000, 0x90DE, 0xFDEF }, // 0x000004B8 { 0x0000, 0x002F, 0x002E, 0x0030, 0x393E, 0x0000, 0x8D84, 0xFCE9 }, // 0x000004C8 { 0x0000, 0x002F, 0x0030, 0x0031, 0x393E, 0x0000, 0x8D84, 0xFCE9 }, // 0x000004D8 { 0x0000, 0x0032, 0x0033, 0x002D, 0x8001, 0x0000, 0x0000, 0x00F3 }, // 0x000004E8 { 0x0000, 0x0032, 0x002D, 0x002C, 0x8001, 0x0000, 0x0000, 0x00F3 }, // 0x000004F8 { 0x0000, 0x0034, 0x0035, 0x0033, 0xC07F, 0x0000, 0x6F22, 0x02F4 }, // 0x00000508 { 0x0000, 0x0034, 0x0033, 0x0032, 0xC07F, 0x0000, 0x6F22, 0x02F4 }, // 0x00000518 { 0x0000, 0x0036, 0x0037, 0x0035, 0x4537, 0x0000, 0x6BAB, 0x01D6 }, // 0x00000528 { 0x0000, 0x0036, 0x0035, 0x0034, 0x4537, 0x0000, 0x6BAB, 0x01D6 }, // 0x00000538 { 0x0000, 0x0031, 0x0030, 0x0037, 0x7FFF, 0x0000, 0x0000, 0xFEF1 }, // 0x00000548 { 0x0000, 0x0031, 0x0037, 0x0036, 0x7FFF, 0x0000, 0x0000, 0xFEF1 }, // 0x00000558 { 0x0000, 0x0038, 0x0039, 0x003A, 0x8041, 0x0000, 0xF804, 0x0024 }, // 0x00000568 { 0x0000, 0x0038, 0x003A, 0x003B, 0x8041, 0x0000, 0xF804, 0x0024 }, // 0x00000578 { 0x0000, 0x003B, 0x003A, 0x003C, 0xC9DF, 0x0000, 0x8C03, 0xFC9F }, // 0x00000588 { 0x0000, 0x003B, 0x003C, 0x003D, 0xC9DF, 0x0000, 0x8C03, 0xFC9F }, // 0x00000598 { 0x0000, 0x003E, 0x003F, 0x0039, 0xB725, 0x0000, 0x693D, 0x0362 }, // 0x000005A8 { 0x0000, 0x003E, 0x0039, 0x0038, 0xB725, 0x0000, 0x693D, 0x0362 }, // 0x000005B8 { 0x0000, 0x0040, 0x0041, 0x003F, 0x3621, 0x0000, 0x73FD, 0x0345 }, // 0x000005C8 { 0x0000, 0x0040, 0x003F, 0x003E, 0x3621, 0x0000, 0x73FD, 0x0345 }, // 0x000005D8 { 0x0000, 0x0042, 0x0043, 0x0041, 0x7FBF, 0x0000, 0x07FC, 0xFFC0 }, // 0x000005E8 { 0x0000, 0x0042, 0x0041, 0x0040, 0x7FBF, 0x0000, 0x07FC, 0xFFC0 }, // 0x000005F8 { 0x0000, 0x003D, 0x003C, 0x0043, 0x48DB, 0x0000, 0x96C3, 0xFC82 }, // 0x00000608 { 0x0000, 0x003D, 0x0043, 0x0042, 0x48DB, 0x0000, 0x96C3, 0xFC82 }, // 0x00000618 { 0x0000, 0x0044, 0x0045, 0x0046, 0xC07F, 0x0000, 0x6F22, 0x02FE }, // 0x00000628 { 0x0000, 0x0044, 0x0046, 0x0047, 0xC07F, 0x0000, 0x6F22, 0x02FE }, // 0x00000638 { 0x0000, 0x0047, 0x0046, 0x0048, 0x8041, 0x0000, 0x07FC, 0xFF8E }, // 0x00000648 { 0x0000, 0x0047, 0x0048, 0x0049, 0x8041, 0x0000, 0x07FC, 0xFF8E }, // 0x00000658 { 0x0000, 0x004A, 0x004B, 0x0045, 0x4537, 0x0000, 0x6BAB, 0x038C }, // 0x00000668 { 0x0000, 0x004A, 0x0045, 0x0044, 0x4537, 0x0000, 0x6BAB, 0x038C }, // 0x00000678 { 0x0000, 0x004C, 0x004D, 0x004B, 0x7FBF, 0x0000, 0xF804, 0x0056 }, // 0x00000688 { 0x0000, 0x004C, 0x004B, 0x004A, 0x7FBF, 0x0000, 0xF804, 0x0056 }, // 0x00000698 { 0x0000, 0x004E, 0x004F, 0x004D, 0x393E, 0x0000, 0x8D84, 0xFCC4 }, // 0x000006A8 { 0x0000, 0x004E, 0x004D, 0x004C, 0x393E, 0x0000, 0x8D84, 0xFCC4 }, // 0x000006B8 { 0x0000, 0x0049, 0x0048, 0x004F, 0xC07F, 0x0000, 0x90DE, 0xFC45 }, // 0x000006C8 { 0x0000, 0x0049, 0x004F, 0x004E, 0xC07F, 0x0000, 0x90DE, 0xFC45 }, // 0x000006D8 { 0x0000, 0x0050, 0x0051, 0x0052, 0x3F81, 0x0000, 0x6F22, 0x030F }, // 0x000006E8 { 0x0000, 0x0050, 0x0052, 0x0053, 0x3F81, 0x0000, 0x6F22, 0x030F }, // 0x000006F8 { 0x0000, 0x0053, 0x0052, 0x0054, 0xBAC9, 0x0000, 0x6BAB, 0x01C5 }, // 0x00000708 { 0x0000, 0x0053, 0x0054, 0x0055, 0xBAC9, 0x0000, 0x6BAB, 0x01C5 }, // 0x00000718 { 0x0000, 0x0056, 0x0057, 0x0051, 0x7FBF, 0x0000, 0x07FC, 0x014B }, // 0x00000728 { 0x0000, 0x0056, 0x0051, 0x0050, 0x7FBF, 0x0000, 0x07FC, 0x014B }, // 0x00000738 { 0x0000, 0x0058, 0x0059, 0x0057, 0x3F81, 0x0000, 0x90DE, 0xFDFD }, // 0x00000748 { 0x0000, 0x0058, 0x0057, 0x0056, 0x3F81, 0x0000, 0x90DE, 0xFDFD }, // 0x00000758 { 0x0000, 0x005A, 0x005B, 0x0059, 0xC6C2, 0x0000, 0x8D84, 0xFCD0 }, // 0x00000768 { 0x0000, 0x005A, 0x0059, 0x0058, 0xC6C2, 0x0000, 0x8D84, 0xFCD0 }, // 0x00000778 { 0x0000, 0x0055, 0x0054, 0x005B, 0x8041, 0x0000, 0xF804, 0xFE99 }, // 0x00000788 { 0x0000, 0x0055, 0x005B, 0x005A, 0x8041, 0x0000, 0xF804, 0xFE99 }, // 0x00000798 { 0x0000, 0x005C, 0x005D, 0x005E, 0x7FBF, 0x0000, 0x07FC, 0x00AF }, // 0x000007A8 { 0x0000, 0x005C, 0x005E, 0x005F, 0x7FBF, 0x0000, 0x07FC, 0x00AF }, // 0x000007B8 { 0x0000, 0x005F, 0x005E, 0x0060, 0x393E, 0x0000, 0x727C, 0x0201 }, // 0x000007C8 { 0x0000, 0x005F, 0x0060, 0x0061, 0x393E, 0x0000, 0x727C, 0x0201 }, // 0x000007D8 { 0x0000, 0x0062, 0x0063, 0x005D, 0x48DB, 0x0000, 0x96C3, 0xFEA8 }, // 0x000007E8 { 0x0000, 0x0062, 0x005D, 0x005C, 0x48DB, 0x0000, 0x96C3, 0xFEA8 }, // 0x000007F8 { 0x0000, 0x0064, 0x0065, 0x0063, 0xC6C2, 0x0000, 0x8D84, 0xFDE4 }, // 0x00000808 { 0x0000, 0x0064, 0x0063, 0x0062, 0xC6C2, 0x0000, 0x8D84, 0xFDE4 }, // 0x00000818 { 0x0000, 0x0066, 0x0067, 0x0065, 0x8041, 0x0000, 0xF804, 0xFF36 }, // 0x00000828 { 0x0000, 0x0066, 0x0065, 0x0064, 0x8041, 0x0000, 0xF804, 0xFF36 }, // 0x00000838 { 0x0000, 0x0061, 0x0060, 0x0067, 0xB725, 0x0000, 0x693D, 0x013C }, // 0x00000848 { 0x0000, 0x0061, 0x0067, 0x0066, 0xB725, 0x0000, 0x693D, 0x013C }, // 0x00000858 { 0x0000, 0x0068, 0x0069, 0x006A, 0x3F81, 0x0000, 0x90DE, 0xFE01 }, // 0x00000868 { 0x0000, 0x0068, 0x006A, 0x006B, 0x3F81, 0x0000, 0x90DE, 0xFE01 }, // 0x00000878 { 0x0000, 0x006B, 0x006A, 0x006C, 0x7FFF, 0x0000, 0x0000, 0xFF84 }, // 0x00000888 { 0x0000, 0x006B, 0x006C, 0x006D, 0x7FFF, 0x0000, 0x0000, 0xFF84 }, // 0x00000898 { 0x0000, 0x006E, 0x006F, 0x0069, 0xC07F, 0x0000, 0x90DE, 0xFE6E }, // 0x000008A8 { 0x0000, 0x006E, 0x0069, 0x0068, 0xC07F, 0x0000, 0x90DE, 0xFE6E }, // 0x000008B8 { 0x0000, 0x0070, 0x0071, 0x006F, 0x8001, 0x0000, 0x0000, 0x0060 }, // 0x000008C8 { 0x0000, 0x0070, 0x006F, 0x006E, 0x8001, 0x0000, 0x0000, 0x0060 }, // 0x000008D8 { 0x0000, 0x0072, 0x0073, 0x0071, 0xC07F, 0x0000, 0x6F22, 0x01E3 }, // 0x000008E8 { 0x0000, 0x0072, 0x0071, 0x0070, 0xC07F, 0x0000, 0x6F22, 0x01E3 }, // 0x000008F8 { 0x0000, 0x006D, 0x006C, 0x0073, 0x3F81, 0x0000, 0x6F22, 0x0176 }, // 0x00000908 { 0x0000, 0x006D, 0x0073, 0x0072, 0x3F81, 0x0000, 0x6F22, 0x0176 }, // 0x00000918 { 0x0000, 0x0074, 0x0075, 0x0076, 0x0000, 0x8001, 0x0000, 0x00BE }, // 0x00000928 { 0x0000, 0x0074, 0x0076, 0x0077, 0x0000, 0x8001, 0x0000, 0x00BE }, // 0x00000938 { 0x0000, 0x0074, 0x0077, 0x0078, 0x0000, 0x8001, 0x0000, 0x00BE }, // 0x00000948 { 0x0000, 0x0074, 0x0078, 0x0079, 0x0000, 0x8001, 0x0000, 0x00BE }, // 0x00000958 { 0x0000, 0x0024, 0x007A, 0x007B, 0x22B4, 0x798A, 0x142D, 0x00E7 }, // 0x00000968 { 0x0000, 0x0024, 0x007B, 0x0023, 0x22B3, 0x798A, 0x142B, 0x00E6 }, // 0x00000978 { 0x0000, 0x007A, 0x007C, 0x007B, 0x6EA7, 0x0000, 0x4055, 0x02FD }, // 0x00000988 { 0x0000, 0x007A, 0x007D, 0x007C, 0x6EA7, 0x0000, 0x4055, 0x02FD }, // 0x00000998 { 0x0000, 0x007C, 0x007E, 0x007B, 0x6EA7, 0x0000, 0x4055, 0x02FD }, // 0x000009A8 { 0x0000, 0x0023, 0x007B, 0x007F, 0x281E, 0x798C, 0x0034, 0x0072 }, // 0x000009B8 { 0x0000, 0x0023, 0x007F, 0x0022, 0x27DD, 0x79A1, 0x0000, 0x0071 }, // 0x000009C8 { 0x0000, 0x007B, 0x0080, 0x007F, 0x7FFF, 0xFFDC, 0x00A5, 0x018B }, // 0x000009D8 { 0x0000, 0x007B, 0x007E, 0x0080, 0x7FFF, 0x0000, 0x0000, 0x0187 }, // 0x000009E8 { 0x0000, 0x0080, 0x0081, 0x007F, 0x7FFD, 0x0000, 0x0148, 0x018E }, // 0x000009F8 { 0x0000, 0x0022, 0x007F, 0x0082, 0x2286, 0x79A4, 0xEC21, 0xFFFB }, // 0x00000A08 { 0x0000, 0x0022, 0x0082, 0x0021, 0x22E6, 0x798B, 0xEC2F, 0xFFFC }, // 0x00000A18 { 0x0000, 0x007F, 0x0083, 0x0082, 0x6EEF, 0xFFE0, 0xC026, 0x000F }, // 0x00000A28 { 0x0000, 0x007F, 0x0081, 0x0083, 0x6EA7, 0x0000, 0xBFAB, 0x000C }, // 0x00000A38 { 0x0000, 0x0083, 0x0084, 0x0082, 0x6F36, 0x0000, 0xC0A3, 0x0011 }, // 0x00000A48 { 0x0000, 0x0021, 0x0082, 0x002A, 0x1441, 0x798C, 0xDD5E, 0xFFA3 }, // 0x00000A58 { 0x0000, 0x0021, 0x002A, 0x0020, 0x1417, 0x7997, 0xDD6F, 0xFFA3 }, // 0x00000A68 { 0x0000, 0x0082, 0x0085, 0x002A, 0x409D, 0xFFEE, 0x9183, 0xFEF6 }, // 0x00000A78 { 0x0000, 0x0085, 0x0086, 0x002A, 0x4055, 0xFFDB, 0x9159, 0xFEF6 }, // 0x00000A88 { 0x0000, 0x0082, 0x0084, 0x0085, 0x4055, 0x0000, 0x9159, 0xFEF5 }, // 0x00000A98 { 0x0000, 0x0020, 0x002A, 0x002B, 0x0000, 0x7988, 0xD7D5, 0xFF80 }, // 0x00000AA8 { 0x0000, 0x0020, 0x002B, 0x001E, 0x0000, 0x7988, 0xD7D5, 0xFF80 }, // 0x00000AB8 { 0x0000, 0x001E, 0x002B, 0x0087, 0xEC2C, 0x7991, 0xDD33, 0xFF9C }, // 0x00000AC8 { 0x0000, 0x001E, 0x0087, 0x001F, 0xEC2F, 0x798B, 0xDD1A, 0xFF9B }, // 0x00000AD8 { 0x0000, 0x002B, 0x0088, 0x0087, 0xC0A3, 0x0000, 0x90CA, 0xFEDD }, // 0x00000AE8 { 0x0000, 0x0088, 0x0089, 0x0087, 0xC0A3, 0x0000, 0x90CA, 0xFEDD }, // 0x00000AF8 { 0x0000, 0x002B, 0x008A, 0x0088, 0xC0A3, 0x0000, 0x90CA, 0xFEDD }, // 0x00000B08 { 0x0000, 0x001F, 0x0087, 0x008B, 0xDD4C, 0x798A, 0xEBD3, 0xFFEF }, // 0x00000B18 { 0x0000, 0x001F, 0x008B, 0x0029, 0xDD74, 0x79A6, 0xEC37, 0xFFF1 }, // 0x00000B28 { 0x0000, 0x0087, 0x008C, 0x008B, 0x9159, 0x0000, 0xBFAB, 0xFFE8 }, // 0x00000B38 { 0x0000, 0x0087, 0x0089, 0x008C, 0x9159, 0x0000, 0xBFAB, 0xFFE8 }, // 0x00000B48 { 0x0000, 0x008C, 0x008D, 0x008B, 0x9159, 0x0000, 0xBFAB, 0xFFE8 }, // 0x00000B58 { 0x0000, 0x0029, 0x008B, 0x008E, 0xD823, 0x79A1, 0x0000, 0x0063 }, // 0x00000B68 { 0x0000, 0x0029, 0x008E, 0x0028, 0xD7C3, 0x7982, 0xFFB4, 0x0063 }, // 0x00000B78 { 0x0000, 0x008B, 0x008F, 0x008E, 0x8001, 0x0000, 0x0000, 0x015E }, // 0x00000B88 { 0x0000, 0x008F, 0x0090, 0x008E, 0x8001, 0x0000, 0x0000, 0x015E }, // 0x00000B98 { 0x0000, 0x008B, 0x008D, 0x008F, 0x8001, 0x0000, 0x0000, 0x015E }, // 0x00000BA8 { 0x0000, 0x0028, 0x008E, 0x0091, 0xDD40, 0x798E, 0x1400, 0x00DA }, // 0x00000BB8 { 0x0000, 0x0028, 0x0091, 0x0027, 0xDCDF, 0x7974, 0x13F2, 0x00DA }, // 0x00000BC8 { 0x0000, 0x008E, 0x0092, 0x0091, 0x9111, 0x0020, 0x3FDA, 0x02D6 }, // 0x00000BD8 { 0x0000, 0x008E, 0x0090, 0x0092, 0x90CA, 0x0000, 0x3F5D, 0x02D4 }, // 0x00000BE8 { 0x0000, 0x0092, 0x0093, 0x0091, 0x9159, 0x0000, 0x4055, 0x02DA }, // 0x00000BF8 { 0x0000, 0x0027, 0x0091, 0x0094, 0xEBAB, 0x797F, 0x22C4, 0x0133 }, // 0x00000C08 { 0x0000, 0x0027, 0x0094, 0x0026, 0xEBD5, 0x798A, 0x22B3, 0x0133 }, // 0x00000C18 { 0x0000, 0x0091, 0x0095, 0x0094, 0xBF63, 0x0012, 0x6E7D, 0x03EF }, // 0x00000C28 { 0x0000, 0x0095, 0x0096, 0x0094, 0xBFAB, 0x0000, 0x6EA7, 0x03F0 }, // 0x00000C38 { 0x0000, 0x0091, 0x0093, 0x0095, 0xBF1A, 0x0000, 0x6E53, 0x03EE }, // 0x00000C48 { 0x0000, 0x0026, 0x0094, 0x0097, 0xFFCC, 0x798C, 0x281E, 0x0156 }, // 0x00000C58 { 0x0000, 0x0026, 0x0097, 0x0025, 0x0000, 0x79A1, 0x27DD, 0x0154 }, // 0x00000C68 { 0x0000, 0x0094, 0x0098, 0x0097, 0xFF5B, 0xFFDB, 0x7FFF, 0x0460 }, // 0x00000C78 { 0x0000, 0x0094, 0x0096, 0x0098, 0x0000, 0x0000, 0x7FFF, 0x0460 }, // 0x00000C88 { 0x0000, 0x0098, 0x0099, 0x0097, 0xFEB5, 0x0000, 0x7FFD, 0x0460 }, // 0x00000C98 { 0x0000, 0x0025, 0x0097, 0x007A, 0x13F2, 0x7997, 0x22A7, 0x0139 }, // 0x00000CA8 { 0x0000, 0x0025, 0x007A, 0x0024, 0x13ED, 0x798E, 0x22CB, 0x013A }, // 0x00000CB8 { 0x0000, 0x0097, 0x009A, 0x007A, 0x3FDA, 0xFFE0, 0x6EEF, 0x0407 }, // 0x00000CC8 { 0x0000, 0x0097, 0x0099, 0x009A, 0x4055, 0x0000, 0x6EA7, 0x0405 }, // 0x00000CD8 { 0x0000, 0x009A, 0x007D, 0x007A, 0x3F5D, 0x0000, 0x6F36, 0x0408 }, // 0x00000CE8 { 0x0000, 0x000F, 0x009B, 0x0011, 0x0000, 0x0000, 0x8001, 0xFE85 }, // 0x00000CF8 { 0x0000, 0x009B, 0x008A, 0x0011, 0x0000, 0x0000, 0x8001, 0xFE85 }, // 0x00000D08 { 0x0000, 0x000F, 0x0086, 0x009B, 0x0000, 0x0000, 0x8001, 0xFE85 }, // 0x00000D18 { 0x0000, 0x009C, 0x009D, 0x009E, 0xC44A, 0x09D1, 0x70CA, 0x028A }, // 0x00000D28 { 0x0000, 0x009F, 0x009C, 0x009E, 0xC44A, 0x09D1, 0x8F36, 0xFD59 }, // 0x00000D38 { 0x0000, 0x00A0, 0x00A1, 0x00A2, 0x68A8, 0xD2BB, 0x3A25, 0x0164 }, // 0x00000D48 { 0x0000, 0x00A0, 0x00A2, 0x00A3, 0x68FE, 0xD301, 0x39BF, 0x0162 }, // 0x00000D58 { 0x0000, 0x00A3, 0x00A2, 0x00A4, 0x6AE6, 0xD230, 0xCA8D, 0xFED3 }, // 0x00000D68 { 0x0000, 0x00A3, 0x00A4, 0x00A5, 0x6A44, 0xD35D, 0xC856, 0xFEC6 }, // 0x00000D78 { 0x0000, 0x00A5, 0x00A4, 0x00A6, 0x0000, 0xD133, 0x88DE, 0xFD3B }, // 0x00000D88 { 0x0000, 0x00A5, 0x00A6, 0x00A7, 0xFAFF, 0xD409, 0x87E5, 0xFD34 }, // 0x00000D98 { 0x0000, 0x00A7, 0x00A6, 0x00A8, 0x93FE, 0xD591, 0xC9FF, 0xFEA5 }, // 0x00000DA8 { 0x0000, 0x00A7, 0x00A8, 0x00A9, 0x9702, 0xD301, 0xC641, 0xFE90 }, // 0x00000DB8 { 0x0000, 0x00A9, 0x00A8, 0x00AA, 0x9739, 0xD318, 0x3A36, 0x013C }, // 0x00000DC8 { 0x0000, 0x00A9, 0x00AA, 0x00AB, 0x9710, 0xD2D7, 0x39B7, 0x0139 }, // 0x00000DD8 { 0x0000, 0x00AB, 0x00AA, 0x00A1, 0x0000, 0xD133, 0x7722, 0x02B8 }, // 0x00000DE8 { 0x0000, 0x00AB, 0x00A1, 0x00A0, 0x0000, 0xD133, 0x7722, 0x02B8 }, // 0x00000DF8 { 0x0000, 0x00AC, 0x00AD, 0x00AE, 0x0000, 0xBAC9, 0x6BAB, 0x0269 }, // 0x00000E08 { 0x0000, 0x00AC, 0x00AE, 0x00AF, 0x0000, 0xBAC9, 0x6BAB, 0x0269 }, // 0x00000E18 { 0x0000, 0x00B0, 0x00B1, 0x00AD, 0xA1A9, 0xBC9D, 0x363F, 0x011C }, // 0x00000E28 { 0x0000, 0x00B0, 0x00AD, 0x00AC, 0xA1EE, 0xBBD9, 0x35C1, 0x011A }, // 0x00000E38 { 0x0000, 0x00B2, 0x00B3, 0x00B1, 0xA161, 0xBC16, 0xCAEC, 0xFEA6 }, // 0x00000E48 { 0x0000, 0x00B2, 0x00B1, 0x00B0, 0xA139, 0xBC4D, 0xCAED, 0xFEA6 }, // 0x00000E58 { 0x0000, 0x00B4, 0x00B5, 0x00B3, 0x0000, 0xBAC9, 0x9455, 0xFD77 }, // 0x00000E68 { 0x0000, 0x00B4, 0x00B3, 0x00B2, 0x0000, 0xBAC9, 0x9455, 0xFD77 }, // 0x00000E78 { 0x0000, 0x00B6, 0x00B7, 0x00B5, 0x5D98, 0xBD26, 0xC7D8, 0xFEB6 }, // 0x00000E88 { 0x0000, 0x00B6, 0x00B5, 0x00B4, 0x5B6D, 0xB73C, 0xCBC2, 0xFED0 }, // 0x00000E98 { 0x0000, 0x00AF, 0x00AE, 0x00B7, 0x5E9F, 0xBC16, 0x3514, 0x0139 }, // 0x00000EA8 { 0x0000, 0x00AF, 0x00B7, 0x00B6, 0x5EC7, 0xBC4D, 0x3513, 0x0139 }, // 0x00000EB8 { 0x0000, 0x00B8, 0x00B9, 0x00BA, 0x6582, 0x3419, 0xC5FF, 0xFE8E }, // 0x00000EC8 { 0x0000, 0x00B8, 0x00BA, 0x00BB, 0x6381, 0x3748, 0xC578, 0xFE8C }, // 0x00000ED8 { 0x0000, 0x00BB, 0x00BA, 0x00BC, 0x6418, 0x379C, 0x3933, 0x0134 }, // 0x00000EE8 { 0x0000, 0x00BB, 0x00BC, 0x00BD, 0x64A7, 0x3469, 0x3B35, 0x013F }, // 0x00000EF8 { 0x0000, 0x00BD, 0x00BC, 0x00BE, 0x0000, 0x33FC, 0x74F7, 0x0281 }, // 0x00000F08 { 0x0000, 0x00BD, 0x00BE, 0x00BF, 0x0000, 0x33FC, 0x74F7, 0x0281 }, // 0x00000F18 { 0x0000, 0x00BF, 0x00BE, 0x00C0, 0x9A7E, 0x3419, 0x3A01, 0x0116 }, // 0x00000F28 { 0x0000, 0x00BF, 0x00C0, 0x00C1, 0x9ABE, 0x3481, 0x3A13, 0x0116 }, // 0x00000F38 { 0x0000, 0x00C1, 0x00C0, 0x00C2, 0x9B51, 0x3435, 0xC4AB, 0xFE65 }, // 0x00000F48 { 0x0000, 0x00C1, 0x00C2, 0x00C3, 0x9B59, 0x3469, 0xC4CB, 0xFE66 }, // 0x00000F58 { 0x0000, 0x00C3, 0x00C2, 0x00B9, 0x0000, 0x33FC, 0x8B09, 0xFD23 }, // 0x00000F68 { 0x0000, 0x00C3, 0x00B9, 0x00B8, 0x0000, 0x33FC, 0x8B09, 0xFD23 }, // 0x00000F78 { 0x0000, 0x00B9, 0x00C2, 0x00C0, 0x0000, 0x7FFF, 0x0000, 0x000D }, // 0x00000F88 { 0x0000, 0x00B9, 0x00C0, 0x00BE, 0x0000, 0x7FFF, 0x0000, 0x000D }, // 0x00000F98 { 0x0000, 0x00B9, 0x00BE, 0x00BC, 0x0000, 0x7FFF, 0x0000, 0x000D }, // 0x00000FA8 { 0x0000, 0x00B9, 0x00BC, 0x00BA, 0x0000, 0x7FFF, 0x0000, 0x000D }, // 0x00000FB8 { 0x0000, 0x009D, 0x009F, 0x009E, 0x7FB2, 0x08BF, 0x0000, 0x0015 }, // 0x00000FC8 { 0x0000, 0x00AF, 0x00C4, 0x00C5, 0x08A1, 0x6562, 0x4DA8, 0x0185 }, // 0x00000FD8 { 0x0000, 0x00AF, 0x00C5, 0x00C6, 0x0000, 0x5A82, 0x5A82, 0x01D0 }, // 0x00000FE8 { 0x0000, 0x00B6, 0x00C7, 0x00C4, 0x4B8A, 0x5E6C, 0x29F7, 0x00C1 }, // 0x00000FF8 { 0x0000, 0x00B6, 0x00C4, 0x00AF, 0x4D22, 0x5C90, 0x2B32, 0x00C8 }, // 0x00001008 { 0x0000, 0x00B4, 0x00C8, 0x00C7, 0x48BC, 0x6093, 0xD5FA, 0xFED2 }, // 0x00001018 { 0x0000, 0x00B4, 0x00C7, 0x00B6, 0x4B4E, 0x5E21, 0xD4F8, 0xFECD }, // 0x00001028 { 0x0000, 0x00C9, 0x00CA, 0x00C8, 0x0000, 0x5A82, 0xA57E, 0xFDA8 }, // 0x00001038 { 0x0000, 0x00C9, 0x00C8, 0x00B4, 0x0000, 0x5A82, 0xA57E, 0xFDA8 }, // 0x00001048 { 0x0000, 0x00AC, 0x00CB, 0x00CC, 0xB840, 0x60DC, 0x2B0D, 0x00AC }, // 0x00001058 { 0x0000, 0x00AC, 0x00CC, 0x00B0, 0xAC16, 0x53EA, 0x2FF4, 0x00C6 }, // 0x00001068 { 0x0000, 0x00B0, 0x00CC, 0x00CD, 0xAC37, 0x53C9, 0xCF97, 0xFE90 }, // 0x00001078 { 0x0000, 0x00B0, 0x00CD, 0x00B2, 0xB2DE, 0x5C90, 0xD4CE, 0xFEB0 }, // 0x00001088 { 0x0000, 0x00CE, 0x00CF, 0x00CB, 0x0000, 0x5A82, 0x5A82, 0x01D0 }, // 0x00001098 { 0x0000, 0x00CE, 0x00CB, 0x00AC, 0x0000, 0x5A82, 0x5A82, 0x01D0 }, // 0x000010A8 { 0x0000, 0x00B2, 0x00CD, 0x00D0, 0xF836, 0x6544, 0xB21B, 0xFDF0 }, // 0x000010B8 { 0x0000, 0x00B2, 0x00D0, 0x00D1, 0x0000, 0x5A82, 0xA57E, 0xFDA8 }, // 0x000010C8 { 0x0000, 0x00D2, 0x00D3, 0x00D4, 0x3D72, 0xD5E8, 0x97E8, 0xFEEB }, // 0x000010D8 { 0x0000, 0x00D2, 0x00D4, 0x00D5, 0x3D73, 0xD703, 0x9778, 0xFEE9 }, // 0x000010E8 { 0x0000, 0x00D6, 0x00D7, 0x00D3, 0x6916, 0xD6ED, 0xC38F, 0xFFF2 }, // 0x000010F8 { 0x0000, 0x00D6, 0x00D3, 0x00D2, 0x6929, 0xD750, 0xC36F, 0xFFF1 }, // 0x00001108 { 0x0000, 0x00D8, 0x00D9, 0x00D7, 0x7826, 0xD3E1, 0x00AE, 0x0158 }, // 0x00001118 { 0x0000, 0x00D8, 0x00D7, 0x00D6, 0x796E, 0xD786, 0x0000, 0x0157 }, // 0x00001128 { 0x0000, 0x00DA, 0x00DB, 0x00D9, 0x687F, 0xD5F3, 0x3CC9, 0x02B7 }, // 0x00001138 { 0x0000, 0x00DA, 0x00D9, 0x00D8, 0x67AD, 0xD3E9, 0x3CC0, 0x02B5 }, // 0x00001148 { 0x0000, 0x00DC, 0x00DD, 0x00DB, 0x3C71, 0xD6ED, 0x6916, 0x03B4 }, // 0x00001158 { 0x0000, 0x00DC, 0x00DB, 0x00DA, 0x3C91, 0xD750, 0x6929, 0x03B5 }, // 0x00001168 { 0x0000, 0x00DE, 0x00DF, 0x00E0, 0x0000, 0xD3F0, 0x782C, 0x0400 }, // 0x00001178 { 0x0000, 0x00DE, 0x00E0, 0x00DC, 0x0000, 0xD3F0, 0x782C, 0x0400 }, // 0x00001188 { 0x0000, 0x00E1, 0x00E2, 0x00DF, 0xC33E, 0xD421, 0x67C4, 0x0396 }, // 0x00001198 { 0x0000, 0x00E1, 0x00DF, 0x00DE, 0xC338, 0xD5AC, 0x6863, 0x039B }, // 0x000011A8 { 0x0000, 0x00E3, 0x00E4, 0x00E2, 0x97DD, 0xD3D4, 0x3BE5, 0x028E }, // 0x000011B8 { 0x0000, 0x00E3, 0x00E2, 0x00E1, 0x97C8, 0xD434, 0x3C06, 0x028F }, // 0x000011C8 { 0x0000, 0x00E5, 0x00E6, 0x00E4, 0x8692, 0xD786, 0x0000, 0x012F }, // 0x000011D8 { 0x0000, 0x00E5, 0x00E4, 0x00E3, 0x87CF, 0xD3FF, 0xFF58, 0x0129 }, // 0x000011E8 { 0x0000, 0x00E7, 0x00E8, 0x00E6, 0x983C, 0xD421, 0xC33E, 0xFFCC }, // 0x000011F8 { 0x0000, 0x00E7, 0x00E6, 0x00E5, 0x971C, 0xD6F5, 0xC334, 0xFFCE }, // 0x00001208 { 0x0000, 0x00E9, 0x00EA, 0x00E8, 0xC4F6, 0xD20C, 0x9825, 0xFED5 }, // 0x00001218 { 0x0000, 0x00E9, 0x00E8, 0x00E7, 0xC42D, 0xD439, 0x97A8, 0xFED4 }, // 0x00001228 { 0x0000, 0x00EB, 0x00D5, 0x00D4, 0x7F5C, 0xF344, 0x0000, 0x007A }, // 0x00001238 { 0x0000, 0x00EB, 0x00D4, 0x00EC, 0x7FB6, 0x0000, 0x0884, 0x0093 }, // 0x00001248 { 0x0000, 0x00D4, 0x00ED, 0x00EC, 0x7A99, 0x24C8, 0x0000, 0x0069 }, // 0x00001258 { 0x0000, 0x00EE, 0x00EF, 0x00EA, 0x846E, 0x2130, 0x0388, 0x004B }, // 0x00001268 { 0x0000, 0x00EA, 0x00E9, 0x00F0, 0x8120, 0xEF15, 0x0000, 0x004E }, // 0x00001278 { 0x0000, 0x00EA, 0x00F0, 0x00EE, 0x807C, 0x0000, 0x0B17, 0x006F }, // 0x00001288 { 0x0000, 0x00D3, 0x00F1, 0x00ED, 0x2CDC, 0x5C73, 0xB3B0, 0xFF16 }, // 0x00001298 { 0x0000, 0x00D3, 0x00ED, 0x00D4, 0x2DB2, 0x5B1E, 0xB297, 0xFF13 }, // 0x000012A8 { 0x0000, 0x00D7, 0x00F2, 0x00F1, 0x4DCB, 0x5B3C, 0xD332, 0xFFD7 }, // 0x000012B8 { 0x0000, 0x00D7, 0x00F1, 0x00D3, 0x4E3C, 0x5AC3, 0xD301, 0xFFD7 }, // 0x000012C8 { 0x0000, 0x00D9, 0x00F3, 0x00F2, 0x5619, 0x5EB6, 0x0000, 0x00D4 }, // 0x000012D8 { 0x0000, 0x00D9, 0x00F2, 0x00D7, 0x5A95, 0x5A6E, 0x0083, 0x00E4 }, // 0x000012E8 { 0x0000, 0x00DB, 0x00F4, 0x00F3, 0x4C62, 0x5C70, 0x2CC3, 0x01E0 }, // 0x000012F8 { 0x0000, 0x00DB, 0x00F3, 0x00D9, 0x4A5D, 0x5EC6, 0x2B42, 0x01CF }, // 0x00001308 { 0x0000, 0x00DD, 0x00F5, 0x00F4, 0x2CCE, 0x5B3C, 0x4DCB, 0x029F }, // 0x00001318 { 0x0000, 0x00DD, 0x00F4, 0x00DB, 0x2CFF, 0x5AC3, 0x4E3C, 0x02A3 }, // 0x00001328 { 0x0000, 0x00DF, 0x00F6, 0x00F5, 0xFF81, 0x5A8E, 0x5A75, 0x02E4 }, // 0x00001338 { 0x0000, 0x00DF, 0x00F5, 0x00E0, 0x0000, 0x5EB6, 0x5619, 0x02BE }, // 0x00001348 { 0x0000, 0x00E2, 0x00F7, 0x00F8, 0xD48B, 0x5E78, 0x4AA2, 0x0275 }, // 0x00001358 { 0x0000, 0x00E2, 0x00F8, 0x00DF, 0xD367, 0x5CB3, 0x4C2A, 0x0283 }, // 0x00001368 { 0x0000, 0x00E4, 0x00F9, 0x00F7, 0xB580, 0x5ED3, 0x2AE9, 0x01B5 }, // 0x00001378 { 0x0000, 0x00E4, 0x00F7, 0x00E2, 0xB514, 0x5E69, 0x2B17, 0x01B7 }, // 0x00001388 { 0x0000, 0x00E6, 0x00FA, 0x00F9, 0xA591, 0x5A95, 0xFF81, 0x00C1 }, // 0x00001398 { 0x0000, 0x00E6, 0x00F9, 0x00E4, 0xA9E7, 0x5EB6, 0x0000, 0x00B8 }, // 0x000013A8 { 0x0000, 0x00E8, 0x00FB, 0x00FA, 0xB543, 0x5E73, 0xD4AE, 0xFFBD }, // 0x000013B8 { 0x0000, 0x00E8, 0x00FA, 0x00E6, 0xB276, 0x5B28, 0xD29A, 0xFFBA }, // 0x000013C8 { 0x0000, 0x00EA, 0x00EF, 0x00FB, 0xD57B, 0x5EE1, 0xB558, 0xFF09 }, // 0x000013D8 { 0x0000, 0x00EA, 0x00FB, 0x00E8, 0xD541, 0x5E5A, 0xB4CF, 0xFF07 }, // 0x000013E8 { 0x0000, 0x00EF, 0x00EE, 0x00FC, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x000013F8 { 0x0000, 0x00EF, 0x00FC, 0x00FB, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001408 { 0x0000, 0x00FB, 0x00FD, 0x00FE, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001418 { 0x0000, 0x00FB, 0x00FE, 0x00FA, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001428 { 0x0000, 0x00FA, 0x00FE, 0x00FF, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001438 { 0x0000, 0x00FA, 0x00FF, 0x00F9, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001448 { 0x0000, 0x00F9, 0x00FF, 0x0100, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001458 { 0x0000, 0x00F9, 0x0100, 0x00F7, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001468 { 0x0000, 0x00F7, 0x0100, 0x0101, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001478 { 0x0000, 0x00F7, 0x0101, 0x00F8, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001488 { 0x0000, 0x00F6, 0x0101, 0x0102, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001498 { 0x0000, 0x00F6, 0x0102, 0x00F5, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x000014A8 { 0x0000, 0x00F5, 0x0102, 0x0103, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x000014B8 { 0x0000, 0x00F5, 0x0103, 0x00F4, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x000014C8 { 0x0000, 0x00F4, 0x0103, 0x0104, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x000014D8 { 0x0000, 0x00F4, 0x0104, 0x00F3, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x000014E8 { 0x0000, 0x00F3, 0x0104, 0x0105, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x000014F8 { 0x0000, 0x00F3, 0x0105, 0x00F2, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001508 { 0x0000, 0x00F2, 0x0105, 0x0106, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001518 { 0x0000, 0x00F2, 0x0106, 0x00F1, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001528 { 0x0000, 0x00F1, 0x0106, 0x00EC, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001538 { 0x0000, 0x00F1, 0x00EC, 0x00ED, 0x0000, 0x7FFF, 0x0000, 0xFFD6 }, // 0x00001548 { 0x0001, 0x0107, 0x0008, 0x0001, 0x0000, 0x7FFF, 0x0000, 0xFFEC }, // 0x00001558 { 0x0001, 0x0107, 0x0001, 0x0108, 0x0000, 0x7FFF, 0x0000, 0xFFEC }, // 0x00001568 { 0x0000, 0x0001, 0x0000, 0x0109, 0x7FFF, 0x0000, 0x0000, 0x002A }, // 0x00001578 { 0x0000, 0x0001, 0x0109, 0x0108, 0x7FFF, 0x0000, 0x0000, 0x002A }, // 0x00001588 { 0x0000, 0x0107, 0x010A, 0x0009, 0x8001, 0x0000, 0x0000, 0x0012 }, // 0x00001598 { 0x0000, 0x0107, 0x0009, 0x0008, 0x8001, 0x0000, 0x0000, 0x0012 }, // 0x000015A8 { 0x0000, 0x0109, 0x0000, 0x0009, 0x0000, 0x8001, 0x0000, 0x0078 }, // 0x000015B8 { 0x0000, 0x0109, 0x0009, 0x010A, 0x0000, 0x8001, 0x0000, 0x0078 }, // 0x000015C8 { 0x0000, 0x010B, 0x010C, 0x010D, 0xD837, 0x79A0, 0x02D7, 0x0071 }, // 0x000015D8 { 0x0000, 0x010B, 0x010D, 0x010E, 0xD485, 0x7858, 0x031B, 0x007A }, // 0x000015E8 { 0x0000, 0x010F, 0x0110, 0x0111, 0xEB94, 0x79C0, 0x21CD, 0x0128 }, // 0x000015F8 { 0x0000, 0x010F, 0x0111, 0x0112, 0xE987, 0x7865, 0x2531, 0x0145 }, // 0x00001608 { 0x0000, 0x0113, 0x0114, 0x0115, 0x1670, 0x79A1, 0x20F5, 0x012C }, // 0x00001618 { 0x0000, 0x0113, 0x0115, 0x0116, 0x184A, 0x7880, 0x23AD, 0x0144 }, // 0x00001628 { 0x0000, 0x0117, 0x0118, 0x0119, 0x2797, 0x79B8, 0xFF4E, 0x0069 }, // 0x00001638 { 0x0000, 0x0117, 0x0119, 0x011A, 0x2B45, 0x7875, 0xFF3E, 0x0071 }, // 0x00001648 { 0x0000, 0x011B, 0x011C, 0x011D, 0x1418, 0x79C4, 0xDE0D, 0xFFA2 }, // 0x00001658 { 0x0000, 0x011B, 0x011D, 0x011E, 0x163E, 0x7851, 0xDA6B, 0xFF97 }, // 0x00001668 { 0x0000, 0x011F, 0x0120, 0x0121, 0xEAB7, 0x7988, 0xDDF2, 0xFF9B }, // 0x00001678 { 0x0000, 0x011F, 0x0121, 0x0122, 0xE91B, 0x787C, 0xDB5E, 0xFF93 }, // 0x00001688 }; Vec3s fairy_fountain_sceneCollisionHeader0x001D6C_vtx_00001698[] = { { -42, 120, 421 }, // 0x00001698 { -42, 20, 421 }, // 0x0000169E { -122, 20, 421 }, // 0x000016A4 { -122, 120, 421 }, // 0x000016AA { -122, 180, 421 }, // 0x000016B0 { 78, 180, 421 }, // 0x000016B6 { 78, 120, 421 }, // 0x000016BC { 78, 20, 421 }, // 0x000016C2 { 18, 20, 421 }, // 0x000016C8 { 18, 120, 421 }, // 0x000016CE { 78, 20, -299 }, // 0x000016D4 { -122, 20, -299 }, // 0x000016DA { 78, 20, -379 }, // 0x000016E0 { -122, 20, -379 }, // 0x000016E6 { -122, 180, -299 }, // 0x000016EC { -122, 180, -379 }, // 0x000016F2 { 78, 180, -299 }, // 0x000016F8 { 78, 180, -379 }, // 0x000016FE { 63, -40, -664 }, // 0x00001704 { 95, -40, -717 }, // 0x0000170A { 96, -40, -779 }, // 0x00001710 { 65, -40, -833 }, // 0x00001716 { 12, -40, -865 }, // 0x0000171C { -50, -40, -866 }, // 0x00001722 { -105, -40, -836 }, // 0x00001728 { -136, -40, -782 }, // 0x0000172E { -137, -40, -720 }, // 0x00001734 { -107, -40, -666 }, // 0x0000173A { -53, -40, -634 }, // 0x00001740 { 9, -40, -633 }, // 0x00001746 { 46, -29, -497 }, // 0x0000174C { 164, -29, -564 }, // 0x00001752 { -89, -29, -497 }, // 0x00001758 { -206, -29, -565 }, // 0x0000175E { -273, -29, -683 }, // 0x00001764 { -273, -29, -818 }, // 0x0000176A { -205, -29, -935 }, // 0x00001770 { -88, -29, -1002 }, // 0x00001776 { 48, -29, -1002 }, // 0x0000177C { 165, -29, -934 }, // 0x00001782 { 232, -29, -816 }, // 0x00001788 { 231, -29, -681 }, // 0x0000178E { -122, 10, -379 }, // 0x00001794 { 78, 10, -379 }, // 0x0000179A { 243, -27, -748 }, // 0x000017A0 { 243, 197, -748 }, // 0x000017A6 { 257, 197, -756 }, // 0x000017AC { 257, -27, -756 }, // 0x000017B2 { 271, 197, -749 }, // 0x000017B8 { 271, -27, -749 }, // 0x000017BE { 243, -27, -732 }, // 0x000017C4 { 243, 197, -732 }, // 0x000017CA { 257, -27, -724 }, // 0x000017D0 { 257, 197, -724 }, // 0x000017D6 { 271, -27, -733 }, // 0x000017DC { 271, 197, -733 }, // 0x000017E2 { 98, -27, -985 }, // 0x000017E8 { 98, 197, -985 }, // 0x000017EE { 99, 197, -1001 }, // 0x000017F4 { 99, -27, -1001 }, // 0x000017FA { 114, 197, -1008 }, // 0x00001800 { 114, -27, -1008 }, // 0x00001806 { 111, -27, -976 }, // 0x0000180C { 111, 197, -976 }, // 0x00001812 { 126, -27, -983 }, // 0x00001818 { 126, 197, -983 }, // 0x0000181E { 127, -27, -999 }, // 0x00001824 { 127, 197, -999 }, // 0x0000182A { -162, -27, -975 }, // 0x00001830 { -162, 197, -975 }, // 0x00001836 { -176, 197, -983 }, // 0x0000183C { -176, -27, -983 }, // 0x00001842 { -177, 197, -999 }, // 0x00001848 { -177, -27, -999 }, // 0x0000184E { -148, -27, -984 }, // 0x00001854 { -148, 197, -984 }, // 0x0000185A { -149, -27, -1000 }, // 0x00001860 { -149, 197, -1000 }, // 0x00001866 { -163, -27, -1007 }, // 0x0000186C { -163, 197, -1007 }, // 0x00001872 { -285, -27, -739 }, // 0x00001878 { -285, 197, -739 }, // 0x0000187E { -299, 197, -731 }, // 0x00001884 { -299, -27, -731 }, // 0x0000188A { -313, 197, -740 }, // 0x00001890 { -313, -27, -740 }, // 0x00001896 { -284, -27, -755 }, // 0x0000189C { -284, 197, -755 }, // 0x000018A2 { -298, -27, -763 }, // 0x000018A8 { -298, 197, -763 }, // 0x000018AE { -312, -27, -756 }, // 0x000018B4 { -312, 197, -756 }, // 0x000018BA { -143, -27, -517 }, // 0x000018C0 { -143, 197, -517 }, // 0x000018C6 { -144, 197, -501 }, // 0x000018CC { -144, -27, -501 }, // 0x000018D2 { -158, 197, -494 }, // 0x000018D8 { -158, -27, -494 }, // 0x000018DE { -156, -27, -526 }, // 0x000018E4 { -156, 197, -526 }, // 0x000018EA { -170, -27, -519 }, // 0x000018F0 { -170, 197, -519 }, // 0x000018F6 { -171, -27, -503 }, // 0x000018FC { -171, 197, -503 }, // 0x00001902 { 110, -27, -526 }, // 0x00001908 { 110, 197, -526 }, // 0x0000190E { 124, 197, -518 }, // 0x00001914 { 124, -27, -518 }, // 0x0000191A { 124, 197, -502 }, // 0x00001920 { 124, -27, -502 }, // 0x00001926 { 96, -27, -518 }, // 0x0000192C { 96, 197, -518 }, // 0x00001932 { 96, -27, -502 }, // 0x00001938 { 96, 197, -502 }, // 0x0000193E { 110, -27, -494 }, // 0x00001944 { 110, 197, -494 }, // 0x0000194A { 110, 190, -488 }, // 0x00001950 { 91, 190, -499 }, // 0x00001956 { 91, 190, -521 }, // 0x0000195C { 110, 190, -532 }, // 0x00001962 { 129, 190, -520 }, // 0x00001968 { 129, 190, -498 }, // 0x0000196E { -291, 10, -1022 }, // 0x00001974 { -391, 10, -850 }, // 0x0000197A { -341, 458, -936 }, // 0x00001980 { -291, 458, -1022 }, // 0x00001986 { -391, 458, -850 }, // 0x0000198C { -392, 10, -651 }, // 0x00001992 { -391, 458, -751 }, // 0x00001998 { -392, 458, -651 }, // 0x0000199E { -293, 10, -479 }, // 0x000019A4 { -342, 458, -565 }, // 0x000019AA { -293, 458, -479 }, // 0x000019B0 { -207, 458, -429 }, // 0x000019B6 { -121, 458, -379 }, // 0x000019BC { 250, 10, -477 }, // 0x000019C2 { 164, 458, -428 }, // 0x000019C8 { 250, 458, -477 }, // 0x000019CE { 78, 458, -379 }, // 0x000019D4 { 350, 10, -649 }, // 0x000019DA { 300, 458, -563 }, // 0x000019E0 { 350, 458, -649 }, // 0x000019E6 { 350, 10, -848 }, // 0x000019EC { 350, 458, -749 }, // 0x000019F2 { 350, 458, -848 }, // 0x000019F8 { 251, 10, -1020 }, // 0x000019FE { 301, 458, -934 }, // 0x00001A04 { 251, 458, -1020 }, // 0x00001A0A { 80, 10, -1120 }, // 0x00001A10 { 166, 458, -1070 }, // 0x00001A16 { 80, 458, -1120 }, // 0x00001A1C { -119, 10, -1121 }, // 0x00001A22 { -20, 458, -1120 }, // 0x00001A28 { -119, 458, -1121 }, // 0x00001A2E { -205, 458, -1071 }, // 0x00001A34 { -22, 458, -379 }, // 0x00001A3A { -36, -28, -754 }, // 0x00001A40 { -19, -28, -745 }, // 0x00001A46 { -24, 45, -754 }, // 0x00001A4C { -19, -28, -763 }, // 0x00001A52 { -13, 34, -734 }, // 0x00001A58 { -19, 6, -745 }, // 0x00001A5E { -14, 6, -754 }, // 0x00001A64 { -2, 34, -754 }, // 0x00001A6A { -19, 6, -764 }, // 0x00001A70 { -13, 34, -775 }, // 0x00001A76 { -31, 6, -764 }, // 0x00001A7C { -37, 34, -774 }, // 0x00001A82 { -36, 6, -754 }, // 0x00001A88 { -48, 34, -754 }, // 0x00001A8E { -31, 6, -745 }, // 0x00001A94 { -37, 34, -734 }, // 0x00001A9A { -52, 47, -703 }, // 0x00001AA0 { -47, 33, -712 }, // 0x00001AA6 { 0, 33, -712 }, // 0x00001AAC { 5, 47, -703 }, // 0x00001AB2 { -80, 47, -752 }, // 0x00001AB8 { -70, 33, -752 }, // 0x00001ABE { -52, 47, -802 }, // 0x00001AC4 { -47, 33, -793 }, // 0x00001ACA { 5, 47, -802 }, // 0x00001AD0 { -1, 33, -793 }, // 0x00001AD6 { 33, 47, -753 }, // 0x00001ADC { 23, 33, -753 }, // 0x00001AE2 { 18, -40, -820 }, // 0x00001AE8 { 11, -13, -808 }, // 0x00001AEE { 43, -13, -752 }, // 0x00001AF4 { 58, -40, -752 }, // 0x00001AFA { 11, -13, -696 }, // 0x00001B00 { 18, -40, -684 }, // 0x00001B06 { -54, -13, -696 }, // 0x00001B0C { -61, -40, -684 }, // 0x00001B12 { -86, -13, -752 }, // 0x00001B18 { -100, -40, -752 }, // 0x00001B1E { -53, -13, -808 }, // 0x00001B24 { -60, -40, -820 }, // 0x00001B2A { 3, 51, -708 }, // 0x00001B30 { -6, 51, -707 }, // 0x00001B36 { -8, 47, -703 }, // 0x00001B3C { 28, 51, -753 }, // 0x00001B42 { 2, 51, -798 }, // 0x00001B48 { -6, 47, -802 }, // 0x00001B4E { -4, 51, -798 }, // 0x00001B54 { -49, 51, -707 }, // 0x00001B5A { -76, 51, -752 }, // 0x00001B60 { -50, 51, -797 }, // 0x00001B66 { -40, 47, -703 }, // 0x00001B6C { -42, 51, -707 }, // 0x00001B72 { -40, 51, -798 }, // 0x00001B78 { -38, 47, -802 }, // 0x00001B7E { -270, 2, -501 }, // 0x00001B84 { -263, 32, -509 }, // 0x00001B8A { -119, 32, -424 }, // 0x00001B90 { -122, 2, -414 }, // 0x00001B96 { -361, 2, -659 }, // 0x00001B9C { -351, 32, -662 }, // 0x00001BA2 { -361, 2, -842 }, // 0x00001BA8 { -350, 32, -839 }, // 0x00001BAE { -269, 2, -999 }, // 0x00001BB4 { -261, 32, -992 }, // 0x00001BBA { -111, 2, -1090 }, // 0x00001BC0 { -108, 32, -1080 }, // 0x00001BC6 { 71, 2, -1090 }, // 0x00001BCC { 69, 32, -1079 }, // 0x00001BD2 { -108, 32, -1079 }, // 0x00001BD8 { 229, 2, -998 }, // 0x00001BDE { 221, 32, -990 }, // 0x00001BE4 { 320, 2, -840 }, // 0x00001BEA { 309, 32, -837 }, // 0x00001BF0 { 319, 2, -657 }, // 0x00001BF6 { 309, 32, -660 }, // 0x00001BFC { 228, 2, -500 }, // 0x00001C02 { 220, 32, -508 }, // 0x00001C08 { 78, 2, -414 }, // 0x00001C0E { 74, 32, -425 }, // 0x00001C14 { -122, 2, -379 }, // 0x00001C1A { -122, 42, -379 }, // 0x00001C20 { -122, 42, -414 }, // 0x00001C26 { 78, 42, -379 }, // 0x00001C2C { 77, 42, -414 }, // 0x00001C32 { 78, 2, -379 }, // 0x00001C38 { -270, 42, -501 }, // 0x00001C3E { -361, 42, -659 }, // 0x00001C44 { -361, 42, -842 }, // 0x00001C4A { -269, 42, -999 }, // 0x00001C50 { -111, 42, -1090 }, // 0x00001C56 { 71, 42, -1089 }, // 0x00001C5C { 229, 42, -998 }, // 0x00001C62 { 71, 42, -1090 }, // 0x00001C68 { 320, 42, -840 }, // 0x00001C6E { 319, 42, -657 }, // 0x00001C74 { 228, 42, -500 }, // 0x00001C7A { 250, 42, -478 }, // 0x00001C80 { 250, 42, -477 }, // 0x00001C86 { 350, 42, -649 }, // 0x00001C8C { 350, 42, -848 }, // 0x00001C92 { 251, 42, -1020 }, // 0x00001C98 { 80, 42, -1120 }, // 0x00001C9E { -119, 42, -1120 }, // 0x00001CA4 { -291, 42, -1022 }, // 0x00001CAA { -391, 42, -850 }, // 0x00001CB0 { -392, 42, -651 }, // 0x00001CB6 { -293, 42, -479 }, // 0x00001CBC { 18, 20, 461 }, // 0x00001CC2 { -42, 20, 461 }, // 0x00001CC8 { -42, 120, 461 }, // 0x00001CCE { 18, 120, 461 }, // 0x00001CD4 { 284, -9, -712 }, // 0x00001CDA { 343, 11, -742 }, // 0x00001CE0 { 280, -9, -768 }, // 0x00001CE6 { 238, -25, -736 }, // 0x00001CEC { 151, -9, -998 }, // 0x00001CF2 { 161, 11, -1064 }, // 0x00001CF8 { 103, -9, -1027 }, // 0x00001CFE { 105, -25, -974 }, // 0x00001D04 { -152, -9, -1029 }, // 0x00001D0A { -209, 11, -1064 }, // 0x00001D10 { -199, -9, -997 }, // 0x00001D16 { -149, -25, -977 }, // 0x00001D1C { -324, -9, -777 }, // 0x00001D22 { -385, 11, -749 }, // 0x00001D28 { -323, -9, -720 }, // 0x00001D2E { -279, -25, -751 }, // 0x00001D34 { -196, -9, -504 }, // 0x00001D3A { -204, 11, -437 }, // 0x00001D40 { -147, -9, -475 }, // 0x00001D46 { -150, -25, -528 }, // 0x00001D4C { 98, -9, -472 }, // 0x00001D52 { 153, 11, -435 }, // 0x00001D58 { 146, -9, -502 }, // 0x00001D5E { 97, -25, -524 }, // 0x00001D64 }; CollisionHeader fairy_fountain_sceneCollisionHeader0x001D6C = { -392, -40, -1121, 350, 458, 461, 291, fairy_fountain_sceneCollisionHeader0x001D6C_vtx_00001698, 349, fairy_fountain_sceneCollisionHeader0x001D6C_polygons_000000C8, fairy_fountain_sceneCollisionHeader0x001D6C_polygonTypes_000000B8, &fairy_fountain_sceneCollisionHeader0x001D6C_camDataList_000000B0, 0, 0 }; static u32 pad1D98 = 0; static u32 pad1D9C = 0; u64 fairy_fountain_sceneTex_001DA0[] = { #include "assets/scenes/misc/fairy_fountain//fairy_fountain_sceneTex_001DA0.rgb5a1.inc.c" }; u64 fairy_fountain_sceneTex_002DA0[] = { #include "assets/scenes/misc/fairy_fountain//fairy_fountain_sceneTex_002DA0.rgb5a1.inc.c" }; u64 fairy_fountain_sceneTex_0035A0[] = { #include "assets/scenes/misc/fairy_fountain//fairy_fountain_sceneTex_0035A0.rgb5a1.inc.c" };
fc35f55d8784f1bc5e960c0f433a349948fdaa05
23ba742dbd55d9d2cef68e624f2d23e4fd76e8a3
/src/saiga/vulkan/svulkan.h
76391793b9bc2b4109660dd4406f1420d1d27cb1
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
darglein/saiga
a4026b86e7397266e5036294a6435d85657f39ee
7617871a8ccdde58847e4f6871bd527f32652a79
refs/heads/master
2023-08-17T03:33:44.387706
2023-08-15T14:54:47
2023-08-15T14:54:47
97,219,629
135
26
MIT
2023-02-13T16:24:21
2017-07-14T09:55:50
C++
UTF-8
C
false
false
474
h
svulkan.h
/** * Copyright (c) 2021 Darius Rückert * Licensed under the MIT License. * See LICENSE file for more information. */ #pragma once #include "saiga/config.h" #include "saiga/core/util/assert.h" #include "vulkan/vulkan.hpp" #ifdef SAIGA_ASSERTS # define CHECK_VK(_f) SAIGA_ASSERT((_f) == vk::Result::eSuccess) #else # define CHECK_VK(_f) (_f) #endif #ifndef SAIGA_USE_VULKAN # error Saiga was build without Vulkan. #endif #define SAIGA_VULKAN_INCLUDED
fc4a493e818207996e998b2cd1fce230c519e0ce
6601ed1b6c24e8b7e78312aeaadf816262c4bee3
/c/libelf/gelftrans.c
dcd0cdd3993c481e0d5ff2c430d5ebfb1cb8cdd1
[ "BSD-2-Clause" ]
permissive
t-crest/patmos
bb9764c5897ee8bbac2a336cb09d7bb77d54916a
c63dadffa3db2ad241c31ae6e952d6fe2298986a
refs/heads/master
2023-04-11T12:18:37.795018
2023-03-25T17:57:33
2023-03-25T17:57:33
1,500,522
108
90
BSD-2-Clause
2023-03-25T17:57:35
2011-03-19T17:01:39
VHDL
UTF-8
C
false
false
9,456
c
gelftrans.c
/* gelftrans.c - gelf_* translation functions. Copyright (C) 2000 - 2001 Michael Riepe This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include <private.h> #if __LIBELF64 #ifndef lint static const char rcsid[] = "@(#) $Id: gelftrans.c,v 1.10 2008/05/23 08:15:34 michael Exp $"; #endif /* lint */ #define check_and_copy(type, d, s, name, eret) \ do { \ if (sizeof((d)->name) < sizeof((s)->name) \ && (type)(s)->name != (s)->name) { \ seterr(ERROR_BADVALUE); \ return (eret); \ } \ (d)->name = (type)(s)->name; \ } while (0) /* * These macros are missing on some Linux systems */ #if !defined(ELF32_R_SYM) || !defined(ELF32_R_TYPE) || !defined(ELF32_R_INFO) # undef ELF32_R_SYM # undef ELF32_R_TYPE # undef ELF32_R_INFO # define ELF32_R_SYM(i) ((i)>>8) # define ELF32_R_TYPE(i) ((unsigned char)(i)) # define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t)) #endif /* !defined(...) */ #if !defined(ELF64_R_SYM) || !defined(ELF64_R_TYPE) || !defined(ELF64_R_INFO) # undef ELF64_R_SYM # undef ELF64_R_TYPE # undef ELF64_R_INFO # define ELF64_R_SYM(i) ((i)>>32) # define ELF64_R_TYPE(i) ((i)&0xffffffffL) # define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL)) #endif /* !defined(...) */ static char* get_addr_and_class(const Elf_Data *data, int ndx, Elf_Type type, unsigned *cls) { Scn_Data *sd = (Scn_Data*)data; Elf_Scn *scn; Elf *elf; size_t n; if (!sd) { return NULL; } elf_assert(sd->sd_magic == DATA_MAGIC); scn = sd->sd_scn; elf_assert(scn); elf_assert(scn->s_magic == SCN_MAGIC); elf = scn->s_elf; elf_assert(elf); elf_assert(elf->e_magic == ELF_MAGIC); if (elf->e_kind != ELF_K_ELF) { seterr(ERROR_NOTELF); return NULL; } if (!valid_class(elf->e_class)) { seterr(ERROR_UNKNOWN_CLASS); return NULL; } if (data->d_type != type) { seterr(ERROR_BADTYPE); return NULL; } n = _msize(elf->e_class, data->d_version, type); if (n == 0) { seterr(ERROR_UNIMPLEMENTED); return NULL; } if (ndx < 0 || data->d_size < (ndx + 1) * n) { seterr(ERROR_BADINDEX); return NULL; } if (!data->d_buf) { seterr(ERROR_NULLBUF); return NULL; } if (cls) { *cls = elf->e_class; } return (char*)data->d_buf + n * ndx; } GElf_Sym* gelf_getsym(Elf_Data *src, int ndx, GElf_Sym *dst) { GElf_Sym buf; unsigned cls; char *tmp; if (!dst) { dst = &buf; } tmp = get_addr_and_class(src, ndx, ELF_T_SYM, &cls); if (!tmp) { return NULL; } if (cls == ELFCLASS64) { *dst = *(Elf64_Sym*)tmp; } else if (cls == ELFCLASS32) { Elf32_Sym *src = (Elf32_Sym*)tmp; check_and_copy(GElf_Word, dst, src, st_name, NULL); check_and_copy(unsigned char, dst, src, st_info, NULL); check_and_copy(unsigned char, dst, src, st_other, NULL); check_and_copy(GElf_Half, dst, src, st_shndx, NULL); check_and_copy(GElf_Addr, dst, src, st_value, NULL); check_and_copy(GElf_Xword, dst, src, st_size, NULL); } else { seterr(ERROR_UNIMPLEMENTED); return NULL; } if (dst == &buf) { dst = (GElf_Sym*)malloc(sizeof(GElf_Sym)); if (!dst) { seterr(ERROR_MEM_SYM); return NULL; } *dst = buf; } return dst; } int gelf_update_sym(Elf_Data *dst, int ndx, GElf_Sym *src) { unsigned cls; char *tmp; tmp = get_addr_and_class(dst, ndx, ELF_T_SYM, &cls); if (!tmp) { return 0; } if (cls == ELFCLASS64) { *(Elf64_Sym*)tmp = *src; } else if (cls == ELFCLASS32) { Elf32_Sym *dst = (Elf32_Sym*)tmp; check_and_copy(Elf32_Word, dst, src, st_name, 0); check_and_copy(Elf32_Addr, dst, src, st_value, 0); check_and_copy(Elf32_Word, dst, src, st_size, 0); check_and_copy(unsigned char, dst, src, st_info, 0); check_and_copy(unsigned char, dst, src, st_other, 0); check_and_copy(Elf32_Half, dst, src, st_shndx, 0); } else { seterr(ERROR_UNIMPLEMENTED); return 0; } return 1; } GElf_Dyn* gelf_getdyn(Elf_Data *src, int ndx, GElf_Dyn *dst) { GElf_Dyn buf; unsigned cls; char *tmp; if (!dst) { dst = &buf; } tmp = get_addr_and_class(src, ndx, ELF_T_DYN, &cls); if (!tmp) { return NULL; } if (cls == ELFCLASS64) { *dst = *(Elf64_Dyn*)tmp; } else if (cls == ELFCLASS32) { Elf32_Dyn *src = (Elf32_Dyn*)tmp; check_and_copy(GElf_Sxword, dst, src, d_tag, NULL); check_and_copy(GElf_Xword, dst, src, d_un.d_val, NULL); } else { seterr(ERROR_UNIMPLEMENTED); return NULL; } if (dst == &buf) { dst = (GElf_Dyn*)malloc(sizeof(GElf_Dyn)); if (!dst) { seterr(ERROR_MEM_DYN); return NULL; } *dst = buf; } return dst; } int gelf_update_dyn(Elf_Data *dst, int ndx, GElf_Dyn *src) { unsigned cls; char *tmp; tmp = get_addr_and_class(dst, ndx, ELF_T_DYN, &cls); if (!tmp) { return 0; } if (cls == ELFCLASS64) { *(Elf64_Dyn*)tmp = *src; } else if (cls == ELFCLASS32) { Elf32_Dyn *dst = (Elf32_Dyn*)tmp; check_and_copy(Elf32_Sword, dst, src, d_tag, 0); check_and_copy(Elf32_Word, dst, src, d_un.d_val, 0); } else { seterr(ERROR_UNIMPLEMENTED); return 0; } return 1; } GElf_Rela* gelf_getrela(Elf_Data *src, int ndx, GElf_Rela *dst) { GElf_Rela buf; unsigned cls; char *tmp; if (!dst) { dst = &buf; } tmp = get_addr_and_class(src, ndx, ELF_T_RELA, &cls); if (!tmp) { return NULL; } if (cls == ELFCLASS64) { *dst = *(Elf64_Rela*)tmp; } else if (cls == ELFCLASS32) { Elf32_Rela *src = (Elf32_Rela*)tmp; check_and_copy(GElf_Addr, dst, src, r_offset, NULL); dst->r_info = ELF64_R_INFO((Elf64_Xword)ELF32_R_SYM(src->r_info), (Elf64_Xword)ELF32_R_TYPE(src->r_info)); check_and_copy(GElf_Sxword, dst, src, r_addend, NULL); } else { seterr(ERROR_UNIMPLEMENTED); return NULL; } if (dst == &buf) { dst = (GElf_Rela*)malloc(sizeof(GElf_Rela)); if (!dst) { seterr(ERROR_MEM_RELA); return NULL; } *dst = buf; } return dst; } int gelf_update_rela(Elf_Data *dst, int ndx, GElf_Rela *src) { unsigned cls; char *tmp; tmp = get_addr_and_class(dst, ndx, ELF_T_RELA, &cls); if (!tmp) { return 0; } if (cls == ELFCLASS64) { *(Elf64_Rela*)tmp = *src; } else if (cls == ELFCLASS32) { Elf32_Rela *dst = (Elf32_Rela*)tmp; check_and_copy(Elf32_Addr, dst, src, r_offset, 0); if (ELF64_R_SYM(src->r_info) > 0xffffffUL || ELF64_R_TYPE(src->r_info) > 0xffUL) { seterr(ERROR_BADVALUE); return 0; } dst->r_info = ELF32_R_INFO((Elf32_Word)ELF64_R_SYM(src->r_info), (Elf32_Word)ELF64_R_TYPE(src->r_info)); check_and_copy(Elf32_Sword, dst, src, r_addend, 0); } else { seterr(ERROR_UNIMPLEMENTED); return 0; } return 1; } GElf_Rel* gelf_getrel(Elf_Data *src, int ndx, GElf_Rel *dst) { GElf_Rel buf; unsigned cls; char *tmp; if (!dst) { dst = &buf; } tmp = get_addr_and_class(src, ndx, ELF_T_REL, &cls); if (!tmp) { return NULL; } if (cls == ELFCLASS64) { *dst = *(Elf64_Rel*)tmp; } else if (cls == ELFCLASS32) { Elf32_Rel *src = (Elf32_Rel*)tmp; check_and_copy(GElf_Addr, dst, src, r_offset, NULL); dst->r_info = ELF64_R_INFO((Elf64_Xword)ELF32_R_SYM(src->r_info), (Elf64_Xword)ELF32_R_TYPE(src->r_info)); } else { seterr(ERROR_UNIMPLEMENTED); return NULL; } if (dst == &buf) { dst = (GElf_Rel*)malloc(sizeof(GElf_Rel)); if (!dst) { seterr(ERROR_MEM_REL); return NULL; } *dst = buf; } return dst; } int gelf_update_rel(Elf_Data *dst, int ndx, GElf_Rel *src) { unsigned cls; char *tmp; tmp = get_addr_and_class(dst, ndx, ELF_T_REL, &cls); if (!tmp) { return 0; } if (cls == ELFCLASS64) { *(Elf64_Rel*)tmp = *src; } else if (cls == ELFCLASS32) { Elf32_Rel *dst = (Elf32_Rel*)tmp; check_and_copy(Elf32_Addr, dst, src, r_offset, 0); if (ELF64_R_SYM(src->r_info) > 0xffffffUL || ELF64_R_TYPE(src->r_info) > 0xffUL) { seterr(ERROR_BADVALUE); return 0; } dst->r_info = ELF32_R_INFO((Elf32_Word)ELF64_R_SYM(src->r_info), (Elf32_Word)ELF64_R_TYPE(src->r_info)); } else { seterr(ERROR_UNIMPLEMENTED); return 0; } return 1; } #if 0 GElf_Syminfo* gelf_getsyminfo(Elf_Data *src, int ndx, GElf_Syminfo *dst) { seterr(ERROR_UNIMPLEMENTED); return NULL; } int gelf_update_syminfo(Elf_Data *dst, int ndx, GElf_Syminfo *src) { seterr(ERROR_UNIMPLEMENTED); return 0; } GElf_Move* gelf_getmove(Elf_Data *src, int ndx, GElf_Move *src) { seterr(ERROR_UNIMPLEMENTED); return NULL; } int gelf_update_move(Elf_Data *dst, int ndx, GElf_Move *src) { seterr(ERROR_UNIMPLEMENTED); return 0; } #endif #endif /* __LIBELF64 */
ccafa2699f582daeb1d2b21800a038632b592947
ed3b24ae57df21a5b089148235dd1b6d728e56f3
/ld/unit-tests/test-cases/archive-force-load/bat.c
f5a7956997df2e94ebec7215b242d984eb874039
[ "APSL-2.0", "MIT" ]
permissive
michaeleisel/zld
36ce14511ca9e0a971a0ed614bbee5dac9bb6fa1
519197a3bf4dbe47ea5a3bbce609df166f6f976d
refs/heads/master
2023-08-23T13:46:50.509156
2023-02-15T06:02:03
2023-02-15T06:02:03
237,002,244
1,217
55
MIT
2023-02-15T06:00:43
2020-01-29T14:32:45
C++
UTF-8
C
false
false
14
c
bat.c
void bat() {}
a45cdd8bb9015b9e0e39f8a6a8dbfdde5b7f2450
c26d7b0ed875357278e61627da2da0650da77986
/sys/include/gpanel.h
6d5b7d0e70f79d74cf5b108956d9dedc3bbe3aff
[ "BSD-3-Clause" ]
permissive
RetroBSD/retrobsd
5343d9e3c424637fc3ad5b03fe720b2744490025
486f81f6abff01c7dcc207235cd2979b226a95ff
refs/heads/master
2023-09-02T23:12:05.110883
2023-07-07T18:41:40
2023-07-07T18:41:40
18,598,087
282
59
BSD-3-Clause
2023-07-18T07:35:36
2014-04-09T13:25:46
C
UTF-8
C
false
false
6,849
h
gpanel.h
/* * Generic interface to a graphics panel device (TFT LCD, OLED and others). * * Copyright (C) 2015 Serge Vakulenko, <serge@vak.ru> * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim 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, 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. */ #ifndef _GPANEL_H #define _GPANEL_H /* * Proportional/fixed font structure. */ struct gpanel_font_t { const char * name; /* font name */ int maxwidth; /* max width in pixels */ unsigned int height; /* height in pixels */ int ascent; /* ascent (baseline) height */ int firstchar; /* first character in bitmap */ int size; /* font size in characters */ const unsigned short *bits; /* 16-bit right-padded bitmap data */ const unsigned short *offset; /* offsets into bitmap data */ const unsigned char *width; /* character widths or 0 if fixed */ int defaultchar; /* default char (not glyph index) */ long bits_size; /* # words of bits */ }; struct gpanel_pixel_t { int color; /* pixel color */ int x, y; /* pixel position */ }; struct gpanel_clear_t { int color; /* pixel color */ int xsize, ysize; /* screen size */ }; struct gpanel_line_t { int color; /* line color */ int x0, y0; /* start point */ int x1, y1; /* end point */ }; struct gpanel_rect_t { int color; /* border or fill color */ int x0, y0; /* start point */ int x1, y1; /* end point */ }; struct gpanel_circle_t { int color; /* border color */ int x, y; /* center point */ int radius; /* circle radius */ }; struct gpanel_image_t { int x, y; /* start point */ int width, height; /* image size radius */ const unsigned short *image; /* array of pixels */ }; struct gpanel_char_t { const struct gpanel_font_t *font; /* font data */ int color; /* text color */ int background; /* background color or -1 for transparent */ int x, y; /* position */ int sym; /* unicode symbol index */ }; struct gpanel_text_t { const struct gpanel_font_t *font; /* font data */ int color; /* text color */ int background; /* background color or -1 for transparent */ int x, y; /* position */ const char *text; /* UTF-8 text */ }; #define GPANEL_CLEAR _IOW('g', 1, struct gpanel_clear_t) #define GPANEL_PIXEL _IOW('g', 2, struct gpanel_pixel_t) #define GPANEL_LINE _IOW('g', 3, struct gpanel_line_t) #define GPANEL_RECT _IOW('g', 4, struct gpanel_rect_t) #define GPANEL_FILL _IOW('g', 5, struct gpanel_rect_t) #define GPANEL_CIRCLE _IOW('g', 6, struct gpanel_circle_t) #define GPANEL_IMAGE _IOW('g', 7, struct gpanel_image_t) #define GPANEL_CHAR _IOW('g', 8, struct gpanel_char_t) #define GPANEL_TEXT _IOW('g', 9, struct gpanel_text_t) #ifndef KERNEL /* * User-level library. */ int gpanel_open(const char *devname); void gpanel_close(void); void gpanel_clear(int color, int *xsize, int *ysize); void gpanel_pixel(int color, int x, int y); void gpanel_line(int color, int x0, int y0, int x1, int y1); void gpanel_rect(int color, int x0, int y0, int x1, int y1); void gpanel_fill(int color, int x0, int y0, int x1, int y1); void gpanel_fill_triangle(int color, int x0, int y0, int x1, int y1, int x2, int y2); void gpanel_circle(int color, int x, int y, int radius); void gpanel_image(int x, int y, int width, int height, const unsigned short *data); void gpanel_char(const struct gpanel_font_t *font, int color, int background, int x, int y, int sym); void gpanel_text(const struct gpanel_font_t *font, int color, int background, int x, int y, const char *text); int gpanel_text_width(const struct gpanel_font_t *font, const char *text, int nchars); extern int _gpanel_fd; #else /* KERNEL */ /* * Kernel driver routines. */ struct uio; extern int gpanel_open(dev_t dev, int flag, int mode); extern int gpanel_close(dev_t dev, int flag, int mode); extern int gpanel_read(dev_t dev, struct uio *uio, int flag); extern int gpanel_write(dev_t dev, struct uio *uio, int flag); extern int gpanel_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag); extern int gpanel_read_byte(void); extern void gpanel_write_byte(int value); extern void gpanel_cs_active(void); extern void gpanel_cs_idle(void); extern void gpanel_rs_command(void); extern void gpanel_rs_data(void); extern void gpanel_wr_strobe(void); extern void gpanel_read_dir(void); extern void gpanel_write_dir(void); extern int gpanel_send_command(int value); extern int gpanel_send_data(int value); /* * Descriptor for access to the hardware-level driver. */ struct gpanel_hw { const char *name; void (*resize)(struct gpanel_hw *hw, int width, int height); void (*set_pixel)(int x, int y, int color); void (*fill_rectangle)(int x0, int y0, int x1, int y1, int color); void (*draw_image)(int x, int y, int width, int height, const unsigned short *data); void (*draw_glyph)(const struct gpanel_font_t *font, int color, int background, int x, int y, int width, const unsigned short *bits); }; extern int gpanel_width; extern int gpanel_height; extern void st7781_init_display(struct gpanel_hw *hw); extern void nt35702_init_display(struct gpanel_hw *hw); extern void ili9341_init_display(struct gpanel_hw *hw); extern void ili9481_init_display(struct gpanel_hw *hw); extern void s6d04h0_init_display(struct gpanel_hw *hw); #endif /* KERNEL */ #endif /* _GPANEL_H */
9ca470b234d0432942102e03151104d6aedfbb90
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/wasi/libc-top-half/musl/src/prng/drand48.c
08283e240b14fad45921469bc7aea39eadda3670
[ "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-musl-exception", "MIT", "LLVM-exception", "Apache-2.0", "NCSA" ]
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
278
c
drand48.c
#include <stdlib.h> #include <inttypes.h> #include "rand48.h" double erand48(unsigned short s[3]) { union { uint64_t u; double f; } x = { 0x3ff0000000000000ULL | __rand48_step(s, __seed48+3)<<4 }; return x.f - 1.0; } double drand48(void) { return erand48(__seed48); }
c7f27a16ec4e15d6d5ca92b56958fc02c4765e7e
ea8fc70c7dbf49059431fa45a940742736c68fb8
/ext/xhprof.h
cdfe8f2d79d1fbdf5bb30a33bc190170a7ca96bc
[ "BSD-3-Clause" ]
permissive
dreamsxin/cphalcon7
1bd2194a251657b48857326927db69fef617ab91
1b8c6b04b4ca237a5ead87d4752df0d2e85c7a9d
refs/heads/master
2023-03-08T04:53:08.829432
2022-07-07T07:48:59
2022-07-07T07:48:59
47,245,335
298
73
null
2021-06-22T11:53:25
2015-12-02T07:44:43
C
UTF-8
C
false
false
9,404
h
xhprof.h
/* +------------------------------------------------------------------------+ | Phalcon Framework | +------------------------------------------------------------------------+ | Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com) | +------------------------------------------------------------------------+ | This source file is subject to the New BSD License that is bundled | | with this package in the file docs/LICENSE.txt. | | | | If you did not receive a copy of the license and are unable to | | obtain it through the world-wide-web, please send an email | | to license@phalconphp.com so we can send you a copy immediately. | +------------------------------------------------------------------------+ | Authors: Andres Gutierrez <andres@phalconphp.com> | | Eduar Carvajal <eduar@phalconphp.com> | | ZhuZongXin <dreamsxin@qq.com> | +------------------------------------------------------------------------+ */ #ifndef PHALCON_XHPROF_H #define PHALCON_XHPROF_H #include "php_phalcon.h" #include "kernel/time.h" #define PHALCON_XHPROF_ROOT_SYMBOL "main()" #define PHALCON_XHPROF_FLAG_CPU 1 #define PHALCON_XHPROF_FLAG_MEMORY_MU 2 #define PHALCON_XHPROF_FLAG_MEMORY_PMU 4 #define PHALCON_XHPROF_FLAG_MEMORY 6 #define PHALCON_XHPROF_FLAG_MEMORY_ALLOC 16 #define PHALCON_XHPROF_FLAG_MEMORY_ALLOC_AS_MU (32|16) #define PHALCON_XHPROF_FLAG_NO_BUILTINS 8 ZEND_API void phalcon_xhprof_execute_internal(zend_execute_data *execute_data, zval *return_value); ZEND_API void phalcon_xhprof_execute_ex(zend_execute_data *execute_data); void tracing_callgraph_append_to_array(zval *return_value, zend_long flags); void tracing_callgraph_get_parent_child_name(xhprof_callgraph_bucket *bucket, char *symbol, size_t symbol_len); zend_ulong tracing_callgraph_bucket_key(xhprof_frame_t *frame); xhprof_callgraph_bucket *tracing_callgraph_bucket_find(xhprof_callgraph_bucket *bucket, xhprof_frame_t *current_frame, xhprof_frame_t *previous, zend_long key); void tracing_callgraph_bucket_free(xhprof_callgraph_bucket *bucket); void tracing_begin(zend_long flags); void tracing_end(); void tracing_enter_root_frame(); void tracing_request_init(); void tracing_request_shutdown(); void tracing_determine_clock_source(); static zend_always_inline void tracing_fast_free_frame(xhprof_frame_t *p) { if (p->function_name != NULL) { zend_string_release(p->function_name); } if (p->class_name != NULL) { zend_string_release(p->class_name); } /* we use/overload the previous_frame field in the structure to link entries in * the free list. */ p->previous_frame = TXRG(frame_free_list); TXRG(frame_free_list) = p; } static zend_always_inline xhprof_frame_t* tracing_fast_alloc_frame() { xhprof_frame_t *p; p = TXRG(frame_free_list); if (p) { TXRG(frame_free_list) = p->previous_frame; return p; } else { return (xhprof_frame_t *)emalloc(sizeof(xhprof_frame_t)); } } static zend_always_inline zend_string* tracing_get_class_name(zend_execute_data *data) { zend_function *curr_func; if (!data) { return NULL; } curr_func = data->func; if (curr_func->common.scope != NULL) { zend_string_addref(curr_func->common.scope->name); return curr_func->common.scope->name; } return NULL; } static zend_always_inline zend_string* tracing_get_function_name(zend_execute_data *data) { zend_function *curr_func; if (!data) { return NULL; } curr_func = data->func; if (!curr_func->common.function_name) { // This branch includes execution of eval and include/require(_once) calls // We assume it is not 1999 anymore and not much PHP code runs in the // body of a file and if it is, we are ok with adding it to the caller's wt. return NULL; } zend_string_addref(curr_func->common.function_name); return curr_func->common.function_name; } zend_always_inline static int tracing_enter_frame_callgraph(zend_string *root_symbol, zend_execute_data *execute_data) { zend_string *function_name = (root_symbol != NULL) ? zend_string_copy(root_symbol) : tracing_get_function_name(execute_data); xhprof_frame_t *current_frame; xhprof_frame_t *p; int recurse_level = 0; if (function_name == NULL) { return 0; } current_frame = tracing_fast_alloc_frame(); current_frame->class_name = (root_symbol == NULL) ? tracing_get_class_name(execute_data) : NULL; current_frame->function_name = function_name; current_frame->previous_frame = TXRG(callgraph_frames); current_frame->recurse_level = 0; current_frame->wt_start = phalcon_time_milliseconds(TXRG(clock_source), TXRG(timebase_factor)); if (TXRG(flags) & PHALCON_XHPROF_FLAG_CPU) { current_frame->cpu_start = phalcon_cpu_timer(); } if (TXRG(flags) & PHALCON_XHPROF_FLAG_MEMORY_PMU) { current_frame->pmu_start = zend_memory_peak_usage(0); } if ((TXRG(flags) & PHALCON_XHPROF_FLAG_MEMORY_MU) || (TXRG(flags) & PHALCON_XHPROF_FLAG_MEMORY_ALLOC_AS_MU)) { current_frame->mu_start = zend_memory_usage(0); } current_frame->num_alloc = TXRG(num_alloc); current_frame->num_free = TXRG(num_free); current_frame->amount_alloc = TXRG(amount_alloc); /* We only need to compute the hash for the function name, * that should be "good" enough, we sort into 1024 buckets only anyways */ current_frame->hash_code = ZSTR_HASH(function_name) % PHALCON_XHPROF_CALLGRAPH_COUNTER_SIZE; /* Update entries linked list */ TXRG(callgraph_frames) = current_frame; if (TXRG(function_hash_counters)[current_frame->hash_code] > 0) { /* Find this symbols recurse level */ for(p = current_frame->previous_frame; p; p = p->previous_frame) { if (zend_string_equals(current_frame->function_name, p->function_name) && (!current_frame->class_name || current_frame->class_name == p->class_name)) { recurse_level = (p->recurse_level) + 1; break; } } } TXRG(function_hash_counters)[current_frame->hash_code]++; /* Init current function's recurse level */ current_frame->recurse_level = recurse_level; return 1; } zend_always_inline static void tracing_exit_frame_callgraph() { xhprof_frame_t *current_frame = TXRG(callgraph_frames); xhprof_frame_t *previous = current_frame->previous_frame; zend_long duration = phalcon_time_milliseconds(TXRG(clock_source), TXRG(timebase_factor)) - current_frame->wt_start; zend_ulong key = tracing_callgraph_bucket_key(current_frame); unsigned int slot = (unsigned int)key % PHALCON_XHPROF_CALLGRAPH_SLOTS; xhprof_callgraph_bucket *bucket = TXRG(callgraph_buckets)[slot]; bucket = tracing_callgraph_bucket_find(bucket, current_frame, previous, key); if (bucket == NULL) { bucket = emalloc(sizeof(xhprof_callgraph_bucket)); bucket->key = key; bucket->child_class = current_frame->class_name ? zend_string_copy(current_frame->class_name) : NULL; bucket->child_function = zend_string_copy(current_frame->function_name); if (previous) { bucket->parent_class = previous->class_name ? zend_string_copy(current_frame->previous_frame->class_name) : NULL; bucket->parent_function = zend_string_copy(previous->function_name); bucket->parent_recurse_level = previous->recurse_level; } else { bucket->parent_class = NULL; bucket->parent_function = NULL; bucket->parent_recurse_level = 0; } bucket->count = 0; bucket->wall_time = 0; bucket->cpu_time = 0; bucket->memory = 0; bucket->memory_peak = 0; bucket->num_alloc = 0; bucket->num_free = 0; bucket->amount_alloc = 0; bucket->child_recurse_level = current_frame->recurse_level; bucket->next = TXRG(callgraph_buckets)[slot]; TXRG(callgraph_buckets)[slot] = bucket; } bucket->count++; bucket->wall_time += duration; bucket->num_alloc += TXRG(num_alloc) - current_frame->num_alloc; bucket->num_free += TXRG(num_free) - current_frame->num_free; bucket->amount_alloc += TXRG(amount_alloc) - current_frame->amount_alloc; if (TXRG(flags) & PHALCON_XHPROF_FLAG_CPU) { bucket->cpu_time += (phalcon_cpu_timer() - current_frame->cpu_start); } if ((TXRG(flags) & PHALCON_XHPROF_FLAG_MEMORY_MU) || (TXRG(flags) & PHALCON_XHPROF_FLAG_MEMORY_ALLOC_AS_MU)) { bucket->memory += (zend_memory_usage(0) - current_frame->mu_start); } if (TXRG(flags) & PHALCON_XHPROF_FLAG_MEMORY_PMU) { bucket->memory_peak += (zend_memory_peak_usage(0) - current_frame->pmu_start); } TXRG(function_hash_counters)[current_frame->hash_code]--; TXRG(callgraph_frames) = TXRG(callgraph_frames)->previous_frame; tracing_fast_free_frame(current_frame); } extern zend_class_entry *phalcon_xhprof_ce; PHALCON_INIT_CLASS(Phalcon_Xhprof); #endif /* PHALCON_XHPROF_H */
8fe986eae0505a714b6e9b4ed47168b6b66ee276
fbe68d84e97262d6d26dd65c704a7b50af2b3943
/third_party/virtualbox/src/VBox/Additions/x11/x11include/xorg-server-1.4.2/xaalocal.h
c365a7de35ed59b409dc1a3d10f511ee68c6e900
[ "MIT", "GPL-2.0-only", "LicenseRef-scancode-unknown-license-reference", "CDDL-1.0", "LicenseRef-scancode-warranty-disclaimer", "GPL-1.0-or-later", "LGPL-2.1-or-later", "GPL-2.0-or-later", "MPL-1.0", "LicenseRef-scancode-generic-exception", "Apache-2.0", "OpenSSL" ]
permissive
thalium/icebox
c4e6573f2b4f0973b6c7bb0bf068fe9e795fdcfb
6f78952d58da52ea4f0e55b2ab297f28e80c1160
refs/heads/master
2022-08-14T00:19:36.984579
2022-02-22T13:10:31
2022-02-22T13:10:31
190,019,914
585
109
MIT
2022-01-13T20:58:15
2019-06-03T14:18:12
C++
UTF-8
C
false
false
35,119
h
xaalocal.h
#ifndef _XAALOCAL_H #define _XAALOCAL_H /* This file is very unorganized ! */ #include "gcstruct.h" #include "regionstr.h" #include "xf86fbman.h" #include "xaa.h" #include "mi.h" #ifdef RENDER #include "picturestr.h" #endif #define GCWhenForced (GCArcMode << 1) #define DO_COLOR_8x8 0x00000001 #define DO_MONO_8x8 0x00000002 #define DO_CACHE_BLT 0x00000003 #define DO_COLOR_EXPAND 0x00000004 #define DO_CACHE_EXPAND 0x00000005 #define DO_IMAGE_WRITE 0x00000006 #define DO_PIXMAP_COPY 0x00000007 #define DO_SOLID 0x00000008 typedef CARD32 * (*GlyphScanlineFuncPtr)( CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width ); typedef CARD32 *(*StippleScanlineProcPtr)(CARD32*, CARD32*, int, int, int); typedef void (*RectFuncPtr) (ScrnInfoPtr, int, int, int, int, int, int, XAACacheInfoPtr); typedef void (*TrapFuncPtr) (ScrnInfoPtr, int, int, int, int, int, int, int, int, int, int, int, int, XAACacheInfoPtr); typedef struct _XAAScreen { CreateGCProcPtr CreateGC; CloseScreenProcPtr CloseScreen; GetImageProcPtr GetImage; GetSpansProcPtr GetSpans; PaintWindowBackgroundProcPtr PaintWindowBackground; PaintWindowBorderProcPtr PaintWindowBorder; CopyWindowProcPtr CopyWindow; WindowExposuresProcPtr WindowExposures; BSFuncRec BackingStoreFuncs; CreatePixmapProcPtr CreatePixmap; DestroyPixmapProcPtr DestroyPixmap; ChangeWindowAttributesProcPtr ChangeWindowAttributes; XAAInfoRecPtr AccelInfoRec; Bool (*EnterVT)(int, int); void (*LeaveVT)(int, int); int (*SetDGAMode)(int, int, DGADevicePtr); void (*EnableDisableFBAccess)(int, Bool); #ifdef RENDER CompositeProcPtr Composite; GlyphsProcPtr Glyphs; #endif } XAAScreenRec, *XAAScreenPtr; #define OPS_ARE_PIXMAP 0x00000001 #define OPS_ARE_ACCEL 0x00000002 typedef struct _XAAGC { GCOps *wrapOps; GCFuncs *wrapFuncs; GCOps *XAAOps; int DashLength; unsigned char* DashPattern; unsigned long changes; unsigned long flags; } XAAGCRec, *XAAGCPtr; #define REDUCIBILITY_CHECKED 0x00000001 #define REDUCIBLE_TO_8x8 0x00000002 #define REDUCIBLE_TO_2_COLOR 0x00000004 #define DIRTY 0x00010000 #define OFFSCREEN 0x00020000 #define DGA_PIXMAP 0x00040000 #define SHARED_PIXMAP 0x00080000 #define LOCKED_PIXMAP 0x00100000 #define REDUCIBILITY_MASK \ (REDUCIBILITY_CHECKED | REDUCIBLE_TO_8x8 | REDUCIBLE_TO_2_COLOR) typedef struct _XAAPixmap { unsigned long flags; CARD32 pattern0; CARD32 pattern1; int fg; int bg; FBAreaPtr offscreenArea; Bool freeData; } XAAPixmapRec, *XAAPixmapPtr; Bool XAACreateGC( GCPtr pGC ); Bool XAAInitAccel( ScreenPtr pScreen, XAAInfoRecPtr infoRec ); RegionPtr XAABitBlt( DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty, void (*doBitBlt)(DrawablePtr, DrawablePtr, GCPtr, RegionPtr, DDXPointPtr), unsigned long bitPlane ); void XAAScreenToScreenBitBlt( ScrnInfoPtr pScrn, int nbox, DDXPointPtr pptSrc, BoxPtr pbox, int xdir, int ydir, int alu, unsigned int planemask ); void XAADoBitBlt( DrawablePtr pSrc, DrawablePtr pDst, GC *pGC, RegionPtr prgnDst, DDXPointPtr pptSrc ); void XAADoImageWrite( DrawablePtr pSrc, DrawablePtr pDst, GC *pGC, RegionPtr prgnDst, DDXPointPtr pptSrc ); void XAADoImageRead( DrawablePtr pSrc, DrawablePtr pDst, GC *pGC, RegionPtr prgnDst, DDXPointPtr pptSrc ); void XAACopyWindow( WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc ); RegionPtr XAACopyArea( DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty ); void XAAValidateCopyArea( GCPtr pGC, unsigned long changes, DrawablePtr pDraw ); void XAAValidatePutImage( GCPtr pGC, unsigned long changes, DrawablePtr pDraw ); void XAAValidateCopyPlane( GCPtr pGC, unsigned long changes, DrawablePtr pDraw ); void XAAValidatePushPixels( GCPtr pGC, unsigned long changes, DrawablePtr pDraw ); void XAAValidateFillSpans( GCPtr pGC, unsigned long changes, DrawablePtr pDraw ); void XAAValidatePolyGlyphBlt( GCPtr pGC, unsigned long changes, DrawablePtr pDraw ); void XAAValidateImageGlyphBlt( GCPtr pGC, unsigned long changes, DrawablePtr pDraw ); void XAAValidatePolylines( GCPtr pGC, unsigned long changes, DrawablePtr pDraw ); RegionPtr XAACopyPlaneColorExpansion( DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty, unsigned long bitPlane ); void XAAPushPixelsSolidColorExpansion( GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg ); void XAAWriteBitmapColorExpandMSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapColorExpand3MSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapColorExpandMSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapColorExpand3MSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapColorExpandLSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapColorExpand3LSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapColorExpandLSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapColorExpand3LSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapScanlineColorExpandMSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapScanlineColorExpand3MSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapScanlineColorExpandMSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapScanlineColorExpand3MSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapScanlineColorExpandLSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapScanlineColorExpand3LSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapScanlineColorExpandLSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWriteBitmapScanlineColorExpand3LSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int skipleft, int fg, int bg, int rop, unsigned int planemask ); void XAAWritePixmap ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int rop, unsigned int planemask, int transparency_color, int bpp, int depth ); void XAAWritePixmapScanline ( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int rop, unsigned int planemask, int transparency_color, int bpp, int depth ); typedef void (*ClipAndRenderRectsFunc)(GCPtr, int, BoxPtr, int, int); void XAAClipAndRenderRects( GCPtr pGC, ClipAndRenderRectsFunc func, int nrectFill, xRectangle *prectInit, int xorg, int yorg ); typedef void (*ClipAndRenderSpansFunc)(GCPtr, int, DDXPointPtr, int*, int, int, int); void XAAClipAndRenderSpans( GCPtr pGC, DDXPointPtr ppt, int *pwidth, int nspans, int fSorted, ClipAndRenderSpansFunc func, int xorg, int yorg ); void XAAFillSolidRects( ScrnInfoPtr pScrn, int fg, int rop, unsigned int planemask, int nBox, BoxPtr pBox ); void XAAFillMono8x8PatternRects( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int pat0, int pat1, int xorg, int yorg ); void XAAFillMono8x8PatternRectsScreenOrigin( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int pat0, int pat1, int xorg, int yorg ); void XAAFillColor8x8PatternRectsScreenOrigin( ScrnInfoPtr pScrn, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorigin, int yorigin, XAACacheInfoPtr pCache ); void XAAFillColor8x8PatternRects( ScrnInfoPtr pScrn, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorigin, int yorigin, XAACacheInfoPtr pCache ); void XAAFillCacheBltRects( ScrnInfoPtr pScrn, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, XAACacheInfoPtr pCache ); void XAAFillCacheExpandRects( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillImageWriteRects( ScrnInfoPtr pScrn, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAPolyFillRect( DrawablePtr pDraw, GCPtr pGC, int nrectFill, xRectangle *prectInit ); void XAATEGlyphRendererMSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRenderer3MSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRendererMSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRenderer3MSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRendererLSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRenderer3LSBFirstFixedBase ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRendererLSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRenderer3LSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRendererScanlineMSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRendererScanline3MSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRendererScanlineLSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); void XAATEGlyphRendererScanline3LSBFirst ( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft, int startline, unsigned int **glyphs, int glyphWidth, int fg, int bg, int rop, unsigned planemask ); extern CARD32 *(*XAAGlyphScanlineFuncMSBFirstFixedBase[32])( CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width ); extern CARD32 *(*XAAGlyphScanlineFuncMSBFirst[32])( CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width ); extern CARD32 *(*XAAGlyphScanlineFuncLSBFirstFixedBase[32])( CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width ); extern CARD32 *(*XAAGlyphScanlineFuncLSBFirst[32])( CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width ); GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirstFixedBase(void); GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirst(void); GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirstFixedBase(void); GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirst(void); void XAAFillColorExpandRectsLSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandRects3LSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandRectsLSBFirstFixedBase( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandRects3LSBFirstFixedBase( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandRectsMSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandRects3MSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandRectsMSBFirstFixedBase( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandRects3MSBFirstFixedBase( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillScanlineColorExpandRectsLSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillScanlineColorExpandRects3LSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillScanlineColorExpandRectsMSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillScanlineColorExpandRects3MSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int nBox, BoxPtr pBox, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandSpansLSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandSpans3LSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandSpansLSBFirstFixedBase( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandSpans3LSBFirstFixedBase( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandSpansMSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandSpans3MSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandSpansMSBFirstFixedBase( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillColorExpandSpans3MSBFirstFixedBase( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillScanlineColorExpandSpansLSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillScanlineColorExpandSpans3LSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAPutImage( DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y, int w, int h, int leftPad, int format, char *pImage ); void XAAFillScanlineColorExpandSpansMSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillScanlineColorExpandSpans3MSBFirst( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); extern CARD32 *(*XAAStippleScanlineFuncMSBFirstFixedBase[6])( CARD32* base, CARD32* src, int offset, int width, int dwords ); extern CARD32 *(*XAAStippleScanlineFuncMSBFirst[6])( CARD32* base, CARD32* src, int offset, int width, int dwords ); extern CARD32 *(*XAAStippleScanlineFuncLSBFirstFixedBase[6])( CARD32* base, CARD32* src, int offset, int width, int dwords ); extern CARD32 *(*XAAStippleScanlineFuncLSBFirst[6])( CARD32* base, CARD32* src, int offset, int width, int dwords ); StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirstFixedBase(void); StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirst(void); StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirstFixedBase(void); StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirst(void); int XAAPolyText8TEColorExpansion( DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, char *chars ); int XAAPolyText16TEColorExpansion( DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, unsigned short *chars ); void XAAImageText8TEColorExpansion( DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, char *chars ); void XAAImageText16TEColorExpansion( DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, unsigned short *chars ); void XAAImageGlyphBltTEColorExpansion( DrawablePtr pDrawable, GCPtr pGC, int xInit, int yInit, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase ); void XAAPolyGlyphBltTEColorExpansion( DrawablePtr pDrawable, GCPtr pGC, int xInit, int yInit, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase ); int XAAPolyText8NonTEColorExpansion( DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, char *chars ); int XAAPolyText16NonTEColorExpansion( DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, unsigned short *chars ); void XAAImageText8NonTEColorExpansion( DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, char *chars ); void XAAImageText16NonTEColorExpansion( DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, unsigned short *chars ); void XAAImageGlyphBltNonTEColorExpansion( DrawablePtr pDrawable, GCPtr pGC, int xInit, int yInit, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase ); void XAAPolyGlyphBltNonTEColorExpansion( DrawablePtr pDrawable, GCPtr pGC, int xInit, int yInit, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase ); void XAANonTEGlyphRenderer( ScrnInfoPtr pScrn, int x, int y, int n, NonTEGlyphPtr glyphs, BoxPtr pbox, int fg, int rop, unsigned int planemask ); void XAAFillSolidSpans( ScrnInfoPtr pScrn, int fg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted ); void XAAFillMono8x8PatternSpans( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int patx, int paty, int xorg, int yorg ); void XAAFillMono8x8PatternSpansScreenOrigin( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int patx, int paty, int xorg, int yorg ); void XAAFillColor8x8PatternSpansScreenOrigin( ScrnInfoPtr pScrn, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, XAACacheInfoPtr, int xorigin, int yorigin ); void XAAFillColor8x8PatternSpans( ScrnInfoPtr pScrn, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, XAACacheInfoPtr, int xorigin, int yorigin ); void XAAFillCacheBltSpans( ScrnInfoPtr pScrn, int rop, unsigned int planemask, int n, DDXPointPtr points, int *widths, int fSorted, XAACacheInfoPtr pCache, int xorg, int yorg ); void XAAFillCacheExpandSpans( ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int n, DDXPointPtr ppt, int *pwidth, int fSorted, int xorg, int yorg, PixmapPtr pPix ); void XAAFillSpans( DrawablePtr pDrawable, GC *pGC, int nInit, DDXPointPtr pptInit, int *pwidth, int fSorted ); void XAAInitPixmapCache( ScreenPtr pScreen, RegionPtr areas, pointer data ); void XAAWriteBitmapToCache( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int fg, int bg ); void XAAWriteBitmapToCacheLinear( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int fg, int bg ); void XAAWritePixmapToCache( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int bpp, int depth ); void XAAWritePixmapToCacheLinear( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int bpp, int depth ); void XAAPaintWindow( WindowPtr pWin, RegionPtr prgn, int what ); void XAASolidHorVertLineAsRects( ScrnInfoPtr pScrn, int x, int y, int len, int dir ); void XAASolidHorVertLineAsTwoPoint( ScrnInfoPtr pScrn, int x, int y, int len, int dir ); void XAASolidHorVertLineAsBresenham( ScrnInfoPtr pScrn, int x, int y, int len, int dir ); void XAAPolyRectangleThinSolid( DrawablePtr pDrawable, GCPtr pGC, int nRectsInit, xRectangle *pRectsInit ); void XAAPolylinesWideSolid ( DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr pPts ); void XAAFillPolygonSolid( DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, int count, DDXPointPtr ptsIn ); void XAAFillPolygonStippled( DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, int count, DDXPointPtr ptsIn ); void XAAFillPolygonTiled( DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, int count, DDXPointPtr ptsIn ); int XAAIsEasyPolygon( DDXPointPtr ptsIn, int count, BoxPtr extents, int origin, DDXPointPtr *topPoint, int *topY, int *bottomY, int shape ); void XAAFillPolygonHelper( ScrnInfoPtr pScrn, DDXPointPtr ptsIn, int count, DDXPointPtr topPoint, int y, int maxy, int origin, RectFuncPtr RectFunc, TrapFuncPtr TrapFunc, int xorg, int yorg, XAACacheInfoPtr pCache ); void XAAPolySegment( DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSeg ); void XAAPolyLines( DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit ); void XAAPolySegmentDashed( DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSeg ); void XAAPolyLinesDashed( DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit ); void XAAWriteMono8x8PatternToCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache); void XAAWriteColor8x8PatternToCache( ScrnInfoPtr pScrn, PixmapPtr pPix, XAACacheInfoPtr pCache ); void XAARotateMonoPattern( int *pat0, int *pat1, int xoffset, int yoffset, Bool msbfirst ); void XAAComputeDash(GCPtr pGC); void XAAMoveDWORDS_FixedBase( register CARD32* dest, register CARD32* src, register int dwords ); void XAAMoveDWORDS_FixedSrc( register CARD32* dest, register CARD32* src, register int dwords ); void XAAMoveDWORDS( register CARD32* dest, register CARD32* src, register int dwords ); int XAAGetRectClipBoxes( GCPtr pGC, BoxPtr pboxClippedBase, int nrectFill, xRectangle *prectInit ); void XAASetupOverlay8_32Planar(ScreenPtr); void XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs); XAACacheInfoPtr XAACacheTile(ScrnInfoPtr Scrn, PixmapPtr pPix); XAACacheInfoPtr XAACacheMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix); XAACacheInfoPtr XAACachePlanarMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix); typedef XAACacheInfoPtr (*XAACachePlanarMonoStippleProc)(ScrnInfoPtr, PixmapPtr); XAACachePlanarMonoStippleProc XAAGetCachePlanarMonoStipple(void); XAACacheInfoPtr XAACacheStipple(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg); XAACacheInfoPtr XAACacheMono8x8Pattern(ScrnInfoPtr Scrn, int pat0, int pat1); XAACacheInfoPtr XAACacheColor8x8Pattern(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg); void XAATileCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache, int w, int h); void XAAClosePixmapCache(ScreenPtr pScreen); void XAAInvalidatePixmapCache(ScreenPtr pScreen); Bool XAACheckStippleReducibility(PixmapPtr pPixmap); Bool XAACheckTileReducibility(PixmapPtr pPixmap, Bool checkMono); int XAAStippledFillChooser(GCPtr pGC); int XAAOpaqueStippledFillChooser(GCPtr pGC); int XAATiledFillChooser(GCPtr pGC); void XAAMoveInOffscreenPixmaps(ScreenPtr pScreen); void XAAMoveOutOffscreenPixmaps(ScreenPtr pScreen); void XAARemoveAreaCallback(FBAreaPtr area); void XAAMoveOutOffscreenPixmap(PixmapPtr pPix); Bool XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec); #ifdef RENDER void XAAComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); Bool XAADoComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); void XAAGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr *glyphs); Bool XAADoGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr *glyphs); /* helpers */ void XAA_888_plus_PICT_a8_to_8888 ( CARD32 color, CARD8 *alphaPtr, /* in bytes */ int alphaPitch, CARD32 *dstPtr, int dstPitch, /* in dwords */ int width, int height ); Bool XAAGetRGBAFromPixel( CARD32 pixel, CARD16 *red, CARD16 *green, CARD16 *blue, CARD16 *alpha, CARD32 format ); Bool XAAGetPixelFromRGBA ( CARD32 *pixel, CARD16 red, CARD16 green, CARD16 blue, CARD16 alpha, CARD32 format ); #endif /* XXX should be static */ extern GCOps XAAFallbackOps; extern GCOps *XAAGetFallbackOps(void); extern GCFuncs XAAGCFuncs; extern int XAAGetScreenIndex(void); extern int XAAGetGCIndex(void); extern int XAAGetPixmapIndex(void); extern unsigned int XAAShiftMasks[32]; extern unsigned int byte_expand3[256], byte_reversed_expand3[256]; CARD32 XAAReverseBitOrder(CARD32 data); #define GET_XAASCREENPTR_FROM_SCREEN(pScreen)\ (pScreen)->devPrivates[XAAGetScreenIndex()].ptr #define GET_XAASCREENPTR_FROM_GC(pGC)\ (pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr #define GET_XAASCREENPTR_FROM_DRAWABLE(pDraw)\ (pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr #define GET_XAAINFORECPTR_FROM_SCREEN(pScreen)\ ((XAAScreenPtr)((pScreen)->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_GC(pGC)\ ((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_DRAWABLE(pDraw)\ ((XAAScreenPtr)((pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn)\ ((XAAScreenPtr)((pScrn)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec #define XAA_GET_PIXMAP_PRIVATE(pix)\ (XAAPixmapPtr)((pix)->devPrivates[XAAGetPixmapIndex()].ptr) #define CHECK_RGB_EQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) #define CHECK_FG(pGC, flags) \ (!(flags & RGB_EQUAL) || CHECK_RGB_EQUAL(pGC->fgPixel)) #define CHECK_BG(pGC, flags) \ (!(flags & RGB_EQUAL) || CHECK_RGB_EQUAL(pGC->bgPixel)) #define CHECK_ROP(pGC, flags) \ (!(flags & GXCOPY_ONLY) || (pGC->alu == GXcopy)) #define CHECK_ROPSRC(pGC, flags) \ (!(flags & ROP_NEEDS_SOURCE) || ((pGC->alu != GXclear) && \ (pGC->alu != GXnoop) && (pGC->alu != GXinvert) && \ (pGC->alu != GXset))) #define CHECK_PLANEMASK(pGC, flags) \ (!(flags & NO_PLANEMASK) || \ ((pGC->planemask & infoRec->FullPlanemasks[pGC->depth - 1]) == \ infoRec->FullPlanemasks[pGC->depth - 1])) #define CHECK_COLORS(pGC, flags) \ (!(flags & RGB_EQUAL) || \ (CHECK_RGB_EQUAL(pGC->fgPixel) && CHECK_RGB_EQUAL(pGC->bgPixel))) #define CHECK_NO_GXCOPY(pGC, flags) \ ((pGC->alu != GXcopy) || !(flags & NO_GXCOPY) || \ ((pGC->planemask & infoRec->FullPlanemask) != infoRec->FullPlanemask)) #define IS_OFFSCREEN_PIXMAP(pPix)\ ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->offscreenArea) #define PIXMAP_IS_SHARED(pPix)\ ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->flags & SHARED_PIXMAP) #define OFFSCREEN_PIXMAP_LOCKED(pPix)\ ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->flags & LOCKED_PIXMAP) #define XAA_DEPTH_BUG(pGC) \ ((pGC->depth == 32) && (pGC->bgPixel == 0xffffffff)) #define DELIST_OFFSCREEN_PIXMAP(pPix) { \ PixmapLinkPtr _pLink, _prev; \ _pLink = infoRec->OffscreenPixmaps; \ _prev = NULL; \ while(_pLink) { \ if(_pLink->pPix == pPix) { \ if(_prev) _prev->next = _pLink->next; \ else infoRec->OffscreenPixmaps = _pLink->next; \ xfree(_pLink); \ break; \ } \ _prev = _pLink; \ _pLink = _pLink->next; \ }} #define SWAP_BITS_IN_BYTES(v) \ (((0x01010101 & (v)) << 7) | ((0x02020202 & (v)) << 5) | \ ((0x04040404 & (v)) << 3) | ((0x08080808 & (v)) << 1) | \ ((0x10101010 & (v)) >> 1) | ((0x20202020 & (v)) >> 3) | \ ((0x40404040 & (v)) >> 5) | ((0x80808080 & (v)) >> 7)) /* * Moved XAAPixmapCachePrivate here from xaaPCache.c, since driver * replacements for CacheMonoStipple need access to it */ typedef struct { int Num512x512; int Current512; XAACacheInfoPtr Info512; int Num256x256; int Current256; XAACacheInfoPtr Info256; int Num128x128; int Current128; XAACacheInfoPtr Info128; int NumMono; int CurrentMono; XAACacheInfoPtr InfoMono; int NumColor; int CurrentColor; XAACacheInfoPtr InfoColor; int NumPartial; int CurrentPartial; XAACacheInfoPtr InfoPartial; DDXPointRec MonoOffsets[64]; DDXPointRec ColorOffsets[64]; } XAAPixmapCachePrivate, *XAAPixmapCachePrivatePtr; #endif /* _XAALOCAL_H */
3cc9b8bb88a8e863183ae8b15d98c5ee16684a46
1db673907c7946c2ea857cc9aa8b6f7f4060e36a
/Module/libbmp/libbmp/libbmp.h
074fccd435ac0cfa58ec5274a3f8241a3ed3de8d
[ "BSD-3-Clause" ]
permissive
pdpdds/SkyOS
a973cd9f1b4e541ae4ac26d19df29aa3f4110db3
db2ce044c581fc2dfe068723fb0be2336c7f18d9
refs/heads/master
2023-07-21T15:24:46.457637
2023-07-17T16:32:04
2023-07-17T16:32:04
97,029,119
160
49
null
2023-04-30T15:33:47
2017-07-12T16:23:01
C
UTF-8
C
false
false
2,277
h
libbmp.h
#ifndef __LIBBMP_H__ #define __LIBBMP_H__ #include "SkyInterface.h" #define BMP_MAGIC 19778 #define BMP_GET_PADDING(a) ((a) % 4) enum bmp_error { BMP_FILE_NOT_OPENED = -4, BMP_HEADER_NOT_INITIALIZED, BMP_INVALID_FILE, BMP_ERROR, BMP_OK = 0 }; typedef struct _bmp_header { unsigned int bfSize; unsigned int bfReserved; unsigned int bfOffBits; unsigned int biSize; int biWidth; int biHeight; unsigned short biPlanes; unsigned short biBitCount; unsigned int biCompression; unsigned int biSizeImage; int biXPelsPerMeter; int biYPelsPerMeter; unsigned int biClrUsed; unsigned int biClrImportant; } bmp_header; typedef struct _bmp_pixel { unsigned char blue; unsigned char green; unsigned char red; } bmp_pixel; // This is faster than a function call #define BMP_PIXEL(r,g,b) ((bmp_pixel){(b),(g),(r)}) typedef struct _bmp_img { bmp_header img_header; bmp_pixel **img_pixels; } bmp_img; // BMP_HEADER void bmp_header_init_df (bmp_header*, const int, const int); enum bmp_error bmp_header_write (const bmp_header*, FILE*); enum bmp_error bmp_header_read (bmp_header*, FILE*); // BMP_PIXEL void bmp_pixel_init (bmp_pixel*, const unsigned char, const unsigned char, const unsigned char); // BMP_IMG void bmp_img_alloc (bmp_img*); void bmp_img_init_df (bmp_img*, const int, const int); void bmp_img_free (bmp_img*); enum bmp_error bmp_img_write (const bmp_img*, const char*); enum bmp_error bmp_img_read (bmp_img*, const char*); #endif /* __LIBBMP_H__ */
2251f86bb0929fbd8991d4a2b14e51a0a755938e
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/imx6sx/iMX6_Platform_SDK/sdk/common/usb_stack/Device/source/driver/usb_devapi.h
7b43085a13b665ae639f46706f1e65936321f03c
[ "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-unknown-license-reference", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "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
16,327
h
usb_devapi.h
/****************************************************************************** * * Freescale Semiconductor Inc. * (c) Copyright 2004-2010 Freescale Semiconductor, Inc. * ALL RIGHTS RESERVED. * ****************************************************************************** * * THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED 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 FREESCALE OR ITS 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 usb_devapi.h * * @author * * @version * * @date * * @brief This file contains S08 USB stack device layer API header function. * *****************************************************************************/ #ifndef _USB_DEVAPI_H #define _USB_DEVAPI_H /****************************************************************************** * Includes *****************************************************************************/ #include "types.h" /* User Defined Data Types */ #include "hidef.h" /* for EnableInterrupts macro */ #include "derivative.h" /* include peripheral declarations */ #include "user_config.h" /* User Configuration File */ /****************************************************************************** * Constants - None *****************************************************************************/ /****************************************************************************** * Macro's *****************************************************************************/ #ifndef _MC9S08JS16_H #define USB_MAX_EP_BUFFER_SIZE (512) #else #define USB_MAX_EP_BUFFER_SIZE (255) #endif #ifndef CONTROL_ENDPOINT #define CONTROL_ENDPOINT (0) #endif #define USB_SETUP_PKT_SIZE (8) /* Setup Packet Size */ /* Error codes */ #define USB_OK (0x00) #define USBERR_ALLOC (0x81) #define USBERR_BAD_STATUS (0x82) #define USBERR_CLOSED_SERVICE (0x83) #define USBERR_OPEN_SERVICE (0x84) #define USBERR_TRANSFER_IN_PROGRESS (0x85) #define USBERR_ENDPOINT_STALLED (0x86) #define USBERR_ALLOC_STATE (0x87) #define USBERR_DRIVER_INSTALL_FAILED (0x88) #define USBERR_DRIVER_NOT_INSTALLED (0x89) #define USBERR_INSTALL_ISR (0x8A) #define USBERR_INVALID_DEVICE_NUM (0x8B) #define USBERR_ALLOC_SERVICE (0x8C) #define USBERR_INIT_FAILED (0x8D) #define USBERR_SHUTDOWN (0x8E) #define USBERR_INVALID_PIPE_HANDLE (0x8F) #define USBERR_OPEN_PIPE_FAILED (0x90) #define USBERR_INIT_DATA (0x91) #define USBERR_SRP_REQ_INVALID_STATE (0x92) #define USBERR_TX_FAILED (0x93) #define USBERR_RX_FAILED (0x94) #define USBERR_EP_INIT_FAILED (0x95) #define USBERR_EP_DEINIT_FAILED (0x96) #define USBERR_TR_FAILED (0x97) #define USBERR_BANDWIDTH_ALLOC_FAILED (0x98) #define USBERR_INVALID_NUM_OF_ENDPOINTS (0x99) #define USBERR_NOT_SUPPORTED (0x9A) #define USBERR_DEVICE_NOT_FOUND (0xC0) #define USBERR_DEVICE_BUSY (0xC1) #define USBERR_NO_DEVICE_CLASS (0xC3) #define USBERR_UNKNOWN_ERROR (0xC4) #define USBERR_INVALID_BMREQ_TYPE (0xC5) #define USBERR_GET_MEMORY_FAILED (0xC6) #define USBERR_INVALID_MEM_TYPE (0xC7) #define USBERR_NO_DESCRIPTOR (0xC8) #define USBERR_NULL_CALLBACK (0xC9) #define USBERR_NO_INTERFACE (0xCA) #define USBERR_INVALID_CFIG_NUM (0xCB) #define USBERR_INVALID_ANCHOR (0xCC) #define USBERR_INVALID_REQ_TYPE (0xCD) /* Pipe Types */ #define USB_CONTROL_PIPE (0x00) #define USB_ISOCHRONOUS_PIPE (0x01) #define USB_BULK_PIPE (0x02) #define USB_INTERRUPT_PIPE (0x03) /* Device States */ #define USB_STATE_UNKNOWN (0xff) #define USB_STATE_PENDING_ADDRESS (0x04) #define USB_STATE_POWERED (0x03) #define USB_STATE_DEFAULT (0x02) #define USB_STATE_ADDRESS (0x01) #define USB_STATE_CONFIG (0x00) #define USB_STATE_SUSPEND (0x80) /* Get_Status Request information for DEVICE */ #define USB_SELF_POWERED (0x01) #define USB_REMOTE_WAKEUP (0x02) /* Get_Status Request information for OTG (WINDEX = 0xF000) */ #ifdef OTG_BUILD #define USB_OTG_HOST_REQUEST_FLAG (0x01) #endif /* Bus Control values */ #define USB_NO_OPERATION (0x00) #define USB_ASSERT_BUS_RESET (0x01) #define USB_DEASSERT_BUS_RESET (0x02) #define USB_ASSERT_RESUME (0x03) #define USB_DEASSERT_RESUME (0x04) #define USB_SUSPEND_SOF (0x05) #define USB_RESUME_SOF (0x06) /* possible values of Status */ #define USB_STATUS_IDLE (0) #define USB_STATUS_TRANSFER_ACCEPTED (6) #define USB_STATUS_TRANSFER_PENDING (2) #define USB_STATUS_TRANSFER_IN_PROGRESS (3) #define USB_STATUS_ERROR (4) #define USB_STATUS_DISABLED (5) #define USB_STATUS_STALLED (1) #define USB_STATUS_TRANSFER_QUEUED (7) #define USB_STATUS_UNKNOWN (0xFF) #define USB_CONTROL_ENDPOINT (0) #define USB_RECV (0) #define USB_SEND (1) #define USB_DEVICE_DONT_ZERO_TERMINATE (0x1) #define USB_SETUP_DATA_XFER_DIRECTION (0x80) #define USB_SPEED_FULL (0) #define USB_SPEED_LOW (1) #define USB_SPEED_HIGH (2) #define USB_MAX_PKTS_PER_UFRAME (0x6) #define USB_TEST_MODE_TEST_PACKET (0x0400) /* Available service types */ /* Services 0 through 15 are reserved for endpoints */ #define USB_SERVICE_EP0 (0x00) #define USB_SERVICE_EP1 (0x01) #define USB_SERVICE_EP2 (0x02) #define USB_SERVICE_EP3 (0x03) #define USB_SERVICE_EP4 (0x04) #define USB_SERVICE_EP5 (0x05) #define USB_SERVICE_EP6 (0x06) #define USB_SERVICE_EP7 (0x07) #define USB_SERVICE_EP8 (0x08) #define USB_SERVICE_EP9 (0x09) #define USB_SERVICE_EP10 (0x0a) #define USB_SERVICE_EP11 (0x0b) #define USB_SERVICE_EP12 (0x0c) #define USB_SERVICE_EP13 (0x0d) #define USB_SERVICE_EP14 (0x0e) #define USB_SERVICE_EP15 (0x0f) #define USB_SERVICE_BUS_RESET (0x10) #define USB_SERVICE_SUSPEND (0x11) #define USB_SERVICE_SOF (0x12) #define USB_SERVICE_RESUME (0x13) #define USB_SERVICE_SLEEP (0x14) #define USB_SERVICE_SPEED_DETECTION (0x15) #define USB_SERVICE_ERROR (0x16) #define USB_SERVICE_STALL (0x17) #define USB_SERVICE_MAX (0x18) #if (defined(_MCF51JM128_H) ||defined(_MCF51MM256_H) || (defined _MCF51JE256_H)) #define USB_SERVICE_MAX_EP USB_SERVICE_EP15 #else #ifdef DOUBLE_BUFFERING_USED #define USB_SERVICE_MAX_EP USB_SERVICE_EP6 #else #define USB_SERVICE_MAX_EP USB_SERVICE_EP4 #endif #endif /* Informational Request/Set Types */ /* component parameter in USB_Device_Get/Set_Status */ #define USB_COMPONENT_DIRECTION_SHIFT (7) #define USB_COMPONENT_DIRECTION_MASK (0x01) #define USB_STATUS_DEVICE_STATE (0x01) #define USB_STATUS_INTERFACE (0x02) #define USB_STATUS_ADDRESS (0x03) #define USB_STATUS_CURRENT_CONFIG (0x04) #define USB_STATUS_SOF_COUNT (0x05) #define USB_STATUS_DEVICE (0x06) // Endpoint attributes #define EP_TRANSFER_TYPE_CONTROL (0x0<<0) #define EP_TRANSFER_TYPE_ISOCHRONOUS (0x1<<0) #define EP_TRANSFER_TYPE_BULK (0x2<<0) #define EP_TRANSFER_TYPE_INTERRUPT (0x3<<0) /* Standard Request Code */ #define GET_STATUS 0x0 #define CLEAR_FEATURE 0x1 #define SET_FEATURE 0x3 #define SET_ADDRESS 0x5 #define GET_DESCRIPTOR 0x6 #define SET_DESCRIPTOR 0x7 #define GET_CONFIGURATION 0x8 #define SET_CONFIGURATION 0x9 #define GET_INTERFACE 0xA #define SET_INTERFACE 0xB #define SYNCH_FRAME 0xC #ifdef OTG_BUILD #define USB_STATUS_OTG (0x07) #define USB_STATUS_TEST_MODE (0x08) #else #define USB_STATUS_TEST_MODE (0x07) #endif #define USB_STATUS_ENDPOINT (0x10) #define USB_STATUS_ENDPOINT_NUMBER_MASK (0x0F) #define UNINITIALISED_VAL (0xffffffff) #if (defined MCU_MK40N512VMD100) || (defined MCU_MK53N512CMD100) || (defined MCU_MK60N512VMD100) || (defined MCU_MK70F12) #define USB_DEVICE_ASSERT_RESUME() USB0_CTL |= USB_CTL_RESUME_MASK; #define USB_DEVICE_DEASSERT_RESUME() USB0_CTL &= ~USB_CTL_RESUME_MASK; #elif (defined _MC9S08JE128_H) || (defined _MC9S08JM16_H) || defined(_MC9S08JM60_H) || (defined _MC9S08JS16_H) || (defined _MC9S08MM128_H) #define USB_DEVICE_ASSERT_RESUME() CTL_CRESUME = 1; #define USB_DEVICE_DEASSERT_RESUME() CTL_CRESUME = 0; #elif (defined _MCF51JE256_H) || (defined MCU_mcf51jf128) || defined(_MCF51MM256_H) #define USB_DEVICE_ASSERT_RESUME() USBTRC0_USBRESMEN = 1; #define USB_DEVICE_DEASSERT_RESUME() USBTRC0_USBRESMEN = 0; #elif (defined __MCF52221_H__) || (defined __MCF52259_H__) #define USB_DEVICE_ASSERT_RESUME() CTL |= MCF_USB_OTG_CTL_RESUME; #define USB_DEVICE_DEASSERT_RESUME() CTL &= ~MCF_USB_OTG_CTL_RESUME; #endif #define USB_PROCESS_PENDING() ((gu8ProcessPendingFlag != 0) || (gtUSBEPEventFlags != 0)) /****************************************************************************** * Types *****************************************************************************/ typedef void _PTR_ _usb_device_handle; typedef uint_8 T_EP_BITFIELD; #if !(defined _MC9S08JE128_H) && !(defined _MC9S08JM16_H) && !defined(_MC9S08JM60_H) && !(defined _MC9S08JS16_H) && !(defined _MC9S08MM128_H) #pragma pack (1) /* Enforce 1 byte struct alignment */ #endif #ifdef __MK_xxx_H__ #if (defined(__CWCC__) || defined(__GNUC__)) #define ALIGN __attribute__ ((packed)) #elif((defined __IAR_SYSTEMS_ICC__) || (defined __CC_ARM)) #define ALIGN #else #define ALIGN #endif #else #define ALIGN #endif typedef struct _USB_DEV_EVENT_STRUCT { uint_8 controller_ID; /* controller ID */ uint_8 ep_num; boolean setup; /* is setup packet */ boolean direction; /* direction of endpoint */ uint_8* buffer_ptr; /* pointer to buffer */ uint_8 errors; /* Any errors */ USB_PACKET_SIZE len; /* buffer size of endpoint */ }ALIGN USB_DEV_EVENT_STRUCT, *PTR_USB_DEV_EVENT_STRUCT; // Same endpoint can have multiple function assignments in g_usb_CB, depending on user input #ifndef MULTIPLE_DEVICES typedef void(_CODE_PTR_ const USB_SERVICE_CALLBACK)(PTR_USB_DEV_EVENT_STRUCT); #else typedef void(_CODE_PTR_ USB_SERVICE_CALLBACK)(PTR_USB_DEV_EVENT_STRUCT); #endif typedef struct _USB_EP_STRUCT { uint_8 ep_num; /* endpoint number */ uint_8 type; /* type of endpoint */ uint_8 direction; /* direction of endpoint */ USB_PACKET_SIZE size ALIGN; /* buffer size of endpoint */ }ALIGN USB_EP_STRUCT, *USB_EP_STRUCT_PTR; #if (defined(__CWCC__)||defined(__GNUC__)) #pragma options align = reset #elif defined(__IAR_SYSTEMS_ICC__) || defined(__CC_ARM) #pragma pack() #endif extern volatile uint_8 gu8ProcessPendingFlag; extern volatile T_EP_BITFIELD gtUSBEPEventFlags; /****************************************************************************** * Global Functions *****************************************************************************/ extern uint_8 _usb_device_init ( uint_8 device_number, _usb_device_handle _PTR_ handle, uint_8 number_of_endpoints, uint_8 bVregEn ); extern uint_8 _usb_device_deinit(void); extern uint_8 _usb_device_init_endpoint( _usb_device_handle handle, uint_8 endpoint_number, uint_16 max_packet_size, uint_8 direction, uint_8 endpoint_type, uint_8 flag ); extern uint_8 _usb_device_cancel_transfer ( _usb_device_handle handle, uint_8 endpoint_number, uint_8 direction ); extern uint_8 _usb_device_deinit_endpoint ( _usb_device_handle handle, uint_8 endpoint_number, uint_8 direction ); extern uint_8 _usb_device_recv_data ( _usb_device_handle handle, uint_8 endpoint_number, uchar_ptr buffer_ptr, uint_32 size ); extern uint_8 _usb_device_send_data ( _usb_device_handle handle, uint_8 endpoint_number, uchar_ptr buffer_ptr, uint_32 size ); extern uint_8 _usb_device_get_send_buffer ( uint_8 controller_ID, /* [IN] Controller ID */ uint_8 ep_num, /* [IN] Endpoint number */ uint_8_ptr *buff_ptr, /* [OUT] Buffer for IN endpoint */ USB_PACKET_SIZE *size /* [OUT] Size of IN endpoint */ ); extern void _usb_device_shutdown ( _usb_device_handle handle ); extern void _usb_device_stall_endpoint ( _usb_device_handle handle, uint_8 endpoint_number, uint_8 direction ); extern void _usb_device_unstall_endpoint ( _usb_device_handle handle, uint_8 endpoint_number, uint_8 direction ); extern void _usb_device_read_setup_data ( _usb_device_handle handle, uint_8 endpoint_number, uint_8_ptr buffer_ptr ); extern uint_8 _usb_device_get_status ( _usb_device_handle handle, uint_8 component, uint_8_ptr status ); extern uint_8 _usb_device_set_status ( _usb_device_handle handle, uint_8 component, uint_8 setting ); extern void _usb_device_assert_resume ( _usb_device_handle handle ); extern uint_8 _usb_device_register_service ( uint_8 controller_ID, uint_8 type, USB_SERVICE_CALLBACK service ); extern uint_8 _usb_device_unregister_service ( _usb_device_handle handle, uint_8 event_endpoint ); extern uint_8 _usb_device_get_transfer_status ( _usb_device_handle handle, uint_8 endpoint_number, uint_8 direction ); extern void _usb_device_set_address ( _usb_device_handle handle, uint_8 address ); extern uint_8 USB_Device_Call_Service( uint_8 type, PTR_USB_DEV_EVENT_STRUCT event ); extern void USB_Engine(void); #endif
ac1858f921a4a8b44599b057004817fe84a18786
607bb971c8fd33ad3df748c492ba77ec92159c42
/src/sparse_matrix_hash.c
570318f63371cdc8b19aff8768d07cd00d6c227c
[ "BSD-2-Clause" ]
permissive
GHamrouni/Recommender
8478c785ad8de16a6e846a334570bd19d6eeac3d
b6cadc8fe611b7dea053568dd131f54c290690f4
refs/heads/master
2022-08-19T14:19:01.840554
2022-07-19T15:21:16
2022-07-19T15:21:16
3,101,244
266
70
BSD-2-Clause
2018-08-28T13:44:06
2012-01-04T10:40:16
C
UTF-8
C
false
false
873
c
sparse_matrix_hash.c
#include "sparse_matrix_hash.h" #include <math.h> #include <assert.h> int lsh_row(projection_family_t* pfamily, sparse_matrix_t* matrix, size_t row_i) { ptrdiff_t i = 0; size_t k = 0; ptrdiff_t r1, r2; /* Range */ unsigned int bwidth, bias; int proj_value; int hash = 0; if (!matrix->row_index[row_i]) return 0; r1 = matrix->row_index[row_i] - 1; r2 = matrix->row_index[row_i + 1] - 1; for (k = 0; k < pfamily->projection_nb; k++) { double dot_product_r = 0; if (r1 >= 0) for (i = r1; i < r2; i++) { int cindex = matrix->column_index[i]; dot_product_r += pfamily->projections[k]->vector[cindex] * matrix->values[i]; } bwidth = pfamily->projections[k]->bin_width; bias = pfamily->projections[k]->bias; proj_value = (int) floor((dot_product_r + bias) / (double) bwidth); hash = 33 * hash + proj_value; } return hash; }
c02630561c95f222a550dc8d07e20b8efabaad79
771fa3a01480527df835c593bf99c5b8ae702b6a
/src/modules/gnutls_filter.c
ca3445c330ea61c2e56ae11e9ee9c88315f7f6f9
[ "CC0-1.0", "Apache-2.0", "MIT" ]
permissive
lighttpd/lighttpd2
cee558174b0a07174a4488591c16882845d43240
23164d557f10d4ccd948b34c5b1323e22ce5088f
refs/heads/master
2023-09-05T03:39:50.805344
2023-07-23T00:03:44
2023-07-23T00:03:44
1,767,422
459
135
NOASSERTION
2023-01-06T20:16:37
2011-05-18T18:13:11
C
UTF-8
C
false
false
19,544
c
gnutls_filter.c
#include "gnutls_filter.h" struct liGnuTLSFilter { int refcount; const liGnuTLSFilterCallbacks *callbacks; gpointer callback_data; liServer *srv; liWorker *wrk; liLogContext *log_context; /* TODO: support setting this to VR context */ gnutls_session_t session; liStream crypt_source; liStream crypt_drain; liStream plain_source; liStream plain_drain; liBuffer *raw_in_buffer; /* for gnutls_record_recv */ liBuffer *raw_out_buffer; /* stream_pushv */ unsigned int initial_handshaked_finished:1; unsigned int closing:1, aborted:1; unsigned int write_wants_read:1; }; #if GNUTLS_VERSION_NUMBER >= 0x020c00 #define HAVE_GIOVEC typedef giovec_t li_iovec_t; #else typedef struct { void *iov_base; size_t iov_len; } li_iovec_t; #endif #if GNUTLS_VERSION_NUMBER >= 0x020a00 #define HAVE_SAVE_RENEGOTIATION #endif static ssize_t stream_push(gnutls_transport_ptr_t, const void*, size_t); static ssize_t stream_pushv(gnutls_transport_ptr_t, const li_iovec_t * iov, int iovcnt); static ssize_t stream_pull(gnutls_transport_ptr_t, void*, size_t); static ssize_t stream_push(gnutls_transport_ptr_t trans, const void *buf, size_t len) { li_iovec_t vec; vec.iov_base = (void *) buf; vec.iov_len = len; return stream_pushv(trans, &vec, 1); } static ssize_t stream_pushv(gnutls_transport_ptr_t trans, const li_iovec_t * iov, int iovcnt) { const ssize_t blocksize = 16*1024; /* 16k */ liGnuTLSFilter *f = (liGnuTLSFilter*) trans; liChunkQueue *cq; int i; liBuffer *buf; gboolean cq_buf_append; ssize_t written = 0; errno = ECONNRESET; if (NULL == f || NULL == f->crypt_source.out) return -1; cq = f->crypt_source.out; if (cq->is_closed) return -1; buf = f->raw_out_buffer; cq_buf_append = (buf != NULL && buf == li_chunkqueue_get_last_buffer(cq, 1024)); for (i = 0; i < iovcnt; ++i) { const char *data = iov[i].iov_base; size_t len = iov[i].iov_len; while (len > 0) { size_t bufsize, do_write; if (NULL == buf) buf = li_buffer_new(blocksize); bufsize = buf->alloc_size - buf->used; do_write = (bufsize > len) ? len : bufsize; memcpy(buf->addr + buf->used, data, do_write); len -= do_write; data += do_write; if (cq_buf_append) { /* also updates buf->used */ li_chunkqueue_update_last_buffer_size(cq, do_write); } else { gsize offset = buf->used; buf->used += do_write; li_buffer_acquire(buf); li_chunkqueue_append_buffer2(cq, buf, offset, do_write); cq_buf_append = TRUE; } if (buf->used == buf->alloc_size) { li_buffer_release(buf); buf = NULL; cq_buf_append = FALSE; } written += do_write; } } if (NULL != buf && buf->alloc_size - buf->used < 1024) { li_buffer_release(buf); f->raw_out_buffer = buf = NULL; } else { f->raw_out_buffer = buf; } li_stream_notify_later(&f->crypt_source); errno = 0; return written; } static ssize_t stream_pull(gnutls_transport_ptr_t trans, void *buf, size_t len) { liGnuTLSFilter *f = (liGnuTLSFilter*) trans; liChunkQueue *cq; errno = ECONNRESET; if (NULL == f || NULL == f->crypt_drain.out) return -1; cq = f->crypt_drain.out; if (0 == cq->length) { if (cq->is_closed) { errno = 0; return 0; } else { errno = EAGAIN; return -1; } } if (len > (size_t) cq->length) len = cq->length; if (!li_chunkqueue_extract_to_memory(cq, len, buf, NULL)) return -1; li_chunkqueue_skip(cq, len); errno = 0; return len; } static void f_close_gnutls(liGnuTLSFilter *f) { if (NULL != f->session && !f->closing) { liCQLimit *limit; f->closing = TRUE; f->session = NULL; LI_FORCE_ASSERT(NULL != f->crypt_source.out); LI_FORCE_ASSERT(NULL != f->crypt_source.out->limit); limit = f->crypt_source.out->limit; limit->notify = NULL; limit->context = NULL; li_stream_disconnect(&f->plain_source); /* crypt in -> plain out */ li_stream_disconnect(&f->plain_drain); /* app -> plain in */ li_stream_disconnect_dest(&f->plain_source); /* plain out -> app */ f->log_context = NULL; if (NULL != f->callbacks && NULL != f->callbacks->closed_cb) { f->callbacks->closed_cb(f, f->callback_data); } } } static void f_acquire(liGnuTLSFilter *f) { LI_FORCE_ASSERT(f->refcount > 0); ++f->refcount; } static void f_release(liGnuTLSFilter *f) { LI_FORCE_ASSERT(f->refcount > 0); if (0 == --f->refcount) { f->refcount = 1; f_close_gnutls(f); if (NULL != f->raw_in_buffer) { li_buffer_release(f->raw_in_buffer); f->raw_in_buffer = NULL; } if (NULL != f->raw_out_buffer) { li_buffer_release(f->raw_out_buffer); f->raw_out_buffer = NULL; } g_slice_free(liGnuTLSFilter, f); } } static void f_abort_gnutls(liGnuTLSFilter *f) { if (f->aborted) return; f->aborted = TRUE; f_acquire(f); f_close_gnutls(f); li_stream_disconnect(&f->crypt_source); /* plain in -> crypt out */ li_stream_disconnect(&f->crypt_drain); /* io -> crypt in */ li_stream_disconnect_dest(&f->crypt_source); /* crypt out -> io */ f_release(f); } static void f_close_with_alert(liGnuTLSFilter *f, int r) { if (f->closing || f->aborted) return; if (GNUTLS_E_SUCCESS > gnutls_alert_send_appropriate(f->session, r)) { f_abort_gnutls(f); return; } /* push alert to io */ li_stream_notify(&f->crypt_source); f->plain_source.out->is_closed = TRUE; f->crypt_drain.out->is_closed = TRUE; f_close_gnutls(f); } static void do_handle_error(liGnuTLSFilter *f, const char *gnutlsfunc, int r, gboolean writing) { switch (r) { case GNUTLS_E_AGAIN: if (writing) f->write_wants_read = TRUE; return; case GNUTLS_E_REHANDSHAKE: #ifdef HAVE_SAVE_RENEGOTIATION if (f->initial_handshaked_finished && !gnutls_safe_renegotiation_status(f->session)) { _ERROR(f->srv, f->wrk, f->log_context, "%s: client initiated unsafe renegotiation, closing connection", gnutlsfunc); f_close_with_alert(f, r); } else { _DEBUG(f->srv, f->wrk, f->log_context, "%s: client initiated renegotiation", gnutlsfunc); } #else if (f->initial_handshaked_finished) { _ERROR(f->srv, f->wrk, f->log_context, "%s: client initiated renegotiation, closing connection", gnutlsfunc); f_close_with_alert(f, r); } #endif return; case GNUTLS_E_UNEXPECTED_PACKET_LENGTH: f_close_with_alert(f, r); return; case GNUTLS_E_UNKNOWN_CIPHER_SUITE: case GNUTLS_E_UNSUPPORTED_VERSION_PACKET: _DEBUG(f->srv, f->wrk, f->log_context, "%s (%s): %s", gnutlsfunc, gnutls_strerror_name(r), gnutls_strerror(r)); f_close_with_alert(f, r); return; case GNUTLS_E_FATAL_ALERT_RECEIVED: case GNUTLS_E_WARNING_ALERT_RECEIVED: { gnutls_alert_description_t alert_desc = gnutls_alert_get(f->session); const char* alert_desc_name = gnutls_alert_get_name(alert_desc); _INFO(f->srv, f->wrk, f->log_context, "%s (%s): %s %s (%u)", gnutlsfunc, gnutls_strerror_name(r), gnutls_strerror(r), (NULL != alert_desc_name) ? alert_desc_name : "unknown alert", (unsigned int) alert_desc); } /* error not handled yet: break instead of return */ break; default: if (gnutls_error_is_fatal(r)) { _ERROR(f->srv, f->wrk, f->log_context, "%s (%s): %s", gnutlsfunc, gnutls_strerror_name(r), gnutls_strerror(r)); } else { _WARNING(f->srv, f->wrk, f->log_context, "%s non fatal (%s): %s", gnutlsfunc, gnutls_strerror_name(r), gnutls_strerror(r)); } /* error not handled yet: break instead of return */ break; } /* generic error handling */ if (gnutls_error_is_fatal(r)) { if (f->initial_handshaked_finished) { f_close_with_alert(f, r); } else { f_abort_gnutls(f); } } } #define TIMEDIFF_MS(ts1, ts2) (((ts2).tv_sec - (ts1).tv_sec)*1.0e3 + ((ts2).tv_nsec - (ts1).tv_nsec)*1.0e-6) static gboolean do_gnutls_handshake(liGnuTLSFilter *f, gboolean writing) { int r; LI_FORCE_ASSERT(!f->initial_handshaked_finished); r = gnutls_handshake(f->session); if (GNUTLS_E_SUCCESS <= r) { f->initial_handshaked_finished = 1; li_stream_acquire(&f->plain_source); li_stream_acquire(&f->plain_drain); f->callbacks->handshake_cb(f, f->callback_data, &f->plain_source, &f->plain_drain); li_stream_release(&f->plain_source); li_stream_release(&f->plain_drain); return TRUE; } else { do_handle_error(f, "gnutls_handshake", r, writing); return FALSE; } } static void do_gnutls_read(liGnuTLSFilter *f) { const ssize_t blocksize = 16*1024; /* 16k */ off_t max_read = 4 * blocksize; /* 64k */ ssize_t r; off_t len = 0; liChunkQueue *cq = f->plain_source.out; f_acquire(f); if (NULL != f->session && !f->initial_handshaked_finished && !do_gnutls_handshake(f, FALSE)) goto out; if (NULL == f->session) { f_abort_gnutls(f); goto out; } do { liBuffer *buf; gboolean cq_buf_append; buf = li_chunkqueue_get_last_buffer(cq, 1024); cq_buf_append = (buf != NULL); if (buf != NULL) { /* use last buffer as raw_in_buffer; they should be the same anyway */ if (HEDLEY_UNLIKELY(buf != f->raw_in_buffer)) { li_buffer_acquire(buf); li_buffer_release(f->raw_in_buffer); f->raw_in_buffer = buf; } } else { buf = f->raw_in_buffer; if (buf != NULL && buf->alloc_size - buf->used < 1024) { /* release *buffer */ li_buffer_release(buf); f->raw_in_buffer = buf = NULL; } if (buf == NULL) { f->raw_in_buffer = buf = li_buffer_new(blocksize); } } LI_FORCE_ASSERT(f->raw_in_buffer == buf); r = gnutls_record_recv(f->session, buf->addr + buf->used, buf->alloc_size - buf->used); if (r < 0) { do_handle_error(f, "gnutls_record_recv", r, FALSE); goto out; } else if (r == 0) { /* clean shutdown? */ f->plain_source.out->is_closed = TRUE; f->plain_drain.out->is_closed = TRUE; f->crypt_source.out->is_closed = TRUE; f->crypt_drain.out->is_closed = TRUE; li_stream_disconnect(&f->crypt_drain); /* io -> crypt in */ li_stream_disconnect_dest(&f->crypt_source); /* crypt out -> io */ li_stream_disconnect(&f->crypt_source); /* plain in -> crypt out */ f_close_gnutls(f); goto out; } if (cq_buf_append) { li_chunkqueue_update_last_buffer_size(cq, r); } else { gsize offset; li_buffer_acquire(buf); offset = buf->used; buf->used += r; li_chunkqueue_append_buffer2(cq, buf, offset, r); } if (buf->alloc_size - buf->used < 1024) { /* release *buffer */ li_buffer_release(buf); f->raw_in_buffer = buf = NULL; } len += r; } while (len < max_read); out: f_release(f); } #if GNUTLS_VERSION_NUMBER >= 0x030109 /* gnutls_record_cork / gnutls_record_uncork available since 3.1.9 */ #define USE_CORK #endif static void do_gnutls_write(liGnuTLSFilter *f) { const ssize_t blocksize = 16*1024; /* 16k */ char *block_data; off_t block_len; ssize_t r; off_t write_max; #ifdef USE_CORK gboolean corked = FALSE; #endif liChunkQueue *cq = f->plain_drain.out; f_acquire(f); f->write_wants_read = FALSE; /* use space in (encrypted) outgoing buffer as amounts of bytes we try to write from (plain) output * don't care if we write a little bit more than the limit allowed */ write_max = li_chunkqueue_limit_available(f->crypt_source.out); LI_FORCE_ASSERT(write_max >= 0); /* we set a limit! */ /* if we start writing, try to write at least blocksize bytes */ if (write_max < blocksize) write_max = blocksize; if (NULL != f->session && !f->initial_handshaked_finished && !do_gnutls_handshake(f, TRUE)) goto out; if (NULL == f->session) { f_abort_gnutls(f); goto out; } #ifdef USE_CORK if (0 != cq->length && cq->queue.length > 1) { corked = TRUE; gnutls_record_cork(f->session); } #endif do { GError *err = NULL; liChunkIter ci; if (0 == cq->length) break; ci = li_chunkqueue_iter(cq); switch (li_chunkiter_read(ci, 0, blocksize, &block_data, &block_len, &err)) { case LI_HANDLER_GO_ON: break; case LI_HANDLER_ERROR: if (NULL != err) { _ERROR(f->srv, f->wrk, f->log_context, "Couldn't read data from chunkqueue: %s", err->message); g_error_free(err); } HEDLEY_FALL_THROUGH; default: f_abort_gnutls(f); goto out; } r = gnutls_record_send(f->session, block_data, block_len); if (r <= 0) { do_handle_error(f, "gnutls_record_send", r, TRUE); goto out; } li_chunkqueue_skip(cq, r); write_max -= r; } while (r == block_len && write_max > 0); if (cq->is_closed && 0 == cq->length) { r = gnutls_bye(f->session, GNUTLS_SHUT_RDWR); switch (r) { case GNUTLS_E_SUCCESS: case GNUTLS_E_AGAIN: case GNUTLS_E_INTERRUPTED: f->plain_source.out->is_closed = TRUE; f->crypt_source.out->is_closed = TRUE; f->crypt_drain.out->is_closed = TRUE; li_stream_disconnect(&f->crypt_source); /* plain in -> crypt out */ f_close_gnutls(f); break; default: do_handle_error(f, "gnutls_bye", r, TRUE); f_abort_gnutls(f); break; } } else if (0 < cq->length && 0 != li_chunkqueue_limit_available(f->crypt_source.out)) { li_stream_again_later(&f->plain_drain); } out: #ifdef USE_CORK if (NULL != f->session && corked) { corked = TRUE; gnutls_record_uncork(f->session, 0); } #endif f_release(f); } /* ssl crypted out -> io */ static void stream_crypt_source_cb(liStream *stream, liStreamEvent event) { liGnuTLSFilter *f = LI_CONTAINER_OF(stream, liGnuTLSFilter, crypt_source); switch (event) { case LI_STREAM_NEW_DATA: /* data comes through SSL */ break; case LI_STREAM_NEW_CQLIMIT: break; case LI_STREAM_CONNECTED_DEST: /* io out */ break; case LI_STREAM_CONNECTED_SOURCE: /* plain_drain */ break; case LI_STREAM_DISCONNECTED_DEST: /* io out disconnect */ if (!stream->out->is_closed || 0 != stream->out->length) { f_abort_gnutls(f); /* didn't read everything */ } break; case LI_STREAM_DISCONNECTED_SOURCE: /* plain_drain */ if (!stream->out->is_closed) { /* f_close_ssl before we were ready */ f_abort_gnutls(f); } break; case LI_STREAM_DESTROY: f_release(f); break; } } /* io -> ssl crypted in */ static void stream_crypt_drain_cb(liStream *stream, liStreamEvent event) { liGnuTLSFilter *f = LI_CONTAINER_OF(stream, liGnuTLSFilter, crypt_drain); switch (event) { case LI_STREAM_NEW_DATA: if (!stream->out->is_closed && NULL != stream->source) { li_chunkqueue_steal_all(stream->out, stream->source->out); stream->out->is_closed = stream->out->is_closed || stream->source->out->is_closed; li_stream_notify(stream); /* tell plain_source to do SSL_read */ } if (stream->out->is_closed) { li_stream_disconnect(stream); } break; case LI_STREAM_NEW_CQLIMIT: break; case LI_STREAM_CONNECTED_DEST: /* plain_source */ break; case LI_STREAM_CONNECTED_SOURCE: /* io in */ break; case LI_STREAM_DISCONNECTED_DEST: /* plain_source */ if (!stream->out->is_closed || 0 != stream->out->length) { f_abort_gnutls(f); /* didn't read everything */ } break; case LI_STREAM_DISCONNECTED_SOURCE: /* io in disconnect */ if (!stream->out->is_closed) { f_abort_gnutls(f); /* conn aborted */ } break; case LI_STREAM_DESTROY: f_release(f); break; } } /* ssl (plain) -> app */ static void stream_plain_source_cb(liStream *stream, liStreamEvent event) { liGnuTLSFilter *f = LI_CONTAINER_OF(stream, liGnuTLSFilter, plain_source); switch (event) { case LI_STREAM_NEW_DATA: do_gnutls_read(f); if (f->write_wants_read) do_gnutls_write(f); li_stream_notify(stream); break; case LI_STREAM_NEW_CQLIMIT: break; case LI_STREAM_CONNECTED_DEST: /* app */ break; case LI_STREAM_CONNECTED_SOURCE: /* crypt_drain */ break; case LI_STREAM_DISCONNECTED_DEST: /* app */ if (!stream->out->is_closed || 0 != stream->out->length) { f_abort_gnutls(f); /* didn't read everything */ } break; case LI_STREAM_DISCONNECTED_SOURCE: /* crypt_drain */ if (!stream->out->is_closed) { f_abort_gnutls(f); /* didn't get everything */ } break; case LI_STREAM_DESTROY: f_release(f); break; } } /* app -> ssl (plain) */ static void stream_plain_drain_cb(liStream *stream, liStreamEvent event) { liGnuTLSFilter *f = LI_CONTAINER_OF(stream, liGnuTLSFilter, plain_drain); switch (event) { case LI_STREAM_NEW_DATA: if (!stream->out->is_closed && NULL != stream->source) { li_chunkqueue_steal_all(stream->out, stream->source->out); stream->out->is_closed = stream->out->is_closed || stream->source->out->is_closed; } do_gnutls_write(f); if (stream->out->is_closed) { li_stream_disconnect(stream); stream->out->is_closed = FALSE; } break; case LI_STREAM_NEW_CQLIMIT: break; case LI_STREAM_CONNECTED_DEST: /* crypt_source */ break; case LI_STREAM_CONNECTED_SOURCE: /* app */ break; case LI_STREAM_DISCONNECTED_DEST: if (!stream->out->is_closed || 0 != stream->out->length) { f_abort_gnutls(f); /* didn't read everything */ } break; case LI_STREAM_DISCONNECTED_SOURCE: if (!stream->out->is_closed) { f_abort_gnutls(f); /* didn't get everything */ } break; case LI_STREAM_DESTROY: f_release(f); break; } } static void stream_crypt_source_limit_notify_cb(gpointer context, gboolean locked) { liGnuTLSFilter *f = context; if (!locked) li_stream_again_later(&f->plain_drain); } static int post_client_hello_cb(gnutls_session_t session) { liGnuTLSFilter *f = gnutls_session_get_ptr(session); if (NULL == f->callbacks->post_client_hello_cb) return GNUTLS_E_SUCCESS; return f->callbacks->post_client_hello_cb(f, f->callback_data); } liGnuTLSFilter* li_gnutls_filter_new( liServer *srv, liWorker *wrk, const liGnuTLSFilterCallbacks *callbacks, gpointer data, gnutls_session_t session, liStream *crypt_source, liStream *crypt_drain ) { liEventLoop *loop = crypt_source->loop; liGnuTLSFilter *f; liCQLimit *out_limit; f = g_slice_new0(liGnuTLSFilter); f->refcount = 5; /* 1 + 4 streams */ f->callbacks = callbacks; f->callback_data = data; f->srv = srv; f->wrk = wrk; f->session = session; gnutls_transport_set_ptr(f->session, (gnutls_transport_ptr_t) f); gnutls_transport_set_push_function(f->session, stream_push); #ifdef HAVE_GIOVEC gnutls_transport_set_vec_push_function(f->session, stream_pushv); #endif gnutls_transport_set_pull_function(f->session, stream_pull); gnutls_session_set_ptr(f->session, f); gnutls_handshake_set_post_client_hello_function(f->session, post_client_hello_cb); f->initial_handshaked_finished = 0; f->closing = f->aborted = 0; f->write_wants_read = 0; li_stream_init(&f->crypt_source, loop, stream_crypt_source_cb); li_stream_init(&f->crypt_drain, loop, stream_crypt_drain_cb); li_stream_init(&f->plain_source, loop, stream_plain_source_cb); li_stream_init(&f->plain_drain, loop, stream_plain_drain_cb); /* "virtual" connections - the content goes through SSL */ li_stream_connect(&f->plain_drain, &f->crypt_source); li_stream_connect(&f->crypt_drain, &f->plain_source); li_stream_connect(crypt_source, &f->crypt_drain); li_stream_connect(&f->crypt_source, crypt_drain); /* separate limit for buffer of encrypted data * * f->plain_drain is already connected to f->crypt_source, * so they won't share the same limit */ out_limit = li_cqlimit_new(); out_limit->notify = stream_crypt_source_limit_notify_cb; out_limit->context = f; li_cqlimit_set_limit(out_limit, 32*1024); li_chunkqueue_set_limit(crypt_drain->out, out_limit); li_chunkqueue_set_limit(f->crypt_source.out, out_limit); li_cqlimit_release(out_limit); return f; } void li_gnutls_filter_free(liGnuTLSFilter *f) { LI_FORCE_ASSERT(NULL != f->callbacks); f->callbacks = NULL; f->callback_data = NULL; f_close_gnutls(f); li_stream_release(&f->crypt_source); li_stream_release(&f->crypt_drain); li_stream_release(&f->plain_source); li_stream_release(&f->plain_drain); f_release(f); }
1ce5fd8d49a24330fe82a3ada1fdf7c0bc394712
75196819c910f3fd523f1a4d28e5d0fe12570ab1
/src/bdb53/src/repmgr/repmgr_msg.c
cbbcbe3513b295654fc2825f8d8d9f5a98ec5370
[ "BSD-3-Clause", "Sleepycat", "MIT" ]
permissive
gridcoin-community/Gridcoin-Research
889967579b5b05bcc3ae836697a0f173b5ae91ea
21414dd0f63c9a34060f7f762f08d1a52aeb9e87
refs/heads/development
2023-09-04T09:21:55.006935
2023-09-03T17:45:20
2023-09-03T17:45:20
23,332,350
292
117
MIT
2023-09-11T10:22:10
2014-08-25T23:41:04
HTML
UTF-8
C
false
false
43,663
c
repmgr_msg.c
/*- * See the file LICENSE for redistribution information. * * Copyright (c) 2005, 2013 Oracle and/or its affiliates. All rights reserved. * * $Id$ */ #include "db_config.h" #include "db_int.h" #include "dbinc/db_page.h" #include "dbinc/btree.h" #include "dbinc/txn.h" #include "dbinc_auto/repmgr_auto.h" static int dispatch_app_message __P((ENV *, REPMGR_MESSAGE *)); static int finish_gmdb_update __P((ENV *, DB_THREAD_INFO *, DBT *, u_int32_t, u_int32_t, __repmgr_member_args *)); static int incr_gm_version __P((ENV *, DB_THREAD_INFO *, DB_TXN *)); static void marshal_site_data __P((ENV *, u_int32_t, u_int8_t *, DBT *)); static void marshal_site_key __P((ENV *, repmgr_netaddr_t *, u_int8_t *, DBT *, __repmgr_member_args *)); static int message_loop __P((ENV *, REPMGR_RUNNABLE *)); static int process_message __P((ENV*, DBT*, DBT*, int)); static int reject_fwd __P((ENV *, REPMGR_CONNECTION *)); static int rescind_pending __P((ENV *, DB_THREAD_INFO *, int, u_int32_t, u_int32_t)); static int resolve_limbo_int __P((ENV *, DB_THREAD_INFO *)); static int resolve_limbo_wrapper __P((ENV *, DB_THREAD_INFO *)); static int send_permlsn __P((ENV *, u_int32_t, DB_LSN *)); static int send_permlsn_conn __P((ENV *, REPMGR_CONNECTION *, u_int32_t, DB_LSN *)); static int serve_join_request __P((ENV *, DB_THREAD_INFO *, REPMGR_MESSAGE *)); static int serve_remove_request __P((ENV *, DB_THREAD_INFO *, REPMGR_MESSAGE *)); static int serve_repmgr_request __P((ENV *, REPMGR_MESSAGE *)); /* * Map one of the phase-1/provisional membership status values to its * corresponding ultimate goal status: if "adding", the goal is to be fully * "present". Otherwise ("deleting") the goal is to not even appear in the * database at all (0). */ #define NEXT_STATUS(s) (u_int32_t)((s) == SITE_ADDING ? SITE_PRESENT : 0) /* * PUBLIC: void *__repmgr_msg_thread __P((void *)); */ void * __repmgr_msg_thread(argsp) void *argsp; { REPMGR_RUNNABLE *th; ENV *env; int ret; th = argsp; env = th->env; if ((ret = message_loop(env, th)) != 0) { __db_err(env, ret, "message thread failed"); (void)__repmgr_thread_failure(env, ret); } return (NULL); } static int message_loop(env, th) ENV *env; REPMGR_RUNNABLE *th; { DB_REP *db_rep; REP *rep; REPMGR_MESSAGE *msg; REPMGR_CONNECTION *conn; REPMGR_SITE *site; __repmgr_permlsn_args permlsn; int incremented, ret, t_ret; u_int32_t membership; COMPQUIET(membership, 0); db_rep = env->rep_handle; rep = db_rep->region; LOCK_MUTEX(db_rep->mutex); while ((ret = __repmgr_queue_get(env, &msg, th)) == 0) { incremented = FALSE; if (IS_DEFERRABLE(msg->msg_hdr.type)) { /* * Count threads currently processing channel requests * or GMDB operations, so that we can limit the number * of them, in order to avoid starving more important * rep messages. */ db_rep->non_rep_th++; incremented = TRUE; } if (msg->msg_hdr.type == REPMGR_REP_MESSAGE) { DB_ASSERT(env, IS_VALID_EID(msg->v.repmsg.originating_eid)); site = SITE_FROM_EID(msg->v.repmsg.originating_eid); membership = site->membership; } UNLOCK_MUTEX(db_rep->mutex); switch (msg->msg_hdr.type) { case REPMGR_REP_MESSAGE: if (membership != SITE_PRESENT) break; while ((ret = process_message(env, &msg->v.repmsg.control, &msg->v.repmsg.rec, msg->v.repmsg.originating_eid)) == DB_LOCK_DEADLOCK) RPRINT(env, (env, DB_VERB_REPMGR_MISC, "repmgr deadlock retry")); break; case REPMGR_APP_MESSAGE: ret = dispatch_app_message(env, msg); conn = msg->v.appmsg.conn; if (conn != NULL) { LOCK_MUTEX(db_rep->mutex); t_ret = __repmgr_decr_conn_ref(env, conn); UNLOCK_MUTEX(db_rep->mutex); if (t_ret != 0 && ret == 0) ret = t_ret; } break; case REPMGR_OWN_MSG: ret = serve_repmgr_request(env, msg); break; case REPMGR_HEARTBEAT: if ((ret = __repmgr_permlsn_unmarshal(env, &permlsn, msg->v.repmsg.control.data, msg->v.repmsg.control.size, NULL)) != 0) ret = DB_REP_UNAVAIL; else if (rep->master_id == db_rep->self_eid) { /* * If a master receives a heartbeat, there * may be a dupmaster. Resend latest log * message to prompt base replication to * detect it without the need for application * activity. */ ret = __rep_flush(env->dbenv); } else { /* * Use heartbeat message to initiate rerequest * processing. */ ret = __rep_check_missing(env, permlsn.generation, &permlsn.lsn); } break; default: ret = __db_unknown_path(env, "message loop"); break; } __os_free(env, msg); LOCK_MUTEX(db_rep->mutex); if (incremented) db_rep->non_rep_th--; if (ret != 0) goto out; } /* * A return of DB_REP_UNAVAIL from __repmgr_queue_get() merely means we * should finish gracefully. */ if (ret == DB_REP_UNAVAIL) ret = 0; out: UNLOCK_MUTEX(db_rep->mutex); return (ret); } static int dispatch_app_message(env, msg) ENV *env; REPMGR_MESSAGE *msg; { DB_REP *db_rep; DB_CHANNEL db_channel; CHANNEL channel; __repmgr_msg_metadata_args meta; DBT *dbt, *segment; u_int32_t flags, i, size, *uiptr; u_int8_t *data; void *ptr; int ret; COMPQUIET(size, 0); db_rep = env->rep_handle; db_channel.channel = &channel; db_channel.send_msg = __repmgr_send_response; /* Supply stub functions for methods inapplicable in msg disp func. */ db_channel.close = __repmgr_channel_close_inval; db_channel.send_request = __repmgr_send_request_inval; db_channel.set_timeout = __repmgr_channel_timeout_inval; channel.msg = msg; channel.env = env; channel.c.conn = msg->v.appmsg.conn; channel.responded = FALSE; channel.meta = &meta; /* * The user data is in a form similar to that of a bulk buffer. * However, there's also our meta-data tacked on to the end of it. * Fortunately, the meta-data is fixed length, so it's easy to peel it * off. * * The user data "bulk buffer" lacks the usual "-1" end-marker. But * that's OK, because we already know how many segments there are (from * the message header). Convert this information into the DBT array * that we will pass to the user's function. * * (See the definition of DB_MULTIPLE_INIT for a reminder of the format * of a bulk buffer.) */ dbt = &msg->v.appmsg.buf; data = dbt->data; dbt->size -= __REPMGR_MSG_METADATA_SIZE; ret = __repmgr_msg_metadata_unmarshal(env, &meta, &data[dbt->size], __REPMGR_MSG_METADATA_SIZE, NULL); DB_ASSERT(env, ret == 0); dbt->ulen = dbt->size; DB_MULTIPLE_INIT(ptr, dbt); for (i = 0; i < APP_MSG_SEGMENT_COUNT(msg->msg_hdr); i++) { segment = &msg->v.appmsg.segments[i]; uiptr = ptr; *uiptr = ntohl(*uiptr); uiptr[-1] = ntohl(uiptr[-1]); DB_MULTIPLE_NEXT(ptr, dbt, data, size); DB_ASSERT(env, data != NULL); DB_INIT_DBT(*segment, data, size); } flags = F_ISSET(&meta, REPMGR_REQUEST_MSG_TYPE) ? DB_REPMGR_NEED_RESPONSE : 0; if (db_rep->msg_dispatch == NULL) { __db_errx(env, DB_STR("3670", "No message dispatch call-back function has been configured")); if (F_ISSET(channel.meta, REPMGR_REQUEST_MSG_TYPE)) return (__repmgr_send_err_resp(env, &channel, DB_NOSERVER)); else return (0); } (*db_rep->msg_dispatch)(env->dbenv, &db_channel, &msg->v.appmsg.segments[0], APP_MSG_SEGMENT_COUNT(msg->msg_hdr), flags); if (F_ISSET(channel.meta, REPMGR_REQUEST_MSG_TYPE) && !channel.responded) { __db_errx(env, DB_STR("3671", "Application failed to provide a response")); return (__repmgr_send_err_resp(env, &channel, DB_KEYEMPTY)); } return (0); } /* * PUBLIC: int __repmgr_send_err_resp __P((ENV *, CHANNEL *, int)); */ int __repmgr_send_err_resp(env, channel, err) ENV *env; CHANNEL *channel; int err; { DB_REP *db_rep; REPMGR_CONNECTION *conn; REPMGR_IOVECS iovecs; __repmgr_msg_hdr_args msg_hdr; u_int8_t msg_hdr_buf[__REPMGR_MSG_HDR_SIZE]; int ret; db_rep = env->rep_handle; msg_hdr.type = REPMGR_RESP_ERROR; /* Make it non-negative, so we can send on wire without worry. */ DB_ASSERT(env, err < 0); RESP_ERROR_CODE(msg_hdr) = (u_int32_t)(-err); RESP_ERROR_TAG(msg_hdr) = channel->meta->tag; __repmgr_iovec_init(&iovecs); __repmgr_msg_hdr_marshal(env, &msg_hdr, msg_hdr_buf); __repmgr_add_buffer(&iovecs, msg_hdr_buf, __REPMGR_MSG_HDR_SIZE); conn = channel->c.conn; LOCK_MUTEX(db_rep->mutex); ret = __repmgr_send_many(env, conn, &iovecs, 0); UNLOCK_MUTEX(db_rep->mutex); return (ret); } static int process_message(env, control, rec, eid) ENV *env; DBT *control, *rec; int eid; { DB_LSN lsn; DB_REP *db_rep; REP *rep; int dirty, ret, t_ret; u_int32_t generation; db_rep = env->rep_handle; rep = db_rep->region; /* * Save initial generation number, in case it changes in a close race * with a NEWMASTER. */ generation = rep->gen; ret = 0; switch (t_ret = __rep_process_message_int(env, control, rec, eid, &lsn)) { case 0: if (db_rep->takeover_pending) ret = __repmgr_claim_victory(env); break; case DB_REP_HOLDELECTION: LOCK_MUTEX(db_rep->mutex); ret = __repmgr_init_election(env, ELECT_F_IMMED | ELECT_F_INVITEE); UNLOCK_MUTEX(db_rep->mutex); break; case DB_REP_DUPMASTER: /* * Initiate an election if we're configured to be using * elections, but only if we're *NOT* using leases. When using * leases, there is never any uncertainty over which site is the * rightful master, and only the loser gets the DUPMASTER return * code. */ if ((ret = __repmgr_become_client(env)) == 0 && FLD_ISSET(rep->config, REP_C_LEASE | REP_C_ELECTIONS) == REP_C_ELECTIONS) { LOCK_MUTEX(db_rep->mutex); ret = __repmgr_init_election(env, ELECT_F_IMMED); UNLOCK_MUTEX(db_rep->mutex); } DB_EVENT(env, DB_EVENT_REP_DUPMASTER, NULL); break; case DB_REP_ISPERM: #ifdef CONFIG_TEST if (env->test_abort == DB_TEST_REPMGR_PERM) VPRINT(env, (env, DB_VERB_REPMGR_MISC, "ISPERM: Test hook. Skip ACK for permlsn [%lu][%lu]", (u_long)lsn.file, (u_long)lsn.offset)); #endif DB_TEST_SET(env->test_abort, DB_TEST_REPMGR_PERM); ret = send_permlsn(env, generation, &lsn); DB_TEST_RECOVERY_LABEL break; case DB_LOCK_DEADLOCK: case DB_REP_IGNORE: case DB_REP_NEWSITE: case DB_REP_NOTPERM: break; case DB_REP_JOIN_FAILURE: RPRINT(env, (env, DB_VERB_REPMGR_MISC, "repmgr fires join failure event")); DB_EVENT(env, DB_EVENT_REP_JOIN_FAILURE, NULL); break; case DB_REP_WOULDROLLBACK: RPRINT(env, (env, DB_VERB_REPMGR_MISC, "repmgr fires would-rollback event")); DB_EVENT(env, DB_EVENT_REP_WOULD_ROLLBACK, &lsn); break; default: __db_err(env, t_ret, "DB_ENV->rep_process_message"); ret = t_ret; } if (ret != 0) goto err; LOCK_MUTEX(db_rep->mutex); dirty = db_rep->gmdb_dirty; db_rep->gmdb_dirty = FALSE; UNLOCK_MUTEX(db_rep->mutex); if (dirty) { if ((ret = __op_rep_enter(env, FALSE, FALSE)) != 0) goto err; ret = __repmgr_reload_gmdb(env); t_ret = __op_rep_exit(env); if (ret == ENOENT) ret = 0; else if (ret == DB_DELETED) ret = __repmgr_bow_out(env); if (t_ret != 0 && ret == 0) ret = t_ret; } err: return (ret); } /* * Handle replication-related events. Returns only 0 or DB_EVENT_NOT_HANDLED; * no other error returns are tolerated. * * PUBLIC: int __repmgr_handle_event __P((ENV *, u_int32_t, void *)); */ int __repmgr_handle_event(env, event, info) ENV *env; u_int32_t event; void *info; { DB_REP *db_rep; db_rep = env->rep_handle; if (db_rep->selector == NULL) { /* Repmgr is not in use, so all events go to application. */ return (DB_EVENT_NOT_HANDLED); } switch (event) { case DB_EVENT_REP_ELECTED: DB_ASSERT(env, info == NULL); db_rep->takeover_pending = TRUE; /* * The application doesn't really need to see this, because the * purpose of this event is to tell the winning site that it * should call rep_start(MASTER), and in repmgr we do that * automatically. Still, they could conceivably be curious, and * it doesn't hurt anything to let them know. */ break; case DB_EVENT_REP_INIT_DONE: db_rep->gmdb_dirty = TRUE; break; case DB_EVENT_REP_NEWMASTER: DB_ASSERT(env, info != NULL); /* Application still needs to see this. */ break; default: break; } return (DB_EVENT_NOT_HANDLED); } static int send_permlsn(env, generation, lsn) ENV *env; u_int32_t generation; DB_LSN *lsn; { DB_REP *db_rep; REP *rep; REPMGR_CONNECTION *conn; REPMGR_SITE *site; int ack, bcast, eid, master, policy, ret; db_rep = env->rep_handle; rep = db_rep->region; ret = 0; master = rep->master_id; LOCK_MUTEX(db_rep->mutex); /* * If the file number has changed, send it to everyone, regardless of * anything else. Otherwise, send it to the master if we know a master, * and that master's ack policy requires it. */ bcast = FALSE; if (LOG_COMPARE(lsn, &db_rep->perm_lsn) > 0) { if (lsn->file > db_rep->perm_lsn.file) { bcast = TRUE; VPRINT(env, (env, DB_VERB_REPMGR_MISC, "send_permlsn: broadcast [%lu][%lu]", (u_long)lsn->file, (u_long)lsn->offset)); } db_rep->perm_lsn = *lsn; } if (IS_KNOWN_REMOTE_SITE(master)) { site = SITE_FROM_EID(master); /* * Use master's ack policy if we know it; use our own if the * master is too old (down-rev) to have told us its policy. */ policy = site->ack_policy > 0 ? site->ack_policy : rep->perm_policy; if (policy == DB_REPMGR_ACKS_NONE || (IS_PEER_POLICY(policy) && rep->priority == 0)) ack = FALSE; else ack = TRUE; } else { site = NULL; RPRINT(env, (env, DB_VERB_REPMGR_MISC, "dropping ack with no known master")); ack = FALSE; } /* * Send to master first, since we need to send to all its connections. */ if (site != NULL && (bcast || ack)) { if (site->state == SITE_CONNECTED) { if ((conn = site->ref.conn.in) != NULL && conn->state == CONN_READY && (ret = send_permlsn_conn(env, conn, generation, lsn)) != 0) goto unlock; if ((conn = site->ref.conn.out) != NULL && conn->state == CONN_READY && (ret = send_permlsn_conn(env, conn, generation, lsn)) != 0) goto unlock; } TAILQ_FOREACH(conn, &site->sub_conns, entries) { if ((ret = send_permlsn_conn(env, conn, generation, lsn)) != 0) goto unlock; } } if (bcast) { /* * Send to everyone except the master (since we've already done * that, above). */ FOR_EACH_REMOTE_SITE_INDEX(eid) { if (eid == master) continue; site = SITE_FROM_EID(eid); /* * Send the ack out on primary connections only. */ if (site->state == SITE_CONNECTED) { if ((conn = site->ref.conn.in) != NULL && conn->state == CONN_READY && (ret = send_permlsn_conn(env, conn, generation, lsn)) != 0) goto unlock; if ((conn = site->ref.conn.out) != NULL && conn->state == CONN_READY && (ret = send_permlsn_conn(env, conn, generation, lsn)) != 0) goto unlock; } } } unlock: UNLOCK_MUTEX(db_rep->mutex); return (ret); } /* * Sends a perm LSN message on one connection, if it needs it. * * !!! Called with mutex held. */ static int send_permlsn_conn(env, conn, generation, lsn) ENV *env; REPMGR_CONNECTION *conn; u_int32_t generation; DB_LSN *lsn; { DBT control2, rec2; __repmgr_permlsn_args permlsn; u_int8_t buf[__REPMGR_PERMLSN_SIZE]; int ret; ret = 0; if (conn->state == CONN_READY) { DB_ASSERT(env, conn->version > 0); permlsn.generation = generation; memcpy(&permlsn.lsn, lsn, sizeof(DB_LSN)); if (conn->version == 1) { control2.data = &permlsn; control2.size = sizeof(permlsn); } else { __repmgr_permlsn_marshal(env, &permlsn, buf); control2.data = buf; control2.size = __REPMGR_PERMLSN_SIZE; } rec2.size = 0; /* * It's hard to imagine anyone would care about a lost ack if * the path to the master is so congested as to need blocking; * so pass "maxblock" argument as 0. */ if ((ret = __repmgr_send_one(env, conn, REPMGR_PERMLSN, &control2, &rec2, 0)) == DB_REP_UNAVAIL) ret = __repmgr_bust_connection(env, conn); } return (ret); } static int serve_repmgr_request(env, msg) ENV *env; REPMGR_MESSAGE *msg; { DB_THREAD_INFO *ip; DBT *dbt; REPMGR_CONNECTION *conn; int ret, t_ret; ENV_ENTER(env, ip); switch (REPMGR_OWN_MSG_TYPE(msg->msg_hdr)) { case REPMGR_JOIN_REQUEST: ret = serve_join_request(env, ip, msg); break; case REPMGR_REJOIN: RPRINT(env, (env, DB_VERB_REPMGR_MISC, "One try at rejoining group automatically")); if ((ret = __repmgr_join_group(env)) == DB_REP_UNAVAIL) ret = __repmgr_bow_out(env); break; case REPMGR_REMOVE_REQUEST: ret = serve_remove_request(env, ip, msg); break; case REPMGR_RESOLVE_LIMBO: ret = resolve_limbo_wrapper(env, ip); break; case REPMGR_SHARING: dbt = &msg->v.gmdb_msg.request; ret = __repmgr_refresh_membership(env, dbt->data, dbt->size); break; default: ret = __db_unknown_path(env, "serve_repmgr_request"); break; } if ((conn = msg->v.gmdb_msg.conn) != NULL) { if ((t_ret = __repmgr_close_connection(env, conn)) != 0 && ret == 0) ret = t_ret; if ((t_ret = __repmgr_decr_conn_ref(env, conn)) != 0 && ret == 0) ret = t_ret; } ENV_LEAVE(env, ip); return (ret); } /* * Attempts to fulfill a remote site's request to join the replication group. * Only the master can grant this request, so if we've received this request * when we're not the master, we'll send an appropriate failure message instead. */ static int serve_join_request(env, ip, msg) ENV *env; DB_THREAD_INFO *ip; REPMGR_MESSAGE *msg; { DB_REP *db_rep; REPMGR_CONNECTION *conn; DBT *dbt; __repmgr_site_info_args site_info; u_int8_t *buf; char *host; size_t len; u_int32_t status; int eid, ret, t_ret; db_rep = env->rep_handle; COMPQUIET(status, 0); conn = msg->v.gmdb_msg.conn; dbt = &msg->v.gmdb_msg.request; ret = __repmgr_site_info_unmarshal(env, &site_info, dbt->data, dbt->size, NULL); host = site_info.host.data; host[site_info.host.size - 1] = '\0'; RPRINT(env, (env, DB_VERB_REPMGR_MISC, "Request to join group from %s:%u", host, (u_int)site_info.port)); if ((ret = __repmgr_hold_master_role(env, conn)) == DB_REP_UNAVAIL) return (0); if (ret != 0) return (ret); LOCK_MUTEX(db_rep->mutex); if ((ret = __repmgr_find_site(env, host, site_info.port, &eid)) == 0) { DB_ASSERT(env, eid != db_rep->self_eid); status = SITE_FROM_EID(eid)->membership; } UNLOCK_MUTEX(db_rep->mutex); if (ret != 0) goto err; switch (status) { case 0: case SITE_ADDING: ret = __repmgr_update_membership(env, ip, eid, SITE_ADDING); break; case SITE_PRESENT: /* Already in desired state. */ break; case SITE_DELETING: ret = rescind_pending(env, ip, eid, SITE_DELETING, SITE_PRESENT); break; default: ret = __db_unknown_path(env, "serve_join_request"); break; } if (ret != 0) goto err; LOCK_MUTEX(db_rep->mutex); ret = __repmgr_marshal_member_list(env, &buf, &len); UNLOCK_MUTEX(db_rep->mutex); if (ret != 0) goto err; ret = __repmgr_send_sync_msg(env, conn, REPMGR_JOIN_SUCCESS, buf, (u_int32_t)len); __os_free(env, buf); err: if ((t_ret = __repmgr_rlse_master_role(env)) != 0 && ret == 0) ret = t_ret; if (ret == DB_REP_UNAVAIL) ret = __repmgr_send_sync_msg(env, conn, REPMGR_GM_FAILURE, NULL, 0); return (ret); } static int serve_remove_request(env, ip, msg) ENV *env; DB_THREAD_INFO *ip; REPMGR_MESSAGE *msg; { DB_REP *db_rep; REPMGR_CONNECTION *conn; REPMGR_SITE *site; DBT *dbt; __repmgr_site_info_args site_info; char *host; u_int32_t status, type; int eid, ret, t_ret; COMPQUIET(status, 0); db_rep = env->rep_handle; conn = msg->v.gmdb_msg.conn; dbt = &msg->v.gmdb_msg.request; ret = __repmgr_site_info_unmarshal(env, &site_info, dbt->data, dbt->size, NULL); host = site_info.host.data; host[site_info.host.size - 1] = '\0'; RPRINT(env, (env, DB_VERB_REPMGR_MISC, "Request to remove %s:%u from group", host, (u_int)site_info.port)); if ((ret = __repmgr_hold_master_role(env, conn)) == DB_REP_UNAVAIL) return (0); if (ret != 0) return (ret); LOCK_MUTEX(db_rep->mutex); if ((site = __repmgr_lookup_site(env, host, site_info.port)) == NULL) eid = DB_EID_INVALID; else { eid = EID_FROM_SITE(site); status = site->membership; } UNLOCK_MUTEX(db_rep->mutex); if (eid == DB_EID_INVALID) { /* Doesn't exist: already been removed. */ ret = 0; goto err; } else if (eid == db_rep->self_eid) { RPRINT(env, (env, DB_VERB_REPMGR_MISC, "Reject request to remove current master")); ret = DB_REP_UNAVAIL; goto err; } switch (status) { case 0: /* Already in desired state. */ break; case SITE_ADDING: ret = rescind_pending(env, ip, eid, SITE_ADDING, 0); break; case SITE_PRESENT: case SITE_DELETING: ret = __repmgr_update_membership(env, ip, eid, SITE_DELETING); break; default: ret = __db_unknown_path(env, "serve_remove_request"); break; } err: if ((t_ret = __repmgr_rlse_master_role(env)) != 0 && ret == 0) ret = t_ret; switch (ret) { case 0: type = REPMGR_REMOVE_SUCCESS; break; case DB_REP_UNAVAIL: type = REPMGR_GM_FAILURE; break; default: return (ret); } return (__repmgr_send_sync_msg(env, conn, type, NULL, 0)); } /* * Runs a limbo resolution on a message processing thread, upon request from the * send() function when it notices that a user transaction has gotten a perm * success. (It wouldn't work for the user thread to do it in-line.) */ static int resolve_limbo_wrapper(env, ip) ENV *env; DB_THREAD_INFO *ip; { int do_close, ret, t_ret; if ((ret = __repmgr_hold_master_role(env, NULL)) == DB_REP_UNAVAIL) return (0); if (ret != 0) return (ret); retry: if ((ret = __repmgr_setup_gmdb_op(env, ip, NULL, 0)) != 0) goto rlse; /* * A limbo resolution request is merely a "best effort" attempt to * shorten the duration of a pending change. So if it fails for lack of * acks again, no one really cares. */ if ((ret = resolve_limbo_int(env, ip)) == DB_REP_UNAVAIL) { do_close = FALSE; ret = 0; } else do_close = TRUE; if ((t_ret = __repmgr_cleanup_gmdb_op(env, do_close)) != 0 && ret == 0) ret = t_ret; if (ret == DB_LOCK_DEADLOCK || ret == DB_LOCK_NOTGRANTED) goto retry; rlse: if ((t_ret = __repmgr_rlse_master_role(env)) != 0 && ret == 0) ret = t_ret; return (ret); } /* * Checks for the need to resolve limbo (failure of a previous GMDB update to * get enough acks), and does it if nec. No-op if none needed. * * Must be called within setup_gmdb_op/cleanup_gmdb_op context. */ static int resolve_limbo_int(env, ip) ENV *env; DB_THREAD_INFO *ip; { DB_REP *db_rep; DB_TXN *txn; REPMGR_SITE *site; DB_LSN orig_lsn; DBT key_dbt, data_dbt; __repmgr_member_args logrec; repmgr_netaddr_t addr; u_int32_t orig_status, status; int eid, locked, ret, t_ret; u_int8_t data_buf[__REPMGR_MEMBERSHIP_DATA_SIZE]; u_int8_t key_buf[MAX_MSG_BUF]; db_rep = env->rep_handle; ret = 0; LOCK_MUTEX(db_rep->mutex); locked = TRUE; /* * Is there a previous GMDB update failure currently pending? If not, * there's nothing for us to do. */ eid = db_rep->limbo_victim; if (!IS_VALID_EID(eid)) goto out; site = SITE_FROM_EID(eid); addr = site->net_addr; marshal_site_key(env, &addr, key_buf, &key_dbt, &logrec); orig_status = site->membership; if (orig_status == SITE_PRESENT || orig_status == 0) goto out; if (IS_ZERO_LSN(db_rep->limbo_failure)) goto out; /* * There are potentially two parts: the self-update of the existing * limbo record, and then the finishing-off if the first is successful. * We might only have to do the finishing-off, if some arbitrary random * txn triggered a limbo resolution request on a msg processing thread. */ if (LOG_COMPARE(&db_rep->durable_lsn, &db_rep->limbo_failure) > 0) { /* * Nice! Limbo has been resolved by an arbitrary other txn * succeeding subsequently. So we don't have to do the * "self-update" part. */ } else { /* * Do a self-update, to try to trigger a "durable". Since * nothing in the database is changing, we need neither an ASL * hint nor a bump in the version sequence. */ orig_lsn = db_rep->limbo_failure; db_rep->active_gmdb_update = gmdb_primary; UNLOCK_MUTEX(db_rep->mutex); locked = FALSE; if ((ret = __txn_begin(env, ip, NULL, &txn, DB_IGNORE_LEASE)) != 0) goto out; marshal_site_data(env, orig_status, data_buf, &data_dbt); ret = __db_put(db_rep->gmdb, ip, txn, &key_dbt, &data_dbt, 0); if ((t_ret = __db_txn_auto_resolve(env, txn, 0, ret)) != 0 && ret == 0) ret = t_ret; if (ret != 0) goto out; /* * Check to see whether we got another PERM failure. This is * quite possible in the case where a GMDB request is being * retried by a requestor, but unlikely if we had a resolution * via an "arbitrary" txn. */ LOCK_MUTEX(db_rep->mutex); locked = TRUE; if (LOG_COMPARE(&db_rep->limbo_failure, &orig_lsn) > 0) { db_rep->limbo_resolution_needed = TRUE; ret = DB_REP_UNAVAIL; goto out; } } DB_ASSERT(env, locked); /* * Here, either we didn't need to do the self-update, or we did it and * it succeeded. So now we're ready to do the second phase update. */ db_rep->limbo_victim = DB_EID_INVALID; UNLOCK_MUTEX(db_rep->mutex); locked = FALSE; status = NEXT_STATUS(orig_status); if ((ret = finish_gmdb_update(env, ip, &key_dbt, orig_status, status, &logrec)) != 0) goto out; /* Track modified membership status in our in-memory sites array. */ LOCK_MUTEX(db_rep->mutex); locked = TRUE; if ((ret = __repmgr_set_membership(env, addr.host, addr.port, status)) != 0) goto out; __repmgr_set_sites(env); out: if (locked) UNLOCK_MUTEX(db_rep->mutex); return (ret); } /* * Update a specific record in the Group Membership database. The record to be * updated is implied by "eid"; "pstatus" is the provisional status (ADDING or * DELETING) to be used in the first phase of the update. The ultimate goal * status is inferred (ADDING -> PRESENT, or DELETING -> 0). * * PUBLIC: int __repmgr_update_membership __P((ENV *, * PUBLIC: DB_THREAD_INFO *, int, u_int32_t)); */ int __repmgr_update_membership(env, ip, eid, pstatus) ENV *env; DB_THREAD_INFO *ip; int eid; u_int32_t pstatus; /* Provisional status. */ { DB_REP *db_rep; REPMGR_SITE *site; DB_TXN *txn; DB_LSN lsn, orig_lsn; DBT key_dbt, data_dbt; __repmgr_member_args logrec; repmgr_netaddr_t addr; u_int32_t orig_status, ult_status; int do_close, locked, ret, t_ret; u_int8_t key_buf[MAX_MSG_BUF]; u_int8_t status_buf[__REPMGR_MEMBERSHIP_DATA_SIZE]; DB_ASSERT(env, pstatus == SITE_ADDING || pstatus == SITE_DELETING); db_rep = env->rep_handle; COMPQUIET(orig_status, 0); COMPQUIET(addr.host, NULL); COMPQUIET(addr.port, 0); retry: txn = NULL; locked = FALSE; DB_ASSERT(env, db_rep->gmdb_busy); if ((ret = __repmgr_setup_gmdb_op(env, ip, NULL, 0)) != 0) return (ret); /* * Usually we'll keep the GMDB closed, to conserve resources, since * changes should be rare. However, if a PERM FAIL puts us in limbo, we * expect to clean that up as soon as we can; so leave it open for now * in that case. */ do_close = TRUE; /* * Before attempting any fresh updates, resolve any lingering incomplete * updates from the past (i.e., those that resulted in PERM_FAIL). If * we can't, then we mustn't proceed with any more updates. Getting an * additional perm failure would increase the dissonance between the * effective group size and the number of sites from which we can safely * accept acks. Besides, if we can't clear the previous failure, * there's practically no hope that a new update would fare any better. */ if ((ret = resolve_limbo_int(env, ip)) != 0) { if (ret == DB_REP_UNAVAIL) do_close = FALSE; goto err; } /* * If there was a successful limbo resolution, it could have either been * for some unrelated change, or it could have been the same change our * caller is now (re-)trying to perform. In the latter case, we have * nothing more to do -- resolve_limbo() has done it all for us! To * find out, compare the site's current status with the ultimate goal * status associated with the provisional status that was passed to us * as input. */ LOCK_MUTEX(db_rep->mutex); locked = TRUE; DB_ASSERT(env, IS_KNOWN_REMOTE_SITE(eid)); site = SITE_FROM_EID(eid); if ((orig_status = site->membership) == NEXT_STATUS(pstatus)) goto err; addr = site->net_addr; /* * Anticipate modified membership status in our in-memory sites array. * This forces us into an awkward rescission, below, if our transaction * suffers a hard failure and must be aborted. But it's necessary * because of the requirement that, on additions, the quorum computation * must be based on the incremented nsites value. An alternative might * possibly be to increment nsites separately from adding the new site * to the array, or even having a special epicycle at the point where * send() counts acks (we'd have to make active_gmdb_update richer), but * those seem even more confusing. */ if ((ret = __repmgr_set_membership(env, addr.host, addr.port, pstatus)) != 0) goto err; __repmgr_set_sites(env); /* * Hint to our send() function that we want to know the result of ack * counting. */ orig_lsn = db_rep->limbo_failure; db_rep->active_gmdb_update = gmdb_primary; UNLOCK_MUTEX(db_rep->mutex); locked = FALSE; if ((ret = __txn_begin(env, ip, NULL, &txn, DB_IGNORE_LEASE)) != 0) goto err; marshal_site_key(env, &addr, key_buf, &key_dbt, &logrec); marshal_site_data(env, pstatus, status_buf, &data_dbt); if ((ret = __db_put(db_rep->gmdb, ip, txn, &key_dbt, &data_dbt, 0)) != 0) goto err; if ((ret = incr_gm_version(env, ip, txn)) != 0) goto err; /* * Add some information to the log for this txn. This is an annotation, * for the sole purpose of enabling the client to notice whenever a * change has occurred in this database. It has nothing to do with * local recovery. */ ZERO_LSN(lsn); if ((ret = __repmgr_member_log(env, txn, &lsn, 0, db_rep->membership_version, orig_status, pstatus, &logrec.host, logrec.port)) != 0) goto err; ret = __txn_commit(txn, 0); txn = NULL; if (ret != 0) goto err; LOCK_MUTEX(db_rep->mutex); locked = TRUE; if (LOG_COMPARE(&db_rep->limbo_failure, &orig_lsn) > 0) { /* * Failure LSN advanced, meaning this update wasn't acked by * enough clients. */ db_rep->limbo_resolution_needed = TRUE; db_rep->limbo_victim = eid; ret = DB_REP_UNAVAIL; do_close = FALSE; goto err; } /* Now we'll complete the status change. */ ult_status = NEXT_STATUS(pstatus); UNLOCK_MUTEX(db_rep->mutex); locked = FALSE; if ((ret = finish_gmdb_update(env, ip, &key_dbt, pstatus, ult_status, &logrec)) != 0) goto err; /* Track modified membership status in our in-memory sites array. */ LOCK_MUTEX(db_rep->mutex); locked = TRUE; ret = __repmgr_set_membership(env, addr.host, addr.port, ult_status); __repmgr_set_sites(env); err: if (locked) UNLOCK_MUTEX(db_rep->mutex); if (txn != NULL) { DB_ASSERT(env, ret != 0); (void)__txn_abort(txn); /* * We've just aborted the txn which moved the site info from * orig_status to something else, so restore that value now so * that we keep in sync. */ (void)__repmgr_set_membership(env, addr.host, addr.port, orig_status); } if ((t_ret = __repmgr_cleanup_gmdb_op(env, do_close)) != 0 && ret == 0) ret = t_ret; if (ret == DB_LOCK_DEADLOCK || ret == DB_LOCK_NOTGRANTED) goto retry; return (ret); } /* * Rescind a partially completed membership DB change, setting the new status to * the value given. */ static int rescind_pending(env, ip, eid, cur_status, new_status) ENV *env; DB_THREAD_INFO *ip; int eid; u_int32_t cur_status, new_status; { DB_REP *db_rep; REPMGR_SITE *site; DBT key_dbt; __repmgr_member_args logrec; repmgr_netaddr_t addr; u_int8_t key_buf[MAX_MSG_BUF]; int ret, t_ret; db_rep = env->rep_handle; retry: if ((ret = __repmgr_setup_gmdb_op(env, ip, NULL, 0)) != 0) return (ret); LOCK_MUTEX(db_rep->mutex); DB_ASSERT(env, IS_KNOWN_REMOTE_SITE(eid)); site = SITE_FROM_EID(eid); addr = site->net_addr; UNLOCK_MUTEX(db_rep->mutex); marshal_site_key(env, &addr, key_buf, &key_dbt, &logrec); if ((ret = finish_gmdb_update(env, ip, &key_dbt, cur_status, new_status, &logrec)) != 0) goto err; /* Track modified membership status in our in-memory sites array. */ LOCK_MUTEX(db_rep->mutex); ret = __repmgr_set_membership(env, addr.host, addr.port, new_status); __repmgr_set_sites(env); UNLOCK_MUTEX(db_rep->mutex); err: if ((t_ret = __repmgr_cleanup_gmdb_op(env, TRUE)) != 0 && ret == 0) ret = t_ret; if (ret == DB_LOCK_DEADLOCK || ret == DB_LOCK_NOTGRANTED) goto retry; return (ret); } /* * Caller must have already taken care of serializing this operation * (hold_master_role(), setup_gmdb_op()). */ static int incr_gm_version(env, ip, txn) ENV *env; DB_THREAD_INFO *ip; DB_TXN *txn; { DB_REP *db_rep; u_int32_t version; int ret; db_rep = env->rep_handle; version = db_rep->membership_version + 1; if ((ret = __repmgr_set_gm_version(env, ip, txn, version)) == 0) db_rep->membership_version = version; return (ret); } /* * PUBLIC: int __repmgr_set_gm_version __P((ENV *, * PUBLIC: DB_THREAD_INFO *, DB_TXN *, u_int32_t)); */ int __repmgr_set_gm_version(env, ip, txn, version) ENV *env; DB_THREAD_INFO *ip; DB_TXN *txn; u_int32_t version; { DB_REP *db_rep; DBT key_dbt, data_dbt; __repmgr_membership_key_args key; __repmgr_member_metadata_args metadata; u_int8_t key_buf[__REPMGR_MEMBERSHIP_KEY_SIZE + 1]; u_int8_t metadata_buf[__REPMGR_MEMBER_METADATA_SIZE]; size_t len; int ret; db_rep = env->rep_handle; metadata.format = REPMGR_GMDB_FMT_VERSION; metadata.version = version; __repmgr_member_metadata_marshal(env, &metadata, metadata_buf); DB_INIT_DBT(data_dbt, metadata_buf, __REPMGR_MEMBER_METADATA_SIZE); DB_INIT_DBT(key.host, NULL, 0); key.port = 0; ret = __repmgr_membership_key_marshal(env, &key, key_buf, sizeof(key_buf), &len); DB_ASSERT(env, ret == 0); DB_INIT_DBT(key_dbt, key_buf, len); if ((ret = __db_put(db_rep->gmdb, ip, txn, &key_dbt, &data_dbt, 0)) != 0) return (ret); return (0); } /* * Performs the second phase of a 2-phase membership DB operation: an "adding" * site becomes fully "present" in the group; a "deleting" site is finally * really deleted. */ static int finish_gmdb_update(env, ip, key_dbt, prev_status, status, logrec) ENV *env; DB_THREAD_INFO *ip; DBT *key_dbt; u_int32_t prev_status, status; __repmgr_member_args *logrec; { DB_REP *db_rep; DB_LSN lsn; DB_TXN *txn; DBT data_dbt; u_int8_t data_buf[__REPMGR_MEMBERSHIP_DATA_SIZE]; int ret, t_ret; db_rep = env->rep_handle; db_rep->active_gmdb_update = gmdb_secondary; if ((ret = __txn_begin(env, ip, NULL, &txn, DB_IGNORE_LEASE)) != 0) return (ret); if (status == 0) ret = __db_del(db_rep->gmdb, ip, txn, key_dbt, 0); else { marshal_site_data(env, status, data_buf, &data_dbt); ret = __db_put(db_rep->gmdb, ip, txn, key_dbt, &data_dbt, 0); } if (ret != 0) goto err; if ((ret = incr_gm_version(env, ip, txn)) != 0) goto err; ZERO_LSN(lsn); if ((ret = __repmgr_member_log(env, txn, &lsn, 0, db_rep->membership_version, prev_status, status, &logrec->host, logrec->port)) != 0) goto err; err: if ((t_ret = __db_txn_auto_resolve(env, txn, 0, ret)) != 0 && ret == 0) ret = t_ret; return (ret); } /* * Set up everything we need to update the Group Membership database. This may * or may not include providing a transaction in which to do the updates * (depending on whether the caller wants the creation of the database to be in * the same transaction as the updates). * * PUBLIC: int __repmgr_setup_gmdb_op __P((ENV *, * PUBLIC: DB_THREAD_INFO *, DB_TXN **, u_int32_t)); */ int __repmgr_setup_gmdb_op(env, ip, txnp, flags) ENV *env; DB_THREAD_INFO *ip; DB_TXN **txnp; u_int32_t flags; { DB_REP *db_rep; DB_TXN *txn; DB *dbp; int ret, was_open; db_rep = env->rep_handle; dbp = NULL; txn = NULL; /* * If the caller provided a place to return a txn handle, create it and * perform any open operation as part of that txn. The caller is * responsible for disposing of the txn. Otherwise, only begin a txn if * we need to do the open and in that case commit it right after the * open. */ DB_ASSERT(env, db_rep->gmdb_busy); was_open = db_rep->gmdb != NULL; if ((txnp != NULL || !was_open) && (ret = __txn_begin(env, ip, NULL, &txn, DB_IGNORE_LEASE)) != 0) goto err; if (!was_open) { DB_ASSERT(env, txn != NULL); /* * Opening the membership database is like a secondary GMDB * operation, in the sense that we don't care how many clients * ack it, yet we don't want the application to see any perm * failure events. */ DB_ASSERT(env, db_rep->active_gmdb_update == none); db_rep->active_gmdb_update = gmdb_secondary; ret = __rep_open_sysdb(env, ip, txn, REPMEMBERSHIP, flags, &dbp); if (ret == 0 && txnp == NULL) { /* The txn was just for the open operation. */ ret = __txn_commit(txn, 0); txn = NULL; } db_rep->active_gmdb_update = none; if (ret != 0) goto err; } /* * Lock out normal API operations. Again because we need to know that * if a PERM_FAIL occurs, it was associated with our txn. Also, so that * we avoid confusing the application with a PERM_FAIL event for our own * txn. */ if ((ret = __rep_take_apilockout(env)) != 0) goto err; /* * Here, all steps have succeeded. Stash and/or pass back the fruits of * our labor. */ if (!was_open) { DB_ASSERT(env, dbp != NULL); db_rep->gmdb = dbp; } if (txnp != NULL) { DB_ASSERT(env, txn != NULL); *txnp = txn; } /* * In the successful case, a later call to cleanup_gmdb_op will * ENV_LEAVE. */ return (0); err: DB_ASSERT(env, ret != 0); if (dbp != NULL) (void)__db_close(dbp, txn, DB_NOSYNC); if (txn != NULL) (void)__txn_abort(txn); return (ret); } /* * PUBLIC: int __repmgr_cleanup_gmdb_op __P((ENV *, int)); */ int __repmgr_cleanup_gmdb_op(env, do_close) ENV *env; int do_close; { DB_REP *db_rep; int ret, t_ret; db_rep = env->rep_handle; db_rep->active_gmdb_update = none; ret = __rep_clear_apilockout(env); if (do_close && db_rep->gmdb != NULL) { if ((t_ret = __db_close(db_rep->gmdb, NULL, DB_NOSYNC) != 0) && ret == 0) ret = t_ret; db_rep->gmdb = NULL; } return (ret); } /* * Check whether we're currently master, and if so hold that role so that we can * perform a Group Membership database operation. After a successful call, the * caller must call rlse_master_role to release the hold. * * If we can't guarantee that we can remain master, send an appropriate failure * message on the given connection (unless NULL). * * We also ensure that only one GMDB operation will take place at time, for a * couple of reasons: if we get a PERM_FAIL it means the fate of the change is * indeterminate, so we have to assume the worst. We have to assume the higher * value of nsites, yet we can't accept ack from the questionable site. If we * allowed concurrent operations, this could lead to more than one questionable * site, which would be even worse. Also, when we get a PERM_FAIL we want to * know which txn failed, and that would be messy if there could be several. * * Of course we can't simply take the mutex for the duration, because * the mutex needs to be available in order to send out the log * records. * * PUBLIC: int __repmgr_hold_master_role __P((ENV *, REPMGR_CONNECTION *)); */ int __repmgr_hold_master_role(env, conn) ENV *env; REPMGR_CONNECTION *conn; { DB_REP *db_rep; REP *rep; int ret, t_ret; db_rep = env->rep_handle; rep = db_rep->region; LOCK_MUTEX(db_rep->mutex); if ((ret = __repmgr_await_gmdbop(env)) == 0) { /* * If we're currently master, but client_intent is set, it means * that another thread is on the way to becoming master, so we * can't promise to hold the master role for the caller: we've * lost a close race. */ if (rep->master_id != db_rep->self_eid || db_rep->client_intent) ret = DB_REP_UNAVAIL; else db_rep->gmdb_busy = TRUE; } UNLOCK_MUTEX(db_rep->mutex); if (conn != NULL && ret == DB_REP_UNAVAIL && (t_ret = reject_fwd(env, conn)) != 0) ret = t_ret; return (ret); } /* * Releases the "master role" lock once we're finished performing a membership * DB operation. * * PUBLIC: int __repmgr_rlse_master_role __P((ENV *)); */ int __repmgr_rlse_master_role(env) ENV *env; { DB_REP *db_rep; int ret; db_rep = env->rep_handle; LOCK_MUTEX(db_rep->mutex); db_rep->gmdb_busy = FALSE; ret = __repmgr_signal(&db_rep->gmdb_idle); UNLOCK_MUTEX(db_rep->mutex); return (ret); } /* * Responds to a membership change request in the case we're not currently * master. If we know the master, responds with a "forward" message, to tell * the requestor who is master. Otherwise rejects it outright. */ static int reject_fwd(env, conn) ENV *env; REPMGR_CONNECTION *conn; { DB_REP *db_rep; REP *rep; SITE_STRING_BUFFER site_string; __repmgr_gm_fwd_args fwd; repmgr_netaddr_t addr; u_int8_t buf[MAX_MSG_BUF]; u_int32_t msg_type; size_t len; int ret; db_rep = env->rep_handle; rep = db_rep->region; if (IS_KNOWN_REMOTE_SITE(rep->master_id)) { msg_type = REPMGR_GM_FORWARD; LOCK_MUTEX(db_rep->mutex); addr = SITE_FROM_EID(rep->master_id)->net_addr; UNLOCK_MUTEX(db_rep->mutex); RPRINT(env, (env, DB_VERB_REPMGR_MISC, "Forwarding request to master %s", __repmgr_format_addr_loc(&addr, site_string))); fwd.host.data = addr.host; fwd.host.size = (u_int32_t)strlen(fwd.host.data) + 1; fwd.port = addr.port; fwd.gen = rep->mgen; ret = __repmgr_gm_fwd_marshal(env, &fwd, buf, sizeof(buf), &len); DB_ASSERT(env, ret == 0); } else { RPRINT(env, (env, DB_VERB_REPMGR_MISC, "Rejecting membership request with no known master")); msg_type = REPMGR_GM_FAILURE; len = 0; } return (__repmgr_send_sync_msg(env, conn, msg_type, buf, (u_int32_t)len)); } /* * The length of "buf" must be at least MAX_GMDB_KEY. */ static void marshal_site_key(env, addr, buf, dbt, logrec) ENV *env; repmgr_netaddr_t *addr; u_int8_t *buf; DBT *dbt; __repmgr_member_args *logrec; { __repmgr_membership_key_args key; size_t len; int ret; DB_INIT_DBT(key.host, addr->host, strlen(addr->host) + 1); logrec->host = key.host; key.port = addr->port; logrec->port = key.port; ret = __repmgr_membership_key_marshal(env, &key, buf, MAX_MSG_BUF, &len); DB_ASSERT(env, ret == 0); DB_INIT_DBT(*dbt, buf, len); } static void marshal_site_data(env, status, buf, dbt) ENV *env; u_int32_t status; u_int8_t *buf; DBT *dbt; { __repmgr_membership_data_args member_status; member_status.flags = status; __repmgr_membership_data_marshal(env, &member_status, buf); DB_INIT_DBT(*dbt, buf, __REPMGR_MEMBERSHIP_DATA_SIZE); } /* * PUBLIC: void __repmgr_set_sites __P((ENV *)); * * Caller must hold mutex. */ void __repmgr_set_sites(env) ENV *env; { DB_REP *db_rep; int ret; u_int32_t n; u_int i; db_rep = env->rep_handle; for (i = 0, n = 0; i < db_rep->site_cnt; i++) { if (db_rep->sites[i].membership > 0) n++; } ret = __rep_set_nsites_int(env, n); DB_ASSERT(env, ret == 0); }
e1c294330918bc0fb7fb271e9aa2d48aab3f795b
83e7dc1281874779c46dfadcc15b2bb66d8e599c
/tests/src/test_cases/test_bar.c
14eacbe04cd088bf18ae86900b18c83b03734fd5
[ "MIT" ]
permissive
lvgl/lvgl
7d51d6774d6ac71df7101fc7ded56fea4b70be01
5c984b4a5364b6455966eb3a860153806c51626f
refs/heads/master
2023-08-30T22:39:20.283922
2023-08-30T19:55:29
2023-08-30T19:55:29
60,667,730
9,296
2,218
MIT
2023-09-14T17:59:34
2016-06-08T04:14:34
C
UTF-8
C
false
false
7,553
c
test_bar.c
#if LV_BUILD_TEST #include "../lvgl.h" #include "unity/unity.h" #include "lv_test_indev.h" static lv_obj_t * active_screen = NULL; static lv_obj_t * bar = NULL; void setUp(void) { active_screen = lv_scr_act(); bar = lv_bar_create(active_screen); } void tearDown(void) { } void test_bar_should_have_valid_default_attributes(void) { TEST_ASSERT_EQUAL(0, lv_bar_get_min_value(bar)); TEST_ASSERT_EQUAL(100, lv_bar_get_max_value(bar)); TEST_ASSERT_EQUAL(LV_BAR_MODE_NORMAL, lv_bar_get_mode(bar)); } /* * Bar has two parts, main and indicator, coordinates of the latter are * calculated based on: * - Bar size * - Bar (main part) padding * - Bar value * - Bar coordinates * - Bar base direction * See Boxing model in docs for reference. * * Bar properties assumed: * - mode: LV_BAR_MODE_NORMAL * - min value: 0 * - max value: 100 * - base direction: LTR */ void test_bar_should_update_indicator_right_coordinate_based_on_bar_value(void) { lv_bar_t * bar_ptr = (lv_bar_t *) bar; static lv_style_t bar_style; const lv_coord_t style_padding = 5u; const lv_coord_t bar_width = 200u; const lv_coord_t bar_height = 20u; int32_t bar_value = 10u; lv_style_init(&bar_style); lv_style_set_pad_all(&bar_style, style_padding); /* Setup new style */ lv_obj_remove_style_all(bar); lv_obj_add_style(bar, &bar_style, LV_PART_MAIN); /* Set properties */ lv_obj_set_size(bar, bar_width, bar_height); lv_bar_set_value(bar, bar_value, LV_ANIM_OFF); /* FIXME: Remove wait */ lv_test_indev_wait(50); int32_t actual_coord = lv_area_get_width(&bar_ptr->indic_area); /* Calculate bar indicator right coordinate, using rule of 3 */ lv_coord_t bar_max_value = lv_bar_get_max_value(bar); lv_coord_t indicator_part_width = lv_obj_get_content_width(bar); lv_coord_t sides_padding = lv_obj_get_style_pad_left(bar, LV_PART_MAIN); sides_padding += lv_obj_get_style_pad_right(bar, LV_PART_MAIN); int32_t expected_coord = (bar_value * indicator_part_width) / bar_max_value; /* NOTE: Add 1 to calculation because the coordinates start at 0 */ expected_coord += 1; TEST_ASSERT_EQUAL_INT32(expected_coord, actual_coord); } /* * Bar has two parts, main and indicator, coordinates of the latter are * calculated based on: * - Bar size * - Bar (main part) padding * - Bar value * - Bar coordinates * - Bar base direction * See Boxing model in docs for reference. * * Bar properties assumed: * - mode: LV_BAR_MODE_NORMAL * - min value: 0 * - max value: 100 */ void test_bar_rtl_should_update_indicator_left_coordinate_based_on_bar_value(void) { lv_bar_t * bar_ptr = (lv_bar_t *) bar; static lv_style_t bar_style; const lv_coord_t style_padding = 5u; const lv_coord_t bar_width = 200u; const lv_coord_t bar_height = 20u; int32_t bar_value = 10u; lv_style_init(&bar_style); lv_style_set_pad_all(&bar_style, style_padding); /* Setup new style */ lv_obj_remove_style_all(bar); lv_obj_add_style(bar, &bar_style, LV_PART_MAIN); /* Set properties */ lv_obj_set_size(bar, bar_width, bar_height); lv_bar_set_value(bar, bar_value, LV_ANIM_OFF); lv_obj_set_style_base_dir(bar, LV_BASE_DIR_RTL, 0); /* FIXME: Remove wait */ lv_test_indev_wait(50); int32_t actual_coord = bar_ptr->indic_area.x1; /* Calculate current indicator width */ lv_coord_t bar_max_value = lv_bar_get_max_value(bar); lv_coord_t indicator_part_width = lv_obj_get_content_width(bar); lv_coord_t right_padding = lv_obj_get_style_pad_right(bar, LV_PART_MAIN); int32_t indicator_width = (bar_value * indicator_part_width) / bar_max_value; int32_t expected_coord = (bar_width - right_padding) - indicator_width; expected_coord -= 1; TEST_ASSERT_EQUAL_INT32(expected_coord, actual_coord); } void test_bar_indicator_area_should_get_smaller_when_padding_is_increased(void) { lv_bar_t * bar_ptr = (lv_bar_t *) bar; const lv_coord_t style_padding = 10u; static lv_style_t bar_style; int32_t new_height = 0u; int32_t new_width = 0u; int32_t original_height = 0u; int32_t original_width = 0u; lv_bar_set_value(bar, 50, LV_ANIM_OFF); lv_test_indev_wait(50); original_width = lv_area_get_width(&bar_ptr->indic_area); original_height = lv_area_get_height(&bar_ptr->indic_area); /* Setup new padding */ lv_style_init(&bar_style); lv_style_set_pad_all(&bar_style, style_padding); lv_obj_set_size(bar, 100, 50); /* Apply new style */ lv_obj_remove_style_all(bar); lv_obj_add_style(bar, &bar_style, LV_PART_MAIN); /* Notify LVGL of style change */ lv_obj_report_style_change(&bar_style); lv_test_indev_wait(50); new_height = lv_area_get_height(&bar_ptr->indic_area); new_width = lv_area_get_width(&bar_ptr->indic_area); TEST_ASSERT_LESS_THAN_INT32(original_height, new_height); TEST_ASSERT_LESS_THAN_INT32(original_width, new_width); } void test_bar_start_value_should_only_change_when_in_range_mode(void) { int32_t new_start_value = 20u; lv_bar_set_value(bar, 90, LV_ANIM_OFF); lv_bar_set_start_value(bar, new_start_value, LV_ANIM_OFF); /* Start value shouldn't be updated when not in RANGE mode */ TEST_ASSERT_EQUAL_INT32(0u, lv_bar_get_start_value(bar)); /* Set bar in RANGE mode so we can edit the start value */ lv_bar_set_mode(bar, LV_BAR_MODE_RANGE); lv_bar_set_start_value(bar, new_start_value, LV_ANIM_OFF); TEST_ASSERT_EQUAL_INT32(new_start_value, lv_bar_get_start_value(bar)); } void test_bar_start_value_should_be_smaller_than_current_value_in_range_mode(void) { /* Set bar in RANGE mode so we can edit the start value */ lv_bar_set_mode(bar, LV_BAR_MODE_RANGE); lv_bar_set_value(bar, 50, LV_ANIM_OFF); lv_bar_set_start_value(bar, 100u, LV_ANIM_OFF); TEST_ASSERT_EQUAL_INT32(lv_bar_get_value(bar), lv_bar_get_start_value(bar)); } void test_bar_current_value_should_be_truncated_to_max_value_when_exceeds_it(void) { int32_t max_value = lv_bar_get_max_value(bar); int32_t new_value = max_value + 1u; lv_bar_set_value(bar, new_value, LV_ANIM_OFF); TEST_ASSERT_EQUAL_INT32(max_value, lv_bar_get_value(bar)); } void test_bar_current_value_should_be_truncated_to_min_value_when_it_is_below_it(void) { int32_t min_value = lv_bar_get_min_value(bar); int32_t new_value = min_value - 1u; lv_bar_set_value(bar, new_value, LV_ANIM_OFF); TEST_ASSERT_EQUAL_INT32(min_value, lv_bar_get_value(bar)); } /** When in symmetrical mode, the bar indicator has to be drawn towards the min * range value. Requires a negative min range value and a positive max range * value. * * Bar properties assumed: * - base direction: LTR */ void test_bar_indicator_should_be_drawn_towards_the_min_range_side_after_setting_a_more_negative_value(void) { lv_bar_t * bar_ptr = (lv_bar_t *) bar; /* Setup bar properties */ lv_obj_set_size(bar, 100, 50); lv_bar_set_mode(bar, LV_BAR_MODE_SYMMETRICAL); lv_bar_set_range(bar, -100, 100); /* Set bar value to 1, so it gets drawn at the middle of the bar */ lv_bar_set_value(bar, 1, LV_ANIM_OFF); lv_test_indev_wait(50); lv_coord_t original_pos = bar_ptr->indic_area.x1; /* Set bar to a more negative value */ lv_bar_set_value(bar, -50, LV_ANIM_OFF); lv_test_indev_wait(50); lv_coord_t final_pos = bar_ptr->indic_area.x1; TEST_ASSERT_LESS_THAN(original_pos, final_pos); } #endif
b20f05539baf41b9c6c8098bf672c69e7fd386bd
7df190df28da7e4ff166e55dc8ce780f11236a9f
/src/switch/sys/brcmtag.h
6ddaafe312a199b237f43f5273efb1e6733189ec
[]
no_license
mirror/dd-wrt
25416946e6132aa54b35809de61834a1825a9a36
8f2934a5a2adfbb59b471375aa3a38de5d036531
refs/heads/master
2023-08-31T14:54:47.496685
2023-08-30T17:40:54
2023-08-30T17:40:54
7,470,282
520
281
null
2023-05-29T20:56:24
2013-01-06T17:21:29
null
UTF-8
C
false
false
2,215
h
brcmtag.h
/* * Broadcom Home Gateway Reference Design * BCM53xx RoboSwitch Broadcom tag driver header * * Copyright 2004, Broadcom Corporation * All Rights Reserved. * * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. * $Id$ */ #ifndef _brcm_h_ #define _brcm_h_ #include <linux/netdevice.h> struct brcm_dev_info { struct net_device *real_dev; /* the underlying device/interface */ struct net_device_stats dev_stats; /* Device stats (rx-bytes, tx-pkts, etc...) */ uint port; }; /* opcode defs */ #define BRCMTAG_UNICAST 0 #define BRCMTAG_MULTICAST 1 #define BRCMTAG_EGRESS_DIRECT 2 #define BRCMTAG_INGRESS_DIRECT 3 #define BRCMTAG_MULT_EGRESS 5 #pragma pack(1) typedef struct _brcm_tag { unsigned char port:4; unsigned char cid_src:2; unsigned char rsvd1:2; unsigned char cid_dest:2; unsigned char rsvd:6; unsigned int count:11; unsigned char mirror_only:1; unsigned char mirror:1; unsigned char opcode:3; } brcm_tag; #pragma pack() typedef struct _brcm_hdr { unsigned short proto; /* BRCM_TYPE */ brcm_tag tag; /* brcm tag */ } brcm_hdr; #define BRCM_DEV_INFO(x) ((struct brcm_dev_info *)(x->priv)) #define BRCM_TYPE 0x8874 #define BRCM_ETH_HLEN 20 /* total octets in header */ #define BRCM_VLAN_ETH_HLEN 24 /* total octets in header w/vlan tag also */ #define BRCM_HLEN 6 /* The additional bytes (on top of the Ethernet header) */ /* required by brcm header */ /* min packet len is ETH_ZLEN + sizeof(FCS). must pad to this length after VLAN and */ /* BRCM headers removed */ #define GET_PAD_BYTES(pkt_len) ((pkt_len) - (ETH_ZLEN + sizeof(uint32_t)) - VLAN_HLEN - sizeof(brcm_hdr)) void brcm_module_init(void); void brcm_module_deinit(void); struct net_device *register_brcmtag_device(const char *eth_IF_name, const char *suffix, uint port); int unregister_brcm_device(const char *brcm_IF_name); #endif /* _brcm_h_ */
d6d9321dab7316f0e8f5bf28f56b271cd3c7c6d7
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/usr.sbin/ifwatchd/ifwatchd.c
793bdda12d703d3017b96a686325b4fa3d67760a
[]
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
15,063
c
ifwatchd.c
/* $NetBSD: ifwatchd.c,v 1.47 2023/07/01 12:36:10 mlelstv Exp $ */ #include <sys/cdefs.h> __RCSID("$NetBSD: ifwatchd.c,v 1.47 2023/07/01 12:36:10 mlelstv Exp $"); /*- * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Martin Husemann <martin@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/types.h> #include <sys/param.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/queue.h> #include <sys/wait.h> #include <net/if.h> #include <net/if_dl.h> #include <net/route.h> #include <netinet/in.h> #include <netinet/in_var.h> #include <arpa/inet.h> #include <err.h> #include <errno.h> #include <ifaddrs.h> #include <netdb.h> #include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <syslog.h> #include <unistd.h> enum event { ARRIVAL, DEPARTURE, UP, DOWN, CARRIER, NO_CARRIER }; enum addrflag { NOTREADY, DETACHED, DEPRECATED, READY }; /* local functions */ __dead static void usage(void); static void dispatch(const void *, size_t); static enum addrflag check_addrflags(int af, int addrflags); static void check_addrs(const struct ifa_msghdr *ifam); static void invoke_script(const char *ifname, enum event ev, const struct sockaddr *sa, const struct sockaddr *dst); static void list_interfaces(const char *ifnames); static void check_announce(const struct if_announcemsghdr *ifan); static void check_carrier(const struct if_msghdr *ifm); static void free_interfaces(void); static struct interface_data * find_interface(int index); static void run_initial_ups(bool); /* global variables */ static int verbose = 0, quiet = 0; static int inhibit_initial = 0; static const char *arrival_script = NULL; static const char *departure_script = NULL; static const char *up_script = NULL; static const char *down_script = NULL; static const char *carrier_script = NULL; static const char *no_carrier_script = NULL; static const char DummyTTY[] = _PATH_DEVNULL; static const char DummySpeed[] = "9600"; static const char **scripts[] = { &arrival_script, &departure_script, &up_script, &down_script, &carrier_script, &no_carrier_script }; struct interface_data { SLIST_ENTRY(interface_data) next; int index; int last_carrier_status; char * ifname; }; static SLIST_HEAD(,interface_data) ifs = SLIST_HEAD_INITIALIZER(ifs); int main(int argc, char **argv) { int c, s, n; int errs = 0; struct msghdr msg; struct iovec iov[1]; char buf[2048]; unsigned char msgfilter[] = { RTM_IFINFO, RTM_IFANNOUNCE, RTM_NEWADDR, RTM_DELADDR, }; openlog(argv[0], LOG_PID|LOG_CONS, LOG_DAEMON); while ((c = getopt(argc, argv, "qvhic:n:u:d:A:D:")) != -1) { switch (c) { case 'h': usage(); return 0; case 'i': inhibit_initial = 1; break; case 'v': verbose++; break; case 'q': quiet = 1; break; case 'c': carrier_script = optarg; break; case 'n': no_carrier_script = optarg; break; case 'u': up_script = optarg; break; case 'd': down_script = optarg; break; case 'A': arrival_script = optarg; break; case 'D': departure_script = optarg; break; default: errs++; break; } } if (errs) usage(); argv += optind; argc -= optind; if (argc <= 0) usage(); if (verbose) { printf("up_script: %s\ndown_script: %s\n", up_script, down_script); printf("arrival_script: %s\ndeparture_script: %s\n", arrival_script, departure_script); printf("carrier_script: %s\nno_carrier_script: %s\n", carrier_script, no_carrier_script); printf("verbosity = %d\n", verbose); } while (argc > 0) { list_interfaces(argv[0]); argv++; argc--; } if (!verbose) daemon(0, 0); s = socket(PF_ROUTE, SOCK_RAW, 0); if (s < 0) { syslog(LOG_ERR, "error opening routing socket: %m"); exit(EXIT_FAILURE); } if (setsockopt(s, PF_ROUTE, RO_MSGFILTER, &msgfilter, sizeof(msgfilter)) < 0) syslog(LOG_ERR, "RO_MSGFILTER: %m"); n = 1; if (setsockopt(s, SOL_SOCKET, SO_RERROR, &n, sizeof(n)) < 0) syslog(LOG_ERR, "SO_RERROR: %m"); if (!inhibit_initial) run_initial_ups(true); iov[0].iov_base = buf; iov[0].iov_len = sizeof(buf); memset(&msg, 0, sizeof(msg)); msg.msg_iov = iov; msg.msg_iovlen = 1; for (;;) { n = recvmsg(s, &msg, 0); if (n == -1) { if (errno == ENOBUFS) { syslog(LOG_ERR, "routing socket overflow detected"); /* XXX We don't track addresses, so they * won't be reported. */ if (!inhibit_initial) run_initial_ups(false); continue; } syslog(LOG_ERR, "recvmsg: %m"); exit(EXIT_FAILURE); } if (n != 0) dispatch(iov[0].iov_base, n); } close(s); free_interfaces(); closelog(); return EXIT_SUCCESS; } static void usage(void) { fprintf(stderr, "usage:\n" "\tifwatchd [-hiqv] [-A arrival-script] [-D departure-script]\n" "\t\t [-d down-script] [-u up-script]\n" "\t\t [-c carrier-script] [-n no-carrier-script] ifname(s)\n" "\twhere:\n" "\t -A <cmd> specify command to run on interface arrival event\n" "\t -c <cmd> specify command to run on interface carrier-detect event\n" "\t -D <cmd> specify command to run on interface departure event\n" "\t -d <cmd> specify command to run on interface down event\n" "\t -n <cmd> specify command to run on interface no-carrier-detect event\n" "\t -h show this help message\n" "\t -i no (!) initial run of the up script if the interface\n" "\t is already up on ifwatchd startup\n" "\t -q quiet mode, don't syslog informational messages\n" "\t -u <cmd> specify command to run on interface up event\n" "\t -v verbose/debug output, don't run in background\n"); exit(EXIT_FAILURE); } static void dispatch(const void *msg, size_t len) { const struct rt_msghdr *hd = msg; if (hd->rtm_version != RTM_VERSION) return; switch (hd->rtm_type) { case RTM_NEWADDR: case RTM_DELADDR: check_addrs(msg); break; case RTM_IFANNOUNCE: check_announce(msg); break; case RTM_IFINFO: check_carrier(msg); break; default: /* Should be impossible as we filter messages. */ if (verbose) printf("unknown message ignored (%d)\n", hd->rtm_type); break; } } static enum addrflag check_addrflags(int af, int addrflags) { switch (af) { case AF_INET: if (addrflags & IN_IFF_NOTREADY) return NOTREADY; if (addrflags & IN_IFF_DETACHED) return DETACHED; break; case AF_INET6: if (addrflags & IN6_IFF_NOTREADY) return NOTREADY; if (addrflags & IN6_IFF_DETACHED) return DETACHED; if (addrflags & IN6_IFF_DEPRECATED) return DEPRECATED; break; } return READY; } static void check_addrs(const struct ifa_msghdr *ifam) { const char *cp = (const char *)(ifam + 1); const struct sockaddr *sa, *ifa = NULL, *brd = NULL; unsigned i; struct interface_data *ifd = NULL; int aflag; enum event ev; if (ifam->ifam_addrs == 0) return; for (i = 1; i; i <<= 1) { if ((i & ifam->ifam_addrs) == 0) continue; sa = (const struct sockaddr *)cp; if (i == RTA_IFP) { const struct sockaddr_dl *li; li = (const struct sockaddr_dl *)sa; if ((ifd = find_interface(li->sdl_index)) == NULL) { if (verbose) printf("ignoring change" " on interface #%d\n", li->sdl_index); return; } } else if (i == RTA_IFA) ifa = sa; else if (i == RTA_BRD) brd = sa; RT_ADVANCE(cp, sa); } if (ifa != NULL && ifd != NULL) { ev = ifam->ifam_type == RTM_DELADDR ? DOWN : UP; aflag = check_addrflags(ifa->sa_family, ifam->ifam_addrflags); if ((ev == UP && aflag == READY) || ev == DOWN) invoke_script(ifd->ifname, ev, ifa, brd); } } static void invoke_script(const char *ifname, enum event ev, const struct sockaddr *sa, const struct sockaddr *dest) { char addr[NI_MAXHOST], daddr[NI_MAXHOST]; const char *script; int status; if (ifname == NULL) return; script = *scripts[ev]; if (script == NULL) return; addr[0] = daddr[0] = 0; if (sa != NULL) { const struct sockaddr_in *sin; const struct sockaddr_in6 *sin6; if (sa->sa_len == 0) { syslog(LOG_ERR, "illegal socket address (sa_len == 0)"); return; } switch (sa->sa_family) { case AF_INET: sin = (const struct sockaddr_in *)sa; if (sin->sin_addr.s_addr == INADDR_ANY || sin->sin_addr.s_addr == INADDR_BROADCAST) return; break; case AF_INET6: sin6 = (const struct sockaddr_in6 *)sa; if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) return; break; default: break; } if (getnameinfo(sa, sa->sa_len, addr, sizeof addr, NULL, 0, NI_NUMERICHOST)) { if (verbose) printf("getnameinfo failed\n"); return; /* this address can not be handled */ } } if (dest != NULL) { if (getnameinfo(dest, dest->sa_len, daddr, sizeof daddr, NULL, 0, NI_NUMERICHOST)) { if (verbose) printf("getnameinfo failed\n"); return; /* this address can not be handled */ } } if (verbose) (void) printf("calling: %s %s %s %s %s %s\n", script, ifname, DummyTTY, DummySpeed, addr, daddr); if (!quiet) syslog(LOG_INFO, "calling: %s %s %s %s %s %s\n", script, ifname, DummyTTY, DummySpeed, addr, daddr); switch (vfork()) { case -1: syslog(LOG_ERR, "cannot fork: %m"); break; case 0: if (execl(script, script, ifname, DummyTTY, DummySpeed, addr, daddr, NULL) == -1) { syslog(LOG_ERR, "could not execute \"%s\": %m", script); } _exit(EXIT_FAILURE); default: (void) wait(&status); } } static void list_interfaces(const char *ifnames) { char * names = strdup(ifnames); char * name, *lasts; static const char sep[] = " \t"; struct interface_data * p; for (name = strtok_r(names, sep, &lasts); name != NULL; name = strtok_r(NULL, sep, &lasts)) { p = malloc(sizeof(*p)); SLIST_INSERT_HEAD(&ifs, p, next); p->last_carrier_status = -1; p->ifname = strdup(name); p->index = if_nametoindex(p->ifname); if (!quiet) syslog(LOG_INFO, "watching interface %s", p->ifname); if (verbose) printf("interface \"%s\" has index %d\n", p->ifname, p->index); } free(names); } static void check_carrier(const struct if_msghdr *ifm) { struct interface_data * p; int carrier_status; enum event ev; SLIST_FOREACH(p, &ifs, next) if (p->index == ifm->ifm_index) break; if (p == NULL) return; /* * Treat it as an event worth handling if: * - the carrier status changed, or * - this is the first time we've been called, and * inhibit_initial is not set */ carrier_status = ifm->ifm_data.ifi_link_state; if (carrier_status != p->last_carrier_status) { switch (carrier_status) { case LINK_STATE_UP: ev = CARRIER; break; case LINK_STATE_DOWN: ev = NO_CARRIER; break; default: if (verbose) printf("unknown link status ignored\n"); return; } invoke_script(p->ifname, ev, NULL, NULL); p->last_carrier_status = carrier_status; } } static void do_announce(struct interface_data *ifd, unsigned short what, unsigned short index) { switch (what) { case IFAN_ARRIVAL: ifd->index = index; invoke_script(ifd->ifname, ARRIVAL, NULL, NULL); break; case IFAN_DEPARTURE: ifd->index = -1; ifd->last_carrier_status = -1; invoke_script(ifd->ifname, DEPARTURE, NULL, NULL); break; default: if (verbose) (void) printf("unknown announce: what=%d\n", what); break; } } static void check_announce(const struct if_announcemsghdr *ifan) { struct interface_data * p; const char *ifname = ifan->ifan_name; SLIST_FOREACH(p, &ifs, next) { if (strcmp(p->ifname, ifname) != 0) continue; do_announce(p, ifan->ifan_what, ifan->ifan_index); return; } } static void free_interfaces(void) { struct interface_data * p; while (!SLIST_EMPTY(&ifs)) { p = SLIST_FIRST(&ifs); SLIST_REMOVE_HEAD(&ifs, next); free(p->ifname); free(p); } } static struct interface_data * find_interface(int idx) { struct interface_data * p; SLIST_FOREACH(p, &ifs, next) if (p->index == idx) return p; return NULL; } static void run_initial_ups(bool do_addrs) { struct interface_data * ifd; struct ifaddrs *res = NULL, *p; struct sockaddr *ifa; const struct if_data *ifi; int s, aflag; s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) return; if (getifaddrs(&res) != 0) goto out; /* Check if any interfaces vanished */ SLIST_FOREACH(ifd, &ifs, next) { for (p = res; p; p = p->ifa_next) { if (strcmp(ifd->ifname, p->ifa_name) != 0) continue; ifa = p->ifa_addr; if (ifa != NULL && ifa->sa_family == AF_LINK) break; } if (p == NULL) do_announce(ifd, IFAN_DEPARTURE, ifd->index); } for (p = res; p; p = p->ifa_next) { SLIST_FOREACH(ifd, &ifs, next) { if (strcmp(ifd->ifname, p->ifa_name) == 0) break; } if (ifd == NULL) continue; ifa = p->ifa_addr; if (ifa != NULL && ifa->sa_family == AF_LINK && ifd->index == -1) invoke_script(ifd->ifname, ARRIVAL, NULL, NULL); if ((p->ifa_flags & IFF_UP) == 0) continue; if (ifa == NULL) continue; if (ifa->sa_family == AF_LINK) { ifi = (const struct if_data *)p->ifa_data; if (ifd->last_carrier_status == ifi->ifi_link_state) continue; switch (ifi->ifi_link_state) { case LINK_STATE_UP: invoke_script(ifd->ifname, CARRIER, NULL, NULL); break; case LINK_STATE_DOWN: if (ifd->last_carrier_status == -1) break; invoke_script(ifd->ifname, CARRIER, NULL, NULL); break; } ifd->last_carrier_status = ifi->ifi_link_state; continue; } if (!do_addrs) continue; aflag = check_addrflags(ifa->sa_family, p->ifa_addrflags); if (aflag != READY) continue; invoke_script(ifd->ifname, UP, ifa, p->ifa_dstaddr); } freeifaddrs(res); out: close(s); }
ecd87473e48e2c19468c2a6ecf60efac55a33c02
3e8f16e18eb953456ca399192ea8c54c1a218376
/src/cl_dll/demo.h
27007b4adce63a630b08449024d9c3f553b2e5db
[]
no_license
maxvollmer/Half-Life-VR
6437ffb3f6b098c0387b70c6e674572d94c0f190
f05957aa919765a1f53e54f3727e2c64ac1ec65f
refs/heads/main
2023-05-14T02:29:24.136125
2023-05-07T19:48:18
2023-05-07T19:48:18
102,905,323
241
42
null
2023-05-07T19:48:19
2017-09-08T21:19:41
C++
UTF-8
C
false
false
560
h
demo.h
//========= Copyright � 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= #if !defined(DEMOH) #define DEMOH #pragma once // Types of demo messages we can write/parse enum { TYPE_SNIPERDOT = 0, TYPE_ZOOM }; void Demo_WriteBuffer(int type, int size, unsigned char* buffer); extern int g_demosniper; extern int g_demosniperdamage; extern float g_demosniperorg[3]; extern float g_demosniperangles[3]; extern float g_demozoom; #endif
8c273f424b155f7774b4e2850026f51000403eab
88ae8695987ada722184307301e221e1ba3cc2fa
/v8/third_party/glibc/src/sysdeps/ieee754/dbl-64/branred.c
3abfa1e0b4df28d0abc4037f1d4cc305f93110b9
[ "LGPL-2.1-only", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "SunPro", "Apache-2.0" ]
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
4,040
c
branred.c
/* * IBM Accurate Mathematical Library * Copyright (C) 2001-2022 Free Software Foundation, Inc. * * 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 2.1 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 Lesser 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 <https://www.gnu.org/licenses/>. */ /*******************************************************************/ /* */ /* MODULE_NAME: branred.c */ /* */ /* FUNCTIONS: branred */ /* */ /* FILES NEEDED: branred.h mydefs.h endian.h mpa.h */ /* mha.c */ /* */ /* Routine branred() performs range reduction of a double number */ /* x into Double length number a+aa,such that */ /* x=n*pi/2+(a+aa), abs(a+aa)<pi/4, n=0,+-1,+-2,.... */ /* Routine returns the integer (n mod 4) of the above description */ /* of x. */ /*******************************************************************/ #include "endian.h" #include "mydefs.h" #include "branred.h" #include <math.h> #ifndef SECTION # define SECTION #endif /*******************************************************************/ /* Routine branred() performs range reduction of a double number */ /* x into Double length number a+aa,such that */ /* x=n*pi/2+(a+aa), abs(a+aa)<pi/4, n=0,+-1,+-2,.... */ /* Routine return integer (n mod 4) */ /*******************************************************************/ int SECTION __branred(double x, double *a, double *aa) { int i,k; mynumber u,gor; double r[6],s,t,sum,b,bb,sum1,sum2,b1,bb1,b2,bb2,x1,x2,t1,t2; x*=tm600.x; t=x*split; /* split x to two numbers */ x1=t-(t-x); x2=x-x1; sum=0; u.x = x1; k = (u.i[HIGH_HALF]>>20)&2047; k = (k-450)/24; if (k<0) k=0; gor.x = t576.x; gor.i[HIGH_HALF] -= ((k*24)<<20); for (i=0;i<6;i++) { r[i] = x1*toverp[k+i]*gor.x; gor.x *= tm24.x; } for (i=0;i<3;i++) { s=(r[i]+big.x)-big.x; sum+=s; r[i]-=s; } t=0; for (i=0;i<6;i++) t+=r[5-i]; bb=(((((r[0]-t)+r[1])+r[2])+r[3])+r[4])+r[5]; s=(t+big.x)-big.x; sum+=s; t-=s; b=t+bb; bb=(t-b)+bb; s=(sum+big1.x)-big1.x; sum-=s; b1=b; bb1=bb; sum1=sum; sum=0; u.x = x2; k = (u.i[HIGH_HALF]>>20)&2047; k = (k-450)/24; if (k<0) k=0; gor.x = t576.x; gor.i[HIGH_HALF] -= ((k*24)<<20); for (i=0;i<6;i++) { r[i] = x2*toverp[k+i]*gor.x; gor.x *= tm24.x; } for (i=0;i<3;i++) { s=(r[i]+big.x)-big.x; sum+=s; r[i]-=s; } t=0; for (i=0;i<6;i++) t+=r[5-i]; bb=(((((r[0]-t)+r[1])+r[2])+r[3])+r[4])+r[5]; s=(t+big.x)-big.x; sum+=s; t-=s; b=t+bb; bb=(t-b)+bb; s=(sum+big1.x)-big1.x; sum-=s; b2=b; bb2=bb; sum2=sum; sum=sum1+sum2; b=b1+b2; bb = (fabs(b1)>fabs(b2))? (b1-b)+b2 : (b2-b)+b1; if (b > 0.5) {b-=1.0; sum+=1.0;} else if (b < -0.5) {b+=1.0; sum-=1.0;} s=b+(bb+bb1+bb2); t=((b-s)+bb)+(bb1+bb2); b=s*split; t1=b-(b-s); t2=s-t1; b=s*hp0.x; bb=(((t1*mp1.x-b)+t1*mp2.x)+t2*mp1.x)+(t2*mp2.x+s*hp1.x+t*hp0.x); s=b+bb; t=(b-s)+bb; *a=s; *aa=t; return ((int) sum)&3; /* return quater of unit circle */ }
6bb648c84f456a3647ae7f6e5c2915d7f1a78ff5
290c96ec464bc49084696b1df71c088ddcc9ffff
/modules/mcemu/mcemu_io.c
b7fd5bb19b1d8b61532325fa4b504a6ea7d8aa19
[ "AFL-3.0" ]
permissive
ps2homebrew/Open-PS2-Loader
c23cce4e8b6d08bdc4b229da9bcb7c9bd31fc255
9e12706ef5ac0f4a3b72fe5860c1e38d2e94e151
refs/heads/master
2023-08-14T21:37:43.222099
2023-08-14T18:18:19
2023-08-14T18:18:19
70,989,832
1,378
262
AFL-3.0
2023-08-19T21:20:14
2016-10-15T13:37:16
C
UTF-8
C
false
false
1,402
c
mcemu_io.c
/* Copyright 2006-2008, Romz Copyright 2010, Polo Licenced under Academic Free License version 3.0 Review OpenUsbLd README & LICENSE files for further details. */ #include "mcemu.h" int mc_configure(MemoryCard *mcds) { register int i; DPRINTF("vmcSpec[0].active = %d\n", vmcSpec[0].active); DPRINTF("vmcSpec[1].active = %d\n", vmcSpec[1].active); if (vmcSpec[0].active == 0 && vmcSpec[1].active == 0) return 0; for (i = 0; i < MCEMU_PORTS; i++, mcds++) { DPRINTF("vmcSpec[%d].flags = 0x%X\n", i, vmcSpec[i].flags); DPRINTF("vmcSpec[%d].cspec.PageSize = 0x%X\n", i, vmcSpec[i].cspec.PageSize); DPRINTF("vmcSpec[%d].cspec.BlockSize = 0x%X\n", i, vmcSpec[i].cspec.BlockSize); DPRINTF("vmcSpec[%d].cspec.CardSize = 0x%X\n", i, (unsigned int)vmcSpec[i].cspec.CardSize); if (vmcSpec[i].active == 1) { // Set virtual memorycard informations mcds->mcnum = i; mcds->tcode = 0x5A; /* 'Z' */ mcds->cbufp = &mceccbuf[i][0]; mcds->dbufp = &mcdatabuf[0]; mcds->flags = vmcSpec[i].flags; mcds->cspec.PageSize = vmcSpec[i].cspec.PageSize; mcds->cspec.BlockSize = vmcSpec[i].cspec.BlockSize; mcds->cspec.CardSize = vmcSpec[i].cspec.CardSize; } else mcds->mcnum = -1; } return 1; }
5c6a551fdc0a5b7cc828d273f78ffc0d0c822292
8b98cd47f934d2a4a8d0b2842d3277b01f3fb7fa
/applications/obsolete/asterix/lib/aio_scrnsz_c.c
dba00285e4f6a7b5ef303169d9f60b6c2bd15dd3
[]
no_license
Starlink/starlink
1cc03b85eb78330a3622003b26b69c1733df50fe
2c374b3e97c9cebcc8f3bd2f8b4bb326eefe061a
refs/heads/master
2023-07-26T09:32:27.987319
2023-07-05T23:56:27
2023-07-05T23:56:27
5,169,323
139
45
null
2022-11-18T13:29:32
2012-07-24T18:15:25
Fortran
UTF-8
C
false
false
864
c
aio_scrnsz_c.c
/* aio_scrnsz /* /* compile with -I/star/include (use gcc on Sun) /* /* History: /* 1-JAN-1992 (KFH): /* Original Version /* 17-MAR-1993 (AJC): /* Added endwin() /* Correctly cast initscr /* 21-JUL-1993 (AJC): /* Use ioctl to prevent problems on Solaris */ #ifndef vms #include "sae_par.h" #include "termio.h" #include "f77.h" #include "asterix.h" F77_INTEGER_FUNCTION(aio_scrnsz)(INTEGER(width),INTEGER(height),INTEGER(status)) { GENPTR_INTEGER(width) GENPTR_INTEGER(height) GENPTR_INTEGER(status) #ifdef TIOCGWINSZ struct winsize s; if ( ! _ok(status) ) return 0; /* this 1 is the file descriptor eqivalent of 'SYS$OUTPUT' on VMS. */ if (ioctl (1, TIOCGWINSZ, &s)) return 0; *height = s.ws_row; *width = s.ws_col; return 1; #else if ( ! _ok(status) ) return 0; *height = 0; *width = 80; #endif } #endif
48336a1f97815385f1fc279dc8333bd7cd27e58c
fbe68d84e97262d6d26dd65c704a7b50af2b3943
/third_party/virtualbox/src/VBox/Additions/WINNT/Graphics/Wine_new/wined3d/nvidia_texture_shader.c
c5580c08a9955b198ffab64672198fed0d60fc75
[ "GPL-2.0-only", "LicenseRef-scancode-unknown-license-reference", "CDDL-1.0", "LicenseRef-scancode-warranty-disclaimer", "GPL-1.0-or-later", "LGPL-2.1-or-later", "GPL-2.0-or-later", "MPL-1.0", "LicenseRef-scancode-generic-exception", "Apache-2.0", "OpenSSL", "MIT" ]
permissive
thalium/icebox
c4e6573f2b4f0973b6c7bb0bf068fe9e795fdcfb
6f78952d58da52ea4f0e55b2ab297f28e80c1160
refs/heads/master
2022-08-14T00:19:36.984579
2022-02-22T13:10:31
2022-02-22T13:10:31
190,019,914
585
109
MIT
2022-01-13T20:58:15
2019-06-03T14:18:12
C++
UTF-8
C
false
false
59,629
c
nvidia_texture_shader.c
/* * Fixed function pipeline replacement using GL_NV_register_combiners * and GL_NV_texture_shader * * Copyright 2006 Henri Verbeet * Copyright 2008 Stefan Dösinger(for CodeWeavers) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ /* * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice * other than GPL or LGPL is available it will apply instead, Oracle elects to use only * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where * a choice of LGPL license versions is made available with the language indicating * that LGPLv2 or any later version may be used, or where a choice of which version * of the LGPL is applied is otherwise unspecified. */ #include "config.h" #include "wine/port.h" #include <math.h> #include <stdio.h> #include "wined3d_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d); /* Context activation for state handlers is done by the caller. */ static void nvts_activate_dimensions(const struct wined3d_state *state, DWORD stage, struct wined3d_context *context) { const struct wined3d_gl_info *gl_info = context->gl_info; BOOL bumpmap = FALSE; if (stage > 0 && (state->texture_states[stage - 1][WINED3D_TSS_COLOR_OP] == WINED3D_TOP_BUMPENVMAP_LUMINANCE || state->texture_states[stage - 1][WINED3D_TSS_COLOR_OP] == WINED3D_TOP_BUMPENVMAP)) { bumpmap = TRUE; context->texShaderBumpMap |= (1 << stage); } else { context->texShaderBumpMap &= ~(1 << stage); } if (state->textures[stage]) { switch (state->textures[stage]->target) { case GL_TEXTURE_2D: gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_2D); checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, ...)"); break; case GL_TEXTURE_RECTANGLE_ARB: gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, ...)"); break; case GL_TEXTURE_3D: gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_3D); checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_3D)"); break; case GL_TEXTURE_CUBE_MAP_ARB: gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_CUBE_MAP_ARB)"); break; } } else { gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE); checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE)"); } } struct tex_op_args { GLenum input[3]; GLenum mapping[3]; GLenum component_usage[3]; }; static GLenum d3dta_to_combiner_input(DWORD d3dta, DWORD stage, INT texture_idx) { switch (d3dta) { case WINED3DTA_DIFFUSE: return GL_PRIMARY_COLOR_NV; case WINED3DTA_CURRENT: if (stage) return GL_SPARE0_NV; else return GL_PRIMARY_COLOR_NV; case WINED3DTA_TEXTURE: if (texture_idx > -1) return GL_TEXTURE0_ARB + texture_idx; else return GL_PRIMARY_COLOR_NV; case WINED3DTA_TFACTOR: return GL_CONSTANT_COLOR0_NV; case WINED3DTA_SPECULAR: return GL_SECONDARY_COLOR_NV; case WINED3DTA_TEMP: return GL_SPARE1_NV; case WINED3DTA_CONSTANT: /* TODO: Support per stage constants (WINED3D_TSS_CONSTANT, NV_register_combiners2) */ FIXME("WINED3DTA_CONSTANT, not properly supported.\n"); return GL_CONSTANT_COLOR1_NV; default: FIXME("Unrecognized texture arg %#x\n", d3dta); return GL_TEXTURE; } } static GLenum invert_mapping(GLenum mapping) { if (mapping == GL_UNSIGNED_INVERT_NV) return GL_UNSIGNED_IDENTITY_NV; else if (mapping == GL_UNSIGNED_IDENTITY_NV) return GL_UNSIGNED_INVERT_NV; FIXME("Unhandled mapping %#x\n", mapping); return mapping; } static void get_src_and_opr_nvrc(DWORD stage, DWORD arg, BOOL is_alpha, GLenum* input, GLenum* mapping, GLenum *component_usage, INT texture_idx) { /* The WINED3DTA_COMPLEMENT flag specifies the complement of the input should * be used. */ if (arg & WINED3DTA_COMPLEMENT) *mapping = GL_UNSIGNED_INVERT_NV; else *mapping = GL_UNSIGNED_IDENTITY_NV; /* Clamp all values to positive ranges */ /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the input * should be used for all input components. */ if (is_alpha || arg & WINED3DTA_ALPHAREPLICATE) *component_usage = GL_ALPHA; else *component_usage = GL_RGB; *input = d3dta_to_combiner_input(arg & WINED3DTA_SELECTMASK, stage, texture_idx); } void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state, BOOL is_alpha, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx, DWORD dst) { struct tex_op_args tex_op_args = {{0}, {0}, {0}}; GLenum portion = is_alpha ? GL_ALPHA : GL_RGB; GLenum target = GL_COMBINER0_NV + stage; GLenum output; TRACE("stage %d, is_alpha %d, op %s, arg1 %#x, arg2 %#x, arg3 %#x, texture_idx %d\n", stage, is_alpha, debug_d3dtop(op), arg1, arg2, arg3, texture_idx); /* If a texture stage references an invalid texture unit the stage just * passes through the result from the previous stage */ if (is_invalid_op(state, stage, op, arg1, arg2, arg3)) { arg1 = WINED3DTA_CURRENT; op = WINED3D_TOP_SELECT_ARG1; } get_src_and_opr_nvrc(stage, arg1, is_alpha, &tex_op_args.input[0], &tex_op_args.mapping[0], &tex_op_args.component_usage[0], texture_idx); get_src_and_opr_nvrc(stage, arg2, is_alpha, &tex_op_args.input[1], &tex_op_args.mapping[1], &tex_op_args.component_usage[1], texture_idx); get_src_and_opr_nvrc(stage, arg3, is_alpha, &tex_op_args.input[2], &tex_op_args.mapping[2], &tex_op_args.component_usage[2], texture_idx); if(dst == WINED3DTA_TEMP) { output = GL_SPARE1_NV; } else { output = GL_SPARE0_NV; } /* This is called by a state handler which has the gl lock held and a context for the thread */ switch (op) { case WINED3D_TOP_DISABLE: /* Only for alpha */ if (!is_alpha) ERR("Shouldn't be called for WINED3D_TSS_COLOR_OP (WINED3DTOP_DISABLE).\n"); /* Input, prev_alpha*1 */ GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA)); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA)); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_SELECT_ARG1: case WINED3D_TOP_SELECT_ARG2: /* Input, arg*1 */ if (op == WINED3D_TOP_SELECT_ARG1) GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); else GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, output, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_MODULATE: case WINED3D_TOP_MODULATE_2X: case WINED3D_TOP_MODULATE_4X: /* Input, arg1*arg2 */ GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); /* Output */ if (op == WINED3D_TOP_MODULATE) GL_EXTCALL(glCombinerOutputNV(target, portion, output, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); else if (op == WINED3D_TOP_MODULATE_2X) GL_EXTCALL(glCombinerOutputNV(target, portion, output, GL_DISCARD_NV, GL_DISCARD_NV, GL_SCALE_BY_TWO_NV, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); else if (op == WINED3D_TOP_MODULATE_4X) GL_EXTCALL(glCombinerOutputNV(target, portion, output, GL_DISCARD_NV, GL_DISCARD_NV, GL_SCALE_BY_FOUR_NV, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_ADD: case WINED3D_TOP_ADD_SIGNED: case WINED3D_TOP_ADD_SIGNED_2X: /* Input, arg1*1+arg2*1 */ GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); /* Output */ if (op == WINED3D_TOP_ADD) GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); else if (op == WINED3D_TOP_ADD_SIGNED) GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_BIAS_BY_NEGATIVE_ONE_HALF_NV, GL_FALSE, GL_FALSE, GL_FALSE)); else if (op == WINED3D_TOP_ADD_SIGNED_2X) GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_SCALE_BY_TWO_NV, GL_BIAS_BY_NEGATIVE_ONE_HALF_NV, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_SUBTRACT: /* Input, arg1*1+-arg2*1 */ GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV, tex_op_args.input[1], GL_SIGNED_NEGATE_NV, tex_op_args.component_usage[1])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_ADD_SMOOTH: /* Input, arg1*1+(1-arg1)*arg2 */ GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV, tex_op_args.input[0], invert_mapping(tex_op_args.mapping[0]), tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_BLEND_DIFFUSE_ALPHA: case WINED3D_TOP_BLEND_TEXTURE_ALPHA: case WINED3D_TOP_BLEND_FACTOR_ALPHA: case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM: case WINED3D_TOP_BLEND_CURRENT_ALPHA: { GLenum alpha_src = GL_PRIMARY_COLOR_NV; if (op == WINED3D_TOP_BLEND_DIFFUSE_ALPHA) alpha_src = d3dta_to_combiner_input(WINED3DTA_DIFFUSE, stage, texture_idx); else if (op == WINED3D_TOP_BLEND_TEXTURE_ALPHA) alpha_src = d3dta_to_combiner_input(WINED3DTA_TEXTURE, stage, texture_idx); else if (op == WINED3D_TOP_BLEND_FACTOR_ALPHA) alpha_src = d3dta_to_combiner_input(WINED3DTA_TFACTOR, stage, texture_idx); else if (op == WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM) alpha_src = d3dta_to_combiner_input(WINED3DTA_TEXTURE, stage, texture_idx); else if (op == WINED3D_TOP_BLEND_CURRENT_ALPHA) alpha_src = d3dta_to_combiner_input(WINED3DTA_CURRENT, stage, texture_idx); else FIXME("Unhandled texture op %s, shouldn't happen.\n", debug_d3dtop(op)); /* Input, arg1*alpha_src+arg2*(1-alpha_src) */ GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); if (op == WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM) { GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); } else { GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, alpha_src, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA)); } GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV, alpha_src, GL_UNSIGNED_INVERT_NV, GL_ALPHA)); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; } case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR: /* Input, arg1_alpha*arg2_rgb+arg1_rgb*1 */ if (is_alpha) ERR("Only supported for WINED3D_TSS_COLOR_OP (WINED3DTOP_MODULATEALPHA_ADDCOLOR).\n"); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], tex_op_args.mapping[0], GL_ALPHA)); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA: /* Input, arg1_rgb*arg2_rgb+arg1_alpha*1 */ if (is_alpha) ERR("Only supported for WINED3D_TSS_COLOR_OP (WINED3DTOP_MODULATECOLOR_ADDALPHA).\n"); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV, tex_op_args.input[0], tex_op_args.mapping[0], GL_ALPHA)); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR: /* Input, (1-arg1_alpha)*arg2_rgb+arg1_rgb*1 */ if (is_alpha) ERR("Only supported for WINED3D_TSS_COLOR_OP (WINED3DTOP_MODULATEINVALPHA_ADDCOLOR).\n"); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], invert_mapping(tex_op_args.mapping[0]), GL_ALPHA)); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA: /* Input, (1-arg1_rgb)*arg2_rgb+arg1_alpha*1 */ if (is_alpha) ERR("Only supported for WINED3D_TSS_COLOR_OP (WINED3DTOP_MODULATEINVCOLOR_ADDALPHA).\n"); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], invert_mapping(tex_op_args.mapping[0]), tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV, tex_op_args.input[0], tex_op_args.mapping[0], GL_ALPHA)); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_DOTPRODUCT3: /* Input, arg1 . arg2 */ /* FIXME: DX7 uses a different calculation? */ GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[0], GL_EXPAND_NORMAL_NV, tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, tex_op_args.input[1], GL_EXPAND_NORMAL_NV, tex_op_args.component_usage[1])); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, output, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_MULTIPLY_ADD: /* Input, arg3*1+arg1*arg2 */ GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[2], tex_op_args.mapping[2], tex_op_args.component_usage[2])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_LERP: /* Input, arg3*arg1+(1-arg3)*arg2 */ GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[2], tex_op_args.mapping[2], tex_op_args.component_usage[2])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV, tex_op_args.input[2], invert_mapping(tex_op_args.mapping[2]), tex_op_args.component_usage[2])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); /* Output */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV, output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; case WINED3D_TOP_BUMPENVMAP_LUMINANCE: case WINED3D_TOP_BUMPENVMAP: if (!gl_info->supported[NV_TEXTURE_SHADER]) { WARN("BUMPENVMAP requires GL_NV_texture_shader in this codepath\n"); break; } /* The bump map stage itself isn't exciting, just read the texture. But tell the next stage to * perform bump mapping and source from the current stage. Pretty much a SELECTARG2. * ARG2 is passed through unmodified(apps will most likely use D3DTA_CURRENT for arg2, arg1 * (which will most likely be D3DTA_TEXTURE) is available as a texture shader input for the * next stage */ GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV, tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1])); GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, portion)); /* Always pass through to CURRENT, ignore temp arg */ GL_EXTCALL(glCombinerOutputNV(target, portion, GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE)); break; default: FIXME("Unhandled texture op: stage %d, is_alpha %d, op %s (%#x), arg1 %#x, arg2 %#x, arg3 %#x, texture_idx %d.\n", stage, is_alpha, debug_d3dtop(op), op, arg1, arg2, arg3, texture_idx); } checkGLcall("set_tex_op_nvrc()"); } static void nvrc_colorop(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); const struct wined3d_device *device = context->swapchain->device; BOOL tex_used = device->fixed_function_usage_map & (1 << stage); DWORD mapped_stage = device->texUnitMap[stage]; const struct wined3d_gl_info *gl_info = context->gl_info; TRACE("Setting color op for stage %u.\n", stage); /* Using a pixel shader? Don't care for anything here, the shader applying does it */ if (use_ps(state)) return; if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage); if (mapped_stage != WINED3D_UNMAPPED_STAGE) { if (tex_used && mapped_stage >= gl_info->limits.textures) { FIXME("Attempt to enable unsupported stage!\n"); return; } context_active_texture(context, gl_info, mapped_stage); } if (state->lowest_disabled_stage > 0) { gl_info->gl_ops.gl.p_glEnable(GL_REGISTER_COMBINERS_NV); GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, state->lowest_disabled_stage)); } else { gl_info->gl_ops.gl.p_glDisable(GL_REGISTER_COMBINERS_NV); } if (stage >= state->lowest_disabled_stage) { TRACE("Stage disabled\n"); if (mapped_stage != WINED3D_UNMAPPED_STAGE) { /* Disable everything here */ gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) { gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) { gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } if (gl_info->supported[NV_TEXTURE_SHADER2] && mapped_stage < gl_info->limits.textures) { gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE); } } /* All done */ return; } /* The sampler will also activate the correct texture dimensions, so no need to do it here * if the sampler for this stage is dirty */ if (!isStateDirty(context, STATE_SAMPLER(stage))) { if (tex_used) { if (gl_info->supported[NV_TEXTURE_SHADER2]) { nvts_activate_dimensions(state, stage, context); } else { texture_activate_dimensions(state->textures[stage], gl_info); } } } /* Set the texture combiners */ set_tex_op_nvrc(gl_info, state, FALSE, stage, state->texture_states[stage][WINED3D_TSS_COLOR_OP], state->texture_states[stage][WINED3D_TSS_COLOR_ARG1], state->texture_states[stage][WINED3D_TSS_COLOR_ARG2], state->texture_states[stage][WINED3D_TSS_COLOR_ARG0], mapped_stage, state->texture_states[stage][WINED3D_TSS_RESULT_ARG]); /* In register combiners bump mapping is done in the stage AFTER the one that has the bump map operation set, * thus the texture shader may have to be updated */ if (gl_info->supported[NV_TEXTURE_SHADER2]) { BOOL usesBump = (state->texture_states[stage][WINED3D_TSS_COLOR_OP] == WINED3D_TOP_BUMPENVMAP_LUMINANCE || state->texture_states[stage][WINED3D_TSS_COLOR_OP] == WINED3D_TOP_BUMPENVMAP); BOOL usedBump = !!(context->texShaderBumpMap & 1 << (stage + 1)); if (usesBump != usedBump) { context_active_texture(context, gl_info, mapped_stage + 1); nvts_activate_dimensions(state, stage + 1, context); context_active_texture(context, gl_info, mapped_stage); } } } static void nvrc_resultarg(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); TRACE("Setting result arg for stage %u.\n", stage); if (!isStateDirty(context, STATE_TEXTURESTAGE(stage, WINED3D_TSS_COLOR_OP))) { context_apply_state(context, state, STATE_TEXTURESTAGE(stage, WINED3D_TSS_COLOR_OP)); } if (!isStateDirty(context, STATE_TEXTURESTAGE(stage, WINED3D_TSS_ALPHA_OP))) { context_apply_state(context, state, STATE_TEXTURESTAGE(stage, WINED3D_TSS_ALPHA_OP)); } } static void nvts_texdim(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { DWORD sampler = state_id - STATE_SAMPLER(0); DWORD mapped_stage = context->swapchain->device->texUnitMap[sampler]; /* No need to enable / disable anything here for unused samplers. The tex_colorop * handler takes care. Also no action is needed with pixel shaders, or if tex_colorop * will take care of this business. */ if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->limits.textures) return; if (sampler >= state->lowest_disabled_stage) return; if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP))) return; nvts_activate_dimensions(state, sampler, context); } static void nvts_bumpenvmat(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD mapped_stage = context->swapchain->device->texUnitMap[stage + 1]; const struct wined3d_gl_info *gl_info = context->gl_info; float mat[2][2]; /* Direct3D sets the matrix in the stage reading the perturbation map. The result is used to * offset the destination stage(always stage + 1 in d3d). In GL_NV_texture_shader, the bump * map offsetting is done in the stage reading the bump mapped texture, and the perturbation * map is read from a specified source stage(always stage - 1 for d3d). Thus set the matrix * for stage + 1. Keep the nvrc tex unit mapping in mind too */ if (mapped_stage < gl_info->limits.textures) { context_active_texture(context, gl_info, mapped_stage); /* We can't just pass a pointer to the state to GL due to the * different matrix format (column major vs row major). */ mat[0][0] = *((float *)&state->texture_states[stage][WINED3D_TSS_BUMPENV_MAT00]); mat[1][0] = *((float *)&state->texture_states[stage][WINED3D_TSS_BUMPENV_MAT01]); mat[0][1] = *((float *)&state->texture_states[stage][WINED3D_TSS_BUMPENV_MAT10]); mat[1][1] = *((float *)&state->texture_states[stage][WINED3D_TSS_BUMPENV_MAT11]); gl_info->gl_ops.gl.p_glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, (float *)mat); checkGLcall("glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, mat)"); } } static void nvrc_texfactor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_info *gl_info = context->gl_info; float col[4]; D3DCOLORTOGLFLOAT4(state->render_states[WINED3D_RS_TEXTUREFACTOR], col); GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &col[0])); } /* Context activation is done by the caller. */ static void nvrc_enable(const struct wined3d_gl_info *gl_info, BOOL enable) { if (enable) { gl_info->gl_ops.gl.p_glEnable(GL_REGISTER_COMBINERS_NV); checkGLcall("glEnable(GL_REGISTER_COMBINERS_NV)"); } else { gl_info->gl_ops.gl.p_glDisable(GL_REGISTER_COMBINERS_NV); checkGLcall("glDisable(GL_REGISTER_COMBINERS_NV)"); } } /* Context activation is done by the caller. */ static void nvts_enable(const struct wined3d_gl_info *gl_info, BOOL enable) { nvrc_enable(gl_info, enable); if (enable) { gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_SHADER_NV); checkGLcall("glEnable(GL_TEXTURE_SHADER_NV)"); } else { gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_SHADER_NV); checkGLcall("glDisable(GL_TEXTURE_SHADER_NV)"); } } static void nvrc_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps) { caps->wined3d_caps = 0; caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_TSSARGTEMP; /* The caps below can be supported but aren't handled yet in utils.c * 'd3dta_to_combiner_input', disable them until support is fixed */ #if 0 if (gl_info->supported[NV_REGISTER_COMBINERS2]) caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_PERSTAGECONSTANT; #endif caps->TextureOpCaps = WINED3DTEXOPCAPS_ADD | WINED3DTEXOPCAPS_ADDSIGNED | WINED3DTEXOPCAPS_ADDSIGNED2X | WINED3DTEXOPCAPS_MODULATE | WINED3DTEXOPCAPS_MODULATE2X | WINED3DTEXOPCAPS_MODULATE4X | WINED3DTEXOPCAPS_SELECTARG1 | WINED3DTEXOPCAPS_SELECTARG2 | WINED3DTEXOPCAPS_DISABLE | WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA | WINED3DTEXOPCAPS_BLENDTEXTUREALPHA | WINED3DTEXOPCAPS_BLENDFACTORALPHA | WINED3DTEXOPCAPS_BLENDCURRENTALPHA | WINED3DTEXOPCAPS_LERP | WINED3DTEXOPCAPS_SUBTRACT | WINED3DTEXOPCAPS_ADDSMOOTH | WINED3DTEXOPCAPS_MULTIPLYADD | WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR | WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA | WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM | WINED3DTEXOPCAPS_DOTPRODUCT3 | WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR | WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA; if (gl_info->supported[NV_TEXTURE_SHADER2]) { /* Bump mapping is supported already in NV_TEXTURE_SHADER, but that extension does * not support 3D textures. This asks for trouble if an app uses both bump mapping * and 3D textures. It also allows us to keep the code simpler by having texture * shaders constantly enabled. */ caps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAP; /* TODO: Luminance bump map? */ } #if 0 /* FIXME: Add caps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE WINED3DTEXOPCAPS_PREMODULATE */ #endif caps->MaxTextureBlendStages = min(MAX_TEXTURES, gl_info->limits.general_combiners); caps->MaxSimultaneousTextures = gl_info->limits.textures; } static void *nvrc_fragment_alloc(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv) { return shader_priv; } /* Context activation is done by the caller. */ static void nvrc_fragment_free(struct wined3d_device *device) {} /* Two fixed function pipeline implementations using GL_NV_register_combiners and * GL_NV_texture_shader. The nvts_fragment_pipeline assumes that both extensions * are available(geforce 3 and newer), while nvrc_fragment_pipeline uses only the * register combiners extension(Pre-GF3). */ static BOOL nvts_color_fixup_supported(struct color_fixup_desc fixup) { if (TRACE_ON(d3d)) { TRACE("Checking support for fixup:\n"); dump_color_fixup_desc(fixup); } /* We only support identity conversions. */ if (is_identity_fixup(fixup)) { TRACE("[OK]\n"); return TRUE; } TRACE("[FAILED]\n"); return FALSE; } static const struct StateEntryTemplate nvrc_fragmentstate_template[] = { { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP), nvrc_colorop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG1), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG2), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP), tex_alphaop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG1), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG2), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG0), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG0), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(0, WINED3D_TSS_RESULT_ARG), { STATE_TEXTURESTAGE(0, WINED3D_TSS_RESULT_ARG), nvrc_resultarg }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP), nvrc_colorop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG1), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG2), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP), tex_alphaop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG1), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG2), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG0), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG0), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(1, WINED3D_TSS_RESULT_ARG), { STATE_TEXTURESTAGE(1, WINED3D_TSS_RESULT_ARG), nvrc_resultarg }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP), nvrc_colorop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG1), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG2), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP), tex_alphaop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG1), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG2), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG0), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG0), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(2, WINED3D_TSS_RESULT_ARG), { STATE_TEXTURESTAGE(2, WINED3D_TSS_RESULT_ARG), nvrc_resultarg }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP), nvrc_colorop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG1), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG2), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP), tex_alphaop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG1), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG2), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG0), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG0), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(3, WINED3D_TSS_RESULT_ARG), { STATE_TEXTURESTAGE(3, WINED3D_TSS_RESULT_ARG), nvrc_resultarg }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP), nvrc_colorop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG1), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG2), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP), tex_alphaop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG1), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG2), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG0), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG0), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(4, WINED3D_TSS_RESULT_ARG), { STATE_TEXTURESTAGE(4, WINED3D_TSS_RESULT_ARG), nvrc_resultarg }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP), nvrc_colorop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG1), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG2), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP), tex_alphaop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG1), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG2), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG0), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG0), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(5, WINED3D_TSS_RESULT_ARG), { STATE_TEXTURESTAGE(5, WINED3D_TSS_RESULT_ARG), nvrc_resultarg }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP), nvrc_colorop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG1), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG2), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP), tex_alphaop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG1), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG2), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG0), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG0), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(6, WINED3D_TSS_RESULT_ARG), { STATE_TEXTURESTAGE(6, WINED3D_TSS_RESULT_ARG), nvrc_resultarg }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP), nvrc_colorop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG1), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG2), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP), tex_alphaop }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG1), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG2), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), nvts_bumpenvmat }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), NULL }, NV_TEXTURE_SHADER2 }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG0), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG0), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP), NULL }, WINED3D_GL_EXT_NONE }, { STATE_TEXTURESTAGE(7, WINED3D_TSS_RESULT_ARG), { STATE_TEXTURESTAGE(7, WINED3D_TSS_RESULT_ARG), nvrc_resultarg }, WINED3D_GL_EXT_NONE }, { STATE_PIXELSHADER, { STATE_PIXELSHADER, apply_pixelshader }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), { STATE_PIXELSHADER, NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR), { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR), nvrc_texfactor }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_FOGCOLOR), { STATE_RENDER(WINED3D_RS_FOGCOLOR), state_fogcolor }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_FOGDENSITY), { STATE_RENDER(WINED3D_RS_FOGDENSITY), state_fogdensity }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_FOGENABLE), { STATE_RENDER(WINED3D_RS_FOGENABLE), state_fog_fragpart }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_FOGTABLEMODE), { STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE), { STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_FOGSTART), { STATE_RENDER(WINED3D_RS_FOGSTART), state_fogstartend }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3D_RS_FOGEND), { STATE_RENDER(WINED3D_RS_FOGSTART), NULL }, WINED3D_GL_EXT_NONE }, { STATE_SAMPLER(0), { STATE_SAMPLER(0), nvts_texdim }, NV_TEXTURE_SHADER2 }, { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, WINED3D_GL_EXT_NONE }, { STATE_SAMPLER(1), { STATE_SAMPLER(1), nvts_texdim }, NV_TEXTURE_SHADER2 }, { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim }, WINED3D_GL_EXT_NONE }, { STATE_SAMPLER(2), { STATE_SAMPLER(2), nvts_texdim }, NV_TEXTURE_SHADER2 }, { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim }, WINED3D_GL_EXT_NONE }, { STATE_SAMPLER(3), { STATE_SAMPLER(3), nvts_texdim }, NV_TEXTURE_SHADER2 }, { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim }, WINED3D_GL_EXT_NONE }, { STATE_SAMPLER(4), { STATE_SAMPLER(4), nvts_texdim }, NV_TEXTURE_SHADER2 }, { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim }, WINED3D_GL_EXT_NONE }, { STATE_SAMPLER(5), { STATE_SAMPLER(5), nvts_texdim }, NV_TEXTURE_SHADER2 }, { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim }, WINED3D_GL_EXT_NONE }, { STATE_SAMPLER(6), { STATE_SAMPLER(6), nvts_texdim }, NV_TEXTURE_SHADER2 }, { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim }, WINED3D_GL_EXT_NONE }, { STATE_SAMPLER(7), { STATE_SAMPLER(7), nvts_texdim }, NV_TEXTURE_SHADER2 }, { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim }, WINED3D_GL_EXT_NONE }, {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE }, }; const struct fragment_pipeline nvts_fragment_pipeline = { nvts_enable, nvrc_fragment_get_caps, nvrc_fragment_alloc, nvrc_fragment_free, nvts_color_fixup_supported, nvrc_fragmentstate_template, }; const struct fragment_pipeline nvrc_fragment_pipeline = { nvrc_enable, nvrc_fragment_get_caps, nvrc_fragment_alloc, nvrc_fragment_free, nvts_color_fixup_supported, nvrc_fragmentstate_template, };
c6354f9d7ea4c79a474162c48a4887b2efae4edf
0744dcc5394cebf57ebcba343747af6871b67017
/os/board/rtl8730e/src/component/soc/amebad2/cmsis-dsp/Source/ComplexMathFunctions/ComplexMathFunctions.c
2143739fd04b9fb2721f1d8e1c3e0c93c486f180
[ "Apache-2.0", "GPL-1.0-or-later", "BSD-3-Clause", "ISC", "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive" ]
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,744
c
ComplexMathFunctions.c
/* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: CompexMathFunctions.c * Description: Combination of all comlex math function source files. * * $Date: 18. March 2019 * $Revision: V1.0.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* * Copyright (C) 2019 ARM Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * 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 "arm_cmplx_conj_f32.c" #include "arm_cmplx_conj_q15.c" #include "arm_cmplx_conj_q31.c" #include "arm_cmplx_dot_prod_f32.c" #include "arm_cmplx_dot_prod_q15.c" #include "arm_cmplx_dot_prod_q31.c" #include "arm_cmplx_mag_f32.c" #include "arm_cmplx_mag_q15.c" #include "arm_cmplx_mag_q31.c" #include "arm_cmplx_mag_squared_f32.c" #include "arm_cmplx_mag_squared_q15.c" #include "arm_cmplx_mag_squared_q31.c" #include "arm_cmplx_mult_cmplx_f32.c" #include "arm_cmplx_mult_cmplx_q15.c" #include "arm_cmplx_mult_cmplx_q31.c" #include "arm_cmplx_mult_real_f32.c" #include "arm_cmplx_mult_real_q15.c" #include "arm_cmplx_mult_real_q31.c"
3112b716b64f98cf8618e382ff021ac44b2e62f8
e814383d36a10839104efaa4df277996ab220fa3
/ompi/mpi/c/isendrecv.c
a4bcc6c7db9ca06e65e15d9b3ee2e3894b7470b5
[ "mpich2", "BSD-3-Clause-Open-MPI" ]
permissive
open-mpi/ompi
a1d7483ae1d83dd8fd8ae3ee95e832e0a0ee04e3
1edfdb025c4450f694600083ad871cf06c8d45cd
refs/heads/main
2023-09-01T01:30:02.040705
2023-08-29T17:32:18
2023-08-29T17:32:18
24,107,001
2,008
973
NOASSERTION
2023-09-14T20:59:26
2014-09-16T16:08:30
C
UTF-8
C
false
false
6,693
c
isendrecv.c
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2004-2022 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2010-2012 Oak Ridge National Labs. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2021 Nanook Consulting. All rights reserved. * Copyright (c) 2021 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */ #include "ompi_config.h" #include "ompi/mpi/c/bindings.h" #include "ompi/runtime/params.h" #include "ompi/communicator/communicator.h" #include "ompi/communicator/comm_request.h" #include "ompi/errhandler/errhandler.h" #include "ompi/mca/pml/pml.h" #include "ompi/request/request.h" #include "ompi/memchecker.h" #include "ompi/runtime/ompi_spc.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_Isendrecv = PMPI_Isendrecv #endif #define MPI_Isendrecv PMPI_Isendrecv #endif static const char FUNC_NAME[] = "MPI_Isendrecv"; struct ompi_isendrecv_context_t { opal_object_t super; int nreqs; int source; ompi_request_t *subreq[2]; }; typedef struct ompi_isendrecv_context_t ompi_isendrecv_context_t; #if OMPI_BUILD_MPI_PROFILING OBJ_CLASS_INSTANCE(ompi_isendrecv_context_t, opal_object_t, NULL, NULL); #else OBJ_CLASS_DECLARATION(ompi_isendrecv_context_t); #endif /* OMPI_BUILD_MPI_PROFILING */ static int ompi_isendrecv_complete_func (ompi_comm_request_t *request) { ompi_isendrecv_context_t *context = (ompi_isendrecv_context_t *) request->context; /* * Copy the status from the receive side of the sendrecv request? * But what if the send failed? * * Probably need to bring up in the MPI forum. */ if (MPI_PROC_NULL != context->source) { OMPI_COPY_STATUS(&request->super.req_status, context->subreq[0]->req_status, false); } else { OMPI_COPY_STATUS(&request->super.req_status, ompi_request_empty.req_status, false); } if(NULL != context->subreq[0]) { ompi_request_free(&context->subreq[0]); } if(NULL != context->subreq[1]) { ompi_request_free(&context->subreq[1]); } return OMPI_SUCCESS; } int MPI_Isendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Request *request) { ompi_isendrecv_context_t *context = NULL; ompi_comm_request_t *crequest; int rc = MPI_SUCCESS; int nreqs = 0; uint32_t flags; SPC_RECORD(OMPI_SPC_ISENDRECV, 1); MEMCHECKER( memchecker_datatype(sendtype); memchecker_datatype(recvtype); memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype); memchecker_comm(comm); ); if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); OMPI_CHECK_DATATYPE_FOR_SEND(rc, sendtype, sendcount); OMPI_CHECK_DATATYPE_FOR_RECV(rc, recvtype, recvcount); OMPI_CHECK_USER_BUFFER(rc, sendbuf, sendtype, sendcount); OMPI_CHECK_USER_BUFFER(rc, recvbuf, recvtype, recvcount); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_COMM, FUNC_NAME); } else if (dest != MPI_PROC_NULL && ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; } else if (sendtag < 0 || sendtag > mca_pml.pml_max_tag) { rc = MPI_ERR_TAG; } else if (source != MPI_PROC_NULL && source != MPI_ANY_SOURCE && ompi_comm_peer_invalid(comm, source)) { rc = MPI_ERR_RANK; } else if (((recvtag < 0) && (recvtag != MPI_ANY_TAG)) || (recvtag > mca_pml.pml_max_tag)) { rc = MPI_ERR_TAG; } else if (request == NULL) { rc = MPI_ERR_REQUEST; } OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } crequest = ompi_comm_request_get (); if (NULL == crequest) { return OMPI_ERR_OUT_OF_RESOURCE; } context = OBJ_NEW(ompi_isendrecv_context_t); if (NULL == context) { ompi_comm_request_return (crequest); return OMPI_ERR_OUT_OF_RESOURCE; } crequest->context = &context->super; context->subreq[0] = MPI_REQUEST_NULL; context->subreq[1] = MPI_REQUEST_NULL; context->source = source; if (source != MPI_PROC_NULL) { /* post recv */ rc = MCA_PML_CALL(irecv(recvbuf, recvcount, recvtype, source, recvtag, comm, &context->subreq[nreqs++])); if (MPI_SUCCESS != rc) { OBJ_RELEASE(context); ompi_comm_request_return (crequest); } OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } if (dest != MPI_PROC_NULL) { /* send */ rc = MCA_PML_CALL(isend(sendbuf, sendcount, sendtype, dest, sendtag, MCA_PML_BASE_SEND_STANDARD, comm, &context->subreq[nreqs++])); if (MPI_SUCCESS != rc) { OBJ_RELEASE(context); ompi_comm_request_return (crequest); } OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } /* * schedule the operation */ context->nreqs = nreqs; assert(nreqs <= 2); flags = OMPI_COMM_REQ_FLAG_RETAIN_SUBREQ; rc = ompi_comm_request_schedule_append_w_flags(crequest, ompi_isendrecv_complete_func, context->subreq, nreqs, flags); if (MPI_SUCCESS != rc) { OBJ_RELEASE(context); ompi_comm_request_return (crequest); } OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); /* kick off the request */ ompi_comm_request_start (crequest); *request = &crequest->super; return rc; }
52f807c2e897dc004eb70121e5b8c4c1bb26cdbc
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/tm4c129x/libraries/driverlib/tiva_timer.h
e23b14d752b64138420b7cdb949d3713e6dbe66b
[ "BSD-3-Clause", "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "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
16,456
h
tiva_timer.h
//***************************************************************************** // // timer.h - Prototypes for the timer module // // Copyright (c) 2005-2020 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the // distribution. // // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // This is part of revision 2.2.0.295 of the Tiva Peripheral Driver Library. // //***************************************************************************** #ifndef __DRIVERLIB_TIMER_H__ #define __DRIVERLIB_TIMER_H__ //***************************************************************************** // // If building with a C++ compiler, make all of the definitions in this header // have a C binding. // //***************************************************************************** #ifdef __cplusplus extern "C" { #endif //***************************************************************************** // // Values that can be passed to TimerConfigure as the ui32Config parameter. // //***************************************************************************** #define TIMER_CFG_ONE_SHOT 0x00000021 // Full-width one-shot timer #define TIMER_CFG_ONE_SHOT_UP 0x00000031 // Full-width one-shot up-count // timer #define TIMER_CFG_PERIODIC 0x00000022 // Full-width periodic timer #define TIMER_CFG_PERIODIC_UP 0x00000032 // Full-width periodic up-count // timer #define TIMER_CFG_RTC 0x01000000 // Full-width RTC timer #define TIMER_CFG_SPLIT_PAIR 0x04000000 // Two half-width timers #define TIMER_CFG_A_ONE_SHOT 0x00000021 // Timer A one-shot timer #define TIMER_CFG_A_ONE_SHOT_UP 0x00000031 // Timer A one-shot up-count timer #define TIMER_CFG_A_PERIODIC 0x00000022 // Timer A periodic timer #define TIMER_CFG_A_PERIODIC_UP 0x00000032 // Timer A periodic up-count timer #define TIMER_CFG_A_CAP_COUNT 0x00000003 // Timer A event counter #define TIMER_CFG_A_CAP_COUNT_UP 0x00000013 // Timer A event up-counter #define TIMER_CFG_A_CAP_TIME 0x00000007 // Timer A event timer #define TIMER_CFG_A_CAP_TIME_UP 0x00000017 // Timer A event up-count timer #define TIMER_CFG_A_ONE_SHOT_PWM 0x00000009 // Timer A one-shot PWM output #define TIMER_CFG_A_PWM 0x0000000A // Timer A PWM output #define TIMER_CFG_B_ONE_SHOT 0x00002100 // Timer B one-shot timer #define TIMER_CFG_B_ONE_SHOT_UP 0x00003100 // Timer B one-shot up-count timer #define TIMER_CFG_B_PERIODIC 0x00002200 // Timer B periodic timer #define TIMER_CFG_B_PERIODIC_UP 0x00003200 // Timer B periodic up-count timer #define TIMER_CFG_B_CAP_COUNT 0x00000300 // Timer B event counter #define TIMER_CFG_B_CAP_COUNT_UP 0x00001300 // Timer B event up-counter #define TIMER_CFG_B_CAP_TIME 0x00000700 // Timer B event timer #define TIMER_CFG_B_CAP_TIME_UP 0x00001700 // Timer B event up-count timer #define TIMER_CFG_B_ONE_SHOT_PWM 0x00000900 // Timer B one-shot PWM output #define TIMER_CFG_B_PWM 0x00000A00 // Timer B PWM output #define TIMER_CFG_A_ACT_TOINTD 0x00010000 // Timer A compare action disable // time-out interrupt. #define TIMER_CFG_A_ACT_NONE 0x00000000 // Timer A compare action none. #define TIMER_CFG_A_ACT_TOGGLE 0x00020000 // Timer A compare action toggle. #define TIMER_CFG_A_ACT_CLRTO 0x00040000 // Timer A compare action CCP // clear on time-out. #define TIMER_CFG_A_ACT_SETTO 0x00060000 // Timer A compare action CCP set // on time-out. #define TIMER_CFG_A_ACT_SETTOGTO 0x00080000 // Timer A compare action set CCP // toggle on time-out. #define TIMER_CFG_A_ACT_CLRTOGTO 0x000A0000 // Timer A compare action clear // CCP toggle on time-out. #define TIMER_CFG_A_ACT_SETCLRTO 0x000C0000 // Timer A compare action set CCP // clear on time-out. #define TIMER_CFG_A_ACT_CLRSETTO 0x000E0000 // Timer A compare action clear // CCP set on time-out. #define TIMER_CFG_B_ACT_TOINTD 0x00100000 // Timer B compare action disable // time-out interrupt. #define TIMER_CFG_B_ACT_NONE 0x00000000 // Timer A compare action none. #define TIMER_CFG_B_ACT_TOGGLE 0x00200000 // Timer A compare action toggle. #define TIMER_CFG_B_ACT_CLRTO 0x00400000 // Timer A compare action CCP // clear on time-out. #define TIMER_CFG_B_ACT_SETTO 0x00600000 // Timer A compare action CCP set // on time-out. #define TIMER_CFG_B_ACT_SETTOGTO 0x00800000 // Timer A compare action set CCP // toggle on time-out. #define TIMER_CFG_B_ACT_CLRTOGTO 0x00A00000 // Timer A compare action clear // CCP toggle on time-out. #define TIMER_CFG_B_ACT_SETCLRTO 0x00C00000 // Timer A compare action set CCP // clear on time-out. #define TIMER_CFG_B_ACT_CLRSETTO 0x0000E000 // Timer A compare action clear // CCP set on time-out. //***************************************************************************** // // Values that can be passed to TimerIntEnable, TimerIntDisable, and // TimerIntClear as the ui32IntFlags parameter, and returned from // TimerIntStatus. // //***************************************************************************** #define TIMER_TIMB_DMA 0x00002000 // TimerB DMA Complete Interrupt. #define TIMER_TIMB_MATCH 0x00000800 // TimerB match interrupt #define TIMER_CAPB_EVENT 0x00000400 // CaptureB event interrupt #define TIMER_CAPB_MATCH 0x00000200 // CaptureB match interrupt #define TIMER_TIMB_TIMEOUT 0x00000100 // TimerB time out interrupt #define TIMER_TIMA_DMA 0x00000020 // TimerA DMA Complete Interrupt. #define TIMER_TIMA_MATCH 0x00000010 // TimerA match interrupt #define TIMER_RTC_MATCH 0x00000008 // RTC interrupt mask #define TIMER_CAPA_EVENT 0x00000004 // CaptureA event interrupt #define TIMER_CAPA_MATCH 0x00000002 // CaptureA match interrupt #define TIMER_TIMA_TIMEOUT 0x00000001 // TimerA time out interrupt //***************************************************************************** // // Values that can be passed to TimerControlEvent as the ui32Event parameter. // //***************************************************************************** #define TIMER_EVENT_POS_EDGE 0x00000000 // Count positive edges #define TIMER_EVENT_NEG_EDGE 0x00000404 // Count negative edges #define TIMER_EVENT_BOTH_EDGES 0x00000C0C // Count both edges //***************************************************************************** // // Values that can be passed to most of the timer APIs as the ui32Timer // parameter. // //***************************************************************************** #define TIMER_A 0x000000ff // Timer A #define TIMER_B 0x0000ff00 // Timer B #define TIMER_BOTH 0x0000ffff // Timer Both //***************************************************************************** // // Values that can be passed to TimerSynchronize as the ui32Timers parameter. // //***************************************************************************** #define TIMER_0A_SYNC 0x00000001 // Synchronize Timer 0A #define TIMER_0B_SYNC 0x00000002 // Synchronize Timer 0B #define TIMER_1A_SYNC 0x00000004 // Synchronize Timer 1A #define TIMER_1B_SYNC 0x00000008 // Synchronize Timer 1B #define TIMER_2A_SYNC 0x00000010 // Synchronize Timer 2A #define TIMER_2B_SYNC 0x00000020 // Synchronize Timer 2B #define TIMER_3A_SYNC 0x00000040 // Synchronize Timer 3A #define TIMER_3B_SYNC 0x00000080 // Synchronize Timer 3B #define TIMER_4A_SYNC 0x00000100 // Synchronize Timer 4A #define TIMER_4B_SYNC 0x00000200 // Synchronize Timer 4B #define TIMER_5A_SYNC 0x00000400 // Synchronize Timer 5A #define TIMER_5B_SYNC 0x00000800 // Synchronize Timer 5B #define WTIMER_0A_SYNC 0x00001000 // Synchronize Wide Timer 0A #define WTIMER_0B_SYNC 0x00002000 // Synchronize Wide Timer 0B #define WTIMER_1A_SYNC 0x00004000 // Synchronize Wide Timer 1A #define WTIMER_1B_SYNC 0x00008000 // Synchronize Wide Timer 1B #define WTIMER_2A_SYNC 0x00010000 // Synchronize Wide Timer 2A #define WTIMER_2B_SYNC 0x00020000 // Synchronize Wide Timer 2B #define WTIMER_3A_SYNC 0x00040000 // Synchronize Wide Timer 3A #define WTIMER_3B_SYNC 0x00080000 // Synchronize Wide Timer 3B #define WTIMER_4A_SYNC 0x00100000 // Synchronize Wide Timer 4A #define WTIMER_4B_SYNC 0x00200000 // Synchronize Wide Timer 4B #define WTIMER_5A_SYNC 0x00400000 // Synchronize Wide Timer 5A #define WTIMER_5B_SYNC 0x00800000 // Synchronize Wide Timer 5B //***************************************************************************** // // Values that can be passed to TimerClockSourceSet() or returned from // TimerClockSourceGet(). // //***************************************************************************** #define TIMER_CLOCK_SYSTEM 0x00000000 #define TIMER_CLOCK_PIOSC 0x00000001 //***************************************************************************** // // Values that can be passed to TimerDMAEventSet() or returned from // TimerDMAEventGet(). // //***************************************************************************** #define TIMER_DMA_MODEMATCH_B 0x00000800 #define TIMER_DMA_CAPEVENT_B 0x00000400 #define TIMER_DMA_CAPMATCH_B 0x00000200 #define TIMER_DMA_TIMEOUT_B 0x00000100 #define TIMER_DMA_MODEMATCH_A 0x00000010 #define TIMER_DMA_RTC_A 0x00000008 #define TIMER_DMA_CAPEVENT_A 0x00000004 #define TIMER_DMA_CAPMATCH_A 0x00000002 #define TIMER_DMA_TIMEOUT_A 0x00000001 //***************************************************************************** // // Values that can be passed to TimerADCEventSet() or returned from // TimerADCEventGet(). // //***************************************************************************** #define TIMER_ADC_MODEMATCH_B 0x00000800 #define TIMER_ADC_CAPEVENT_B 0x00000400 #define TIMER_ADC_CAPMATCH_B 0x00000200 #define TIMER_ADC_TIMEOUT_B 0x00000100 #define TIMER_ADC_MODEMATCH_A 0x00000010 #define TIMER_ADC_RTC_A 0x00000008 #define TIMER_ADC_CAPEVENT_A 0x00000004 #define TIMER_ADC_CAPMATCH_A 0x00000002 #define TIMER_ADC_TIMEOUT_A 0x00000001 //***************************************************************************** // // Values that can be passed to TimerUpdateMode(). // //***************************************************************************** #define TIMER_UP_LOAD_IMMEDIATE 0x00000000 #define TIMER_UP_LOAD_TIMEOUT 0x00000100 #define TIMER_UP_MATCH_IMMEDIATE \ 0x00000000 #define TIMER_UP_MATCH_TIMEOUT 0x00000400 //***************************************************************************** // // Prototypes for the APIs. // //***************************************************************************** extern void TimerEnable(uint32_t ui32Base, uint32_t ui32Timer); extern void TimerDisable(uint32_t ui32Base, uint32_t ui32Timer); extern void TimerConfigure(uint32_t ui32Base, uint32_t ui32Config); extern void TimerControlLevel(uint32_t ui32Base, uint32_t ui32Timer, bool bInvert); extern void TimerControlTrigger(uint32_t ui32Base, uint32_t ui32Timer, bool bEnable); extern void TimerControlEvent(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Event); extern void TimerControlStall(uint32_t ui32Base, uint32_t ui32Timer, bool bStall); extern void TimerControlWaitOnTrigger(uint32_t ui32Base, uint32_t ui32Timer, bool bWait); extern void TimerRTCEnable(uint32_t ui32Base); extern void TimerRTCDisable(uint32_t ui32Base); extern void TimerPrescaleSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value); extern uint32_t TimerPrescaleGet(uint32_t ui32Base, uint32_t ui32Timer); extern void TimerPrescaleMatchSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value); extern uint32_t TimerPrescaleMatchGet(uint32_t ui32Base, uint32_t ui32Timer); extern void TimerLoadSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value); extern uint32_t TimerLoadGet(uint32_t ui32Base, uint32_t ui32Timer); extern void TimerLoadSet64(uint32_t ui32Base, uint64_t ui64Value); extern uint64_t TimerLoadGet64(uint32_t ui32Base); extern uint32_t TimerValueGet(uint32_t ui32Base, uint32_t ui32Timer); extern uint64_t TimerValueGet64(uint32_t ui32Base); extern void TimerMatchSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value); extern uint32_t TimerMatchGet(uint32_t ui32Base, uint32_t ui32Timer); extern void TimerMatchSet64(uint32_t ui32Base, uint64_t ui64Value); extern uint64_t TimerMatchGet64(uint32_t ui32Base); extern void TimerIntRegister(uint32_t ui32Base, uint32_t ui32Timer, void (*pfnHandler)(void)); extern void TimerIntUnregister(uint32_t ui32Base, uint32_t ui32Timer); extern void TimerIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags); extern void TimerIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags); extern uint32_t TimerIntStatus(uint32_t ui32Base, bool bMasked); extern void TimerIntClear(uint32_t ui32Base, uint32_t ui32IntFlags); extern void TimerSynchronize(uint32_t ui32Base, uint32_t ui32Timers); extern uint32_t TimerClockSourceGet(uint32_t ui32Base); extern void TimerClockSourceSet(uint32_t ui32Base, uint32_t ui32Source); extern uint32_t TimerADCEventGet(uint32_t ui32Base); extern void TimerADCEventSet(uint32_t ui32Base, uint32_t ui32ADCEvent); extern uint32_t TimerDMAEventGet(uint32_t ui32Base); extern void TimerDMAEventSet(uint32_t ui32Base, uint32_t ui32DMAEvent); extern void TimerUpdateMode(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Config); //***************************************************************************** // // Mark the end of the C bindings section for C++ compilers. // //***************************************************************************** #ifdef __cplusplus } #endif #endif // __DRIVERLIB_TIMER_H__
122f259304da31e7611f49c1d604042c23e8bb3a
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/arm/nwfpe/fpopcode.h
78f02dbfaa8ffea4efda621044b119367f1e57e4
[ "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
15,445
h
fpopcode.h
/* NetWinder Floating Point Emulator (c) Rebel.COM, 1998,1999 (c) Philip Blundell, 2001 Direct questions, comments to Scott Bambrough <scottb@netwinder.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __FPOPCODE_H__ #define __FPOPCODE_H__ /* ARM Floating Point Instruction Classes | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |c o n d|1 1 0 P|U|u|W|L| Rn |v| Fd |0|0|0|1| o f f s e t | CPDT |c o n d|1 1 0 P|U|w|W|L| Rn |x| Fd |0|0|1|0| o f f s e t | CPDT (copro 2) | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |c o n d|1 1 1 0|a|b|c|d|e| Fn |j| Fd |0|0|0|1|f|g|h|0|i| Fm | CPDO |c o n d|1 1 1 0|a|b|c|L|e| Fn | Rd |0|0|0|1|f|g|h|1|i| Fm | CPRT |c o n d|1 1 1 0|a|b|c|1|e| Fn |1|1|1|1|0|0|0|1|f|g|h|1|i| Fm | comparisons | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CPDT data transfer instructions LDF, STF, LFM (copro 2), SFM (copro 2) CPDO dyadic arithmetic instructions ADF, MUF, SUF, RSF, DVF, RDF, POW, RPW, RMF, FML, FDV, FRD, POL CPDO monadic arithmetic instructions MVF, MNF, ABS, RND, SQT, LOG, LGN, EXP, SIN, COS, TAN, ASN, ACS, ATN, URD, NRM CPRT joint arithmetic/data transfer instructions FIX (arithmetic followed by load/store) FLT (load/store followed by arithmetic) CMF, CNF CMFE, CNFE (comparisons) WFS, RFS (write/read floating point status register) WFC, RFC (write/read floating point control register) cond condition codes P pre/post index bit: 0 = postindex, 1 = preindex U up/down bit: 0 = stack grows down, 1 = stack grows up W write back bit: 1 = update base register (Rn) L load/store bit: 0 = store, 1 = load Rn base register Rd destination/source register Fd floating point destination register Fn floating point source register Fm floating point source register or floating point constant uv transfer length (TABLE 1) wx register count (TABLE 2) abcd arithmetic opcode (TABLES 3 & 4) ef destination size (rounding precision) (TABLE 5) gh rounding mode (TABLE 6) j dyadic/monadic bit: 0 = dyadic, 1 = monadic i constant bit: 1 = constant (TABLE 6) */ /* TABLE 1 +-------------------------+---+---+---------+---------+ | Precision | u | v | FPSR.EP | length | +-------------------------+---+---+---------+---------+ | Single | 0 | 0 | x | 1 words | | Double | 1 | 1 | x | 2 words | | Extended | 1 | 1 | x | 3 words | | Packed decimal | 1 | 1 | 0 | 3 words | | Expanded packed decimal | 1 | 1 | 1 | 4 words | +-------------------------+---+---+---------+---------+ Note: x = don't care */ /* TABLE 2 +---+---+---------------------------------+ | w | x | Number of registers to transfer | +---+---+---------------------------------+ | 0 | 1 | 1 | | 1 | 0 | 2 | | 1 | 1 | 3 | | 0 | 0 | 4 | +---+---+---------------------------------+ */ /* TABLE 3: Dyadic Floating Point Opcodes +---+---+---+---+----------+-----------------------+-----------------------+ | a | b | c | d | Mnemonic | Description | Operation | +---+---+---+---+----------+-----------------------+-----------------------+ | 0 | 0 | 0 | 0 | ADF | Add | Fd := Fn + Fm | | 0 | 0 | 0 | 1 | MUF | Multiply | Fd := Fn * Fm | | 0 | 0 | 1 | 0 | SUF | Subtract | Fd := Fn - Fm | | 0 | 0 | 1 | 1 | RSF | Reverse subtract | Fd := Fm - Fn | | 0 | 1 | 0 | 0 | DVF | Divide | Fd := Fn / Fm | | 0 | 1 | 0 | 1 | RDF | Reverse divide | Fd := Fm / Fn | | 0 | 1 | 1 | 0 | POW | Power | Fd := Fn ^ Fm | | 0 | 1 | 1 | 1 | RPW | Reverse power | Fd := Fm ^ Fn | | 1 | 0 | 0 | 0 | RMF | Remainder | Fd := IEEE rem(Fn/Fm) | | 1 | 0 | 0 | 1 | FML | Fast Multiply | Fd := Fn * Fm | | 1 | 0 | 1 | 0 | FDV | Fast Divide | Fd := Fn / Fm | | 1 | 0 | 1 | 1 | FRD | Fast reverse divide | Fd := Fm / Fn | | 1 | 1 | 0 | 0 | POL | Polar angle (ArcTan2) | Fd := arctan2(Fn,Fm) | | 1 | 1 | 0 | 1 | | undefined instruction | trap | | 1 | 1 | 1 | 0 | | undefined instruction | trap | | 1 | 1 | 1 | 1 | | undefined instruction | trap | +---+---+---+---+----------+-----------------------+-----------------------+ Note: POW, RPW, POL are deprecated, and are available for backwards compatibility only. */ /* TABLE 4: Monadic Floating Point Opcodes +---+---+---+---+----------+-----------------------+-----------------------+ | a | b | c | d | Mnemonic | Description | Operation | +---+---+---+---+----------+-----------------------+-----------------------+ | 0 | 0 | 0 | 0 | MVF | Move | Fd := Fm | | 0 | 0 | 0 | 1 | MNF | Move negated | Fd := - Fm | | 0 | 0 | 1 | 0 | ABS | Absolute value | Fd := abs(Fm) | | 0 | 0 | 1 | 1 | RND | Round to integer | Fd := int(Fm) | | 0 | 1 | 0 | 0 | SQT | Square root | Fd := sqrt(Fm) | | 0 | 1 | 0 | 1 | LOG | Log base 10 | Fd := log10(Fm) | | 0 | 1 | 1 | 0 | LGN | Log base e | Fd := ln(Fm) | | 0 | 1 | 1 | 1 | EXP | Exponent | Fd := e ^ Fm | | 1 | 0 | 0 | 0 | SIN | Sine | Fd := sin(Fm) | | 1 | 0 | 0 | 1 | COS | Cosine | Fd := cos(Fm) | | 1 | 0 | 1 | 0 | TAN | Tangent | Fd := tan(Fm) | | 1 | 0 | 1 | 1 | ASN | Arc Sine | Fd := arcsin(Fm) | | 1 | 1 | 0 | 0 | ACS | Arc Cosine | Fd := arccos(Fm) | | 1 | 1 | 0 | 1 | ATN | Arc Tangent | Fd := arctan(Fm) | | 1 | 1 | 1 | 0 | URD | Unnormalized round | Fd := int(Fm) | | 1 | 1 | 1 | 1 | NRM | Normalize | Fd := norm(Fm) | +---+---+---+---+----------+-----------------------+-----------------------+ Note: LOG, LGN, EXP, SIN, COS, TAN, ASN, ACS, ATN are deprecated, and are available for backwards compatibility only. */ /* TABLE 5 +-------------------------+---+---+ | Rounding Precision | e | f | +-------------------------+---+---+ | IEEE Single precision | 0 | 0 | | IEEE Double precision | 0 | 1 | | IEEE Extended precision | 1 | 0 | | undefined (trap) | 1 | 1 | +-------------------------+---+---+ */ /* TABLE 5 +---------------------------------+---+---+ | Rounding Mode | g | h | +---------------------------------+---+---+ | Round to nearest (default) | 0 | 0 | | Round toward plus infinity | 0 | 1 | | Round toward negative infinity | 1 | 0 | | Round toward zero | 1 | 1 | +---------------------------------+---+---+ */ /* === === Definitions for load and store instructions === */ /* bit masks */ #define BIT_PREINDEX 0x01000000 #define BIT_UP 0x00800000 #define BIT_WRITE_BACK 0x00200000 #define BIT_LOAD 0x00100000 /* masks for load/store */ #define MASK_CPDT 0x0c000000 /* data processing opcode */ #define MASK_OFFSET 0x000000ff #define MASK_TRANSFER_LENGTH 0x00408000 #define MASK_REGISTER_COUNT MASK_TRANSFER_LENGTH #define MASK_COPROCESSOR 0x00000f00 /* Tests for transfer length */ #define TRANSFER_SINGLE 0x00000000 #define TRANSFER_DOUBLE 0x00008000 #define TRANSFER_EXTENDED 0x00400000 #define TRANSFER_PACKED MASK_TRANSFER_LENGTH /* Get the coprocessor number from the opcode. */ #define getCoprocessorNumber(opcode) ((opcode & MASK_COPROCESSOR) >> 8) /* Get the offset from the opcode. */ #define getOffset(opcode) (opcode & MASK_OFFSET) /* Tests for specific data transfer load/store opcodes. */ #define TEST_OPCODE(opcode,mask) (((opcode) & (mask)) == (mask)) #define LOAD_OP(opcode) TEST_OPCODE((opcode),MASK_CPDT | BIT_LOAD) #define STORE_OP(opcode) ((opcode & (MASK_CPDT | BIT_LOAD)) == MASK_CPDT) #define LDF_OP(opcode) (LOAD_OP(opcode) && (getCoprocessorNumber(opcode) == 1)) #define LFM_OP(opcode) (LOAD_OP(opcode) && (getCoprocessorNumber(opcode) == 2)) #define STF_OP(opcode) (STORE_OP(opcode) && (getCoprocessorNumber(opcode) == 1)) #define SFM_OP(opcode) (STORE_OP(opcode) && (getCoprocessorNumber(opcode) == 2)) #define PREINDEXED(opcode) ((opcode & BIT_PREINDEX) != 0) #define POSTINDEXED(opcode) ((opcode & BIT_PREINDEX) == 0) #define BIT_UP_SET(opcode) ((opcode & BIT_UP) != 0) #define BIT_UP_CLEAR(opcode) ((opcode & BIT_DOWN) == 0) #define WRITE_BACK(opcode) ((opcode & BIT_WRITE_BACK) != 0) #define LOAD(opcode) ((opcode & BIT_LOAD) != 0) #define STORE(opcode) ((opcode & BIT_LOAD) == 0) /* === === Definitions for arithmetic instructions === */ /* bit masks */ #define BIT_MONADIC 0x00008000 #define BIT_CONSTANT 0x00000008 #define CONSTANT_FM(opcode) ((opcode & BIT_CONSTANT) != 0) #define MONADIC_INSTRUCTION(opcode) ((opcode & BIT_MONADIC) != 0) /* instruction identification masks */ #define MASK_CPDO 0x0e000000 /* arithmetic opcode */ #define MASK_ARITHMETIC_OPCODE 0x00f08000 #define MASK_DESTINATION_SIZE 0x00080080 /* dyadic arithmetic opcodes. */ #define ADF_CODE 0x00000000 #define MUF_CODE 0x00100000 #define SUF_CODE 0x00200000 #define RSF_CODE 0x00300000 #define DVF_CODE 0x00400000 #define RDF_CODE 0x00500000 #define POW_CODE 0x00600000 #define RPW_CODE 0x00700000 #define RMF_CODE 0x00800000 #define FML_CODE 0x00900000 #define FDV_CODE 0x00a00000 #define FRD_CODE 0x00b00000 #define POL_CODE 0x00c00000 /* 0x00d00000 is an invalid dyadic arithmetic opcode */ /* 0x00e00000 is an invalid dyadic arithmetic opcode */ /* 0x00f00000 is an invalid dyadic arithmetic opcode */ /* monadic arithmetic opcodes. */ #define MVF_CODE 0x00008000 #define MNF_CODE 0x00108000 #define ABS_CODE 0x00208000 #define RND_CODE 0x00308000 #define SQT_CODE 0x00408000 #define LOG_CODE 0x00508000 #define LGN_CODE 0x00608000 #define EXP_CODE 0x00708000 #define SIN_CODE 0x00808000 #define COS_CODE 0x00908000 #define TAN_CODE 0x00a08000 #define ASN_CODE 0x00b08000 #define ACS_CODE 0x00c08000 #define ATN_CODE 0x00d08000 #define URD_CODE 0x00e08000 #define NRM_CODE 0x00f08000 /* === === Definitions for register transfer and comparison instructions === */ #define MASK_CPRT 0x0e000010 /* register transfer opcode */ #define MASK_CPRT_CODE 0x00f00000 #define FLT_CODE 0x00000000 #define FIX_CODE 0x00100000 #define WFS_CODE 0x00200000 #define RFS_CODE 0x00300000 #define WFC_CODE 0x00400000 #define RFC_CODE 0x00500000 #define CMF_CODE 0x00900000 #define CNF_CODE 0x00b00000 #define CMFE_CODE 0x00d00000 #define CNFE_CODE 0x00f00000 /* === === Common definitions === */ /* register masks */ #define MASK_Rd 0x0000f000 #define MASK_Rn 0x000f0000 #define MASK_Fd 0x00007000 #define MASK_Fm 0x00000007 #define MASK_Fn 0x00070000 /* condition code masks */ #define CC_MASK 0xf0000000 #define CC_NEGATIVE 0x80000000 #define CC_ZERO 0x40000000 #define CC_CARRY 0x20000000 #define CC_OVERFLOW 0x10000000 #define CC_EQ 0x00000000 #define CC_NE 0x10000000 #define CC_CS 0x20000000 #define CC_HS CC_CS #define CC_CC 0x30000000 #define CC_LO CC_CC #define CC_MI 0x40000000 #define CC_PL 0x50000000 #define CC_VS 0x60000000 #define CC_VC 0x70000000 #define CC_HI 0x80000000 #define CC_LS 0x90000000 #define CC_GE 0xa0000000 #define CC_LT 0xb0000000 #define CC_GT 0xc0000000 #define CC_LE 0xd0000000 #define CC_AL 0xe0000000 #define CC_NV 0xf0000000 /* rounding masks/values */ #define MASK_ROUNDING_MODE 0x00000060 #define ROUND_TO_NEAREST 0x00000000 #define ROUND_TO_PLUS_INFINITY 0x00000020 #define ROUND_TO_MINUS_INFINITY 0x00000040 #define ROUND_TO_ZERO 0x00000060 #define MASK_ROUNDING_PRECISION 0x00080080 #define ROUND_SINGLE 0x00000000 #define ROUND_DOUBLE 0x00000080 #define ROUND_EXTENDED 0x00080000 /* Get the condition code from the opcode. */ #define getCondition(opcode) (opcode >> 28) /* Get the source register from the opcode. */ #define getRn(opcode) ((opcode & MASK_Rn) >> 16) /* Get the destination floating point register from the opcode. */ #define getFd(opcode) ((opcode & MASK_Fd) >> 12) /* Get the first source floating point register from the opcode. */ #define getFn(opcode) ((opcode & MASK_Fn) >> 16) /* Get the second source floating point register from the opcode. */ #define getFm(opcode) (opcode & MASK_Fm) /* Get the destination register from the opcode. */ #define getRd(opcode) ((opcode & MASK_Rd) >> 12) /* Get the rounding mode from the opcode. */ #define getRoundingMode(opcode) ((opcode & MASK_ROUNDING_MODE) >> 5) #ifdef CONFIG_FPE_NWFPE_XP static inline floatx80 __pure getExtendedConstant(const unsigned int nIndex) { extern const floatx80 floatx80Constant[]; return floatx80Constant[nIndex]; } #endif static inline float64 __pure getDoubleConstant(const unsigned int nIndex) { extern const float64 float64Constant[]; return float64Constant[nIndex]; } static inline float32 __pure getSingleConstant(const unsigned int nIndex) { extern const float32 float32Constant[]; return float32Constant[nIndex]; } static inline unsigned int getTransferLength(const unsigned int opcode) { unsigned int nRc; switch (opcode & MASK_TRANSFER_LENGTH) { case 0x00000000: nRc = 1; break; /* single precision */ case 0x00008000: nRc = 2; break; /* double precision */ case 0x00400000: nRc = 3; break; /* extended precision */ default: nRc = 0; } return (nRc); } static inline unsigned int getRegisterCount(const unsigned int opcode) { unsigned int nRc; switch (opcode & MASK_REGISTER_COUNT) { case 0x00000000: nRc = 4; break; case 0x00008000: nRc = 1; break; case 0x00400000: nRc = 2; break; case 0x00408000: nRc = 3; break; default: nRc = 0; } return (nRc); } static inline unsigned int getRoundingPrecision(const unsigned int opcode) { unsigned int nRc; switch (opcode & MASK_ROUNDING_PRECISION) { case 0x00000000: nRc = 1; break; case 0x00000080: nRc = 2; break; case 0x00080000: nRc = 3; break; default: nRc = 0; } return (nRc); } static inline unsigned int getDestinationSize(const unsigned int opcode) { unsigned int nRc; switch (opcode & MASK_DESTINATION_SIZE) { case 0x00000000: nRc = typeSingle; break; case 0x00000080: nRc = typeDouble; break; case 0x00080000: nRc = typeExtended; break; default: nRc = typeNone; } return (nRc); } extern const float64 float64Constant[]; extern const float32 float32Constant[]; #endif
c54dfcc0120956b3565558f2866b97ddf877a6c8
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/vax/vax/crx.c
1c93e64538ab5dd6ef80dcdbf485c5b53feb2422
[]
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
7,108
c
crx.c
/* $NetBSD: crx.c,v 1.15 2014/07/25 08:10:35 dholland Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)rx50.c 7.5 (Berkeley) 12/16/90 */ /* * Routines to handle the console RX50. */ #include <sys/cdefs.h> __KERNEL_RCSID(0, "$NetBSD: crx.c,v 1.15 2014/07/25 08:10:35 dholland Exp $"); #include <sys/param.h> #include <sys/time.h> #include <sys/proc.h> #include <sys/kernel.h> #include <sys/buf.h> #include <sys/errno.h> #include <sys/uio.h> #include <sys/device.h> #include <sys/systm.h> #include <sys/conf.h> #include <machine/ka820.h> #include <vax/vax/crx.h> static dev_type_open(crxopen); static dev_type_close(crxclose); static dev_type_read(crxrw); const struct cdevsw crx_cdevsw = { .d_open = crxopen, .d_close = crxclose, .d_read = crxrw, .d_write = crxrw, .d_ioctl = noioctl, .d_stop = nostop, .d_tty = notty, .d_poll = nopoll, .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, .d_flag = 0 }; extern struct rx50device *rx50device_ptr; #define rxaddr rx50device_ptr extern struct ka820port *ka820port_ptr; #define rx50unit(dev) minor(dev) struct rx50state { short rs_flags; /* see below */ short rs_drive; /* current drive number */ u_int rs_blkno; /* current block number */ } rx50state; /* flags */ #define RS_0OPEN 0x01 /* drive 0 open -- must be first */ #define RS_1OPEN 0x02 /* drive 1 open -- must be second */ #define RS_BUSY 0x04 /* operation in progress */ #define RS_WANT 0x08 /* wakeup when done */ #define RS_DONE 0x20 /* I/O operation done */ #define RS_ERROR 0x40 /* error bit set at interrupt */ #if 0 #define CRXDEBUG 1 #endif /* * Open a console RX50. */ /*ARGSUSED*/ int crxopen(dev_t dev, int flags, int fmt, struct lwp *l) { int unit; #if CRXDEBUG printf("crxopen(csa%d)\n", rx50unit(dev)); #endif if ((unit = rx50unit(dev)) >= 2) return (ENXIO); /* enforce exclusive access */ if (rx50state.rs_flags & (1 << unit)) return (EBUSY); rx50state.rs_flags |= 1 << unit; return (0); } /* * Close a console RX50. */ /*ARGSUSED*/ int crxclose(dev_t dev, int flags, int fmt, struct lwp *l) { #if CRXDEBUG printf("crxclose(csa%d)\n", rx50unit(dev)); #endif rx50state.rs_flags &= ~(1 << rx50unit(dev)); /* atomic */ return 0; } /* * Perform a read (uio->uio_rw==UIO_READ) or write (uio->uio_rw==UIO_WRITE). */ int crxrw(dev_t dev, struct uio *uio, int flags) { struct rx50state *rs; char *cp; int error, i, t; char secbuf[512]; static char driveselect[2] = { RXCMD_DRIVE0, RXCMD_DRIVE1 }; #if CRXDEBUG printf("crxrw(csa%d): %s\n", rx50unit(dev), uio->uio_rw==UIO_READ?"read":"write"); printf("crxrw: ka820port = %x\n", ka820port_ptr->csr); #endif /* enforce whole-sector I/O */ if ((uio->uio_offset & 511) || (uio->uio_resid & 511)) return (EINVAL); rs = &rx50state; /* lock out others */ i = splvm(); while (rs->rs_flags & RS_BUSY) { rs->rs_flags |= RS_WANT; (void) tsleep(&rx50state, PRIBIO, "crxbusy", 0); } rs->rs_flags |= RS_BUSY; rs->rs_drive = rx50unit(dev); splx(i); rxaddr = rx50device_ptr; error = 0; while (uio->uio_resid) { rs->rs_blkno = uio->uio_offset >> 9; if (rs->rs_blkno >= RX50MAXSEC) { if (rs->rs_blkno > RX50MAXSEC) error = EINVAL; else if (uio->uio_rw == UIO_WRITE) error = ENOSPC; /* else ``eof'' */ break; } rs->rs_flags &= ~(RS_ERROR | RS_DONE); if (uio->uio_rw == UIO_WRITE) { /* copy the data to the RX50 silo */ error = uiomove(secbuf, 512, uio); if (error) break; i = rxaddr->rxrda; for (cp = secbuf, i = 512; --i >= 0;) rxaddr->rxfdb = *cp++; i = RXCMD_WRITE; } else i = RXCMD_READ; rxaddr->rxcmd = i | driveselect[rs->rs_drive]; i = rs->rs_blkno - ((t = rs->rs_blkno / RX50SEC) * RX50SEC); rxaddr->rxtrk = t == 79 ? 0 : t + 1; #ifdef notdef rxaddr->rxsec = "\1\3\5\7\11\1\3\5\7"[(2*t + i) % 5] + (i > 4); #else rxaddr->rxsec = RX50SKEW(i, t); #endif #if CRXDEBUG printf("crx: going off\n"); printf("crxrw: ka820port = %x\n", ka820port_ptr->csr); #endif rxaddr->rxgo = 0; /* start it up */ ka820port_ptr->csr |= KA820PORT_RXIRQ; i = splvm(); while ((rs->rs_flags & RS_DONE) == 0) { #if CRXDEBUG printf("crx: sleeping on I/O\n"); printf("crxopen: ka820port = %x\n", ka820port_ptr->csr); #endif (void) tsleep(&rs->rs_blkno, PRIBIO, "crxrw", 0); } splx(i); if (rs->rs_flags & RS_ERROR) { error = EIO; break; } if (uio->uio_rw == UIO_READ) { /* copy the data out of the silo */ i = rxaddr->rxrda; for (cp = secbuf, i = 512; --i >= 0;) *cp++ = rxaddr->rxedb; error = uiomove(secbuf, 512, uio); if (error) break; } } /* let others in */ #if CRXDEBUG printf("crx: let others in\n"); #endif rs->rs_flags &= ~RS_BUSY; if (rs->rs_flags & RS_WANT) wakeup((void *) rs); return (error); } void crxintr(void *arg) { struct rx50state *rs = &rx50state; /* ignore spurious interrupts */ if ((rxaddr->rxcmd & RXCMD_DONE) == 0) return; if ((rs->rs_flags & RS_BUSY) == 0) { printf("stray rx50 interrupt ignored (rs_flags: 0x%x, rxcmd: 0x%x)\n", rs->rs_flags, rxaddr->rxcmd); return; } if (rxaddr->rxcmd & RXCMD_ERROR) { printf( "csa%d: hard error sn%d: cmd=%x trk=%x sec=%x csc=%x ict=%x ext=%x\n", rs->rs_drive + 1, rs->rs_blkno, rxaddr->rxcmd, rxaddr->rxtrk, rxaddr->rxsec, rxaddr->rxcsc, rxaddr->rxict, rxaddr->rxext); rxaddr->rxcmd = RXCMD_RESET; rxaddr->rxgo = 0; rs->rs_flags |= RS_ERROR; } rs->rs_flags |= RS_DONE; wakeup((void *) &rs->rs_blkno); }
8afbfd61452ca00727c8bef6c61847f717f8acff
72a2fc906bb1219257b5cd02ba46a9f77c60c762
/components/entropy.c
65010b0274fc69b6ae02649f36d20db5e7a665c6
[ "ISC" ]
permissive
drkhsh/slstatus
fac0cc8d1855c0447a54a2d2ac032134c32dd3ad
f68f49273e70b3767b30c549dda04ddd4d25fc91
refs/heads/master
2023-07-07T01:53:56.359434
2023-07-04T18:47:18
2023-07-04T18:47:18
53,124,988
219
123
ISC
2022-12-26T15:27:31
2016-03-04T09:46:18
C
UTF-8
C
false
false
617
c
entropy.c
/* See LICENSE file for copyright and license details. */ #include "../slstatus.h" #if defined(__linux__) #include <stdint.h> #include <stdio.h> #include "../util.h" #define ENTROPY_AVAIL "/proc/sys/kernel/random/entropy_avail" const char * entropy(const char *unused) { uintmax_t num; if (pscanf(ENTROPY_AVAIL, "%ju", &num) != 1) return NULL; return bprintf("%ju", num); } #elif defined(__OpenBSD__) | defined(__FreeBSD__) const char * entropy(const char *unused) { // https://www.unicode.org/charts/PDF/U2200.pdf /* Unicode Character 'INFINITY' (U+221E) */ return "\u221E"; } #endif
3756156fdebce8db71d2df70913d90c2a7979a1a
cf46338edd0b0fee666b897ba1ea719ea058ba36
/guacamole/src/protocols/rdp/rdp_cliprdr.c
53019115a7faad6cd20c73c4976199b58f088d3b
[ "MIT" ]
permissive
changkun/occamy
ed72ead996fb0417b8978259098c4ea46b0d906b
b6fdf8cf5f1a3a674e0aabbfee54cb185776ea40
refs/heads/master
2021-12-31T05:54:37.964570
2021-12-07T11:00:11
2021-12-07T11:06:10
166,392,711
314
56
MIT
2021-12-16T08:31:34
2019-01-18T11:10:22
Go
UTF-8
C
false
false
8,215
c
rdp_cliprdr.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. */ #include "config.h" #include "client.h" #include "common/clipboard.h" #include "common/iconv.h" #include "rdp.h" #include "rdp_cliprdr.h" #include <freerdp/channels/channels.h> #include <freerdp/freerdp.h> #include <freerdp/utils/event.h> #include <guacamole/client.h> #ifdef ENABLE_WINPR #include <winpr/wtypes.h> #else #include "compat/winpr-wtypes.h" #endif #ifdef HAVE_FREERDP_CLIENT_CLIPRDR_H #include <freerdp/client/cliprdr.h> #else #include "compat/client-cliprdr.h" #endif #include <stdlib.h> #include <string.h> void guac_rdp_process_cliprdr_event(guac_client* client, wMessage* event) { #ifdef LEGACY_EVENT switch (event->event_type) { #else switch (GetMessageType(event->id)) { #endif case CliprdrChannel_MonitorReady: guac_rdp_process_cb_monitor_ready(client, event); break; case CliprdrChannel_FormatList: guac_rdp_process_cb_format_list(client, (RDP_CB_FORMAT_LIST_EVENT*) event); break; case CliprdrChannel_DataRequest: guac_rdp_process_cb_data_request(client, (RDP_CB_DATA_REQUEST_EVENT*) event); break; case CliprdrChannel_DataResponse: guac_rdp_process_cb_data_response(client, (RDP_CB_DATA_RESPONSE_EVENT*) event); break; default: #ifdef LEGACY_EVENT guac_client_log(client, GUAC_LOG_INFO, "Unknown cliprdr event type: 0x%x", event->event_type); #else guac_client_log(client, GUAC_LOG_INFO, "Unknown cliprdr event type: 0x%x", GetMessageType(event->id)); #endif } } void guac_rdp_process_cb_monitor_ready(guac_client* client, wMessage* event) { rdpChannels* channels = ((guac_rdp_client*) client->data)->rdp_inst->context->channels; RDP_CB_FORMAT_LIST_EVENT* format_list = (RDP_CB_FORMAT_LIST_EVENT*) freerdp_event_new( CliprdrChannel_Class, CliprdrChannel_FormatList, NULL, NULL); /* Received notification of clipboard support. */ /* Respond with supported format list */ format_list->formats = (UINT32*) malloc(sizeof(UINT32)*2); format_list->formats[0] = CB_FORMAT_TEXT; format_list->formats[1] = CB_FORMAT_UNICODETEXT; format_list->num_formats = 2; freerdp_channels_send_event(channels, (wMessage*) format_list); } /** * Sends a clipboard data request for the given format. * * @param client * The guac_client associated with the current RDP session. * * @param format * The clipboard format to request. This format must be one of the * documented values used by the CLIPRDR channel for clipboard format IDs. */ static void __guac_rdp_cb_request_format(guac_client* client, int format) { guac_rdp_client* rdp_client = (guac_rdp_client*) client->data; rdpChannels* channels = rdp_client->rdp_inst->context->channels; /* Create new data request */ RDP_CB_DATA_REQUEST_EVENT* data_request = (RDP_CB_DATA_REQUEST_EVENT*) freerdp_event_new( CliprdrChannel_Class, CliprdrChannel_DataRequest, NULL, NULL); /* Set to requested format */ rdp_client->requested_clipboard_format = format; data_request->format = format; /* Send request */ freerdp_channels_send_event(channels, (wMessage*) data_request); } void guac_rdp_process_cb_format_list(guac_client* client, RDP_CB_FORMAT_LIST_EVENT* event) { int formats = 0; /* Received notification of available data */ int i; for (i=0; i<event->num_formats; i++) { /* If plain text available, request it */ if (event->formats[i] == CB_FORMAT_TEXT) formats |= GUAC_RDP_CLIPBOARD_FORMAT_CP1252; else if (event->formats[i] == CB_FORMAT_UNICODETEXT) formats |= GUAC_RDP_CLIPBOARD_FORMAT_UTF16; } /* Prefer Unicode to plain text */ if (formats & GUAC_RDP_CLIPBOARD_FORMAT_UTF16) { __guac_rdp_cb_request_format(client, CB_FORMAT_UNICODETEXT); return; } /* Use plain text if Unicode unavailable */ if (formats & GUAC_RDP_CLIPBOARD_FORMAT_CP1252) { __guac_rdp_cb_request_format(client, CB_FORMAT_TEXT); return; } /* Ignore if no supported format available */ guac_client_log(client, GUAC_LOG_INFO, "Ignoring unsupported clipboard data"); } void guac_rdp_process_cb_data_request(guac_client* client, RDP_CB_DATA_REQUEST_EVENT* event) { guac_rdp_client* rdp_client = (guac_rdp_client*) client->data; rdpChannels* channels = rdp_client->rdp_inst->context->channels; guac_iconv_write* writer; const char* input = rdp_client->clipboard->buffer; char* output = malloc(GUAC_RDP_CLIPBOARD_MAX_LENGTH); RDP_CB_DATA_RESPONSE_EVENT* data_response; /* Determine output encoding */ switch (event->format) { case CB_FORMAT_TEXT: writer = GUAC_WRITE_CP1252; break; case CB_FORMAT_UNICODETEXT: writer = GUAC_WRITE_UTF16; break; default: guac_client_log(client, GUAC_LOG_ERROR, "Server requested unsupported clipboard data type"); free(output); return; } /* Create new data response */ data_response = (RDP_CB_DATA_RESPONSE_EVENT*) freerdp_event_new( CliprdrChannel_Class, CliprdrChannel_DataResponse, NULL, NULL); /* Set data and size */ data_response->data = (BYTE*) output; guac_iconv(GUAC_READ_UTF8, &input, rdp_client->clipboard->length, writer, &output, GUAC_RDP_CLIPBOARD_MAX_LENGTH); data_response->size = ((BYTE*) output) - data_response->data; /* Send response */ freerdp_channels_send_event(channels, (wMessage*) data_response); } void guac_rdp_process_cb_data_response(guac_client* client, RDP_CB_DATA_RESPONSE_EVENT* event) { guac_rdp_client* rdp_client = (guac_rdp_client*) client->data; char received_data[GUAC_RDP_CLIPBOARD_MAX_LENGTH]; guac_iconv_read* reader; const char* input = (char*) event->data; char* output = received_data; /* Find correct source encoding */ switch (rdp_client->requested_clipboard_format) { /* Non-Unicode */ case CB_FORMAT_TEXT: reader = GUAC_READ_CP1252; break; /* Unicode (UTF-16) */ case CB_FORMAT_UNICODETEXT: reader = GUAC_READ_UTF16; break; default: guac_client_log(client, GUAC_LOG_ERROR, "Requested clipboard data in " "unsupported format %i", rdp_client->requested_clipboard_format); return; } /* Convert send clipboard data */ if (guac_iconv(reader, &input, event->size, GUAC_WRITE_UTF8, &output, sizeof(received_data))) { int length = strnlen(received_data, sizeof(received_data)); guac_common_clipboard_reset(rdp_client->clipboard, "text/plain"); guac_common_clipboard_append(rdp_client->clipboard, received_data, length); guac_common_clipboard_send(rdp_client->clipboard, client); } }
e712fa686bf2819701b3de4a0f625f2bc49a51af
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/tests/usr.bin/xlint/lint1/msg_046.c
b84b0a030658c388518fcd9a9011264190f3736f
[]
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
1,399
c
msg_046.c
/* $NetBSD: msg_046.c,v 1.6 2023/03/28 14:44:34 rillig Exp $ */ # 3 "msg_046.c" // Test for message: %s tag '%s' redeclared as %s [46] /* lint1-extra-flags: -X 351 */ /* expect+1: warning: struct 'tag1' never defined [233] */ struct tag1; /* expect+2: error: struct tag 'tag1' redeclared as union [46] */ /* expect+1: warning: union 'tag1' never defined [234] */ union tag1; /* expect+1: warning: union 'tag2' never defined [234] */ union tag2; /* expect+2: error: union tag 'tag2' redeclared as enum [46] */ /* expect+1: warning: enum 'tag2' never defined [235] */ enum tag2; /* expect+1: warning: enum 'tag3' never defined [235] */ enum tag3; /* expect+2: error: enum tag 'tag3' redeclared as struct [46] */ /* expect+1: warning: struct 'tag3' never defined [233] */ struct tag3; /* expect+2: error: union tag 'tag1' redeclared as struct [46] */ /* expect+1: warning: struct 'tag1' never defined [233] */ struct tag1 *use_tag1(void); /* expect+2: error: enum tag 'tag2' redeclared as union [46] */ /* expect+1: warning: union 'tag2' never defined [234] */ union tag2 *use_tag2(void); /* expect+2: error: struct tag 'tag3' redeclared as enum [46] */ /* expect+1: warning: enum 'tag3' never defined [235] */ enum tag3 *use_tag3(void); /* expect+2: error: struct tag 'tag1' redeclared as union [46] */ /* expect+1: warning: union 'tag1' never defined [234] */ union tag1 *mismatch_tag1(void);