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
02bf9079d88ef2bdb5705e70d5a7455337f7f5ff
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/include/linux/ptp_classify.h
1dc420ba213a52624920184c620441516270c6bf
[ "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
5,601
h
ptp_classify.h
/* * PTP 1588 support * * This file implements a BPF that recognizes PTP event messages. * * Copyright (C) 2010 OMICRON electronics GmbH * * 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 _PTP_CLASSIFY_H_ #define _PTP_CLASSIFY_H_ #include <linux/if_ether.h> #include <linux/if_vlan.h> #include <linux/ip.h> #include <linux/filter.h> #ifdef __KERNEL__ #include <linux/in.h> #else #include <netinet/in.h> #endif #define PTP_CLASS_NONE 0x00 /* not a PTP event message */ #define PTP_CLASS_V1 0x01 /* protocol version 1 */ #define PTP_CLASS_V2 0x02 /* protocol version 2 */ #define PTP_CLASS_VMASK 0x0f /* max protocol version is 15 */ #define PTP_CLASS_IPV4 0x10 /* event in an IPV4 UDP packet */ #define PTP_CLASS_IPV6 0x20 /* event in an IPV6 UDP packet */ #define PTP_CLASS_L2 0x30 /* event in a L2 packet */ #define PTP_CLASS_VLAN 0x40 /* event in a VLAN tagged L2 packet */ #define PTP_CLASS_PMASK 0xf0 /* mask for the packet type field */ #define PTP_CLASS_V1_IPV4 (PTP_CLASS_V1 | PTP_CLASS_IPV4) #define PTP_CLASS_V1_IPV6 (PTP_CLASS_V1 | PTP_CLASS_IPV6) /*probably DNE*/ #define PTP_CLASS_V2_IPV4 (PTP_CLASS_V2 | PTP_CLASS_IPV4) #define PTP_CLASS_V2_IPV6 (PTP_CLASS_V2 | PTP_CLASS_IPV6) #define PTP_CLASS_V2_L2 (PTP_CLASS_V2 | PTP_CLASS_L2) #define PTP_CLASS_V2_VLAN (PTP_CLASS_V2 | PTP_CLASS_VLAN) #define PTP_EV_PORT 319 #define PTP_GEN_BIT 0x08 /* indicates general message, if set in message type */ #define OFF_ETYPE 12 #define OFF_IHL 14 #define OFF_FRAG 20 #define OFF_PROTO4 23 #define OFF_NEXT 6 #define OFF_UDP_DST 2 #define OFF_PTP_SOURCE_UUID 22 /* PTPv1 only */ #define OFF_PTP_SEQUENCE_ID 30 #define OFF_PTP_CONTROL 32 /* PTPv1 only */ #define IPV4_HLEN(data) (((struct iphdr *)(data + OFF_IHL))->ihl << 2) #define IP6_HLEN 40 #define UDP_HLEN 8 #define RELOFF_DST4 (ETH_HLEN + OFF_UDP_DST) #define OFF_DST6 (ETH_HLEN + IP6_HLEN + OFF_UDP_DST) #define OFF_PTP6 (ETH_HLEN + IP6_HLEN + UDP_HLEN) #define OP_AND (BPF_ALU | BPF_AND | BPF_K) #define OP_JEQ (BPF_JMP | BPF_JEQ | BPF_K) #define OP_JSET (BPF_JMP | BPF_JSET | BPF_K) #define OP_LDB (BPF_LD | BPF_B | BPF_ABS) #define OP_LDH (BPF_LD | BPF_H | BPF_ABS) #define OP_LDHI (BPF_LD | BPF_H | BPF_IND) #define OP_LDX (BPF_LDX | BPF_B | BPF_MSH) #define OP_OR (BPF_ALU | BPF_OR | BPF_K) #define OP_RETA (BPF_RET | BPF_A) #define OP_RETK (BPF_RET | BPF_K) static inline int ptp_filter_init(struct sock_filter *f, int len) { if (OP_LDH == f[0].code) return sk_chk_filter(f, len); else return 0; } #define PTP_FILTER \ {OP_LDH, 0, 0, OFF_ETYPE }, /* */ \ {OP_JEQ, 0, 12, ETH_P_IP }, /* f goto L20 */ \ {OP_LDB, 0, 0, OFF_PROTO4 }, /* */ \ {OP_JEQ, 0, 9, IPPROTO_UDP }, /* f goto L10 */ \ {OP_LDH, 0, 0, OFF_FRAG }, /* */ \ {OP_JSET, 7, 0, 0x1fff }, /* t goto L11 */ \ {OP_LDX, 0, 0, OFF_IHL }, /* */ \ {OP_LDHI, 0, 0, RELOFF_DST4 }, /* */ \ {OP_JEQ, 0, 4, PTP_EV_PORT }, /* f goto L12 */ \ {OP_LDHI, 0, 0, ETH_HLEN + UDP_HLEN }, /* */ \ {OP_AND, 0, 0, PTP_CLASS_VMASK }, /* */ \ {OP_OR, 0, 0, PTP_CLASS_IPV4 }, /* */ \ {OP_RETA, 0, 0, 0 }, /* */ \ /*L1x*/ {OP_RETK, 0, 0, PTP_CLASS_NONE }, /* */ \ /*L20*/ {OP_JEQ, 0, 9, ETH_P_IPV6 }, /* f goto L40 */ \ {OP_LDB, 0, 0, ETH_HLEN + OFF_NEXT }, /* */ \ {OP_JEQ, 0, 6, IPPROTO_UDP }, /* f goto L30 */ \ {OP_LDH, 0, 0, OFF_DST6 }, /* */ \ {OP_JEQ, 0, 4, PTP_EV_PORT }, /* f goto L31 */ \ {OP_LDH, 0, 0, OFF_PTP6 }, /* */ \ {OP_AND, 0, 0, PTP_CLASS_VMASK }, /* */ \ {OP_OR, 0, 0, PTP_CLASS_IPV6 }, /* */ \ {OP_RETA, 0, 0, 0 }, /* */ \ /*L3x*/ {OP_RETK, 0, 0, PTP_CLASS_NONE }, /* */ \ /*L40*/ {OP_JEQ, 0, 9, ETH_P_8021Q }, /* f goto L50 */ \ {OP_LDH, 0, 0, OFF_ETYPE + 4 }, /* */ \ {OP_JEQ, 0, 15, ETH_P_1588 }, /* f goto L60 */ \ {OP_LDB, 0, 0, ETH_HLEN + VLAN_HLEN }, /* */ \ {OP_AND, 0, 0, PTP_GEN_BIT }, /* */ \ {OP_JEQ, 0, 12, 0 }, /* f goto L6x */ \ {OP_LDH, 0, 0, ETH_HLEN + VLAN_HLEN }, /* */ \ {OP_AND, 0, 0, PTP_CLASS_VMASK }, /* */ \ {OP_OR, 0, 0, PTP_CLASS_VLAN }, /* */ \ {OP_RETA, 0, 0, 0 }, /* */ \ /*L50*/ {OP_JEQ, 0, 7, ETH_P_1588 }, /* f goto L61 */ \ {OP_LDB, 0, 0, ETH_HLEN }, /* */ \ {OP_AND, 0, 0, PTP_GEN_BIT }, /* */ \ {OP_JEQ, 0, 4, 0 }, /* f goto L6x */ \ {OP_LDH, 0, 0, ETH_HLEN }, /* */ \ {OP_AND, 0, 0, PTP_CLASS_VMASK }, /* */ \ {OP_OR, 0, 0, PTP_CLASS_L2 }, /* */ \ {OP_RETA, 0, 0, 0 }, /* */ \ /*L6x*/ {OP_RETK, 0, 0, PTP_CLASS_NONE }, #endif
9134440090e004f213cfb7564d774a78237c0858
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/arm/mach-w90x900/time.c
30fbca8445759aed5cef7350f91b4c8881e1da05
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
3,776
c
time.c
/* * linux/arch/arm/mach-w90x900/time.c * * Based on linux/arch/arm/plat-s3c24xx/time.c by Ben Dooks * * Copyright (c) 2009 Nuvoton technology corporation * All rights reserved. * * Wan ZongShun <mcuos.com@gmail.com> * * 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. * */ #include <linux/kernel.h> #include <linux/sched.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/err.h> #include <linux/clk.h> #include <linux/io.h> #include <linux/leds.h> #include <linux/clocksource.h> #include <linux/clockchips.h> #include <asm/mach-types.h> #include <asm/mach/irq.h> #include <asm/mach/time.h> #include <mach/map.h> #include <mach/regs-timer.h> #include "nuc9xx.h" #define RESETINT 0x1f #define PERIOD (0x01 << 27) #define ONESHOT (0x00 << 27) #define COUNTEN (0x01 << 30) #define INTEN (0x01 << 29) #define TICKS_PER_SEC 100 #define PRESCALE 0x63 /* Divider = prescale + 1 */ #define TDR_SHIFT 24 static unsigned int timer0_load; static void nuc900_clockevent_setmode(enum clock_event_mode mode, struct clock_event_device *clk) { unsigned int val; val = __raw_readl(REG_TCSR0); val &= ~(0x03 << 27); switch (mode) { case CLOCK_EVT_MODE_PERIODIC: __raw_writel(timer0_load, REG_TICR0); val |= (PERIOD | COUNTEN | INTEN | PRESCALE); break; case CLOCK_EVT_MODE_ONESHOT: val |= (ONESHOT | COUNTEN | INTEN | PRESCALE); break; case CLOCK_EVT_MODE_UNUSED: case CLOCK_EVT_MODE_SHUTDOWN: case CLOCK_EVT_MODE_RESUME: break; } __raw_writel(val, REG_TCSR0); } static int nuc900_clockevent_setnextevent(unsigned long evt, struct clock_event_device *clk) { unsigned int val; __raw_writel(evt, REG_TICR0); val = __raw_readl(REG_TCSR0); val |= (COUNTEN | INTEN | PRESCALE); __raw_writel(val, REG_TCSR0); return 0; } static struct clock_event_device nuc900_clockevent_device = { .name = "nuc900-timer0", .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, .set_mode = nuc900_clockevent_setmode, .set_next_event = nuc900_clockevent_setnextevent, .rating = 300, }; /*IRQ handler for the timer*/ static irqreturn_t nuc900_timer0_interrupt(int irq, void *dev_id) { struct clock_event_device *evt = &nuc900_clockevent_device; __raw_writel(0x01, REG_TISR); /* clear TIF0 */ evt->event_handler(evt); return IRQ_HANDLED; } static struct irqaction nuc900_timer0_irq = { .name = "nuc900-timer0", .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, .handler = nuc900_timer0_interrupt, }; static void __init nuc900_clockevents_init(void) { unsigned int rate; struct clk *clk = clk_get(NULL, "timer0"); BUG_ON(IS_ERR(clk)); __raw_writel(0x00, REG_TCSR0); clk_enable(clk); rate = clk_get_rate(clk) / (PRESCALE + 1); timer0_load = (rate / TICKS_PER_SEC); __raw_writel(RESETINT, REG_TISR); setup_irq(IRQ_TIMER0, &nuc900_timer0_irq); nuc900_clockevent_device.cpumask = cpumask_of(0); clockevents_config_and_register(&nuc900_clockevent_device, rate, 0xf, 0xffffffff); } static void __init nuc900_clocksource_init(void) { unsigned int val; unsigned int rate; struct clk *clk = clk_get(NULL, "timer1"); BUG_ON(IS_ERR(clk)); __raw_writel(0x00, REG_TCSR1); clk_enable(clk); rate = clk_get_rate(clk) / (PRESCALE + 1); __raw_writel(0xffffffff, REG_TICR1); val = __raw_readl(REG_TCSR1); val |= (COUNTEN | PERIOD | PRESCALE); __raw_writel(val, REG_TCSR1); clocksource_mmio_init(REG_TDR1, "nuc900-timer1", rate, 200, TDR_SHIFT, clocksource_mmio_readl_down); } void __init nuc900_timer_init(void) { nuc900_clocksource_init(); nuc900_clockevents_init(); }
286a6852c331e4f6388493cec943fb0973daab5b
837528ef9e9a55c416e9592ecb54e1c8f1ff9cf8
/WarpLib/GeoMeshApply.c
407ce082e619bb0eddb8c400206adfefe9a9978c
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
gopro/cineform-sdk
a38fbfa4e9c693ff840ceb934b688ab0fd238856
11574d0295771edccadd17af14af74a539f924c7
refs/heads/master
2023-03-08T15:53:26.569984
2022-02-18T18:36:15
2022-02-18T18:36:15
97,512,165
268
70
Apache-2.0
2022-09-21T13:36:49
2017-07-17T19:03:12
C
UTF-8
C
false
false
40,419
c
GeoMeshApply.c
/*! @file GeoMeshApply.c * @brief Mesh tools * * @version 1.0.0 * * (C) Copyright 2017 GoPro Inc (http://gopro.com/). * * Licensed under either: * - Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0 * - MIT license, http://opensource.org/licenses/MIT * at your option. * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include <stdio.h> #include "GeoMesh.h" #include "GeoMeshPrivate.h" #include "sse_types.h" int geomesh_apply_bilinear(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { geomesh_t *gm = (geomesh_t *)opaque; GEOMESH_CHECK(gm, GEOMESH_CHECK_OBJ_EXISTS | GEOMESH_CHECK_MESH_EXISTS | GEOMESH_CHECK_MESH_INITIALIZED | GEOMESH_CHECK_CACHE_EXISTS | GEOMESH_CHECK_CACHE_INITIALIZED); // right now, only support dest format == src format if (gm->srcformat != gm->destformat) return WARPLIB_ERROR_UNSUPPORTED_CONVERSION; if (gm->separable) return geomesh_apply_bilinear_separable(opaque, src, dest, row0, row1); switch(gm->srcformat) { case WARPLIB_FORMAT_2vuy: switch(gm->srcformat) { case WARPLIB_FORMAT_YUY2: geomesh_apply_bilinear_2vuy_yuy2(opaque, src, dest, row0, row1); break; case WARPLIB_FORMAT_2vuy: geomesh_apply_bilinear_2vuy(opaque, src, dest, row0, row1); break; default: return WARPLIB_ERROR_UNSUPPORTED_FORMAT; break; } break; case WARPLIB_FORMAT_YUY2: switch(gm->srcformat) { case WARPLIB_FORMAT_YUY2: geomesh_apply_bilinear_yuy2(opaque, src, dest, row0, row1); break; case WARPLIB_FORMAT_2vuy: //geomesh_apply_bilinear_yuy2_2vuy(opaque, src, dest, row0, row1); return WARPLIB_ERROR_UNSUPPORTED_FORMAT; break; default: return WARPLIB_ERROR_UNSUPPORTED_FORMAT; break; } break; case WARPLIB_FORMAT_422YpCbCr8: geomesh_apply_bilinear_422YpCbCr8(opaque, src, dest, row0, row1); break; case WARPLIB_FORMAT_32BGRA: geomesh_apply_bilinear_32BGRA(opaque, src, dest, row0, row1); break; case WARPLIB_FORMAT_64ARGB: geomesh_apply_bilinear_64ARGB(opaque, src, dest, row0, row1); break; case WARPLIB_FORMAT_RG48: geomesh_apply_bilinear_RG48(opaque, src, dest, row0, row1); break;; case WARPLIB_FORMAT_W13A: geomesh_apply_bilinear_W13A(opaque, src, dest, row0, row1); break; case WARPLIB_FORMAT_WP13: geomesh_apply_bilinear_WP13(opaque, src, dest, row0, row1); break; default: return WARPLIB_ERROR_UNSUPPORTED_FORMAT; break; } return WARPLIB_SUCCESS; } int geomesh_apply_bilinear_separable(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { return WARPLIB_SUCCESS; } // REVISIT: copied from below - WRONG IMPL int geomesh_apply_bilinear_yuy2(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { geomesh_t *gm = (geomesh_t *)opaque; unsigned char *destptr; int col0 = 0; int col1; int *iptr; int stride; int row, col; GEOMESH_CHECK(gm, GEOMESH_CHECK_OBJ_EXISTS | GEOMESH_CHECK_MESH_EXISTS | GEOMESH_CHECK_MESH_INITIALIZED | GEOMESH_CHECK_CACHE_EXISTS | GEOMESH_CHECK_CACHE_INITIALIZED); col1 = gm->destwidth; iptr = gm->cache + gm->destwidth * gm->num_elements_allocated * row0; stride = gm->srcstride; if (row1 >= gm->destheight) row1 = gm->destheight; for (row = row0; row < row1; row++) { destptr = dest + row * gm->deststride; if (row >= gm->destheight - 1) stride = 0; for (col = col0; col < col1; col++) { int yidx = *iptr++; int uvidx = *iptr++; int xlever = *iptr++; int ylever = *iptr++; int alpha = 0; unsigned char *yptr = src + yidx; unsigned char *uvptr = src + uvidx; unsigned char y00, y01, y10, y11; unsigned char uv00, uv10; int w00, w01, w10, w11; if(gm->backgroundfill) alpha = *iptr++; if (yidx < 0) { *destptr++ = 0; *destptr++ = 128; continue; } #ifdef USE_SSE m128i y, uv, w0, w1; m128i acc0, acc1, acc2; w0.idata[0] = (256 - xlever) * (256 - ylever); w0.idata[2] = (xlever) * (256 - ylever); w1.idata[0] = (256 - xlever) * (ylever); w1.idata[2] = (xlever) * (ylever); y.idata[0] = *yptr; y.idata[2] = *(yptr + stride); acc0.m128 = _mm_mul_epu32(y.m128, w0.m128); y.idata[0] = *(yptr + 2); y.idata[2] = *(yptr + stride + 2); acc1.m128 = _mm_mul_epu32(y.m128, w1.m128); acc2.m128 = _mm_add_epi64(acc0.m128, acc1.m128); *destptr++ = (unsigned char)((acc2.idata[0] + acc2.idata[2]) >> 16); uv.idata[0] = *uvptr; uv.idata[2] = *(uvptr + 4); acc0.m128 = _mm_mul_epu32(uv.m128, w0.m128); uv.idata[0] = *(uvptr + stride); uv.idata[2] = *(uvptr + stride + 4); acc1.m128 = _mm_mul_epu32(uv.m128, w1.m128); acc2.m128 = _mm_add_epi64(acc0.m128, acc1.m128); *destptr++ = (unsigned char)((acc2.idata[0] + acc2.idata[2]) >> 16); #else y00 = *yptr; y01 = *(yptr + 2); y10 = *(yptr + stride); y11 = *(yptr + stride + 2); // TODO: 4:2:2 UV horizontal bilinear interpolation uv00 = *uvptr; // uv01 = *(uvptr + 4); uv10 = *(uvptr + stride); // uv11 = *(uvptr + stride + 4); w00 = (256 - xlever) * (256 - ylever); w01 = (xlever) * (256 - ylever); w10 = (256 - xlever) * (ylever); w11 = (xlever) * (ylever); if(alpha > 0) { alpha *= 32; if(alpha > 200) alpha = 200; *destptr = ((unsigned int)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256-alpha) + *(destptr-2)*alpha + 128 )>>8; destptr++; *destptr = ((unsigned int)((uv00 * (256 - ylever) + uv10 * ylever) >> 8)*(256-alpha) + *(destptr-4)*alpha + 128)>>8; destptr++; } else { *destptr++ = (unsigned char)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16); *destptr++ = (unsigned char)((uv00 * (256 - ylever) + uv10 * ylever) >> 8); } #endif } } return WARPLIB_SUCCESS; } int geomesh_apply_bilinear_2vuy(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { geomesh_t *gm = (geomesh_t *)opaque; unsigned char *destptr; int col0 = 0; int col1; int *iptr; int stride; int row, col; GEOMESH_CHECK(gm, GEOMESH_CHECK_OBJ_EXISTS | GEOMESH_CHECK_MESH_EXISTS | GEOMESH_CHECK_MESH_INITIALIZED | GEOMESH_CHECK_CACHE_EXISTS | GEOMESH_CHECK_CACHE_INITIALIZED); col1 = gm->destwidth; iptr = gm->cache + gm->destwidth * gm->num_elements_allocated * row0; stride = gm->srcstride; if (row1 >= gm->destheight) row1 = gm->destheight; for (row = row0; row < row1; row++) { destptr = dest + row * gm->deststride; if (row >= gm->destheight - 1) stride = 0; for (col = col0; col < col1; col++) { int yidx = *iptr++; int uvidx = *iptr++; int xlever = *iptr++; int ylever = *iptr++; unsigned char *yptr = src + yidx; unsigned char *uvptr = src + uvidx; unsigned char y00, y01, y10, y11; unsigned char uv00, uv01, uv10, uv11; int w00, w01, w10, w11; if (yidx < 0) { *destptr++ = 128; *destptr++ = 0; continue; } y00 = *(yptr); y01 = *(yptr + 2); y10 = *(yptr + stride); y11 = *(yptr + stride + 2); uv00 = *(uvptr); uv01 = *(uvptr + 4); uv10 = *(uvptr + stride); uv11 = *(uvptr + stride + 4); w00 = (256 - xlever) * (256 - ylever); w01 = (xlever) * (256 - ylever); w10 = (256 - xlever) * (ylever); w11 = (xlever) * (ylever); *destptr++ = (unsigned char)((uv00 * w00 + uv01 * w01 + uv10 * w10 + uv11 * w11) >> 16); *destptr++ = (unsigned char)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16); } } return WARPLIB_SUCCESS; } int geomesh_apply_bilinear_2vuy_yuy2(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { geomesh_t *gm = (geomesh_t *)opaque; unsigned char *destptr; int col0 = 0; int col1; int *iptr; int stride; int row, col; GEOMESH_CHECK(gm, GEOMESH_CHECK_OBJ_EXISTS | GEOMESH_CHECK_MESH_EXISTS | GEOMESH_CHECK_MESH_INITIALIZED | GEOMESH_CHECK_CACHE_EXISTS | GEOMESH_CHECK_CACHE_INITIALIZED); col1 = gm->destwidth; iptr = gm->cache + gm->destwidth * gm->num_elements_allocated * row0; stride = gm->srcstride; if (row1 >= gm->destheight) row1 = gm->destheight; for (row = row0; row < row1; row++) { destptr = dest + row * gm->deststride; if (row >= gm->destheight - 1) stride = 0; for (col = col0; col < col1; col++) { int yidx = *iptr++; int uvidx = *iptr++; int xlever = *iptr++; int ylever = *iptr++; unsigned char *yptr = src + yidx; unsigned char *uvptr = src + uvidx; unsigned char y00, y01, y10, y11; unsigned char uv00, uv01, uv10, uv11; int w00, w01, w10, w11; if (yidx < 0) { *destptr++ = 0; *destptr++ = 128; continue; } y00 = *(yptr); y01 = *(yptr + 2); y10 = *(yptr + stride); y11 = *(yptr + stride + 2); uv00 = *uvptr; uv01 = *(uvptr + 4); uv10 = *(uvptr + stride); uv11 = *(uvptr + stride + 4); w00 = (256 - xlever) * (256 - ylever); w01 = (xlever) * (256 - ylever); w10 = (256 - xlever) * (ylever); w11 = (xlever) * (ylever); *destptr++ = (unsigned char)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16); *destptr++ = (unsigned char)((uv00 * w00 + uv01 * w01 + uv10 * w10 + uv11 * w11) >> 16); } } return WARPLIB_SUCCESS; } int geomesh_apply_bilinear_422YpCbCr8(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { //geomesh_t *gm = (geomesh_t *)opaque; GEOMESH_CHECK(gm, GEOMESH_CHECK_OBJ_EXISTS | GEOMESH_CHECK_MESH_EXISTS | GEOMESH_CHECK_MESH_INITIALIZED | GEOMESH_CHECK_CACHE_EXISTS | GEOMESH_CHECK_CACHE_INITIALIZED); return WARPLIB_SUCCESS; } int geomesh_apply_bilinear_32BGRA(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { geomesh_t *gm = (geomesh_t *)opaque; int col0 = 0; int col1; int *iptr; int stride; int row, col; GEOMESH_CHECK(gm, GEOMESH_CHECK_OBJ_EXISTS | GEOMESH_CHECK_MESH_EXISTS | GEOMESH_CHECK_MESH_INITIALIZED | GEOMESH_CHECK_CACHE_EXISTS | GEOMESH_CHECK_CACHE_INITIALIZED); col1 = gm->destwidth; iptr = gm->cache + gm->destwidth * gm->num_elements_allocated * row0; stride = gm->srcstride; if (row1 >= gm->destheight) row1 = gm->destheight; for (row = row0; row < row1; row++) { unsigned char *oT = dest + row * gm->deststride; if (row >= gm->destheight - 1) stride = 0; for (col = col0; col < col1; col++) { int yidx = *iptr++; int xlever = *iptr++; int ylever = *iptr++; int alpha = 0; unsigned char *iT = src + yidx; unsigned char y00, y01, y10, y11; int w00, w01, w10, w11; if(gm->backgroundfill) alpha = *iptr++; if (yidx < 0) { *oT++ = 0; *oT++ = 0; *oT++ = 0; *oT++ = 255; continue; } if(ylever == 0) { w00 = (256 - xlever); w01 = (xlever); if(alpha > 0 && col) { alpha *= 32; if(alpha > 200) alpha = 200; y00 = *(iT); y01 = *(iT + 4); *oT = ((unsigned char)((y00 * w00 + y01 * w01) >> 8)*(256-alpha) + *(oT-4)*alpha + 128 )>>8; oT++; iT++; y00 = *(iT); y01 = *(iT + 4); *oT = ((unsigned char)((y00 * w00 + y01 * w01) >> 8)*(256-alpha) + *(oT-4)*alpha + 128 )>>8; oT++; iT++; y00 = *(iT); y01 = *(iT + 4); *oT = ((unsigned char)((y00 * w00 + y01 * w01) >> 8)*(256-alpha) + *(oT-4)*alpha + 128 )>>8; oT++; iT++; y00 = *(iT); y01 = *(iT + 4); *oT = ((unsigned char)((y00 * w00 + y01 * w01) >> 8)*(256-alpha) + *(oT-4)*alpha + 128 )>>8; oT++; } else { y00 = *(iT); y01 = *(iT + 4); *oT++ = (unsigned char)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + 4); *oT++ = (unsigned char)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + 4); *oT++ = (unsigned char)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + 4); *oT++ = (unsigned char)((y00 * w00 + y01 * w01) >> 8); } } else { w00 = (256 - xlever) * (256 - ylever); w01 = (xlever) * (256 - ylever); w10 = (256 - xlever) * (ylever); w11 = (xlever) * (ylever); if (alpha == 0 || col == 0) { oT[0] = (unsigned char)((iT[0] * w00 + iT[4] * w01 + iT[stride + 0] * w10 + iT[stride + 4] * w11) >> 16); oT[1] = (unsigned char)((iT[1] * w00 + iT[5] * w01 + iT[stride + 1] * w10 + iT[stride + 5] * w11) >> 16); oT[2] = (unsigned char)((iT[2] * w00 + iT[6] * w01 + iT[stride + 2] * w10 + iT[stride + 6] * w11) >> 16); oT[3] = (unsigned char)((iT[3] * w00 + iT[7] * w01 + iT[stride + 3] * w10 + iT[stride + 7] * w11) >> 16); oT += 4; iT += 4; } else { alpha *= 32; if(alpha > 200) alpha = 200; y00 = *(iT); y01 = *(iT + 4); y10 = *(iT + stride); y11 = *(iT + stride + 4); oT[0] = ((unsigned char)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - 4)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + 4); y10 = *(iT + stride); y11 = *(iT + stride + 4); oT[1] = ((unsigned char)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - 4)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + 4); y10 = *(iT + stride); y11 = *(iT + stride + 4); oT[2] = ((unsigned char)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - 4)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + 4); y10 = *(iT + stride); y11 = *(iT + stride + 4); oT[3] = ((unsigned char)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - 4)*alpha + 128) >> 8; oT += 4; } } } } return WARPLIB_SUCCESS; } int geomesh_apply_bilinear_64ARGB(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { geomesh_t *gm = (geomesh_t *)opaque; int col0 = 0; int col1; int nxtln; int *iptr; int row, col; const int nxtpix = 4; GEOMESH_CHECK(gm, GEOMESH_CHECK_OBJ_EXISTS | GEOMESH_CHECK_MESH_EXISTS | GEOMESH_CHECK_MESH_INITIALIZED | GEOMESH_CHECK_CACHE_EXISTS | GEOMESH_CHECK_CACHE_INITIALIZED); col1 = gm->destwidth; iptr = gm->cache + gm->destwidth * gm->num_elements_allocated * row0; nxtln = gm->srcstride >> 1; if (row1 >= gm->destheight) row1 = gm->destheight; for (row = row0; row < row1; row++) { unsigned char *oTchar = dest + row * gm->deststride; unsigned short *oT = (unsigned short *)oTchar; if (row >= gm->destheight - 1) nxtln = 0; for (col = col0; col < col1; col++) { int yidx = *iptr++; int xlever = *iptr++; int ylever = *iptr++; int alpha = 0; unsigned char *iTchar = src + yidx; unsigned short *iT = (unsigned short *)iTchar; unsigned short y00, y01, y10, y11; int w00, w01, w10, w11; if (gm->backgroundfill) alpha = *iptr++; if (yidx < 0) { *oT++ = 0; *oT++ = 0; *oT++ = 0; *oT++ = 65535; continue; } if (ylever == 0) { w00 = (256 - xlever); w01 = (xlever); if (alpha > 0 && col) { alpha *= 32; if (alpha > 200) alpha = 200; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((unsigned short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((unsigned short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((unsigned short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((unsigned short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; } else { y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (unsigned short)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (unsigned short)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (unsigned short)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (unsigned short)((y00 * w00 + y01 * w01) >> 8); } } else { w00 = (256 - xlever) * (256 - ylever); w01 = (xlever)* (256 - ylever); w10 = (256 - xlever) * (ylever); w11 = (xlever)* (ylever); if (alpha == 0 || col == 0) { oT[0] = (unsigned short)((iT[0] * w00 + iT[nxtpix + 0] * w01 + iT[nxtln + 0] * w10 + iT[nxtln + nxtpix + 0] * w11) >> 16); oT[1] = (unsigned short)((iT[1] * w00 + iT[nxtpix + 1] * w01 + iT[nxtln + 1] * w10 + iT[nxtln + nxtpix + 1] * w11) >> 16); oT[2] = (unsigned short)((iT[2] * w00 + iT[nxtpix + 2] * w01 + iT[nxtln + 2] * w10 + iT[nxtln + nxtpix + 2] * w11) >> 16); oT[3] = (unsigned short)((iT[3] * w00 + iT[nxtpix + 3] * w01 + iT[nxtln + 3] * w10 + iT[nxtln + nxtpix + 3] * w11) >> 16); oT += nxtpix; iT += nxtpix; } else { alpha *= 32; if (alpha > 200) alpha = 200; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[0] = ((unsigned short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[1] = ((unsigned short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[2] = ((unsigned short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[3] = ((unsigned short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT += nxtpix; } } } } return WARPLIB_SUCCESS; } int geomesh_apply_bilinear_RG48(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { geomesh_t *gm = (geomesh_t *)opaque; int col0 = 0; int col1; int nxtln; int *iptr; int row, col; const int nxtpix = 3; GEOMESH_CHECK(gm, GEOMESH_CHECK_OBJ_EXISTS | GEOMESH_CHECK_MESH_EXISTS | GEOMESH_CHECK_MESH_INITIALIZED | GEOMESH_CHECK_CACHE_EXISTS | GEOMESH_CHECK_CACHE_INITIALIZED); col1 = gm->destwidth; iptr = gm->cache + gm->destwidth * gm->num_elements_allocated * row0; nxtln = gm->srcstride>>1; if (row1 >= gm->destheight) row1 = gm->destheight; for (row = row0; row < row1; row++) { unsigned char *oTchar = dest + row * gm->deststride; unsigned short *oT = (unsigned short *)oTchar; if (row >= gm->destheight - 1) nxtln = 0; for (col = col0; col < col1; col++) { int yidx = *iptr++; int xlever = *iptr++; int ylever = *iptr++; int alpha = 0; unsigned char *iTchar = src + yidx; unsigned short *iT = (unsigned short *)iTchar; unsigned short y00, y01, y10, y11; int w00, w01, w10, w11; if (gm->backgroundfill) alpha = *iptr++; if (yidx < 0) { *oT++ = 0; *oT++ = 0; *oT++ = 0; continue; } if (ylever == 0) { w00 = (256 - xlever); w01 = (xlever); if (alpha > 0 && col) { alpha *= 32; if (alpha > 200) alpha = 200; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((unsigned short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((unsigned short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((unsigned short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; } else { y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (unsigned short)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (unsigned short)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (unsigned short)((y00 * w00 + y01 * w01) >> 8); } } else { w00 = (256 - xlever) * (256 - ylever); w01 = (xlever)* (256 - ylever); w10 = (256 - xlever) * (ylever); w11 = (xlever)* (ylever); if (alpha == 0 || col == 0) { oT[0] = (unsigned short)((iT[0] * w00 + iT[nxtpix + 0] * w01 + iT[nxtln + 0] * w10 + iT[nxtln + nxtpix + 0] * w11) >> 16); oT[1] = (unsigned short)((iT[1] * w00 + iT[nxtpix + 1] * w01 + iT[nxtln + 1] * w10 + iT[nxtln + nxtpix + 1] * w11) >> 16); oT[2] = (unsigned short)((iT[2] * w00 + iT[nxtpix + 2] * w01 + iT[nxtln + 2] * w10 + iT[nxtln + nxtpix + 2] * w11) >> 16); oT += nxtpix; iT += nxtpix; } else { alpha *= 32; if (alpha > 200) alpha = 200; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[0] = ((unsigned short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[1] = ((unsigned short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[2] = ((unsigned short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT += nxtpix; } } } } return WARPLIB_SUCCESS; } int geomesh_apply_bilinear_W13A(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { geomesh_t *gm = (geomesh_t *)opaque; int col0 = 0; int col1; int nxtln; int *iptr; int row, col; const int nxtpix = 4; GEOMESH_CHECK(gm, GEOMESH_CHECK_OBJ_EXISTS | GEOMESH_CHECK_MESH_EXISTS | GEOMESH_CHECK_MESH_INITIALIZED | GEOMESH_CHECK_CACHE_EXISTS | GEOMESH_CHECK_CACHE_INITIALIZED); col1 = gm->destwidth; iptr = gm->cache + gm->destwidth * gm->num_elements_allocated * row0; nxtln = gm->srcstride >> 1; if (row1 >= gm->destheight) row1 = gm->destheight; for (row = row0; row < row1; row++) { unsigned char *oTchar = dest + row * gm->deststride; short *oT = (short *)oTchar; if (row >= gm->destheight - 1) nxtln = 0; for (col = col0; col < col1; col++) { int yidx = *iptr++; int xlever = *iptr++; int ylever = *iptr++; int alpha = 0; unsigned char *iTchar = src + yidx; short *iT = (short *)iTchar; short y00, y01, y10, y11; int w00, w01, w10, w11; if (gm->backgroundfill) alpha = *iptr++; if (yidx < 0) { *oT++ = 0; *oT++ = 0; *oT++ = 0; *oT++ = 8191; continue; } if (ylever == 0) { w00 = (256 - xlever); w01 = (xlever); if (alpha > 0 && col) { alpha *= 32; if (alpha > 200) alpha = 200; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; } else { y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (short)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (short)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (short)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (short)((y00 * w00 + y01 * w01) >> 8); } } else { w00 = (256 - xlever) * (256 - ylever); w01 = (xlever)* (256 - ylever); w10 = (256 - xlever) * (ylever); w11 = (xlever)* (ylever); if (alpha == 0 || col == 0) { oT[0] = (short)((iT[0] * w00 + iT[nxtpix + 0] * w01 + iT[nxtln + 0] * w10 + iT[nxtln + nxtpix + 0] * w11) >> 16); oT[1] = (short)((iT[1] * w00 + iT[nxtpix + 1] * w01 + iT[nxtln + 1] * w10 + iT[nxtln + nxtpix + 1] * w11) >> 16); oT[2] = (short)((iT[2] * w00 + iT[nxtpix + 2] * w01 + iT[nxtln + 2] * w10 + iT[nxtln + nxtpix + 2] * w11) >> 16); oT[3] = (short)((iT[3] * w00 + iT[nxtpix + 3] * w01 + iT[nxtln + 3] * w10 + iT[nxtln + nxtpix + 3] * w11) >> 16); oT += nxtpix; iT += nxtpix; } else { alpha *= 32; if (alpha > 200) alpha = 200; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[0] = ((short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[1] = ((short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[2] = ((short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[3] = ((short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT += nxtpix; } } } } return WARPLIB_SUCCESS; } int geomesh_apply_bilinear_WP13(void *opaque, unsigned char *src, unsigned char *dest, int row0, int row1) { geomesh_t *gm = (geomesh_t *)opaque; int col0 = 0; int col1; int nxtln; int *iptr; int row, col; const int nxtpix = 3; GEOMESH_CHECK(gm, GEOMESH_CHECK_OBJ_EXISTS | GEOMESH_CHECK_MESH_EXISTS | GEOMESH_CHECK_MESH_INITIALIZED | GEOMESH_CHECK_CACHE_EXISTS | GEOMESH_CHECK_CACHE_INITIALIZED); col1 = gm->destwidth; iptr = gm->cache + gm->destwidth * gm->num_elements_allocated * row0; nxtln = gm->srcstride >> 1; if (row1 >= gm->destheight) row1 = gm->destheight; for (row = row0; row < row1; row++) { unsigned char *oTchar = dest + row * gm->deststride; short *oT = (short *)oTchar; if (row >= gm->destheight - 1) nxtln = 0; for (col = col0; col < col1; col++) { int yidx = *iptr++; int xlever = *iptr++; int ylever = *iptr++; int alpha = 0; unsigned char *iTchar = src + yidx; short *iT = (short *)iTchar; short y00, y01, y10, y11; int w00, w01, w10, w11; if (gm->backgroundfill) alpha = *iptr++; if (yidx < 0) { *oT++ = 0; *oT++ = 0; *oT++ = 0; continue; } if (ylever == 0) { w00 = (256 - xlever); w01 = (xlever); if (alpha > 0 && col) { alpha *= 32; if (alpha > 200) alpha = 200; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT = ((short)((y00 * w00 + y01 * w01) >> 8)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT++; } else { y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (short)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (short)((y00 * w00 + y01 * w01) >> 8); iT++; y00 = *(iT); y01 = *(iT + nxtpix); *oT++ = (short)((y00 * w00 + y01 * w01) >> 8); } } else { w00 = (256 - xlever) * (256 - ylever); w01 = (xlever)* (256 - ylever); w10 = (256 - xlever) * (ylever); w11 = (xlever)* (ylever); if (alpha == 0 || col == 0) { oT[0] = (short)((iT[0] * w00 + iT[nxtpix + 0] * w01 + iT[nxtln + 0] * w10 + iT[nxtln + nxtpix + 0] * w11)>> 16); oT[1] = (short)((iT[1] * w00 + iT[nxtpix + 1] * w01 + iT[nxtln + 1] * w10 + iT[nxtln + nxtpix + 1] * w11) >> 16); oT[2] = (short)((iT[2] * w00 + iT[nxtpix + 2] * w01 + iT[nxtln + 2] * w10 + iT[nxtln + nxtpix + 2] * w11) >> 16); oT += nxtpix; iT += nxtpix; } else { alpha *= 32; if (alpha > 200) alpha = 200; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[0] = ((short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[1] = ((short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; iT++; y00 = *(iT); y01 = *(iT + nxtpix); y10 = *(iT + nxtln); y11 = *(iT + nxtln + nxtpix); oT[2] = ((short)((y00 * w00 + y01 * w01 + y10 * w10 + y11 * w11) >> 16)*(256 - alpha) + *(oT - nxtpix)*alpha + 128) >> 8; oT += nxtpix; } } } } return WARPLIB_SUCCESS; }
039e023af10e52707567ce9d5d9307a3c1e82bd0
9467e2502183e843a67736800199e31674b1d8f6
/HybridCLRData/LocalIl2CppData-OSXEditor/il2cpp/external/mono/mono/metadata/w32file-win32.c
f428031a7a3746f9e26c34bb1179560c67cf513f
[ "Apache-2.0" ]
permissive
yimengfan/BDFramework.Core
3a046fcd755a84ba55d648dd3ad52c37a1cc1a04
81380fce8e84367f912777717665b53f074ab617
refs/heads/master
2023-09-04T10:08:47.644992
2023-07-05T16:22:11
2023-07-05T16:22:11
85,928,537
2,421
497
Apache-2.0
2023-03-21T06:56:21
2017-03-23T09:03:48
C#
UTF-8
C
false
false
12,789
c
w32file-win32.c
/** * \file * Windows File IO internal calls. * * Copyright 2016 Microsoft * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #include <config.h> #include <glib.h> #include <winsock2.h> #include <windows.h> #include "mono/metadata/w32file-win32-internals.h" #include "mono/metadata/profiler-private.h" #include "mono/metadata/w32error.h" void mono_w32file_init (void) { } void mono_w32file_cleanup (void) { } gunichar2 ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar () { return (gunichar2) ':'; /* colon */ } gunichar2 ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar () { return (gunichar2) '\\'; /* backslash */ } gunichar2 ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar () { return (gunichar2) '/'; /* forward slash */ } gunichar2 ves_icall_System_IO_MonoIO_get_PathSeparator () { return (gunichar2) ';'; /* semicolon */ } void ves_icall_System_IO_MonoIO_DumpHandles (void) { return; } gpointer mono_w32file_create(const gunichar2 *name, guint32 fileaccess, guint32 sharemode, guint32 createmode, guint32 attrs) { gpointer res; MONO_ENTER_GC_SAFE; res = CreateFile (name, fileaccess, sharemode, NULL, createmode, attrs, NULL); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_close (gpointer handle) { gboolean res; MONO_ENTER_GC_SAFE; res = CloseHandle (handle); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_delete (const gunichar2 *name) { gboolean res; MONO_ENTER_GC_SAFE; res = DeleteFile (name); MONO_EXIT_GC_SAFE; return res; } static void cancel_w32_io (HANDLE file_handle) { CancelIoEx (file_handle, NULL); } gboolean mono_w32file_read (gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread) { gboolean res = FALSE; gboolean interrupted; mono_thread_info_install_interrupt (cancel_w32_io, handle, &interrupted); if (!interrupted) { guint32 last_error; MONO_ENTER_GC_SAFE; res = ReadFile (handle, buffer, numbytes, bytesread, NULL); MONO_PROFILER_RAISE (fileio, (1, *bytesread)); MONO_EXIT_GC_SAFE; /* need to save and restore since clients expect error code set for * failed IO calls and mono_thread_info_uninstall_interrupt overwrites value */ last_error = mono_w32error_get_last (); mono_thread_info_uninstall_interrupt (&interrupted); mono_w32error_set_last (last_error); } return res; } gboolean mono_w32file_write (gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten) { gboolean res = FALSE; gboolean interrupted; mono_thread_info_install_interrupt (cancel_w32_io, handle, &interrupted); if (!interrupted) { guint32 last_error; MONO_ENTER_GC_SAFE; res = WriteFile (handle, buffer, numbytes, byteswritten, NULL); MONO_PROFILER_RAISE (fileio, (0, *byteswritten)); MONO_EXIT_GC_SAFE; /* need to save and restore since clients expect error code set for * failed IO calls and mono_thread_info_uninstall_interrupt overwrites value */ last_error = mono_w32error_get_last (); mono_thread_info_uninstall_interrupt (&interrupted); mono_w32error_set_last (last_error); } return res; } gboolean mono_w32file_flush (gpointer handle) { gboolean res; MONO_ENTER_GC_SAFE; res = FlushFileBuffers (handle); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_truncate (gpointer handle) { gboolean res; MONO_ENTER_GC_SAFE; res = SetEndOfFile (handle); MONO_EXIT_GC_SAFE; return res; } guint32 mono_w32file_seek (gpointer handle, gint32 movedistance, gint32 *highmovedistance, guint32 method) { guint32 res; MONO_ENTER_GC_SAFE; res = SetFilePointer (handle, movedistance, highmovedistance, method); MONO_EXIT_GC_SAFE; return res; } gint mono_w32file_get_type (gpointer handle) { gint res; MONO_ENTER_GC_SAFE; res = GetFileType (handle); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_get_times (gpointer handle, FILETIME *create_time, FILETIME *access_time, FILETIME *write_time) { gboolean res; MONO_ENTER_GC_SAFE; res = GetFileTime (handle, create_time, access_time, write_time); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_set_times (gpointer handle, const FILETIME *create_time, const FILETIME *access_time, const FILETIME *write_time) { gboolean res; MONO_ENTER_GC_SAFE; res = SetFileTime (handle, create_time, access_time, write_time); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_filetime_to_systemtime (const FILETIME *file_time, SYSTEMTIME *system_time) { gboolean res; MONO_ENTER_GC_SAFE; res = FileTimeToSystemTime (file_time, system_time); MONO_EXIT_GC_SAFE; return res; } gpointer mono_w32file_find_first (const gunichar2 *pattern, WIN32_FIND_DATA *find_data) { gpointer res; MONO_ENTER_GC_SAFE; res = FindFirstFile (pattern, find_data); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_find_next (gpointer handle, WIN32_FIND_DATA *find_data) { gboolean res; MONO_ENTER_GC_SAFE; res = FindNextFile (handle, find_data); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_find_close (gpointer handle) { gboolean res; MONO_ENTER_GC_SAFE; res = FindClose (handle); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_create_directory (const gunichar2 *name) { gboolean res; MONO_ENTER_GC_SAFE; res = CreateDirectory (name, NULL); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_remove_directory (const gunichar2 *name) { gboolean res; MONO_ENTER_GC_SAFE; res = RemoveDirectory (name); MONO_EXIT_GC_SAFE; return res; } /* * GetFileAttributes|Ex () seems to try opening the file, which might lead to sharing violation errors, whereas * FindFirstFile always succeeds. */ guint32 mono_w32file_get_attributes (const gunichar2 *name) { guint32 res; guint32 error; HANDLE find_handle; WIN32_FIND_DATA find_data; MONO_ENTER_GC_SAFE; res = GetFileAttributes (name); MONO_EXIT_GC_SAFE; if (res != INVALID_FILE_ATTRIBUTES) return res; error = GetLastError (); if (error != ERROR_SHARING_VIOLATION) return INVALID_FILE_ATTRIBUTES; MONO_ENTER_GC_SAFE; find_handle = FindFirstFile (name, &find_data); MONO_EXIT_GC_SAFE; if (find_handle == INVALID_HANDLE_VALUE) return INVALID_FILE_ATTRIBUTES; MONO_ENTER_GC_SAFE; FindClose (find_handle); MONO_EXIT_GC_SAFE; return find_data.dwFileAttributes; } static gint64 convert_filetime (const FILETIME *filetime) { return (gint64) ((((guint64) filetime->dwHighDateTime) << 32) + filetime->dwLowDateTime); } gboolean mono_w32file_get_attributes_ex (const gunichar2 *name, MonoIOStat *stat) { gboolean res; guint32 error; HANDLE find_handle; WIN32_FIND_DATA find_data; WIN32_FILE_ATTRIBUTE_DATA file_attribute_data; MONO_ENTER_GC_SAFE; res = GetFileAttributesEx (name, GetFileExInfoStandard, &file_attribute_data); MONO_EXIT_GC_SAFE; if (res) { stat->attributes = file_attribute_data.dwFileAttributes; stat->creation_time = convert_filetime (&file_attribute_data.ftCreationTime); stat->last_access_time = convert_filetime (&file_attribute_data.ftLastAccessTime); stat->last_write_time = convert_filetime (&file_attribute_data.ftLastWriteTime); stat->length = ((gint64)file_attribute_data.nFileSizeHigh << 32) | file_attribute_data.nFileSizeLow; return TRUE; } error = GetLastError (); if (error != ERROR_SHARING_VIOLATION) return FALSE; MONO_ENTER_GC_SAFE; find_handle = FindFirstFile (name, &find_data); MONO_EXIT_GC_SAFE; if (find_handle == INVALID_HANDLE_VALUE) return FALSE; MONO_ENTER_GC_SAFE; FindClose (find_handle); MONO_EXIT_GC_SAFE; stat->attributes = find_data.dwFileAttributes; stat->creation_time = convert_filetime (&find_data.ftCreationTime); stat->last_access_time = convert_filetime (&find_data.ftLastAccessTime); stat->last_write_time = convert_filetime (&find_data.ftLastWriteTime); stat->length = ((gint64)find_data.nFileSizeHigh << 32) | find_data.nFileSizeLow; return TRUE; } gboolean mono_w32file_set_attributes (const gunichar2 *name, guint32 attrs) { gboolean res; MONO_ENTER_GC_SAFE; res = SetFileAttributes (name, attrs); MONO_EXIT_GC_SAFE; return res; } guint32 mono_w32file_get_cwd (guint32 length, gunichar2 *buffer) { guint32 res; MONO_ENTER_GC_SAFE; res = GetCurrentDirectory (length, buffer); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_set_cwd (const gunichar2 *path) { gboolean res; MONO_ENTER_GC_SAFE; res = SetCurrentDirectory (path); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_create_pipe (gpointer *readpipe, gpointer *writepipe, guint32 size) { gboolean res; SECURITY_ATTRIBUTES attr; attr.nLength = sizeof(SECURITY_ATTRIBUTES); attr.bInheritHandle = TRUE; attr.lpSecurityDescriptor = NULL; MONO_ENTER_GC_SAFE; res = CreatePipe (readpipe, writepipe, &attr, size); MONO_EXIT_GC_SAFE; return res; } gboolean mono_w32file_get_disk_free_space (const gunichar2 *path_name, guint64 *free_bytes_avail, guint64 *total_number_of_bytes, guint64 *total_number_of_free_bytes) { gboolean result; ULARGE_INTEGER wapi_free_bytes_avail; ULARGE_INTEGER wapi_total_number_of_bytes; ULARGE_INTEGER wapi_total_number_of_free_bytes; MONO_ENTER_GC_SAFE; result = GetDiskFreeSpaceEx (path_name, &wapi_free_bytes_avail, &wapi_total_number_of_bytes, &wapi_total_number_of_free_bytes); MONO_EXIT_GC_SAFE; if (result) { if (free_bytes_avail) *free_bytes_avail = wapi_free_bytes_avail.QuadPart; if (total_number_of_bytes) *total_number_of_bytes = wapi_total_number_of_bytes.QuadPart; if (total_number_of_free_bytes) *total_number_of_free_bytes = wapi_total_number_of_free_bytes.QuadPart; } return result; } gboolean mono_w32file_get_volume_information (const gunichar2 *path, gunichar2 *volumename, gint volumesize, gint *outserial, gint *maxcomp, gint *fsflags, gunichar2 *fsbuffer, gint fsbuffersize) { gboolean res; MONO_ENTER_GC_SAFE; res = GetVolumeInformation (path, volumename, volumesize, outserial, maxcomp, fsflags, fsbuffer, fsbuffersize); MONO_EXIT_GC_SAFE; return res; } #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) gboolean mono_w32file_move (const gunichar2 *path, const gunichar2 *dest, gint32 *error) { gboolean result; MONO_ENTER_GC_SAFE; result = MoveFile (path, dest); if (!result) *error = GetLastError (); MONO_EXIT_GC_SAFE; return result; } gboolean mono_w32file_replace (const gunichar2 *destinationFileName, const gunichar2 *sourceFileName, const gunichar2 *destinationBackupFileName, guint32 flags, gint32 *error) { gboolean result; MONO_ENTER_GC_SAFE; result = ReplaceFile (destinationFileName, sourceFileName, destinationBackupFileName, flags, NULL, NULL); if (!result) *error = GetLastError (); MONO_EXIT_GC_SAFE; return result; } gboolean mono_w32file_copy (const gunichar2 *path, const gunichar2 *dest, gboolean overwrite, gint32 *error) { gboolean result; MONO_ENTER_GC_SAFE; result = CopyFile (path, dest, !overwrite); if (!result) *error = GetLastError (); MONO_EXIT_GC_SAFE; return result; } gboolean mono_w32file_lock (gpointer handle, gint64 position, gint64 length, gint32 *error) { gboolean result; MONO_ENTER_GC_SAFE; result = LockFile (handle, position & 0xFFFFFFFF, position >> 32, length & 0xFFFFFFFF, length >> 32); if (!result) *error = GetLastError (); MONO_EXIT_GC_SAFE; return result; } gboolean mono_w32file_unlock (gpointer handle, gint64 position, gint64 length, gint32 *error) { gboolean result; MONO_ENTER_GC_SAFE; result = UnlockFile (handle, position & 0xFFFFFFFF, position >> 32, length & 0xFFFFFFFF, length >> 32); if (!result) *error = GetLastError (); MONO_EXIT_GC_SAFE; return result; } HANDLE mono_w32file_get_console_input (void) { HANDLE res; MONO_ENTER_GC_SAFE; res = GetStdHandle (STD_INPUT_HANDLE); MONO_EXIT_GC_SAFE; return res; } HANDLE mono_w32file_get_console_output (void) { HANDLE res; MONO_ENTER_GC_SAFE; res = GetStdHandle (STD_OUTPUT_HANDLE); MONO_EXIT_GC_SAFE; return res; } HANDLE mono_w32file_get_console_error (void) { HANDLE res; MONO_ENTER_GC_SAFE; res = GetStdHandle (STD_ERROR_HANDLE); MONO_EXIT_GC_SAFE; return res; } gint64 mono_w32file_get_file_size (gpointer handle, gint32 *error) { gint64 length; guint32 length_hi; MONO_ENTER_GC_SAFE; length = GetFileSize (handle, &length_hi); if(length==INVALID_FILE_SIZE) { *error=GetLastError (); } MONO_EXIT_GC_SAFE; return length | ((gint64)length_hi << 32); } guint32 mono_w32file_get_drive_type (const gunichar2 *root_path_name) { guint32 res; MONO_ENTER_GC_SAFE; res = GetDriveType (root_path_name); MONO_EXIT_GC_SAFE; return res; } gint32 mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf) { gint32 res; MONO_ENTER_GC_SAFE; res = GetLogicalDriveStrings (len, buf); MONO_EXIT_GC_SAFE; return res; } #endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
7801f054dfff807b22527c9cf33d52486c3e3a31
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/gpu/drm/drm_mm.c
07cf99cc886283aedf9feee690d71ee6fbe2fb77
[ "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
21,150
c
drm_mm.c
/************************************************************************** * * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA. * All Rights Reserved. * * 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, sub license, 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 (including the * next paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. * * **************************************************************************/ /* * Generic simple memory manager implementation. Intended to be used as a base * class implementation for more advanced memory managers. * * Note that the algorithm used is quite simple and there might be substantial * performance gains if a smarter free list is implemented. Currently it is just an * unordered stack of free regions. This could easily be improved if an RB-tree * is used instead. At least if we expect heavy fragmentation. * * Aligned allocations can also see improvement. * * Authors: * Thomas Hellström <thomas-at-tungstengraphics-dot-com> */ #include <drm/drmP.h> #include <drm/drm_mm.h> #include <linux/slab.h> #include <linux/seq_file.h> #include <linux/export.h> #define MM_UNUSED_TARGET 4 static struct drm_mm_node *drm_mm_kmalloc(struct drm_mm *mm, int atomic) { struct drm_mm_node *child; if (atomic) child = kzalloc(sizeof(*child), GFP_ATOMIC); else child = kzalloc(sizeof(*child), GFP_KERNEL); if (unlikely(child == NULL)) { spin_lock(&mm->unused_lock); if (list_empty(&mm->unused_nodes)) child = NULL; else { child = list_entry(mm->unused_nodes.next, struct drm_mm_node, node_list); list_del(&child->node_list); --mm->num_unused; } spin_unlock(&mm->unused_lock); } return child; } /* drm_mm_pre_get() - pre allocate drm_mm_node structure * drm_mm: memory manager struct we are pre-allocating for * * Returns 0 on success or -ENOMEM if allocation fails. */ int drm_mm_pre_get(struct drm_mm *mm) { struct drm_mm_node *node; spin_lock(&mm->unused_lock); while (mm->num_unused < MM_UNUSED_TARGET) { spin_unlock(&mm->unused_lock); node = kzalloc(sizeof(*node), GFP_KERNEL); spin_lock(&mm->unused_lock); if (unlikely(node == NULL)) { int ret = (mm->num_unused < 2) ? -ENOMEM : 0; spin_unlock(&mm->unused_lock); return ret; } ++mm->num_unused; list_add_tail(&node->node_list, &mm->unused_nodes); } spin_unlock(&mm->unused_lock); return 0; } EXPORT_SYMBOL(drm_mm_pre_get); static void drm_mm_insert_helper(struct drm_mm_node *hole_node, struct drm_mm_node *node, unsigned long size, unsigned alignment, unsigned long color) { struct drm_mm *mm = hole_node->mm; unsigned long hole_start = drm_mm_hole_node_start(hole_node); unsigned long hole_end = drm_mm_hole_node_end(hole_node); unsigned long adj_start = hole_start; unsigned long adj_end = hole_end; BUG_ON(node->allocated); if (mm->color_adjust) mm->color_adjust(hole_node, color, &adj_start, &adj_end); if (alignment) { unsigned tmp = adj_start % alignment; if (tmp) adj_start += alignment - tmp; } if (adj_start == hole_start) { hole_node->hole_follows = 0; list_del(&hole_node->hole_stack); } node->start = adj_start; node->size = size; node->mm = mm; node->color = color; node->allocated = 1; INIT_LIST_HEAD(&node->hole_stack); list_add(&node->node_list, &hole_node->node_list); BUG_ON(node->start + node->size > adj_end); node->hole_follows = 0; if (__drm_mm_hole_node_start(node) < hole_end) { list_add(&node->hole_stack, &mm->hole_stack); node->hole_follows = 1; } } struct drm_mm_node *drm_mm_create_block(struct drm_mm *mm, unsigned long start, unsigned long size, bool atomic) { struct drm_mm_node *hole, *node; unsigned long end = start + size; unsigned long hole_start; unsigned long hole_end; drm_mm_for_each_hole(hole, mm, hole_start, hole_end) { if (hole_start > start || hole_end < end) continue; node = drm_mm_kmalloc(mm, atomic); if (unlikely(node == NULL)) return NULL; node->start = start; node->size = size; node->mm = mm; node->allocated = 1; INIT_LIST_HEAD(&node->hole_stack); list_add(&node->node_list, &hole->node_list); if (start == hole_start) { hole->hole_follows = 0; list_del_init(&hole->hole_stack); } node->hole_follows = 0; if (end != hole_end) { list_add(&node->hole_stack, &mm->hole_stack); node->hole_follows = 1; } return node; } WARN(1, "no hole found for block 0x%lx + 0x%lx\n", start, size); return NULL; } EXPORT_SYMBOL(drm_mm_create_block); struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *hole_node, unsigned long size, unsigned alignment, unsigned long color, int atomic) { struct drm_mm_node *node; node = drm_mm_kmalloc(hole_node->mm, atomic); if (unlikely(node == NULL)) return NULL; drm_mm_insert_helper(hole_node, node, size, alignment, color); return node; } EXPORT_SYMBOL(drm_mm_get_block_generic); /** * Search for free space and insert a preallocated memory node. Returns * -ENOSPC if no suitable free area is available. The preallocated memory node * must be cleared. */ int drm_mm_insert_node_generic(struct drm_mm *mm, struct drm_mm_node *node, unsigned long size, unsigned alignment, unsigned long color) { struct drm_mm_node *hole_node; hole_node = drm_mm_search_free_generic(mm, size, alignment, color, 0); if (!hole_node) return -ENOSPC; drm_mm_insert_helper(hole_node, node, size, alignment, color); return 0; } EXPORT_SYMBOL(drm_mm_insert_node_generic); int drm_mm_insert_node(struct drm_mm *mm, struct drm_mm_node *node, unsigned long size, unsigned alignment) { return drm_mm_insert_node_generic(mm, node, size, alignment, 0); } EXPORT_SYMBOL(drm_mm_insert_node); static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node, struct drm_mm_node *node, unsigned long size, unsigned alignment, unsigned long color, unsigned long start, unsigned long end) { struct drm_mm *mm = hole_node->mm; unsigned long hole_start = drm_mm_hole_node_start(hole_node); unsigned long hole_end = drm_mm_hole_node_end(hole_node); unsigned long adj_start = hole_start; unsigned long adj_end = hole_end; BUG_ON(!hole_node->hole_follows || node->allocated); if (adj_start < start) adj_start = start; if (adj_end > end) adj_end = end; if (mm->color_adjust) mm->color_adjust(hole_node, color, &adj_start, &adj_end); if (alignment) { unsigned tmp = adj_start % alignment; if (tmp) adj_start += alignment - tmp; } if (adj_start == hole_start) { hole_node->hole_follows = 0; list_del(&hole_node->hole_stack); } node->start = adj_start; node->size = size; node->mm = mm; node->color = color; node->allocated = 1; INIT_LIST_HEAD(&node->hole_stack); list_add(&node->node_list, &hole_node->node_list); BUG_ON(node->start + node->size > adj_end); BUG_ON(node->start + node->size > end); node->hole_follows = 0; if (__drm_mm_hole_node_start(node) < hole_end) { list_add(&node->hole_stack, &mm->hole_stack); node->hole_follows = 1; } } struct drm_mm_node *drm_mm_get_block_range_generic(struct drm_mm_node *hole_node, unsigned long size, unsigned alignment, unsigned long color, unsigned long start, unsigned long end, int atomic) { struct drm_mm_node *node; node = drm_mm_kmalloc(hole_node->mm, atomic); if (unlikely(node == NULL)) return NULL; drm_mm_insert_helper_range(hole_node, node, size, alignment, color, start, end); return node; } EXPORT_SYMBOL(drm_mm_get_block_range_generic); /** * Search for free space and insert a preallocated memory node. Returns * -ENOSPC if no suitable free area is available. This is for range * restricted allocations. The preallocated memory node must be cleared. */ int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, struct drm_mm_node *node, unsigned long size, unsigned alignment, unsigned long color, unsigned long start, unsigned long end) { struct drm_mm_node *hole_node; hole_node = drm_mm_search_free_in_range_generic(mm, size, alignment, color, start, end, 0); if (!hole_node) return -ENOSPC; drm_mm_insert_helper_range(hole_node, node, size, alignment, color, start, end); return 0; } EXPORT_SYMBOL(drm_mm_insert_node_in_range_generic); int drm_mm_insert_node_in_range(struct drm_mm *mm, struct drm_mm_node *node, unsigned long size, unsigned alignment, unsigned long start, unsigned long end) { return drm_mm_insert_node_in_range_generic(mm, node, size, alignment, 0, start, end); } EXPORT_SYMBOL(drm_mm_insert_node_in_range); /** * Remove a memory node from the allocator. */ void drm_mm_remove_node(struct drm_mm_node *node) { struct drm_mm *mm = node->mm; struct drm_mm_node *prev_node; BUG_ON(node->scanned_block || node->scanned_prev_free || node->scanned_next_free); prev_node = list_entry(node->node_list.prev, struct drm_mm_node, node_list); if (node->hole_follows) { BUG_ON(__drm_mm_hole_node_start(node) == __drm_mm_hole_node_end(node)); list_del(&node->hole_stack); } else BUG_ON(__drm_mm_hole_node_start(node) != __drm_mm_hole_node_end(node)); if (!prev_node->hole_follows) { prev_node->hole_follows = 1; list_add(&prev_node->hole_stack, &mm->hole_stack); } else list_move(&prev_node->hole_stack, &mm->hole_stack); list_del(&node->node_list); node->allocated = 0; } EXPORT_SYMBOL(drm_mm_remove_node); /* * Remove a memory node from the allocator and free the allocated struct * drm_mm_node. Only to be used on a struct drm_mm_node obtained by one of the * drm_mm_get_block functions. */ void drm_mm_put_block(struct drm_mm_node *node) { struct drm_mm *mm = node->mm; drm_mm_remove_node(node); spin_lock(&mm->unused_lock); if (mm->num_unused < MM_UNUSED_TARGET) { list_add(&node->node_list, &mm->unused_nodes); ++mm->num_unused; } else kfree(node); spin_unlock(&mm->unused_lock); } EXPORT_SYMBOL(drm_mm_put_block); static int check_free_hole(unsigned long start, unsigned long end, unsigned long size, unsigned alignment) { if (end - start < size) return 0; if (alignment) { unsigned tmp = start % alignment; if (tmp) start += alignment - tmp; } return end >= start + size; } struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm, unsigned long size, unsigned alignment, unsigned long color, bool best_match) { struct drm_mm_node *entry; struct drm_mm_node *best; unsigned long adj_start; unsigned long adj_end; unsigned long best_size; BUG_ON(mm->scanned_blocks); best = NULL; best_size = ~0UL; drm_mm_for_each_hole(entry, mm, adj_start, adj_end) { if (mm->color_adjust) { mm->color_adjust(entry, color, &adj_start, &adj_end); if (adj_end <= adj_start) continue; } if (!check_free_hole(adj_start, adj_end, size, alignment)) continue; if (!best_match) return entry; if (entry->size < best_size) { best = entry; best_size = entry->size; } } return best; } EXPORT_SYMBOL(drm_mm_search_free_generic); struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm, unsigned long size, unsigned alignment, unsigned long color, unsigned long start, unsigned long end, bool best_match) { struct drm_mm_node *entry; struct drm_mm_node *best; unsigned long adj_start; unsigned long adj_end; unsigned long best_size; BUG_ON(mm->scanned_blocks); best = NULL; best_size = ~0UL; drm_mm_for_each_hole(entry, mm, adj_start, adj_end) { if (adj_start < start) adj_start = start; if (adj_end > end) adj_end = end; if (mm->color_adjust) { mm->color_adjust(entry, color, &adj_start, &adj_end); if (adj_end <= adj_start) continue; } if (!check_free_hole(adj_start, adj_end, size, alignment)) continue; if (!best_match) return entry; if (entry->size < best_size) { best = entry; best_size = entry->size; } } return best; } EXPORT_SYMBOL(drm_mm_search_free_in_range_generic); /** * Moves an allocation. To be used with embedded struct drm_mm_node. */ void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new) { list_replace(&old->node_list, &new->node_list); list_replace(&old->hole_stack, &new->hole_stack); new->hole_follows = old->hole_follows; new->mm = old->mm; new->start = old->start; new->size = old->size; new->color = old->color; old->allocated = 0; new->allocated = 1; } EXPORT_SYMBOL(drm_mm_replace_node); /** * Initializa lru scanning. * * This simply sets up the scanning routines with the parameters for the desired * hole. * * Warning: As long as the scan list is non-empty, no other operations than * adding/removing nodes to/from the scan list are allowed. */ void drm_mm_init_scan(struct drm_mm *mm, unsigned long size, unsigned alignment, unsigned long color) { mm->scan_color = color; mm->scan_alignment = alignment; mm->scan_size = size; mm->scanned_blocks = 0; mm->scan_hit_start = 0; mm->scan_hit_end = 0; mm->scan_check_range = 0; mm->prev_scanned_node = NULL; } EXPORT_SYMBOL(drm_mm_init_scan); /** * Initializa lru scanning. * * This simply sets up the scanning routines with the parameters for the desired * hole. This version is for range-restricted scans. * * Warning: As long as the scan list is non-empty, no other operations than * adding/removing nodes to/from the scan list are allowed. */ void drm_mm_init_scan_with_range(struct drm_mm *mm, unsigned long size, unsigned alignment, unsigned long color, unsigned long start, unsigned long end) { mm->scan_color = color; mm->scan_alignment = alignment; mm->scan_size = size; mm->scanned_blocks = 0; mm->scan_hit_start = 0; mm->scan_hit_end = 0; mm->scan_start = start; mm->scan_end = end; mm->scan_check_range = 1; mm->prev_scanned_node = NULL; } EXPORT_SYMBOL(drm_mm_init_scan_with_range); /** * Add a node to the scan list that might be freed to make space for the desired * hole. * * Returns non-zero, if a hole has been found, zero otherwise. */ int drm_mm_scan_add_block(struct drm_mm_node *node) { struct drm_mm *mm = node->mm; struct drm_mm_node *prev_node; unsigned long hole_start, hole_end; unsigned long adj_start, adj_end; mm->scanned_blocks++; BUG_ON(node->scanned_block); node->scanned_block = 1; prev_node = list_entry(node->node_list.prev, struct drm_mm_node, node_list); node->scanned_preceeds_hole = prev_node->hole_follows; prev_node->hole_follows = 1; list_del(&node->node_list); node->node_list.prev = &prev_node->node_list; node->node_list.next = &mm->prev_scanned_node->node_list; mm->prev_scanned_node = node; adj_start = hole_start = drm_mm_hole_node_start(prev_node); adj_end = hole_end = drm_mm_hole_node_end(prev_node); if (mm->scan_check_range) { if (adj_start < mm->scan_start) adj_start = mm->scan_start; if (adj_end > mm->scan_end) adj_end = mm->scan_end; } if (mm->color_adjust) mm->color_adjust(prev_node, mm->scan_color, &adj_start, &adj_end); if (check_free_hole(adj_start, adj_end, mm->scan_size, mm->scan_alignment)) { mm->scan_hit_start = hole_start; mm->scan_hit_end = hole_end; return 1; } return 0; } EXPORT_SYMBOL(drm_mm_scan_add_block); /** * Remove a node from the scan list. * * Nodes _must_ be removed in the exact same order from the scan list as they * have been added, otherwise the internal state of the memory manager will be * corrupted. * * When the scan list is empty, the selected memory nodes can be freed. An * immediately following drm_mm_search_free with best_match = 0 will then return * the just freed block (because its at the top of the free_stack list). * * Returns one if this block should be evicted, zero otherwise. Will always * return zero when no hole has been found. */ int drm_mm_scan_remove_block(struct drm_mm_node *node) { struct drm_mm *mm = node->mm; struct drm_mm_node *prev_node; mm->scanned_blocks--; BUG_ON(!node->scanned_block); node->scanned_block = 0; prev_node = list_entry(node->node_list.prev, struct drm_mm_node, node_list); prev_node->hole_follows = node->scanned_preceeds_hole; list_add(&node->node_list, &prev_node->node_list); return (drm_mm_hole_node_end(node) > mm->scan_hit_start && node->start < mm->scan_hit_end); } EXPORT_SYMBOL(drm_mm_scan_remove_block); int drm_mm_clean(struct drm_mm * mm) { struct list_head *head = &mm->head_node.node_list; return (head->next->next == head); } EXPORT_SYMBOL(drm_mm_clean); int drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size) { INIT_LIST_HEAD(&mm->hole_stack); INIT_LIST_HEAD(&mm->unused_nodes); mm->num_unused = 0; mm->scanned_blocks = 0; spin_lock_init(&mm->unused_lock); /* Clever trick to avoid a special case in the free hole tracking. */ INIT_LIST_HEAD(&mm->head_node.node_list); INIT_LIST_HEAD(&mm->head_node.hole_stack); mm->head_node.hole_follows = 1; mm->head_node.scanned_block = 0; mm->head_node.scanned_prev_free = 0; mm->head_node.scanned_next_free = 0; mm->head_node.mm = mm; mm->head_node.start = start + size; mm->head_node.size = start - mm->head_node.start; list_add_tail(&mm->head_node.hole_stack, &mm->hole_stack); mm->color_adjust = NULL; return 0; } EXPORT_SYMBOL(drm_mm_init); void drm_mm_takedown(struct drm_mm * mm) { struct drm_mm_node *entry, *next; if (!list_empty(&mm->head_node.node_list)) { DRM_ERROR("Memory manager not clean. Delaying takedown\n"); return; } spin_lock(&mm->unused_lock); list_for_each_entry_safe(entry, next, &mm->unused_nodes, node_list) { list_del(&entry->node_list); kfree(entry); --mm->num_unused; } spin_unlock(&mm->unused_lock); BUG_ON(mm->num_unused != 0); } EXPORT_SYMBOL(drm_mm_takedown); void drm_mm_debug_table(struct drm_mm *mm, const char *prefix) { struct drm_mm_node *entry; unsigned long total_used = 0, total_free = 0, total = 0; unsigned long hole_start, hole_end, hole_size; hole_start = drm_mm_hole_node_start(&mm->head_node); hole_end = drm_mm_hole_node_end(&mm->head_node); hole_size = hole_end - hole_start; if (hole_size) printk(KERN_DEBUG "%s 0x%08lx-0x%08lx: %8lu: free\n", prefix, hole_start, hole_end, hole_size); total_free += hole_size; drm_mm_for_each_node(entry, mm) { printk(KERN_DEBUG "%s 0x%08lx-0x%08lx: %8lu: used\n", prefix, entry->start, entry->start + entry->size, entry->size); total_used += entry->size; if (entry->hole_follows) { hole_start = drm_mm_hole_node_start(entry); hole_end = drm_mm_hole_node_end(entry); hole_size = hole_end - hole_start; printk(KERN_DEBUG "%s 0x%08lx-0x%08lx: %8lu: free\n", prefix, hole_start, hole_end, hole_size); total_free += hole_size; } } total = total_free + total_used; printk(KERN_DEBUG "%s total: %lu, used %lu free %lu\n", prefix, total, total_used, total_free); } EXPORT_SYMBOL(drm_mm_debug_table); #if defined(CONFIG_DEBUG_FS) static unsigned long drm_mm_dump_hole(struct seq_file *m, struct drm_mm_node *entry) { unsigned long hole_start, hole_end, hole_size; if (entry->hole_follows) { hole_start = drm_mm_hole_node_start(entry); hole_end = drm_mm_hole_node_end(entry); hole_size = hole_end - hole_start; seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n", hole_start, hole_end, hole_size); return hole_size; } return 0; } int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm) { struct drm_mm_node *entry; unsigned long total_used = 0, total_free = 0, total = 0; total_free += drm_mm_dump_hole(m, &mm->head_node); drm_mm_for_each_node(entry, mm) { seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: used\n", entry->start, entry->start + entry->size, entry->size); total_used += entry->size; total_free += drm_mm_dump_hole(m, entry); } total = total_free + total_used; seq_printf(m, "total: %lu, used %lu free %lu\n", total, total_used, total_free); return 0; } EXPORT_SYMBOL(drm_mm_dump_table); #endif
caf7223389f468df4fdd6bae480e689cb357e6aa
3a2071c34e3c35847b2bcc2a5d3b3a74114daa0f
/subversion/libsvn_fs_x/util.h
0382c2e6541519257482d0ccf9c6a0308335d5b3
[ "BSD-3-Clause", "LicenseRef-scancode-generic-cla", "LicenseRef-scancode-other-permissive", "X11", "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "MIT", "HPND-Markus-Kuhn", "LicenseRef-scancode-unicode", "Apache-2.0", "FSFAP" ]
permissive
apache/subversion
18a9142afe63f060ffc0814fe0c758c91ad8bd31
dd957c4991e61bde23cc60d13449ea8b65f80c43
refs/heads/trunk
2023-09-04T15:22:36.755177
2023-08-29T19:55:03
2023-08-29T19:55:03
454,263
520
207
Apache-2.0
2023-08-26T14:17:30
2009-12-31T09:00:10
C
UTF-8
C
false
false
17,253
h
util.h
/* util.h --- utility functions for FSX repo access * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * ==================================================================== */ #ifndef SVN_LIBSVN_FS_X_UTIL_H #define SVN_LIBSVN_FS_X_UTIL_H #include "svn_fs.h" #include "id.h" #include "batch_fsync.h" /* Functions for dealing with recoverable errors on mutable files * * Revprops, current, and txn-current files are mutable; that is, they * change as part of normal fsx operation, in constrat to revs files, or * the format file, which are written once at create (or upgrade) time. * When more than one host writes to the same repository, we will * sometimes see these recoverable errors when accesssing these files. * * These errors all relate to NFS, and thus we only use this retry code if * ESTALE is defined. * ** ESTALE * * In NFS v3 and under, the server doesn't track opened files. If you * unlink(2) or rename(2) a file held open by another process *on the * same host*, that host's kernel typically renames the file to * .nfsXXXX and automatically deletes that when it's no longer open, * but this behavior is not required. * * For obvious reasons, this does not work *across hosts*. No one * knows about the opened file; not the server, and not the deleting * client. So the file vanishes, and the reader gets stale NFS file * handle. * ** EIO, ENOENT * * Some client implementations (at least the 2.6.18.5 kernel that ships * with Ubuntu Dapper) sometimes give spurious ENOENT (only on open) or * even EIO errors when trying to read these files that have been renamed * over on some other host. * ** Solution * * Try open and read of such files in try_stringbuf_from_file(). Call * this function within a loop of SVN_FS_X__RECOVERABLE_RETRY_COUNT * iterations (though, realistically, the second try will succeed). */ #define SVN_FS_X__RECOVERABLE_RETRY_COUNT 10 /* Pathname helper functions */ /* Return TRUE is REV is packed in FS, FALSE otherwise. */ svn_boolean_t svn_fs_x__is_packed_rev(svn_fs_t *fs, svn_revnum_t rev); /* Return TRUE is REV is packed in FS, FALSE otherwise. */ svn_boolean_t svn_fs_x__is_packed_revprop(svn_fs_t *fs, svn_revnum_t rev); /* Return the first revision in the pack / rev file containing REV in * filesystem FS. For non-packed revs, this will simply be REV. */ svn_revnum_t svn_fs_x__packed_base_rev(svn_fs_t *fs, svn_revnum_t rev); /* Return the number of revisions in the pack / rev file in FS that contains * revision REV. */ svn_revnum_t svn_fs_x__pack_size(svn_fs_t *fs, svn_revnum_t rev); /* Return the full path of the "format" file in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_format(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the path to the 'current' file in FS. Perform allocation in RESULT_POOL. */ const char * svn_fs_x__path_current(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the path to the 'next' file in FS. Perform allocation in RESULT_POOL. */ const char * svn_fs_x__path_next(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the full path of the "uuid" file in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_uuid(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the full path of the "txn-current" file in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txn_current(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the full path of the "txn-current-lock" file in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txn_current_lock(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the full path of the global write lock file in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_lock(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the full path of the pack operation lock file in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_pack_lock(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the full path of the revprop generation file in FS. * Allocate the result in RESULT_POOL. */ const char * svn_fs_x__path_revprop_generation(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the path of the pack-related file that for revision REV in FS. * KIND specifies the file name base, e.g. "pack". * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_rev_packed(svn_fs_t *fs, svn_revnum_t rev, const char *kind, apr_pool_t *result_pool); /* Return the full path of the rev shard directory that will contain * revision REV in FS. Allocate the result in RESULT_POOL. */ const char * svn_fs_x__path_shard(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *result_pool); /* Return the full path of the non-packed rev file containing revision REV * in FS. Allocate the result in RESULT_POOL. */ const char * svn_fs_x__path_rev(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *result_pool); /* Set *PATH to the path of REV in FS, whether in a pack file or not. Allocate *PATH in RESULT_POOL. Note: If the caller does not have the write lock on FS, then the path is not guaranteed to be correct or to remain correct after the function returns, because the revision might become packed before or after this call. If a file exists at that path, then it is correct; if not, then the caller should call update_min_unpacked_rev() and re-try once. */ const char * svn_fs_x__path_rev_absolute(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *result_pool); /* Return the full path of the pack shard directory that will contain the * packed revision REV in FS. Allocate the result in RESULT_POOL. */ const char * svn_fs_x__path_pack_shard(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *result_pool); /* Return the full path of the non-packed revision properties file that * contains the props for revision REV in FS. * Allocate the result in RESULT_POOL. */ const char * svn_fs_x__path_revprops(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *result_pool); /* Convert the TXN_ID into a string, allocated from RESULT_POOL. */ const char * svn_fs_x__txn_name(svn_fs_x__txn_id_t txn_id, apr_pool_t *result_pool); /* Convert TXN_NAME into an ID and return it in *TXN_ID. */ svn_error_t * svn_fs_x__txn_by_name(svn_fs_x__txn_id_t *txn_id, const char *txn_name); /* Return the path of the directory containing the transaction TXN_ID in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txn_dir(svn_fs_t *fs, svn_fs_x__txn_id_t txn_id, apr_pool_t *result_pool); /* Return the path of the 'transactions' directory in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txns_dir(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the name of the sha1->rep mapping file in transaction TXN_ID * within FS for the given SHA1 checksum. Use POOL for allocations. */ const char * svn_fs_x__path_txn_sha1(svn_fs_t *fs, svn_fs_x__txn_id_t txn_id, const unsigned char *sha1, apr_pool_t *pool); /* Return the path of the 'txn-protorevs' directory in FS, even if that * folder may not exist in FS. The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txn_proto_revs(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the path of the changes file for transaction TXN_ID in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txn_changes(svn_fs_t *fs, svn_fs_x__txn_id_t txn_id, apr_pool_t *result_pool); /* Return the path of the file containing the log-to-phys index for * the transaction identified by TXN_ID in FS. * The result will be allocated in RESULT_POOL. */ const char* svn_fs_x__path_l2p_proto_index(svn_fs_t *fs, svn_fs_x__txn_id_t txn_id, apr_pool_t *result_pool); /* Return the path of the file containing the phys-to-log index for * the transaction identified by TXN_ID in FS. * The result will be allocated in RESULT_POOL. */ const char* svn_fs_x__path_p2l_proto_index(svn_fs_t *fs, svn_fs_x__txn_id_t txn_id, apr_pool_t *result_pool); /* Return the path of the file containing the transaction properties for * the transaction identified by TXN_ID in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txn_props(svn_fs_t *fs, svn_fs_x__txn_id_t txn_id, apr_pool_t *result_pool); /* Return the path of the file containing the node and copy ID counters for * the transaction identified by TXN_ID in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txn_next_ids(svn_fs_t *fs, svn_fs_x__txn_id_t txn_id, apr_pool_t *result_pool); /* Return the path of the file storing the oldest non-packed revision in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_min_unpacked_rev(svn_fs_t *fs, apr_pool_t *result_pool); /* Return the path of the file containing item_index counter for * the transaction identified by TXN_ID in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txn_item_index(svn_fs_t *fs, svn_fs_x__txn_id_t txn_id, apr_pool_t *result_pool); /* Return the path of the proto-revision file for transaction TXN_ID in FS. * The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txn_proto_rev(svn_fs_t *fs, svn_fs_x__txn_id_t txn_id, apr_pool_t *result_pool); /* Return the path of the proto-revision lock file for transaction TXN_ID * in FS. The result will be allocated in RESULT_POOL. */ const char * svn_fs_x__path_txn_proto_rev_lock(svn_fs_t *fs, svn_fs_x__txn_id_t txn_id, apr_pool_t *result_pool); /* Return the path of the file containing the in-transaction node revision * identified by ID in FS. * The result will be allocated in RESULT_POOL, temporaries in SCRATCH_POOL. */ const char * svn_fs_x__path_txn_node_rev(svn_fs_t *fs, const svn_fs_x__id_t *id, apr_pool_t *result_pool, apr_pool_t *scratch_pool); /* Return the path of the file containing the in-transaction properties of * the node identified by ID in FS. * The result will be allocated in RESULT_POOL, temporaries in SCRATCH_POOL. */ const char * svn_fs_x__path_txn_node_props(svn_fs_t *fs, const svn_fs_x__id_t *id, apr_pool_t *result_pool, apr_pool_t *scratch_pool); /* Return the path of the file containing the directory entries of the * in-transaction directory node identified by ID in FS. * The result will be allocated in RESULT_POOL, temporaries in SCRATCH_POOL. */ const char * svn_fs_x__path_txn_node_children(svn_fs_t *fs, const svn_fs_x__id_t *id, apr_pool_t *result_pool, apr_pool_t *scratch_pool); /* Check that BUF, a nul-terminated buffer of text from file PATH, contains only digits at OFFSET and beyond, raising an error if not. TITLE contains a user-visible description of the file, usually the short file name. Uses SCRATCH_POOL for temporary allocation. */ svn_error_t * svn_fs_x__check_file_buffer_numeric(const char *buf, apr_off_t offset, const char *path, const char *title, apr_pool_t *scratch_pool); /* Set *MIN_UNPACKED_REV to the integer value read from the file returned * by #svn_fs_x__path_min_unpacked_rev() for FS. * Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__read_min_unpacked_rev(svn_revnum_t *min_unpacked_rev, svn_fs_t *fs, apr_pool_t *scratch_pool); /* Re-read the MIN_UNPACKED_REV member of FS from disk. * Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__update_min_unpacked_rev(svn_fs_t *fs, apr_pool_t *scratch_pool); /* Atomically update the 'min-unpacked-rev' file in FS to hold the specified * REVNUM. Perform temporary allocations in SCRATCH_POOL. */ svn_error_t * svn_fs_x__write_min_unpacked_rev(svn_fs_t *fs, svn_revnum_t revnum, apr_pool_t *scratch_pool); /* Set *REV to the value read from the 'current' file. Perform temporary * allocations in SCRATCH_POOL. */ svn_error_t * svn_fs_x__read_current(svn_revnum_t *rev, svn_fs_t *fs, apr_pool_t *scratch_pool); /* Atomically update the 'current' file to hold the specified REV. Perform temporary allocations in SCRATCH_POOL. */ svn_error_t * svn_fs_x__write_current(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *scratch_pool); /* Read the file at PATH and return its content in *CONTENT, allocated in * RESULT_POOL. *CONTENT will not be modified unless the whole file was * read successfully. * * ESTALE, EIO and ENOENT will not cause this function to return an error * unless LAST_ATTEMPT has been set. If MISSING is not NULL, indicate * missing files (ENOENT) there. */ svn_error_t * svn_fs_x__try_stringbuf_from_file(svn_stringbuf_t **content, svn_boolean_t *missing, const char *path, svn_boolean_t last_attempt, apr_pool_t *result_pool); /* Read the file FNAME and store the contents in *BUF. Allocations are performed in RESULT_POOL. */ svn_error_t * svn_fs_x__read_content(svn_stringbuf_t **content, const char *fname, apr_pool_t *result_pool); /* Reads a line from STREAM and converts it to a 64 bit integer to be * returned in *RESULT. If we encounter eof, set *HIT_EOF and leave * *RESULT unchanged. If HIT_EOF is NULL, EOF causes an "corrupt FS" * error return. * SCRATCH_POOL is used for temporary allocations. */ svn_error_t * svn_fs_x__read_number_from_stream(apr_int64_t *result, svn_boolean_t *hit_eof, svn_stream_t *stream, apr_pool_t *scratch_pool); /* Move a file into place from temporary OLD_FILENAME to its final location NEW_FILENAME, which must be on to the same volume. Schedule any necessary fsync calls in BATCH. On Unix, match the permissions of the new file to the permissions of PERMS_REFERENCE. Temporary allocations are from SCRATCH_POOL. This function almost duplicates svn_io_file_move(), but it tries to guarantee a flush if BATCH->FLUSH_TO_DISK is non-zero. */ svn_error_t * svn_fs_x__move_into_place(const char *old_filename, const char *new_filename, const char *perms_reference, svn_fs_x__batch_fsync_t *batch, apr_pool_t *scratch_pool); #endif
d914faa358c722062f95720c1961d367eeffde52
5816ae8b5fdfe9ab93b3653742b5d4c2a1567111
/hitcon-2018/abyss/src/kernel/utils/panic.h
cbe2c69632962663aaf56b4393c3fe7b10a105db
[]
no_license
david942j/ctf-writeups
6c2ff633d80809e422f0263b8ac9a69607d31e84
a4d086684a939000286d0876dd29463ccdceea2e
refs/heads/master
2022-09-07T00:27:23.594820
2021-12-14T10:50:47
2021-12-14T10:50:47
77,058,219
316
49
null
null
null
null
UTF-8
C
false
false
144
h
panic.h
#ifndef PANIC_H #define PANIC_H /* panic occurs when assertion fails in kernel */ void __attribute__((noreturn)) panic(const char *s); #endif
b86725a3d93de5fe27ab036fc46e80ddaaf9c0c5
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/atari/include/psl.h
7c8a05c8baedfb5c502432c3ca2d6bd757279519
[]
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
85
h
psl.h
/* $NetBSD: psl.h,v 1.3 2005/12/11 12:16:59 christos Exp $ */ #include <m68k/psl.h>
79d5038892a7cf83a2692741a22bfd98157580da
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/imxrt/libraries/MIMXRT1170/MIMXRT1176/drivers/fsl_smartcard_phy.h
21408bef7692fbdf0a4f1d6464e6d4c46eebf957
[ "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
4,274
h
fsl_smartcard_phy.h
/* * Copyright (c) 2015-2016, Freescale Semiconductor, Inc. * Copyright 2016-2017 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef _FSL_SMARTCARD_PHY_H_ #define _FSL_SMARTCARD_PHY_H_ #include "fsl_smartcard.h" /*! * @addtogroup smartcard_phy_driver * @{ */ /******************************************************************************* * Definitions ******************************************************************************/ /*! @brief Smart card definition which specifies the adjustment number of clock cycles during which an ATR string has to * be received. */ #define SMARTCARD_ATR_DURATION_ADJUSTMENT (360u) /*! @brief Smart card definition which specifies the adjustment number of clock cycles until an initial 'TS' character * has to be * received. */ #define SMARTCARD_INIT_DELAY_CLOCK_CYCLES_ADJUSTMENT (4200u) /******************************************************************************* * API ******************************************************************************/ #if defined(__cplusplus) extern "C" { #endif /*! * @brief Fills in the configuration structure with default values. * * @param config The Smart card user configuration structure which contains configuration structure of type * smartcard_interface_config_t. * Function fill in members: * clockToResetDelay = 42000, * vcc = kSmartcardVoltageClassB3_3V, * with default values. */ void SMARTCARD_PHY_GetDefaultConfig(smartcard_interface_config_t *config); /*! * @brief Initializes a Smart card interface instance. * * @param base The Smart card peripheral base address. * @param config The user configuration structure of type smartcard_interface_config_t. Call the * function SMARTCARD_PHY_GetDefaultConfig() to fill the configuration structure. * @param srcClock_Hz Smart card clock generation module source clock. * * @retval kStatus_SMARTCARD_Success or kStatus_SMARTCARD_OtherError in case of error. */ status_t SMARTCARD_PHY_Init(void *base, smartcard_interface_config_t const *config, uint32_t srcClock_Hz); /*! * @brief De-initializes a Smart card interface, stops the Smart card clock, and disables the VCC. * * @param base The Smart card peripheral module base address. * @param config The user configuration structure of type smartcard_interface_config_t. */ void SMARTCARD_PHY_Deinit(void *base, smartcard_interface_config_t const *config); /*! * @brief Activates the Smart card IC. * * @param base The Smart card peripheral module base address. * @param context A pointer to a Smart card driver context structure. * @param resetType type of reset to be performed, possible values * = kSmartcardColdReset, kSmartcardWarmReset * * @retval kStatus_SMARTCARD_Success or kStatus_SMARTCARD_OtherError in case of error. */ status_t SMARTCARD_PHY_Activate(void *base, smartcard_context_t *context, smartcard_reset_type_t resetType); /*! * @brief De-activates the Smart card IC. * * @param base The Smart card peripheral module base address. * @param context A pointer to a Smart card driver context structure. * * @retval kStatus_SMARTCARD_Success or kStatus_SMARTCARD_OtherError in case of error. */ status_t SMARTCARD_PHY_Deactivate(void *base, smartcard_context_t *context); /*! * @brief Controls the Smart card interface IC. * * @param base The Smart card peripheral module base address. * @param context A pointer to a Smart card driver context structure. * @param control A interface command type. * @param param Integer value specific to control type * * @retval kStatus_SMARTCARD_Success or kStatus_SMARTCARD_OtherError in case of error. */ status_t SMARTCARD_PHY_Control(void *base, smartcard_context_t *context, smartcard_interface_control_t control, uint32_t param); /*! * @brief Smart card interface IC IRQ ISR. * * @param base The Smart card peripheral module base address. * @param context The Smart card context pointer. */ #if defined(USING_PHY_TDA8035) void SMARTCARD_PHY_IRQHandler(void *base, smartcard_context_t *context); #endif /*@}*/ #if defined(__cplusplus) } #endif /*! @}*/ #endif /* _FSL_SMARTCARD_PHY_H_*/
d3edb593105738416fda6e6cb08f4f7a84b0faab
2753608f87a1e8fa312feced7af20917ea9cc004
/Sorting/Selection Sort/C/selection_sort.c
eaf848d7f061b84f168b44b7b83acc9d193e3402
[ "MIT" ]
permissive
VAR-solutions/Algorithms
76faed6515367b6f27638b910dbc07f340fae56f
4ad6773e9675ef35aa858ca3969be5ddf6e3daea
refs/heads/dev
2023-08-15T11:37:26.048316
2021-08-03T07:00:28
2021-08-03T07:00:28
151,157,582
794
1,249
MIT
2023-07-29T00:28:36
2018-10-01T20:50:24
C++
UTF-8
C
false
false
828
c
selection_sort.c
/* Selection Sort implementation in C; * Author : Felipe Gabriel; * Input : Array lenght and elements; * Output : Sorted array elements; */ #include <stdio.h> void selection_sort(int size, int *v){ int i, j, min, aux; for (i = 0; i < (size-1); i++){ min = i; for (j = (i+1); j < size; j++) { if(v[j] < v[min]){ min = j; } } if (v[i] != v[min]) { aux = v[i]; v[i] = v[min]; v[min] = aux; } } } int main(){ int size,j; scanf("%d",&size); int v[size]; for(j = 0; j < size; j++){ scanf("%d",&v[j]); } selection_sort(size,v); for(j = 0; j < size; j++){ if(j != size-1){ printf("%d ",v[j]); } else{ printf("%d\n",v[j]); } } return 0; }
6fb6708e6a2527f1be0f30db3ea7c54e41ae5c98
9de0cec678bc4a3bec2b4adabef9f39ff5b4afac
/PWG/DevNanoAOD/runLocalCorrelations.C
7a30a6fc69d3b431c71564f78c207066b2d9cf66
[]
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
3,316
c
runLocalCorrelations.C
#if !defined (__CINT__) || (defined(__MAKECINT__)) #include <iostream> #include "AliAnalysisGrid.h" #include "TSystem.h" #include "TROOT.h" #include "AliAnalysisManager.h" #include "AliAnalysisGrid.h" #include "AliVEventHandler.h" #include "AliAODInputHandler.h" #include "AliAnalysisAlien.h" #include "AliMCEventHandler.h" #include "AliPhysicsSelectionTask.h" #include "TRegexp.h" #include "AliTriggerAnalysis.h" #include "TChain.h" #include "AliAnalysisTaskPIDResponse.h" #include "AliAODHandler.h" #include "AliAnalysisTaskNanoAODFilter.h" #include "AliESEHelpers.h" #endif void LoadLibs(); class AliAnalysisGrid; //______________________________________________________________________________ void runLocalCorrelations( const int iMCtruth = 2, const char * addTaskString = ".x AddTaskNanoAODFilter.C(%d,0)" // ) { LoadLibs(); // analysis manager AliAnalysisManager* mgr = new AliAnalysisManager("NanoAOD Filter", "NanoAOD filter for nanoAOD production"); AliAODInputHandler* iH = new AliAODInputHandler(); mgr->SetInputEventHandler(iH); // Define aod output handler AliAODHandler* aodOutputHandler = new AliAODHandler(); aodOutputHandler->SetOutputFileName("AliAOD.NanoAOD.root"); mgr->SetOutputEventHandler(aodOutputHandler); // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); // AliAnalysisTaskPIDResponse *taskPID=AddTaskPIDResponse(iMCtruth); // taskPID->SetUseTPCEtaCorrection(kTRUE); // create task cout << "Macro: "<< addTaskString << " " << Form(addTaskString, iMCtruth) << endl; AliAnalysisTaskNanoAODFilter * task = (AliAnalysisTaskNanoAODFilter*) gROOT->ProcessLine(Form(addTaskString, iMCtruth)); // Set Track event and vertex cuts here! AliAnalysisNanoAODTrackCuts* trk = new AliAnalysisNanoAODTrackCuts; trk->SetBitMask((1 << 4) | (1 << 8)); // hybrid 2010 trk->SetMaxEta(0.9); trk->SetMinPt(0.2); AliAnalysisNanoAODEventCuts* evt = new AliAnalysisNanoAODEventCuts; evt->SetVertexRange(10); task->SetTrkCuts(trk); task->SetEvtCuts(evt); task->AddSetter(new AliNanoAODSimpleSetter); task->SetVarListTrack("pt,theta,phi"); task->SetVarListHeader("cstCentr,cstMagField"); task->SelectCollisionCandidates(AliVEvent::kMB); // enable debug printouts mgr->SetDebugLevel(10); // mgr->SetNSysInfo(100); if (!mgr->InitAnalysis()) return; mgr->PrintStatus(); // start analysis // Always read the same file: TChain * chain = new TChain("aodTree"); chain->Add("./AliAOD.root"); Printf("Starting Analysis...."); mgr->StartAnalysis("local", chain,123456789); } //______________________________________________________________________________ void LoadLibs() { gSystem->Load("libCore"); gSystem->Load("libGeom"); gSystem->Load("libPhysics"); gSystem->Load("libVMC"); gSystem->Load("libTree"); gSystem->Load("libProof"); gSystem->Load("libMatrix"); gSystem->Load("libMinuit"); gSystem->Load("libSTEERBase"); gSystem->Load("libESD"); gSystem->Load("libAOD"); gSystem->Load("libANALYSIS"); // return; gSystem->Load("libOADB"); gSystem->Load("libANALYSISalice"); gSystem->Load("libTender"); gSystem->Load("libCORRFW"); // gSystem->Load("libNanoAOD"); gSystem->Load("libPWGLFspectra"); gSystem->Load("libPWGDevNanoAOD"); }
83e24e23b8d5949767153c87c42dd36b69dacba2
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/harfbuzz-ng/src/test/api/test-var-coords.c
490e5fc061d2fe2f0597132c8d2443778c5ee893
[ "MIT", "LicenseRef-scancode-other-permissive", "MIT-Modern-Variant", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "GPL-1.0-or-later", "OFL-1.1" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C
false
false
3,355
c
test-var-coords.c
/* * Copyright © 2019 Ebrahim Byagowi * * This is part of HarfBuzz, a text shaping library. * * Permission is hereby granted, without written agreement and without * license or royalty fees, to use, copy, modify, and distribute this * software and its documentation for any purpose, provided that the * above copyright notice and the following two paragraphs appear in * all copies of this software. * * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ #include "hb-test.h" #include <hb-ot.h> /* Unit tests for hb_font_[gs]et_var_coords_ */ static void test_get_var_coords (void) { #ifndef G_APPROX_VALUE #define G_APPROX_VALUE(a, b, epsilon) \ (((a) > (b) ? (a) - (b) : (b) - (a)) < (epsilon)) #endif #define EPSILON 0.05f hb_face_t *face = hb_test_open_font_file ("fonts/TestCFF2VF.otf"); hb_font_t *font = hb_font_create (face); /* Normalized coords as input */ int normalized_coords[] = {100, 0}; hb_font_set_var_coords_normalized (font, normalized_coords, 2); g_assert_cmpint ((int) hb_font_get_var_coords_design (font, NULL)[0], ==, 403); g_assert_cmpint ((int) hb_font_get_var_coords_normalized (font, NULL)[0], ==, 100); /* Design coords as input */ float design_coords[] = {206.f, 0}; hb_font_set_var_coords_design (font, design_coords, 2); g_assert_cmpint ((int) hb_font_get_var_coords_normalized (font, NULL)[0], ==, -16117); g_assert_cmpint ((int) hb_font_get_var_coords_design (font, NULL)[0], ==, 206); for (float weight = 200; weight < 901; ++weight) { int normalized; hb_ot_var_normalize_coords (face, 1, &weight, &normalized); hb_font_set_var_coords_normalized (font, &normalized, 1); float converted_back = hb_font_get_var_coords_design (font, NULL)[0]; // fprintf (stderr, "%f: %d => %f\n", weight, normalized, converted_back); g_assert_true (G_APPROX_VALUE (converted_back, weight, EPSILON)); } hb_font_destroy (font); hb_face_destroy (face); } static void test_get_var_get_axis_infos (void) { hb_face_t *face = hb_test_open_font_file ("fonts/Estedad-VF.ttf"); g_assert_cmpint (hb_ot_var_get_axis_count (face), ==, 2); hb_ot_var_axis_info_t info; unsigned c = 1; g_assert_cmpint (hb_ot_var_get_axis_infos (face, 0, &c, &info), ==, 2); g_assert (info.tag == HB_TAG ('w','g','h','t')); g_assert_cmpint (c, ==, 1); hb_ot_var_get_axis_infos (face, 1, &c, &info); g_assert (info.tag == HB_TAG ('w','d','t','h')); g_assert_cmpint (c, ==, 1); hb_ot_var_get_axis_infos (face, 2, &c, &info); g_assert_cmpint (c, ==, 0); hb_face_destroy (face); } int main (int argc, char **argv) { hb_test_init (&argc, &argv); hb_test_add (test_get_var_coords); hb_test_add (test_get_var_get_axis_infos); return hb_test_run (); }
47729a9e6b949d704917f29f2fdc2a1ec6d22ff8
2c73a693c2b3c162eae2ab94f649d8c4494878ba
/components/epaper/EPD_1in54_V3.c
c3e4fbd4ac6ab8e76bc3bd8dbdde7f350790d97d
[ "MIT" ]
permissive
openLuat/LuatOS
185e1e140aed908434168133571ddcafe98f4e12
4b29d5121ab4f7133630331e8502c526c7856897
refs/heads/master
2023-08-23T04:57:23.263539
2023-08-23T04:46:46
2023-08-23T04:46:46
230,403,844
378
93
MIT
2021-12-17T02:19:30
2019-12-27T08:29:19
C
UTF-8
C
false
false
8,559
c
EPD_1in54_V3.c
#include "EPD_1in54_V3.h" #include "Debug.h" void lut_bw(void); /****************************************************************************** function : Software reset parameter: ******************************************************************************/ static void EPD_1IN54_V3_Reset(void) { DEV_Digital_Write(EPD_RST_PIN, 1); DEV_Delay_ms(200); DEV_Digital_Write(EPD_RST_PIN, 0); DEV_Delay_ms(10); DEV_Digital_Write(EPD_RST_PIN, 1); DEV_Delay_ms(200); } /****************************************************************************** function : send command parameter: Reg : Command register ******************************************************************************/ static void EPD_1IN54_V3_SendCommand(UBYTE Reg) { DEV_Digital_Write(EPD_DC_PIN, 0); DEV_Digital_Write(EPD_CS_PIN, 0); DEV_SPI_WriteByte(Reg); DEV_Digital_Write(EPD_CS_PIN, 1); } /****************************************************************************** function : send data parameter: Data : Write data ******************************************************************************/ static void EPD_1IN54_V3_SendData(UBYTE Data) { DEV_Digital_Write(EPD_DC_PIN, 1); DEV_Digital_Write(EPD_CS_PIN, 0); DEV_SPI_WriteByte(Data); DEV_Digital_Write(EPD_CS_PIN, 1); } /****************************************************************************** function : Wait until the busy_pin goes LOW parameter: ******************************************************************************/ static void EPD_1IN54_V3_ReadBusy(void) { EPD_Busy_WaitUntil(1,0); // unsigned char count = 100; // Debug("e-Paper busy\r\n"); // while(DEV_Digital_Read(EPD_BUSY_PIN) == 0) { //0:BUSY,1:FREE // if(!(count--)) // { // Debug("error: e-Paper busy timeout!!!\r\n"); // break; // } // else // DEV_Delay_ms(100); // } // Debug("e-Paper busy release\r\n"); } /****************************************************************************** function : Turn On Display full parameter: ******************************************************************************/ static void EPD_1IN54_V3_TurnOnDisplay(void) { EPD_1IN54_V3_SendCommand(0xE0); //cascade setting EPD_1IN54_V3_SendData(0x01); EPD_1IN54_V3_SendCommand(0x12); //DISPLAY REFRESH DEV_Delay_ms(100); //!!!The delay here is necessary, 200uS at least!!! EPD_1IN54_V3_ReadBusy(); } /****************************************************************************** function : Turn On Display part parameter: ******************************************************************************/ static void EPD_1IN54_V3_TurnOnDisplayPart(void) { //不支持局刷好像 EPD_1IN54_V3_TurnOnDisplay(); } /****************************************************************************** function : Initialize the e-Paper register parameter: ******************************************************************************/ void EPD_1IN54_V3_Init(UBYTE mode) { EPD_1IN54_V3_Reset(); EPD_1IN54_V3_SendCommand(0x01); //power setting EPD_1IN54_V3_SendData(0xC7); EPD_1IN54_V3_SendData(0x00); EPD_1IN54_V3_SendData(0x0D); EPD_1IN54_V3_SendData(0x00); EPD_1IN54_V3_SendCommand(0x04); EPD_1IN54_V3_ReadBusy(); EPD_1IN54_V3_SendCommand(0x00); //panel setting EPD_1IN54_V3_SendData(0xDf); //df-bw cf-r EPD_1IN54_V3_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING EPD_1IN54_V3_SendData(0x77); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7 EPD_1IN54_V3_SendCommand(0x30); //PLL setting EPD_1IN54_V3_SendData(0x2A); EPD_1IN54_V3_SendCommand(0x61); //resolution setting EPD_1IN54_V3_SendData(0xC8); EPD_1IN54_V3_SendData(0x00); EPD_1IN54_V3_SendData(0xC8); EPD_1IN54_V3_SendCommand(0x82); //vcom setting EPD_1IN54_V3_SendData(0x0A); lut_bw(); } //2s const unsigned char EPD_1IN54_V3_lut_vcom0[] ={0x02 ,0x03 ,0x03 ,0x08 ,0x08 ,0x03 ,0x05 ,0x05 ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }; const unsigned char EPD_1IN54_V3_lut_w[] ={ 0x42 ,0x43 ,0x03 ,0x48 ,0x88 ,0x03 ,0x85 ,0x08 ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }; const unsigned char EPD_1IN54_V3_lut_b[] ={ 0x82 ,0x83 ,0x03 ,0x48 ,0x88 ,0x03 ,0x05 ,0x45 ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }; const unsigned char EPD_1IN54_V3_lut_g1[] ={ 0x82 ,0x83 ,0x03 ,0x48 ,0x88 ,0x03 ,0x05 ,0x45 ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }; const unsigned char EPD_1IN54_V3_lut_g2[] ={ 0x82 ,0x83 ,0x03 ,0x48 ,0x88 ,0x03 ,0x05 ,0x45 ,0x03 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }; void lut_bw(void) { unsigned int count; EPD_1IN54_V3_SendCommand(0x20); for(count=0;count<15;count++) {EPD_1IN54_V3_SendData(EPD_1IN54_V3_lut_vcom0[count]);} EPD_1IN54_V3_SendCommand(0x21); for(count=0;count<15;count++) {EPD_1IN54_V3_SendData(EPD_1IN54_V3_lut_w[count]);} EPD_1IN54_V3_SendCommand(0x22); for(count=0;count<15;count++) {EPD_1IN54_V3_SendData(EPD_1IN54_V3_lut_b[count]);} EPD_1IN54_V3_SendCommand(0x23); for(count=0;count<15;count++) {EPD_1IN54_V3_SendData(EPD_1IN54_V3_lut_g1[count]);} EPD_1IN54_V3_SendCommand(0x24); for(count=0;count<15;count++) {EPD_1IN54_V3_SendData(EPD_1IN54_V3_lut_g2[count]);} } /****************************************************************************** function : Clear screen parameter: ******************************************************************************/ void EPD_1IN54_V3_Clear(void) { UWORD Width, Height; Width = (EPD_1IN54_V3_WIDTH % 8 == 0)? (EPD_1IN54_V3_WIDTH / 8 ): (EPD_1IN54_V3_WIDTH / 8 + 1); Height = EPD_1IN54_V3_HEIGHT*2; EPD_1IN54_V3_SendCommand(0x10); for (UWORD j = 0; j < Height; j++) { for (UWORD i = 0; i < Width; i++) { EPD_1IN54_V3_SendData(0XFF); } } EPD_1IN54_V3_TurnOnDisplay(); } /****************************************************************************** function : Sends the image buffer in RAM to e-Paper and displays parameter: ******************************************************************************/ void EPD_1IN54_V3_Display(UBYTE *Image, UBYTE *Image2) { UBYTE Temp = 0x00; UWORD Width, Height; Width = (EPD_1IN54_V3_WIDTH % 8 == 0)? (EPD_1IN54_V3_WIDTH / 8 ): (EPD_1IN54_V3_WIDTH / 8 + 1); Height = EPD_1IN54_V3_HEIGHT; UDOUBLE Addr = 0; EPD_1IN54_V3_SendCommand(0x10); for (UWORD j = 0; j < Height; j++) { for (UWORD i = 0; i < Width; i++) { Addr = i + j * Width; Temp = 0x00; for (int bit = 0; bit < 4; bit++) { if ((Image[Addr] & (0x80 >> bit)) != 0) { Temp |= 0xC0 >> (bit * 2); } } EPD_1IN54_V3_SendData(Temp); Temp = 0x00; for (int bit = 4; bit < 8; bit++) { if ((Image[Addr] & (0x80 >> bit)) != 0) { Temp |= 0xC0 >> ((bit - 4) * 2); } } EPD_1IN54_V3_SendData(Temp); } } EPD_1IN54_V3_TurnOnDisplay(); } /****************************************************************************** function : The image of the previous frame must be uploaded, otherwise the first few seconds will display an exception. parameter: ******************************************************************************/ void EPD_1IN54_V3_DisplayPartBaseImage(UBYTE *Image) { EPD_1IN54_V3_Display(Image, NULL); } /****************************************************************************** function : Sends the image buffer in RAM to e-Paper and displays parameter: ******************************************************************************/ void EPD_1IN54_V3_DisplayPart(UBYTE *Image) { EPD_1IN54_V3_Display(Image, NULL); } /****************************************************************************** function : Enter sleep mode parameter: ******************************************************************************/ void EPD_1IN54_V3_Sleep(void) { EPD_1IN54_V3_SendCommand(0x82); EPD_1IN54_V3_SendData(0x00); EPD_1IN54_V3_SendCommand(0x01); //power setting EPD_1IN54_V3_SendData(0x02); //gate switch to external EPD_1IN54_V3_SendData(0x00); EPD_1IN54_V3_SendData(0x00); EPD_1IN54_V3_SendData(0x00); DEV_Delay_ms(1500); EPD_1IN54_V3_SendCommand(0X02); //deep sleep DEV_Delay_ms(100); }
2e2b286be2d8a6154912727cfb900d2d70ce7e16
2d11442aa09b51e10c245ee2b64231aeb051744f
/platforms/unix/plugins/LocalePlugin/sqUnixLocale.c
5ad23dcd5a2182ba003fab5d4bed2d7f28a67f02
[ "MIT" ]
permissive
OpenSmalltalk/opensmalltalk-vm
622b01c10017a93fdff4f1ef2188c45342384c78
330d6779ad2ecbce1f07131f53d75cd168165f0b
refs/heads/Cog
2023-09-04T05:36:54.320281
2023-08-17T11:32:52
2023-08-31T12:26:44
59,481,716
556
153
NOASSERTION
2023-06-19T19:58:13
2016-05-23T12:40:27
C
ISO-8859-2
C
false
false
22,732
c
sqUnixLocale.c
/* sqUnixLocale.c -- support for POSIX locales * * Copyright (C) 1996-2005 by Ian Piumarta and other authors/contributors * listed elsewhere in this file. * All rights reserved. * * This file is part of Unix Squeak. * * 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. */ /* Author: Ian.Piumarta@inria.fr * * Last edited: 2008-11-10 13:25:18 by piumarta on ubuntu.piumarta.com */ #include "sq.h" #include "LocalePlugin.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <sys/time.h> #include <locale.h> #include <langinfo.h> #define CODELEN 2 /* 2 for ISO two-letter codes, 3 for UN three-letter codes */ #define DEFAULT_LOCALE "en_US.ISO8859-1" #if (CODELEN == 2) # define DEFAULT_COUNTRY "US" # define DEFAULT_LANGUAGE "en" #elif (CODELEN == 3) # define DEFAULT_COUNTRY "USA" # define DEFAULT_LANGUAGE "eng" #else # error -- CODELEN must be 2 or 3 #endif static const char *localeString= 0; static struct lconv *localeConv= 0; /*** SUNDRY STUPIDITY ***/ #if (CODELEN == 3) static struct CountryCode { const char *iso, *un; } countryCodes[] = { /* ISO UN COUNTRY */ { "AD", "AND" }, /* Andorra */ { "AE", "ARE" }, /* United Arab Emirates */ { "AF", "AFG" }, /* Afghanistan */ { "AG", "ATG" }, /* Antigua and Barbuda */ { "AI", "AIA" }, /* Anguilla */ { "AL", "ALB" }, /* Albania */ { "AM", "ARM" }, /* Armenia */ { "AN", "ANT" }, /* Netherlands Antilles */ { "AO", "AGO" }, /* Angola */ { "AQ", "ATA" }, /* Antarctica */ { "AR", "ARG" }, /* Argentina */ { "AS", "ASM" }, /* American Samoa */ { "AT", "AUT" }, /* Austria */ { "AU", "AUS" }, /* Australia */ { "AW", "ABW" }, /* Aruba */ { "AX", "ALA" }, /* Aland Islands */ { "AZ", "AZE" }, /* Azerbaijan */ { "BA", "BIH" }, /* Bosnia and Herzegovina */ { "BB", "BRB" }, /* Barbados */ { "BD", "BGD" }, /* Bangladesh */ { "BE", "BEL" }, /* Belgium */ { "BF", "BFA" }, /* Burkina Faso */ { "BG", "BGR" }, /* Bulgaria */ { "BH", "BHR" }, /* Bahrain */ { "BI", "BDI" }, /* Burundi */ { "BJ", "BEN" }, /* Benin */ { "BM", "BMU" }, /* Bermuda */ { "BN", "BRN" }, /* Brunei Darussalam */ { "BO", "BOL" }, /* Bolivia */ { "BR", "BRA" }, /* Brazil */ { "BS", "BHS" }, /* Bahamas */ { "BT", "BTN" }, /* Bhutan */ { "BV", "BVT" }, /* Bouvet Island */ { "BW", "BWA" }, /* Botswana */ { "BY", "BLR" }, /* Belarus */ { "BZ", "BLZ" }, /* Belize */ { "CA", "CAN" }, /* Canada */ { "CC", "CCK" }, /* Cocos (Keeling) Islands */ { "CD", "COD" }, /* Congo, Democratic Republic of the */ { "CF", "CAF" }, /* Central African Republic */ { "CG", "COG" }, /* Congo, Republic of the */ { "CH", "CHE" }, /* Switzerland */ { "CI", "CIV" }, /* Cote D'Ivoire */ { "CK", "COK" }, /* Cook Islands */ { "CL", "CHL" }, /* Chile */ { "CM", "CMR" }, /* Cameroon */ { "CN", "CHN" }, /* China */ { "CO", "COL" }, /* Colombia */ { "CR", "CRI" }, /* Costa Rica */ { "CS", "SCG" }, /* Serbia and Montenegro */ { "CU", "CUB" }, /* Cuba */ { "CV", "CPV" }, /* Cape Verde */ { "CX", "CXR" }, /* Christmas Island */ { "CY", "CYP" }, /* Cyprus */ { "CZ", "CZE" }, /* Czech Republic */ { "DE", "DEU" }, /* Germany */ { "DJ", "DJI" }, /* Djibouti */ { "DK", "DNK" }, /* Denmark */ { "DM", "DMA" }, /* Dominica */ { "DO", "DOM" }, /* Dominican Republic */ { "DZ", "DZA" }, /* Algeria */ { "EC", "ECU" }, /* Ecuador */ { "EE", "EST" }, /* Estonia */ { "EG", "EGY" }, /* Egypt */ { "EH", "ESH" }, /* Western Sahara */ { "ER", "ERI" }, /* Eritrea */ { "ES", "ESP" }, /* Spain */ { "ET", "ETH" }, /* Ethiopia */ { "FI", "FIN" }, /* Finland */ { "FJ", "FJI" }, /* Fiji */ { "FK", "FLK" }, /* Falkland Islands (Islas Malvinas) */ { "FM", "FSM" }, /* Micronesia, Federated States of */ { "FO", "FRO" }, /* Faroe Islands */ { "FR", "FRA" }, /* France */ { "FX", "FXX" }, /* France, Metropolitan */ { "GA", "GAB" }, /* Gabon */ { "GB", "GBR" }, /* United Kingdom */ { "GD", "GRD" }, /* Grenada */ { "GE", "GEO" }, /* Georgia */ { "GF", "GUF" }, /* French Guiana */ { "GH", "GHA" }, /* Ghana */ { "GI", "GIB" }, /* Gibraltar */ { "GL", "GRL" }, /* Greenland */ { "GM", "GMB" }, /* Gambia */ { "GN", "GIN" }, /* Guinea */ { "GP", "GLP" }, /* Guadeloupe */ { "GQ", "GNQ" }, /* Equatorial Guinea */ { "GR", "GRC" }, /* Greece */ { "GS", "SGS" }, /* South Georgia and the South Sandwich Islands */ { "GT", "GTM" }, /* Guatemala */ { "GU", "GUM" }, /* Guam */ { "GW", "GNB" }, /* Guinea-Bissau */ { "GY", "GUY" }, /* Guyana */ { "HK", "HKG" }, /* Hong Kong */ { "HM", "HMD" }, /* Heard Island and McDonald Islands */ { "HN", "HND" }, /* Honduras */ { "HR", "HRV" }, /* Croatia */ { "HT", "HTI" }, /* Haiti */ { "HU", "HUN" }, /* Hungary */ { "ID", "IDN" }, /* Indonesia */ { "IE", "IRL" }, /* Ireland */ { "IL", "ISR" }, /* Israel */ { "IN", "IND" }, /* India */ { "IO", "IOT" }, /* British Indian Ocean Territory */ { "IQ", "IRQ" }, /* Iraq */ { "IR", "IRN" }, /* Iran */ { "IS", "ISL" }, /* Iceland */ { "IT", "ITA" }, /* Italy */ { "JM", "JAM" }, /* Jamaica */ { "JO", "JOR" }, /* Jordan */ { "JP", "JPN" }, /* Japan */ { "KE", "KEN" }, /* Kenya */ { "KG", "KGZ" }, /* Kyrgyzstan */ { "KH", "KHM" }, /* Cambodia */ { "KI", "KIR" }, /* Kiribati */ { "KM", "COM" }, /* Comoros */ { "KN", "KNA" }, /* Saint Kitts and Nevis */ { "KP", "PRK" }, /* North Korea */ { "KR", "KOR" }, /* South Korea */ { "KW", "KWT" }, /* Kuwait */ { "KY", "CYM" }, /* Cayman Islands */ { "KZ", "KAZ" }, /* Kazakstan */ { "LA", "LAO" }, /* Lao People's Democratic Republic */ { "LB", "LBN" }, /* Lebanon */ { "LC", "LCA" }, /* Saint Lucia */ { "LI", "LIE" }, /* Liechtenstein */ { "LK", "LKA" }, /* Sri Lanka */ { "LR", "LBR" }, /* Liberia */ { "LS", "LSO" }, /* Lesotho */ { "LT", "LTU" }, /* Lithuania */ { "LU", "LUX" }, /* Luxembourg */ { "LV", "LVA" }, /* Latvia */ { "LY", "LBY" }, /* Libya */ { "MA", "MAR" }, /* Morocco */ { "MC", "MCO" }, /* Monaco */ { "MD", "MDA" }, /* Moldova */ { "MG", "MDG" }, /* Madagascar */ { "MH", "MHL" }, /* Marshall Islands */ { "MK", "MKD" }, /* Macedonia */ { "ML", "MLI" }, /* Mali */ { "MM", "MMR" }, /* Burma */ { "MN", "MNG" }, /* Mongolia */ { "MO", "MAC" }, /* Macau */ { "MP", "MNP" }, /* Northern Mariana Islands */ { "MQ", "MTQ" }, /* Martinique */ { "MR", "MRT" }, /* Mauritania */ { "MS", "MSR" }, /* Montserrat */ { "MT", "MLT" }, /* Malta */ { "MU", "MUS" }, /* Mauritius */ { "MV", "MDV" }, /* Maldives */ { "MW", "MWI" }, /* Malawi */ { "MX", "MEX" }, /* Mexico */ { "MY", "MYS" }, /* Malaysia */ { "MZ", "MOZ" }, /* Mozambique */ { "NA", "NAM" }, /* Namibia */ { "NC", "NCL" }, /* New Caledonia */ { "NE", "NER" }, /* Niger */ { "NF", "NFK" }, /* Norfolk Island */ { "NG", "NGA" }, /* Nigeria */ { "NI", "NIC" }, /* Nicaragua */ { "NL", "NLD" }, /* Netherlands */ { "NO", "NOR" }, /* Norway */ { "NP", "NPL" }, /* Nepal */ { "NR", "NRU" }, /* Nauru */ { "NU", "NIU" }, /* Niue */ { "NZ", "NZL" }, /* New Zealand */ { "OM", "OMN" }, /* Oman */ { "PA", "PAN" }, /* Panama */ { "PE", "PER" }, /* Peru */ { "PF", "PYF" }, /* French Polynesia */ { "PG", "PNG" }, /* Papua New Guinea */ { "PH", "PHL" }, /* Philippines */ { "PK", "PAK" }, /* Pakistan */ { "PL", "POL" }, /* Poland */ { "PM", "SPM" }, /* Saint Pierre and Miquelon */ { "PN", "PCN" }, /* Pitcairn Island */ { "PR", "PRI" }, /* Puerto Rico */ { "PS", "PSE" }, /* Palestinian Territory, Occupied */ { "PT", "PRT" }, /* Portugal */ { "PW", "PLW" }, /* Palau */ { "PY", "PRY" }, /* Paraguay */ { "QA", "QAT" }, /* Qatar */ { "RE", "REU" }, /* Reunion */ { "RO", "ROU" }, /* Romania */ { "RU", "RUS" }, /* Russia */ { "RW", "RWA" }, /* Rwanda */ { "SA", "SAU" }, /* Saudi Arabia */ { "SB", "SLB" }, /* Solomon Islands */ { "SC", "SYC" }, /* Seychelles */ { "SD", "SDN" }, /* Sudan */ { "SE", "SWE" }, /* Sweden */ { "SG", "SGP" }, /* Singapore */ { "SH", "SHN" }, /* Saint Helena */ { "SI", "SVN" }, /* Slovenia */ { "SJ", "SJM" }, /* Svalbard */ { "SK", "SVK" }, /* Slovakia */ { "SL", "SLE" }, /* Sierra Leone */ { "SM", "SMR" }, /* San Marino */ { "SN", "SEN" }, /* Senegal */ { "SO", "SOM" }, /* Somalia */ { "SR", "SUR" }, /* Suriname */ { "ST", "STP" }, /* Sao Tome and Principe */ { "SV", "SLV" }, /* El Salvador */ { "SY", "SYR" }, /* Syria */ { "SZ", "SWZ" }, /* Swaziland */ { "TC", "TCA" }, /* Turks and Caicos Islands */ { "TD", "TCD" }, /* Chad */ { "TF", "ATF" }, /* French Southern and Antarctic Lands */ { "TG", "TGO" }, /* Togo */ { "TH", "THA" }, /* Thailand */ { "TJ", "TJK" }, /* Tajikistan */ { "TK", "TKL" }, /* Tokelau */ { "TM", "TKM" }, /* Turkmenistan */ { "TN", "TUN" }, /* Tunisia */ { "TO", "TON" }, /* Tonga */ { "TL", "TLS" }, /* East Timor */ { "TR", "TUR" }, /* Turkey */ { "TT", "TTO" }, /* Trinidad and Tobago */ { "TV", "TUV" }, /* Tuvalu */ { "TW", "TWN" }, /* Taiwan */ { "TZ", "TZA" }, /* Tanzania */ { "UA", "UKR" }, /* Ukraine */ { "UG", "UGA" }, /* Uganda */ { "UM", "UMI" }, /* United States Minor Outlying Islands */ { "US", "USA" }, /* United States of America */ { "UY", "URY" }, /* Uruguay */ { "UZ", "UZB" }, /* Uzbekistan */ { "VA", "VAT" }, /* Holy See (Vatican City) */ { "VC", "VCT" }, /* Saint Vincent and the Grenadines */ { "VE", "VEN" }, /* Venezuela */ { "VG", "VGB" }, /* British Virgin Islands */ { "VI", "VIR" }, /* Virgin Islands, U.S. */ { "VN", "VNM" }, /* Vietnam */ { "VU", "VUT" }, /* Vanuatu */ { "WF", "WLF" }, /* Wallis and Futuna */ { "WS", "WSM" }, /* Samoa */ { "YE", "YEM" }, /* Yemen */ { "YT", "MYT" }, /* Mayotte */ { "ZA", "ZAF" }, /* South Africa */ { "ZM", "ZMB" }, /* Zambia */ { "ZW", "ZWE" }, /* Zimbabwe */ { 0, 0 } }; static struct LanguageCode { const char *iso, *un; } languageCodes[] = { /* ISO UN LANGUAGE */ { "ab", "abk" }, /* Abkhazian */ { "aa", "aar" }, /* Afar */ { "af", "afr" }, /* Afrikaans */ { "sq", "alb" }, /* Albanian */ { "sq", "sqi" }, /* Albanian */ { "am", "amh" }, /* Amharic */ { "ar", "ara" }, /* Arabic */ { "hy", "arm" }, /* Armenian */ { "hy", "hye" }, /* Armenian */ { "as", "asm" }, /* Assamese */ { "ay", "aym" }, /* Aymara */ { "az", "aze" }, /* Azerbaijani */ { "ba", "bak" }, /* Bashkir */ { "eu", "baq" }, /* Basque */ { "eu", "eus" }, /* Basque */ { "bn", "ben" }, /* Bengali */ { "bh", "bih" }, /* Bihari */ { "bi", "bis" }, /* Bislama */ { "be", "bre" }, /* Breton */ { "bg", "bul" }, /* Bulgarian */ { "my", "bur" }, /* Burmese */ { "my", "mya" }, /* Burmese */ { "be", "bel" }, /* Byelorussian */ { "ca", "cat" }, /* Catalan */ { "zh", "chi" }, /* Chinese */ { "zh", "zho" }, /* Chinese */ { "co", "cos" }, /* Corsican */ { "cs", "ces" }, /* Czech */ { "cs", "cze" }, /* Czech */ { "da", "dan" }, /* Danish */ { "nl", "dut" }, /* Dutch */ { "nl", "nla" }, /* Dutch */ { "dz", "dzo" }, /* Dzongkha */ { "en", "eng" }, /* English */ { "eo", "epo" }, /* Esperanto */ { "et", "est" }, /* Estonian */ { "fo", "fao" }, /* Faroese */ { "fj", "fij" }, /* Fijian */ { "fi", "fin" }, /* Finnish */ { "fr", "fra" }, /* French */ { "fr", "fre" }, /* French */ { "fy", "fry" }, /* Frisian */ { "gl", "glg" }, /* Gallegan */ { "ka", "geo" }, /* Georgian */ { "ka", "kat" }, /* Georgian */ { "de", "deu" }, /* German */ { "de", "ger" }, /* German */ { "el", "ell" }, /* Greek, Modern (1453-) */ { "el", "gre" }, /* Greek, Modern (1453-) */ { "kl", "kal" }, /* Greenlandic */ { "gn", "grn" }, /* Guarani */ { "gu", "guj" }, /* Gujarati */ { "ha", "hau" }, /* Hausa */ { "he", "heb" }, /* Hebrew */ { "hi", "hin" }, /* Hindi */ { "hu", "hun" }, /* Hungarian */ { "is", "ice" }, /* Icelandic */ { "is", "isl" }, /* Icelandic */ { "id", "ind" }, /* Indonesian */ { "ia", "ina" }, /* Interlingua (International Auxiliary language Association) */ { "iu", "iku" }, /* Inuktitut */ { "ik", "ipk" }, /* Inupiak */ { "ga", "gai" }, /* Irish */ { "ga", "iri" }, /* Irish */ { "it", "ita" }, /* Italian */ { "ja", "jpn" }, /* Japanese */ { "jv", "jav" }, /* Javanese */ { "jw", "jaw" }, /* Javanese */ { "kn", "kan" }, /* Kannada */ { "ks", "kas" }, /* Kashmiri */ { "kk", "kaz" }, /* Kazakh */ { "km", "khm" }, /* Khmer */ { "rw", "kin" }, /* Kinyarwanda */ { "ky", "kir" }, /* Kirghiz */ { "ko", "kor" }, /* Korean */ { "ku", "kur" }, /* Kurdish */ { "oc", "oci" }, /* Langue d'Oc (post 1500) */ { "lo", "lao" }, /* Lao */ { "la", "lat" }, /* Latin */ { "lv", "lav" }, /* Latvian */ { "ln", "lin" }, /* Lingala */ { "lt", "lit" }, /* Lithuanian */ { "mk", "mac" }, /* Macedonian */ { "mk", "mak" }, /* Macedonian */ { "mg", "mlg" }, /* Malagasy */ { "ms", "may" }, /* Malay */ { "ms", "msa" }, /* Malay */ { "ml", "mlt" }, /* Maltese */ { "mi", "mao" }, /* Maori */ { "mi", "mri" }, /* Maori */ { "mr", "mar" }, /* Marathi */ { "mo", "mol" }, /* Moldavian */ { "mn", "mon" }, /* Mongolian */ { "na", "nau" }, /* Nauru */ { "ne", "nep" }, /* Nepali */ { "no", "nor" }, /* Norwegian */ { "or", "ori" }, /* Oriya */ { "om", "orm" }, /* Oromo */ { "pa", "pan" }, /* Panjabi */ { "fa", "fas" }, /* Persian */ { "fa", "per" }, /* Persian */ { "pl", "pol" }, /* Polish */ { "pt", "por" }, /* Portuguese */ { "ps", "pus" }, /* Pushto */ { "qu", "que" }, /* Quechua */ { "rm", "roh" }, /* Rhaeto-Romance */ { "ro", "ron" }, /* Romanian */ { "ro", "rum" }, /* Romanian */ { "rn", "run" }, /* Rundi */ { "ru", "rus" }, /* Russian */ { "sm", "smo" }, /* Samoan */ { "sg", "sag" }, /* Sango */ { "sa", "san" }, /* Sanskrit */ { "sh", "scr" }, /* Serbo-Croatian */ { "sn", "sna" }, /* Shona */ { "sd", "snd" }, /* Sindhi */ { "si", "sin" }, /* Singhalese */ { "ss", "ssw" }, /* Siswant */ { "sk", "slk" }, /* Slovak */ { "sk", "slo" }, /* Slovak */ { "sl", "slv" }, /* Slovenian */ { "so", "som" }, /* Somali */ { "st", "sot" }, /* Sotho, Southern */ { "es", "esl" }, /* Spanish */ { "es", "spa" }, /* Spanish */ { "su", "sun" }, /* Sudanese */ { "sw", "swa" }, /* Swahili */ { "sv", "sve" }, /* Swedish */ { "sv", "swe" }, /* Swedish */ { "tl", "tgl" }, /* Tagalog */ { "tg", "tgk" }, /* Tajik */ { "ta", "tam" }, /* Tamil */ { "tt", "tat" }, /* Tatar */ { "te", "tel" }, /* Telugu */ { "th", "tha" }, /* Thai */ { "bo", "bod" }, /* Tibetan */ { "bo", "tib" }, /* Tibetan */ { "ti", "tir" }, /* Tigrinya */ { "to", "tog" }, /* Tonga (Nyasa) */ { "ts", "tso" }, /* Tsonga */ { "tn", "tsn" }, /* Tswana */ { "tr", "tur" }, /* Turkish */ { "tk", "tuk" }, /* Turkmen */ { "tw", "twi" }, /* Twi */ { "ug", "uig" }, /* Uighur */ { "uk", "ukr" }, /* Ukrainian */ { "ur", "urd" }, /* Urdu */ { "uz", "uzb" }, /* Uzbek */ { "vi", "vie" }, /* Vietnamese */ { "vo", "vol" }, /* Volapük */ { "cy", "cym" }, /* Welsh */ { "cy", "wel" }, /* Welsh */ { "wo", "wol" }, /* Wolof */ { "xh", "xho" }, /* Xhosa */ { "yi", "yid" }, /* Yiddish */ { "yo", "yor" }, /* Yoruba */ { "za", "zha" }, /* Zhuang */ { "zu", "zul" }, /* Zulu */ { 0, 0 } }; #endif /* CODELEN == 3 */ /* Answer a canonical, sanitised locale string. */ static const char *getlocale(void) { const char *locale= 0; /* Use LC_ALL or LANG or current OS locale or some suitable default, in that order. Convert "C" and POSIX locales to the default, along with anything else that seems malformed. */ if (( !(locale= getenv("LC_ALL"))) && (!(locale= getenv("LANG"))) && (!(locale= setlocale(LC_ALL, 0)))) return DEFAULT_LOCALE; else if ((!strcmp(locale, "C")) || (!strcmp(locale, "POSIX")) || strchr(locale, ' ') || strchr(locale, '/')) return DEFAULT_LOCALE; return locale; } /* Answer the 2- or 3-letter country code CC within one of: * _CC * _CC.PP * ll_CC * ll_CC.PP */ static const char *getCountry(void) { static const char *country= 0; if (!country) { static char buf[4]= { 0, 0, 0, 0 }; const char *l, *r; if ((l= strrchr(localeString, '_'))) { ++l; if (!(r= strchr(l, '.'))) r= strchr(l, '\0'); # if (CODELEN == 2) if (r - l == 2) { strncpy(buf, l, 2); country= buf; } # else /* CODELEN == 3 */ if (r - l == 3) { strncpy(buf, l, 3); country= buf; } else if (r - l == 2) { struct CountryCode *cc= countryCodes; strncpy(buf, l, 2); while ((!country) && cc->iso) if (!strcasecmp(cc->iso, buf)) country= cc->un; else ++cc; } # endif /* CODELEN == 3 */ } if (!country) country= DEFAULT_COUNTRY; } return country; } /* Answer the 2- or 3-letter language code ll within one of: * ll * ll.PP * ll_CC * ll_CC.PP */ static const char *getLanguage(void) { static const char *language= 0; if (!language) { static char buf[4]= { 0, 0, 0, 0 }; if (isalpha(localeString[0]) && isalpha(localeString[1]) && ((localeString[2] == '.') || (localeString[2] == '_') || !localeString[2])) { strncpy(buf, localeString, 2); # if (CODELEN == 2) language= buf; # elif (CODELEN == 3) { struct LanguageCode *lc= languageCodes; while ((!language) && lc->iso) if (!strcasecmp(lc->iso, buf)) language= lc->un; else ++lc; } # endif /* CODELEN == 3 */ } if (!language) language= DEFAULT_LANGUAGE; } return language; } /* CURRENCY */ /* Answer true if the currency symbol is to be placed in front of the * currency value */ sqInt sqLocCurrencyNotation(void) { return localeConv->p_cs_precedes; } /* For Cog do *not* copy the trailing null since the VM checks for attempts to * overwrite the end of an object, and copying the trailing null into a string * does precisely this. */ #define safestrcpy(str,source) do { \ const char *src = (source); \ int len = strlen(src); \ strncpy(str,src,len); \ } while (0) /* Store the currency symbol into the given string. */ void sqLocGetCurrencySymbolInto(char *str) { safestrcpy(str, localeConv->currency_symbol); } sqInt sqLocCurrencySymbolSize(void) { return strlen(localeConv->currency_symbol); } /* NUMBERS AND MEASUREMENTS */ /* Answer true if the metric measurements system is to be used. */ sqInt sqLocMeasurementMetric(void) { return 1; } /* Store the seperator for thousands into the given string. */ void sqLocGetDigitGroupingSymbolInto(char *str) { safestrcpy(str, localeConv->thousands_sep); } /* Store the decimal point into the given string. */ void sqLocGetDecimalSymbolInto(char *str) { safestrcpy(str, localeConv->decimal_point); } /* TIME AND DATE */ /* Answer the offset between local time and VM time. (Despite the * function name, this is how it is used.) */ sqInt sqLocGetVMOffsetToUTC(void) { return 0; } /* Answer the offset to (number of minutes EAST of) GMT. */ sqInt sqLocGetTimezoneOffset(void) { /* Match the behaviour of convertToSqueakTime(). */ #ifdef HAVE_TM_GMTOFF time_t now= time(0); return localtime(&now)->tm_gmtoff / 60; #else # ifdef HAVE_TIMEZONE extern long timezone; extern int daylight; return daylight * 60 - timezone / 60; # else # error: cannot determine timezone correction # endif #endif } /* Answer true if DST is in use. */ sqInt sqLocDaylightSavings(void) { time_t now= time(0); return localtime(&now)->tm_isdst > 0; } /* Answer the number of characters in the long date format. */ sqInt sqLocLongDateFormatSize(void) { return strlen(nl_langinfo(D_FMT)); } /* Store the long date format into the given string. */ void sqLocGetLongDateFormatInto(char *str) { safestrcpy(str, nl_langinfo(D_FMT)); } /* Answer the number of characters in the short date format. */ sqInt sqLocShortDateFormatSize(void) { return strlen(nl_langinfo(D_FMT)); } /* Store the short date format into the given string. */ void sqLocGetShortDateFormatInto(char *str) { safestrcpy(str, nl_langinfo(D_FMT)); } /* Answer the number of characters in the time format. */ sqInt sqLocTimeFormatSize(void) { return strlen(nl_langinfo(T_FMT)); } /* Store the time format into the given string. */ void sqLocGetTimeFormatInto(char *str) { safestrcpy(str, nl_langinfo(T_FMT)); } sqInt sqLocInitialize(void) { if (!(localeString= setlocale(LC_ALL, ""))) setlocale(LC_ALL, localeString= getlocale()); localeConv= localeconv(); return 1; } void sqLocGetCountryInto(char * str) { safestrcpy(str, getCountry()); } void sqLocGetLanguageInto(char * str) { safestrcpy(str, getLanguage()); }
d84cd4e9b58500eeb1c9363389bca522c877dab0
5ab69c8644a936a3d9dec1669a86c7369c911bf8
/os/services/ipso-objects/ipso-sensor-template.h
375dbad7cc2969cbb74275feb41cd3385f66be42
[ "BSD-3-Clause" ]
permissive
contiki-ng/contiki-ng
393d36f68b98f5ee3544ea32502cf662ffb2fe9f
31fcaadf7a0dc8ceea07f438cd69db73174879e6
refs/heads/develop
2023-09-01T20:10:30.000765
2023-09-01T14:37:12
2023-09-01T14:37:12
91,191,972
1,242
788
BSD-3-Clause
2023-09-14T19:08:35
2017-05-13T17:37:59
C
UTF-8
C
false
false
3,210
h
ipso-sensor-template.h
/* * Copyright (c) 2016, SICS Swedish ICT AB * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * \addtogroup ipso-objects * @{ * */ /** * \file * Implementation of OMA LWM2M / IPSO sensor template. * \author * Joakim Eriksson <joakime@sics.se> * Niclas Finne <nfi@sics.se> */ #ifndef IPSO_SENSOR_TEMPLATE_H_ #define IPSO_SENSOR_TEMPLATE_H_ #include "lwm2m-engine.h" typedef struct ipso_sensor ipso_sensor_t; typedef lwm2m_status_t (*ipso_sensor_get_value_millis_t)(const ipso_sensor_t *sensor, int32_t *v); /* Values of the IPSO object */ typedef struct ipso_sensor_value { lwm2m_object_instance_t reg_object; const ipso_sensor_t *sensor; uint8_t flags; int32_t last_value; int32_t min_value; int32_t max_value; } ipso_sensor_value_t; /* Meta data about an IPSO sensor object */ struct ipso_sensor { /* LWM2M object type */ uint16_t object_id; uint16_t instance_id; /* When we read out the value we send in a context to write to */ ipso_sensor_get_value_millis_t get_value_in_millis; int32_t min_range; int32_t max_range; char *unit; /* update interval in seconds */ uint16_t update_interval; ipso_sensor_value_t *sensor_value; }; #define IPSO_SENSOR(name, oid, get_value, ...) \ static ipso_sensor_value_t name##_value; \ static const ipso_sensor_t name = { \ .object_id = oid, \ .sensor_value = &name##_value, \ .get_value_in_millis = get_value, \ __VA_ARGS__ \ } int ipso_sensor_add(const ipso_sensor_t *sensor); int ipso_sensor_remove(const ipso_sensor_t *sensor); #endif /* IPSO_SENSOR_TEMPLATE_H_ */ /** @} */
24f1861c8eb3686c29f93794a7ff06bcb7c99864
2c73a693c2b3c162eae2ab94f649d8c4494878ba
/components/multimedia/amr_decode/amr_wb/dec/include/pvamrwbdecoder_basic_op_gcc_armv5.h
c2c9f365687e984ea26031854851705b0dc17c41
[ "MIT" ]
permissive
openLuat/LuatOS
185e1e140aed908434168133571ddcafe98f4e12
4b29d5121ab4f7133630331e8502c526c7856897
refs/heads/master
2023-08-23T04:57:23.263539
2023-08-23T04:46:46
2023-08-23T04:46:46
230,403,844
378
93
MIT
2021-12-17T02:19:30
2019-12-27T08:29:19
C
UTF-8
C
false
false
8,058
h
pvamrwbdecoder_basic_op_gcc_armv5.h
/* ------------------------------------------------------------------ * Copyright (C) 1998-2010 PacketVideo * * 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. * ------------------------------------------------------------------- */ /**************************************************************************************** Portions of this file are derived from the following 3GPP standard: 3GPP TS 26.173 ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec Available from http://www.3gpp.org (C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC) Permission to distribute, modify and use this file under the standard license terms listed above has been obtained from the copyright holder. ****************************************************************************************/ /* ------------------------------------------------------------------------------ Pathname: ./src/pvamrwbdecoder_basic_op_gcc_armv5.h ------------------------------------------------------------------------------ INCLUDE DESCRIPTION ------------------------------------------------------------------------------ */ #ifndef PVAMRWBDECODER_BASIC_OP_GCC_ARMV5_H #define PVAMRWBDECODER_BASIC_OP_GCC_ARMV5_H #ifdef __cplusplus extern "C" { #endif static inline int16 sub_int16(int16 var1, int16 var2) { register int32 L_var_out; register int32 L_var_aux; register int32 ra = (int32)var1; register int32 rb = (int32)var2; asm volatile( "mov %0, %2, lsl #16\n" "mov %1, %3, lsl #16\n" "qsub %0, %0, %1\n" "mov %0, %0, asr #16" : "=&r*i"(L_var_out), "=&r*i"(L_var_aux) : "r"(ra), "r"(rb)); return (int16)L_var_out; } static inline int16 add_int16(int16 var1, int16 var2) { register int32 L_var_out; register int32 L_var_aux; register int32 ra = (int32)var1; register int32 rb = (int32)var2; asm volatile( "mov %0, %2, lsl #16\n" "mov %1, %3, lsl #16\n" "qadd %0, %0, %1\n" "mov %0, %0, asr #16" : "=&r*i"(L_var_out), "=&r*i"(L_var_aux) : "r"(ra), "r"(rb)); return (int16)L_var_out; } static inline int32 mul_32by16(int16 hi, int16 lo, int16 n) { register int32 H_32; register int32 L_32; register int32 ra = (int32)hi; register int32 rb = (int32)lo; register int32 rc = (int32)n; asm volatile( "smulbb %0, %2, %4\n" "smulbb %1, %3, %4\n" "add %0, %0, %1, asr #15\n" "qadd %0, %0, %0" : "=&r*i"(H_32), "=&r*i"(L_32) : "r"(ra), "r"(rb), "r"(rc)); return H_32; } static inline int32 sub_int32(int32 L_var1, int32 L_var2) { register int32 L_var_out; register int32 ra = L_var1; register int32 rb = L_var2; asm volatile( "qsub %0, %1, %2" : "=&r*i"(L_var_out) : "r"(ra), "r"(rb)); return L_var_out; } static inline int32 add_int32(int32 L_var1, int32 L_var2) { register int32 L_var_out; register int32 ra = L_var1; register int32 rb = L_var2; asm volatile( "qadd %0, %1, %2" : "=&r*i"(L_var_out) : "r"(ra), "r"(rb)); return L_var_out; } static inline int32 msu_16by16_from_int32(int32 L_var3, int16 var1, int16 var2) { register int32 L_var_out; register int32 ra = (int32)var1; register int32 rb = (int32)var2; register int32 rc = L_var3; asm volatile( "smulbb %0, %1, %2\n" "qdsub %0, %3, %0" : "=&r*i"(L_var_out) : "r"(ra), "r"(rb), "r"(rc)); return L_var_out; } static inline int32 mac_16by16_to_int32(int32 L_var3, int16 var1, int16 var2) { register int32 L_var_out; register int32 ra = (int32)var1; register int32 rb = (int32)var2; register int32 rc = L_var3; asm volatile( "smulbb %0, %1, %2\n" "qdadd %0, %3, %0" : "=&r*i"(L_var_out) : "r"(ra), "r"(rb), "r"(rc)); return L_var_out; } static inline int32 mul_16by16_to_int32(int16 var1, int16 var2) { register int32 L_var_out; register int32 ra = (int32)var1; register int32 rb = (int32)var2; asm volatile( "smulbb %0, %1, %2\n" "qadd %0, %0, %0" : "=&r*i"(L_var_out) : "r"(ra), "r"(rb)); return L_var_out; } static inline int16 mult_int16(int16 var1, int16 var2) { register int32 L_var_out; register int32 ra = (int32)var1; register int32 rb = (int32)var2; asm volatile( "smulbb %0, %1, %2\n" "mov %0, %0, asr #15" : "=&r*i"(L_var_out) : "r"(ra), "r"(rb)); return (int16)L_var_out; } static inline int16 amr_wb_round(int32 L_var1) { register int32 L_var_out; register int32 ra = (int32)L_var1; register int32 rb = (int32)0x00008000L; asm volatile( "qadd %0, %1, %2\n" "mov %0, %0, asr #16" : "=&r*i"(L_var_out) : "r"(ra), "r"(rb)); return (int16)L_var_out; } static inline int16 amr_wb_shl1_round(int32 L_var1) { register int32 L_var_out; register int32 ra = (int32)L_var1; register int32 rb = (int32)0x00008000L; asm volatile( "qadd %0, %1, %1\n" "qadd %0, %0, %2\n" "mov %0, %0, asr #16" : "=&r*i"(L_var_out) : "r"(ra), "r"(rb)); return (int16)L_var_out; } static inline int32 fxp_mac_16by16(const int16 L_var1, const int16 L_var2, int32 L_add) { register int32 tmp; register int32 ra = (int32)L_var1; register int32 rb = (int32)L_var2; register int32 rc = (int32)L_add; asm volatile( "smlabb %0, %1, %2, %3" : "=&r*i"(tmp) : "r"(ra), "r"(rb), "r"(rc)); return (tmp); } static inline int32 fxp_mul_16by16bb(int16 L_var1, const int16 L_var2) { register int32 tmp; register int32 ra = (int32)L_var1; register int32 rb = (int32)L_var2; asm volatile( "smulbb %0, %1, %2" : "=&r*i"(tmp) : "r"(ra), "r"(rb)); return (tmp); } #define fxp_mul_16by16(a, b) fxp_mul_16by16bb( a, b) static inline int32 fxp_mul32_by_16(int32 L_var1, const int32 L_var2) { register int32 tmp; register int32 ra = (int32)L_var1; register int32 rb = (int32)L_var2; asm volatile( "smulwb %0, %1, %2" : "=&r*i"(tmp) : "r"(ra), "r"(rb)); return (tmp); } #define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b) #ifdef __cplusplus } #endif #endif /* PVAMRWBDECODER_BASIC_OP_GCC_ARMV5_H */
236d2c7afb4c599f3fa47ba58d735906b2eaf521
52c0949315583ba8898694cceacfaafaeab6f902
/third_party/libpg_query/src/postgres/include/catalog/pg_conversion.h
466c183c4b6789c4fd1a3cc1e0eadaba2d9971a7
[ "MIT", "BSD-3-Clause", "PostgreSQL", "LicenseRef-scancode-unknown-license-reference" ]
permissive
cmu-db/noisepage
97093adcc9474419e063fdd97a5aa7a7ea6f3150
79276e68fe83322f1249e8a8be96bd63c583ae56
refs/heads/master
2023-08-29T05:51:04.628704
2021-11-05T14:12:08
2021-11-05T14:12:08
140,325,970
1,245
287
MIT
2022-11-08T02:06:48
2018-07-09T18:22:34
C++
UTF-8
C
false
false
2,177
h
pg_conversion.h
/*------------------------------------------------------------------------- * * pg_conversion.h * definition of the system "conversion" relation (pg_conversion) * along with the relation's initial contents. * * * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/catalog/pg_conversion.h * * NOTES * the genbki.pl script reads this file and generates .bki * information from the DATA() statements. * *------------------------------------------------------------------------- */ #ifndef PG_CONVERSION_H #define PG_CONVERSION_H #include "catalog/genbki.h" /* ---------------------------------------------------------------- * pg_conversion definition. * * cpp turns this into typedef struct FormData_pg_namespace * * conname name of the conversion * connamespace name space which the conversion belongs to * conowner owner of the conversion * conforencoding FOR encoding id * contoencoding TO encoding id * conproc OID of the conversion proc * condefault TRUE if this is a default conversion * ---------------------------------------------------------------- */ #define ConversionRelationId 2607 CATALOG(pg_conversion,2607) { NameData conname; Oid connamespace; Oid conowner; int32 conforencoding; int32 contoencoding; regproc conproc; bool condefault; } FormData_pg_conversion; /* ---------------- * Form_pg_conversion corresponds to a pointer to a tuple with * the format of pg_conversion relation. * ---------------- */ typedef FormData_pg_conversion *Form_pg_conversion; /* ---------------- * compiler constants for pg_conversion * ---------------- */ #define Natts_pg_conversion 7 #define Anum_pg_conversion_conname 1 #define Anum_pg_conversion_connamespace 2 #define Anum_pg_conversion_conowner 3 #define Anum_pg_conversion_conforencoding 4 #define Anum_pg_conversion_contoencoding 5 #define Anum_pg_conversion_conproc 6 #define Anum_pg_conversion_condefault 7 /* ---------------- * initial contents of pg_conversion * --------------- */ #endif /* PG_CONVERSION_H */
e95c5a94e7e0c34128f09cd7c43ff0325cd41ae0
4e62733f42024b74809fe79d8e08110a5f001ec8
/TERZO ANNO/I SEMESTRE/Reti Informatiche/Progetti/Esempi/A.A.22-23 - Cremente/TavoloTrovato.c
b290097def1aadd0171b19adaa1f1c713e8726b5
[]
no_license
Guray00/IngegneriaInformatica
f8f56a310ac7585f105cbf1635240df2d7a43095
752ac634bb7f03556fd8587bf5f5a295843a76b9
refs/heads/master
2023-08-31T12:23:44.354698
2023-08-28T15:19:22
2023-08-28T15:19:22
234,406,145
233
80
null
2023-07-04T14:02:14
2020-01-16T20:31:24
C++
UTF-8
C
false
false
1,058
c
TavoloTrovato.c
#include "head.h" #include "TavoloTrovato.h" //alloca la memoria per un nuovo tavolo trovato e assegna i relativi parametri struct TavoloTrovato* new_tavolo_trovato(int p_id){ struct TavoloTrovato* ret = malloc(sizeof(struct TavoloTrovato)); ret->id = p_id; ret->next = NULL; return ret; } //libera la memoria relativa a un tavolo trovato void del_tavolo_trovato(struct TavoloTrovato* p_tavolo){ free(p_tavolo); } //inserisce un tavolo trovato in fondo alla lista di tavoli trovati void ins_tavolo_trovato(struct TavoloTrovato** p_head, struct TavoloTrovato* p_tavolo){ if(*p_head == NULL){ *p_head = p_tavolo; return; } struct TavoloTrovato* tmp = *p_head; while(tmp->next != NULL){ tmp = tmp->next; } tmp->next = p_tavolo; return; } void svuota_lista_tavoli_trovati(struct TavoloTrovato** p_head){ struct TavoloTrovato* tmp = NULL; while(*p_head != NULL){ tmp = *p_head; *p_head = (*p_head)->next; del_tavolo_trovato(tmp); } return; }
b904ee5ff49ca56580a2086d777c8da9b77dbeca
2308899071a849a199e3b70806b4dd1c396efc8a
/kitty_win.c
da6755e68b5ca012611cc9cb369a0e4feee34e8d
[ "MIT" ]
permissive
cyd01/KiTTY
b0b06d771508668ccbd6316474382b538a65bac0
0e5d8582aad192db96ba240444a6840fa82ccf05
refs/heads/master
2023-08-10T21:25:06.926589
2023-05-23T17:23:03
2023-05-23T17:56:00
154,540,955
1,451
147
NOASSERTION
2023-05-30T17:16:10
2018-10-24T17:26:24
C
UTF-8
C
false
false
16,063
c
kitty_win.c
#include "kitty_win.h" // Modifie la transparence void SetTransparency( HWND hwnd, int value ) { #ifndef MOD_NOTRANSPARENCY SetLayeredWindowAttributes( hwnd, 0, value, LWA_ALPHA ) ; #endif } // Numéro de version de l'OS void GetOSInfo( char * version ) { // ==> Deprecated with version >= Windows 8.1 OSVERSIONINFO osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osvi); sprintf( version, "%ld.%ld %ld %ld %s %dx%d", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber, osvi.dwPlatformId, osvi.szCSDVersion, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) ) ; } /* http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832%28v=vs.85%29.aspx Operating system Version number Windows 10 Insider Preview 10.0* Windows Server Technical Preview 10.0* Windows Server 2019 10.0* Windows Server 2016 10.0* Windows 8.1 6.3* Windows Server 2012 R2 6.3* Windows 8 6.2 Windows Server 2012 6.2 Windows 7 6.1 Windows Server 2008 R2 6.1 Windows Server 2008 6.0 Windows Vista 6.0 Windows Server 2003 R2 5.2 Windows Server 2003 5.2 Windows XP 64-Bit Edition 5.2 Windows XP 5.1 Windows 2000 5.0 */ /* https://msdn.microsoft.com/en-us/library/aa383745%28v=vs.85%29.aspx#faster_builds_with_smaller_header_files Minimum system required Minimum value for _WIN32_WINNT and WINVER Windows 8.1 _WIN32_WINNT_WINBLUE (0x0602) Windows 8 _WIN32_WINNT_WIN8 (0x0602) Windows 7 _WIN32_WINNT_WIN7 (0x0601) Windows Server 2008 _WIN32_WINNT_WS08 (0x0600) Windows Vista _WIN32_WINNT_VISTA (0x0600) Windows Server 2003 with SP1, Windows XP with SP2 _WIN32_WINNT_WS03 (0x0502) Windows Server 2003, Windows XP _WIN32_WINNT_WINXP (0x0501) Minimum version required Minimum value of _WIN32_IE Internet Explorer 10.0 _WIN32_IE_IE100 (0x0A00) Internet Explorer 9.0 _WIN32_IE_IE90 (0x0900) Internet Explorer 8.0 _WIN32_IE_IE80 (0x0800) Internet Explorer 7.0 _WIN32_IE_IE70 (0x0700) Internet Explorer 6.0 SP2 _WIN32_IE_IE60SP2 (0x0603) Internet Explorer 6.0 SP1 _WIN32_IE_IE60SP1 (0x0601) Internet Explorer 6.0 _WIN32_IE_IE60 (0x0600) Internet Explorer 5.5 _WIN32_IE_IE55 (0x0550) Internet Explorer 5.01 _WIN32_IE_IE501 (0x0501) Internet Explorer 5.0, 5.0a, 5.0b _WIN32_IE_IE50 (0x0500) */ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); LPFN_ISWOW64PROCESS fnIsWow64Process; BOOL IsWow64() { BOOL bIsWow64 = FALSE; //IsWow64Process is not available on all supported versions of Windows. //Use GetModuleHandle to get a handle to the DLL that contains the function //and GetProcAddress to get a pointer to the function if available. fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( GetModuleHandle(TEXT("kernel32")),"IsWow64Process"); if(NULL != fnIsWow64Process) { if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) { //handle error } } return bIsWow64 ; } int OpenFileName( HWND hFrame, char * filename, char * Title, char * Filter ) { char * szTitle = Title ; char szFilter[256] ; strcpy( szFilter, Filter ) ; // on remplace les caractères '|' par des caractères NULL. int i = 0; while(i < sizeof(szFilter) && szFilter[i] != '\0') { if(szFilter[i] == '|') szFilter[i] = '\0'; i++; } // boîte de dialogue de demande d'ouverture de fichier //char szFileName[_MAX_PATH + 1] = ""; char * szFileName = filename ; szFileName[0] = '\0' ; OPENFILENAME ofn = {0}; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hFrame; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFileName; //ofn.nMaxFile = sizeof(szFileName); ofn.nMaxFile = 4096 ; ofn.lpstrTitle = szTitle; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_EXTENSIONDIFFERENT | OFN_DONTADDTORECENT ; // si aucun nom de fichier n'a été sélectionné, on abandonne if(!GetOpenFileName(&ofn)) { return 0 ; } else { return 1 ; } } int SaveFileName( HWND hFrame, char * filename, char * Title, char * Filter ) { char * szTitle = Title ; char szFilter[256] ; strcpy( szFilter, Filter ) ; // on remplace les caractères '|' par des caractères NULL. int i = 0; while(i < sizeof(szFilter) && szFilter[i] != '\0') { if(szFilter[i] == '|') szFilter[i] = '\0'; i++; } // boîte de dialogue de demande d'ouverture de fichier //char szFileName[_MAX_PATH + 1] = ""; char * szFileName = filename ; szFileName[0] = '\0' ; OPENFILENAME ofn = {0}; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hFrame; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = szFileName; //ofn.nMaxFile = sizeof(szFileName); ofn.nMaxFile = 4096 ; ofn.lpstrTitle = szTitle; ofn.lpstrDefExt = ".ktx" ; ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_EXTENSIONDIFFERENT | OFN_DONTADDTORECENT ; // si aucun nom de fichier n'a été sélectionné, on abandonne if(!GetSaveFileName(&ofn)) { return 0 ; } else { return 1 ; } } #include <shlobj.h> int OpenDirName( HWND hFrame, char * dirname ) { BROWSEINFO bi ; ITEMIDLIST *il ; LPITEMIDLIST ol = NULL ; char Buffer[4096],Result[4096]="" ; dirname[0]='\0' ; strcpy( Buffer, getenv("ProgramFiles") ) ; //SHGetSpecialFolderLocation( hFrame, CSIDL_MYDOCUMENTS, &ol ); memset(&bi,0,sizeof(BROWSEINFO)); bi.hwndOwner = hFrame ; //bi.pidlRoot=NULL ; // bi.pidlRoot=ol ; bi.pszDisplayName=&Buffer[0]; bi.lpszTitle="Select a folder..."; bi.ulFlags=0; bi.lpfn=NULL; if ((il=SHBrowseForFolder(&bi))!=NULL) { SHGetPathFromIDList(il,&Result[0]) ; //ILFree( il ) ; ILFree( ol ) ; GlobalFree(il);GlobalFree(ol); if( strlen( Result ) == 0 ) return 0 ; strcpy( dirname, Result ) ; return 1 ; } //ILFree( ol ) ; GlobalFree(ol); return 0 ; } // Centre un dialog au milieu de la fenetre parent void CenterDlgInParent(HWND hDlg) { RECT rcDlg; HWND hParent; RECT rcParent; MONITORINFO mi; HMONITOR hMonitor; int xMin, yMin, xMax, yMax, x, y; GetWindowRect(hDlg,&rcDlg); hParent = GetParent(hDlg); GetWindowRect(hParent,&rcParent); hMonitor = MonitorFromRect(&rcParent,MONITOR_DEFAULTTONEAREST); mi.cbSize = sizeof(mi); GetMonitorInfo(hMonitor,&mi); xMin = mi.rcWork.left; yMin = mi.rcWork.top; xMax = (mi.rcWork.right) - (rcDlg.right - rcDlg.left); yMax = (mi.rcWork.bottom) - (rcDlg.bottom - rcDlg.top); if ((rcParent.right - rcParent.left) - (rcDlg.right - rcDlg.left) > 20) x = rcParent.left + (((rcParent.right - rcParent.left) - (rcDlg.right - rcDlg.left)) / 2); else x = rcParent.left + 70; if ((rcParent.bottom - rcParent.top) - (rcDlg.bottom - rcDlg.top) > 20) y = rcParent.top + (((rcParent.bottom - rcParent.top) - (rcDlg.bottom - rcDlg.top)) / 2); else y = rcParent.top + 60; SetWindowPos(hDlg,NULL,max(xMin,min(xMax,x)),max(yMin,min(yMax,y)),0,0,SWP_NOZORDER|SWP_NOSIZE); } // // Envoi vers l'imprimante // // Parametres de l'impression int PrintCharSize = 100 ; int PrintMaxLinePerPage = 60 ; int PrintMaxCharPerLine = 85 ; int PrintText( const char * Text ) { int return_code = 0 ; PRINTDLG pd; DOCINFO di; int i, TextLen = 0, Index1 = 0, Index2 = 2; //int Exit = 0 ; char* LinePrint = NULL ; char* szMessage = NULL ; if( Text == NULL ) return 1 ; if( strlen( Text ) == 0 ) return 1 ; memset (&pd, 0, sizeof(PRINTDLG)); memset (&di, 0, sizeof(DOCINFO)); di.cbSize = sizeof(DOCINFO); di.lpszDocName = "Test"; pd.lStructSize = sizeof(PRINTDLG); pd.Flags = PD_PAGENUMS | PD_RETURNDC; pd.nFromPage = 1; pd.nToPage = 1; pd.nMinPage = 1; pd.nMaxPage = 1; szMessage = 0; if( PrintDlg( &pd ) ) { if( pd.hDC ) { if (StartDoc (pd.hDC, &di) != SP_ERROR) { TextLen = strlen( Text ) ; if( TextLen > 0 ) { LinePrint = (char*) malloc( TextLen + 2 ) ; Index1 = 0 ; Index2 = 2 ; //Exit = 0 ; for( i = 0 ; i < TextLen ; i++ ) { if( Text[i]=='\r' ) i++; LinePrint[Index1] = Text[i] ; if( Text[i] == '\n' ) { Index2++ ; LinePrint[Index1] = '\0' ; TextOut(pd.hDC,100, Index2*PrintCharSize, LinePrint, strlen(LinePrint) ) ; Index1 = 0 ; } else if( Index1>=PrintMaxCharPerLine ) { Index2++ ; LinePrint[Index1+1] = '\0' ; TextOut(pd.hDC,100, Index2*PrintCharSize, LinePrint, strlen(LinePrint) ) ; Index1 = 0 ; } else { Index1++ ; } if( Index2 >= PrintMaxLinePerPage ) { EndPage( pd.hDC ) ; //EndDoc(pd.hDC) ; //StartDoc(pd.hDC, &di) ; StartPage( pd.hDC ) ; Index2 = 2 ; } } Index2++ ; LinePrint[Index1] = '\0'; // Impression de la dernière page TextOut(pd.hDC,100, Index2*PrintCharSize, LinePrint, strlen(LinePrint)) ; EndPage(pd.hDC) ; EndDoc(pd.hDC) ; szMessage = "Print successful"; free( LinePrint ) ; } else { return_code = 1 ; /* Chaine vide */ } } else { // Problème StartDoc szMessage = "ERROR Type 1" ; return_code = 2 ; } } else { // Probleme pd.hDC szMessage = "ERROR Type 2." ; return_code = 3 ; } } else { // Problème PrintDlg //szMessage = "Impression annulée par l'utilisateur" ; return_code = 4 ; } if (szMessage) { MessageBox (NULL, szMessage, "Print report", MB_OK) ; } return return_code ; } // Impression du texte dans le bloc-notes void ManagePrint( HWND hwnd ) { char *pst = NULL ; if( OpenClipboard(NULL) ) { HGLOBAL hglb ; if( (hglb = GetClipboardData( CF_TEXT ) ) != NULL ) { if( ( pst = GlobalLock( hglb ) ) != NULL ) { PrintText( pst ) ; GlobalUnlock( hglb ) ; } } CloseClipboard(); } } // Met un texte dans le press-papier int SetTextToClipboard( const char * buf ) { HGLOBAL hglbCopy ; LPTSTR lptstrCopy ; if( !IsClipboardFormatAvailable(CF_TEXT) ) return 0 ; if( !OpenClipboard(NULL) ) return 0 ; EmptyClipboard() ; if( (hglbCopy= GlobalAlloc(GMEM_MOVEABLE, (strlen(buf)+1) * sizeof(TCHAR)) ) == NULL ) { CloseClipboard() ; return 0 ; } lptstrCopy = GlobalLock( hglbCopy ) ; memcpy( lptstrCopy, buf, (strlen(buf)+1) * sizeof(TCHAR) ) ; GlobalUnlock( hglbCopy ) ; if( SetClipboardData(CF_TEXT, hglbCopy) == NULL ) { CloseClipboard() ; return 0 ; } CloseClipboard() ; return 1 ; } // Execute une commande void RunCommand( HWND hwnd, const char * cmd ) { PROCESS_INFORMATION ProcessInformation ; ZeroMemory( &ProcessInformation, sizeof(ProcessInformation) ); STARTUPINFO StartUpInfo ; ZeroMemory( &StartUpInfo, sizeof(StartUpInfo) ); StartUpInfo.cb=sizeof(STARTUPINFO); StartUpInfo.lpReserved=0; StartUpInfo.lpDesktop=0; StartUpInfo.lpTitle=0; StartUpInfo.dwX=0; StartUpInfo.dwY=0; StartUpInfo.dwXSize=0; StartUpInfo.dwYSize=0; StartUpInfo.dwXCountChars=0; StartUpInfo.dwYCountChars=0; StartUpInfo.dwFillAttribute=0; StartUpInfo.dwFlags=0; StartUpInfo.wShowWindow=0; StartUpInfo.cbReserved2=0; StartUpInfo.lpReserved2=0; StartUpInfo.hStdInput=0; StartUpInfo.hStdOutput=0; StartUpInfo.hStdError=0; //MessageBox(hwnd,cmd,"Info",MB_OK); if( !CreateProcess(NULL,(CHAR*)cmd,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&StartUpInfo,&ProcessInformation) ) { ShellExecute(hwnd, "open", cmd ,0 , 0, SW_SHOWDEFAULT); } else { WaitForInputIdle(ProcessInformation.hProcess, INFINITE ); CloseHandle( &StartUpInfo ); CloseHandle( &ProcessInformation ); } } void RunPuttyEd( HWND hwnd, char * filename ) { char buffer[1024]="", shortname[1024]="" ; if( GetModuleFileName( NULL, (LPTSTR)buffer, 1023 ) ) if( GetShortPathName( buffer, shortname, 1023 ) ) { strcat( shortname, " -ed" ); if( filename!=NULL ) if( strlen(filename)>0 ) { strcat( shortname, "b " ) ; strcat( shortname, filename ) ; } debug_logevent( shortname ) ; RunCommand( hwnd, shortname ) ; } } // Verifie si une mise a jour est disponible sur le site web extern char BuildVersionTime[256] ; void CheckVersionFromWebSite( HWND hwnd ) { char buffer[1024]="", vers[1024]="" ; int i ; strcpy( vers, BuildVersionTime ) ; for( i = 0 ; i < strlen( vers ) ; i ++ ) { if( !(((vers[i]>='0')&&(vers[i]<='9'))||(vers[i]=='.')) ) { vers[i] = '\0' ; break ; } } sprintf( buffer, "http://www.9bis.net/kitty/check_update.php?version=%s", vers ) ; ShellExecute(hwnd, "open", buffer, 0, 0, SW_SHOWDEFAULT); } // Affichage d'un message dans l'event log void debug_logevent( const char *fmt, ... ) { va_list ap; char *buf; va_start(ap, fmt); buf = dupvprintf(fmt, ap) ; va_end(ap); do_eventlog(buf) ; free(buf); } // Test si un chemin est absolu bool IsPathAbsolute( const char * path ) { bool test = false ; if( path == NULL ) { return false ; } if( strlen( path ) < 3 ) { return false ; } if( ((path[0]>='a') && (path[0]<='z')) || ((path[0]>='A') && (path[0]<='Z')) ) if( path[1]==':' ) if( (path[2]=='/') || (path[2]=='\\') ) test = true ; return test ; } void PopUpSystemMenu( HWND hwnd, int npos ) { RECT rc ; GetWindowRect( hwnd, &rc ) ; HMENU m = GetSystemMenu( hwnd, FALSE) ; TrackPopupMenu( m, 0, rc.left, rc.top, 0, hwnd, NULL) ; if( npos>0 ) { int nb = GetMenuItemCount(m), i; MENUITEMINFO mi ; mi.cbSize = sizeof(MENUITEMINFO) ; for( i=0; i<nb; i++ ) { mi.dwTypeData = NULL ; GetMenuItemInfoA( m, i, TRUE, &mi); char *txt = (char*)malloc(mi.cch+1); mi.dwTypeData = txt ; mi.cch= mi.cch+1; GetMenuItemInfoA( m, i, FALSE, &mi); MessageBox(NULL,txt,"info",MB_OK); free(txt); } } } // Description: // Creates a tooltip for an item in a dialog box. // Parameters: // idTool - identifier of an dialog box item. // nDlg - window handle of the dialog box. // pszText - string to use as the tooltip text. // Returns: // The handle to the tooltip. // HWND CreateToolTip(int toolID, HWND hDlg, PTSTR pszText) { if (!toolID || !hDlg || !pszText) { return FALSE; } // Get the window of the tool. HWND hwndTool = GetDlgItem(hDlg, toolID); // Create the tooltip. g_hInst is the global instance handle. HWND hwndTip = CreateWindowEx((DWORD)NULL, TOOLTIPS_CLASS, NULL, WS_POPUP |TTS_ALWAYSTIP | TTS_BALLOON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hDlg, NULL, hinst /*g_hInst*/, NULL); if (!hwndTool || !hwndTip) { return (HWND)NULL; } // Associate the tooltip with the tool. TOOLINFO toolInfo = { 0 }; toolInfo.cbSize = sizeof(toolInfo); toolInfo.hwnd = hDlg; toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; toolInfo.uId = (UINT_PTR)hwndTool; toolInfo.lpszText = pszText; SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo); return hwndTip; } /* HWND CreateToolTip2(int toolID, HWND hDlg, PTSTR pszText) { HWND hwndToolTips = CreateWindow(TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_BALLOON, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); if (hwndToolTips) { TOOLINFO ti; ti.cbSize = sizeof(ti); ti.uFlags = TTF_TRANSPARENT | TTF_CENTERTIP; ti.hwnd = hDlg; ti.uId = toolID; ti.hinst = NULL; ti.lpszText = pszText; GetClientRect(hwnd, &ti.rect); SendMessage(hwndToolTips, TTM_ADDTOOL, 0, (LPARAM) &ti ); } return hwndToolTips ; } */
d2c11d05fae4b4e4c7b8b93f6fed05adadfcb0dd
908814829c9c568ae9994c49c372af9151e91576
/arch/avr/src/common/up_assert.c
b51b14ab9caa1cac8ca8c8d777f529c1938b48e4
[ "HPND-sell-variant", "MIT-open-group", "BSD-4-Clause-UC", "LicenseRef-scancode-warranty-disclaimer", "BSD-3-Clause", "MIT-0", "LicenseRef-scancode-gary-s-brown", "GPL-1.0-or-later", "MIT", "LicenseRef-scancode-bsd-atmel", "HPND", "ISC", "LicenseRef-scancode-other-permissive", "SunPro", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-proprietary-license", "CC-BY-2.0", "CC-BY-4.0" ]
permissive
PX4/NuttX
53c93fc5ff9c6443df23efc8a7f3380e2120048e
c23b72dffeb0de0d1a836ab561eb9169c4a9e58e
refs/heads/px4_firmware_nuttx-10.3.0+
2023-09-04T07:35:46.839633
2023-08-10T18:47:04
2023-08-14T16:53:04
39,532,678
121
203
Apache-2.0
2023-08-15T15:11:35
2015-07-22T22:06:58
C
UTF-8
C
false
false
4,534
c
up_assert.c
/**************************************************************************** * arch/avr/src/common/up_assert.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 <stdint.h> #include <stdlib.h> #include <assert.h> #include <debug.h> #include <nuttx/irq.h> #include <nuttx/arch.h> #include <nuttx/board.h> #include <nuttx/syslog/syslog.h> #include <nuttx/usb/usbdev_trace.h> #include <arch/board/board.h> #include "sched/sched.h" #include "up_internal.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /* USB trace dumping */ #ifndef CONFIG_USBDEV_TRACE # undef CONFIG_ARCH_USBDUMP #endif #ifndef CONFIG_BOARD_RESET_ON_ASSERT # define CONFIG_BOARD_RESET_ON_ASSERT 0 #endif /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** * Name: _up_assert ****************************************************************************/ static void _up_assert(void) { /* Flush any buffered SYSLOG data */ syslog_flush(); /* Are we in an interrupt handler or the idle task? */ if (g_current_regs || running_task()->flink == NULL) { #if CONFIG_BOARD_RESET_ON_ASSERT >= 1 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif up_irq_save(); for (; ; ) { #ifdef CONFIG_ARCH_LEDS board_autoled_on(LED_PANIC); up_mdelay(250); board_autoled_off(LED_PANIC); up_mdelay(250); #endif } } else { #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif } } /**************************************************************************** * Name: assert_tracecallback ****************************************************************************/ #ifdef CONFIG_ARCH_USBDUMP static int usbtrace_syslog(FAR const char *fmt, ...) { va_list ap; /* Let vsyslog do the real work */ va_start(ap, fmt); vsyslog(LOG_EMERG, fmt, ap); va_end(ap); return OK; } static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) { usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; } #endif /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: up_assert ****************************************************************************/ void up_assert(const char *filename, int lineno) { board_autoled_on(LED_ASSERTION); /* Flush any buffered SYSLOG data (prior to the assertion) */ syslog_flush(); #if CONFIG_TASK_NAME_SIZE > 0 _alert("Assertion failed at file:%s line: %d task: %s\n", filename, lineno, running_task()->name); #else _alert("Assertion failed at file:%s line: %d\n", filename, lineno); #endif up_dumpstate(); /* Flush any buffered SYSLOG data (from the above) */ syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP board_crashdump(up_getsp(), running_task(), filename, lineno); #endif #ifdef CONFIG_ARCH_USBDUMP /* Dump USB trace data */ usbtrace_enumerate(assert_tracecallback, NULL); #endif _up_assert(); }
7f2e128fb7531d204892d85953acd0727148b5d4
e6da5a3210800cdfde59f3bbb7986ff3fc878598
/contrib/tbase_subscription/tbase_subscription.c
33312ad22a3eff8077b8a79d248914aef55f7dd9
[ "BSD-3-Clause", "PostgreSQL", "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
Tencent/TBase
b66f13583ce6cd02ee5d453e2ce5a3a61e8b8f13
7cf7f8afbcab7290538ad5e65893561710be3dfa
refs/heads/master
2023-09-04T03:27:38.289238
2023-03-09T12:02:41
2023-03-09T12:18:46
220,177,733
1,433
283
NOASSERTION
2023-07-31T07:31:58
2019-11-07T07:34:03
C
UTF-8
C
false
false
553
c
tbase_subscription.c
#include "postgres.h" #include <unistd.h> #include <time.h> #include "access/hash.h" #include "executor/instrument.h" #include "funcapi.h" #include "mb/pg_wchar.h" #include "miscadmin.h" #include "parser/analyze.h" #include "parser/parsetree.h" #include "parser/scanner.h" #include "parser/scansup.h" #include "pgstat.h" #include "storage/fd.h" #include "storage/ipc.h" #include "storage/spin.h" #include "tcop/utility.h" #include "utils/builtins.h" #include "access/xact.h" #include "access/transam.h" #include "utils/timestamp.h" PG_MODULE_MAGIC;
d17ea99223a1da49a9599c93d95dad975653e770
42ab733e143d02091d13424fb4df16379d5bba0d
/third_party/libsdl2/src/video/SDL_blit_0.c
b5c8efb3cc435aa21b4fc04b205756e92abc42f1
[ "Zlib", "Apache-2.0", "CC0-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
google/filament
11cd37ac68790fcf8b33416b7d8d8870e48181f0
0aa0efe1599798d887fa6e33c412c09e81bea1bf
refs/heads/main
2023-08-29T17:58:22.496956
2023-08-28T17:27:38
2023-08-28T17:27:38
143,455,116
16,631
1,961
Apache-2.0
2023-09-14T16:23:39
2018-08-03T17:26:00
C++
UTF-8
C
false
false
12,396
c
SDL_blit_0.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #include "SDL_video.h" #include "SDL_blit.h" /* Functions to blit from bitmaps to other surfaces */ static void BlitBto1(SDL_BlitInfo * info) { int c; int width, height; Uint8 *src, *map, *dst; int srcskip, dstskip; /* Set up some basic variables */ width = info->dst_w; height = info->dst_h; src = info->src; srcskip = info->src_skip; dst = info->dst; dstskip = info->dst_skip; map = info->table; srcskip += width - (width + 7) / 8; if (map) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (1) { *dst = map[bit]; } dst++; byte <<= 1; } src += srcskip; dst += dstskip; } } else { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (1) { *dst = bit; } dst++; byte <<= 1; } src += srcskip; dst += dstskip; } } } static void BlitBto2(SDL_BlitInfo * info) { int c; int width, height; Uint8 *src; Uint16 *map, *dst; int srcskip, dstskip; /* Set up some basic variables */ width = info->dst_w; height = info->dst_h; src = info->src; srcskip = info->src_skip; dst = (Uint16 *) info->dst; dstskip = info->dst_skip / 2; map = (Uint16 *) info->table; srcskip += width - (width + 7) / 8; while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (1) { *dst = map[bit]; } byte <<= 1; dst++; } src += srcskip; dst += dstskip; } } static void BlitBto3(SDL_BlitInfo * info) { int c, o; int width, height; Uint8 *src, *map, *dst; int srcskip, dstskip; /* Set up some basic variables */ width = info->dst_w; height = info->dst_h; src = info->src; srcskip = info->src_skip; dst = info->dst; dstskip = info->dst_skip; map = info->table; srcskip += width - (width + 7) / 8; while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (1) { o = bit * 4; dst[0] = map[o++]; dst[1] = map[o++]; dst[2] = map[o++]; } byte <<= 1; dst += 3; } src += srcskip; dst += dstskip; } } static void BlitBto4(SDL_BlitInfo * info) { int width, height; Uint8 *src; Uint32 *map, *dst; int srcskip, dstskip; int c; /* Set up some basic variables */ width = info->dst_w; height = info->dst_h; src = info->src; srcskip = info->src_skip; dst = (Uint32 *) info->dst; dstskip = info->dst_skip / 4; map = (Uint32 *) info->table; srcskip += width - (width + 7) / 8; while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (1) { *dst = map[bit]; } byte <<= 1; dst++; } src += srcskip; dst += dstskip; } } static void BlitBto1Key(SDL_BlitInfo * info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; Uint8 *dst = info->dst; int srcskip = info->src_skip; int dstskip = info->dst_skip; Uint32 ckey = info->colorkey; Uint8 *palmap = info->table; int c; /* Set up some basic variables */ srcskip += width - (width + 7) / 8; if (palmap) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (bit != ckey) { *dst = palmap[bit]; } dst++; byte <<= 1; } src += srcskip; dst += dstskip; } } else { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (bit != ckey) { *dst = bit; } dst++; byte <<= 1; } src += srcskip; dst += dstskip; } } } static void BlitBto2Key(SDL_BlitInfo * info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; Uint16 *dstp = (Uint16 *) info->dst; int srcskip = info->src_skip; int dstskip = info->dst_skip; Uint32 ckey = info->colorkey; Uint8 *palmap = info->table; int c; /* Set up some basic variables */ srcskip += width - (width + 7) / 8; dstskip /= 2; while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (bit != ckey) { *dstp = ((Uint16 *) palmap)[bit]; } byte <<= 1; dstp++; } src += srcskip; dstp += dstskip; } } static void BlitBto3Key(SDL_BlitInfo * info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; Uint8 *dst = info->dst; int srcskip = info->src_skip; int dstskip = info->dst_skip; Uint32 ckey = info->colorkey; Uint8 *palmap = info->table; int c; /* Set up some basic variables */ srcskip += width - (width + 7) / 8; while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (bit != ckey) { SDL_memcpy(dst, &palmap[bit * 4], 3); } byte <<= 1; dst += 3; } src += srcskip; dst += dstskip; } } static void BlitBto4Key(SDL_BlitInfo * info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; Uint32 *dstp = (Uint32 *) info->dst; int srcskip = info->src_skip; int dstskip = info->dst_skip; Uint32 ckey = info->colorkey; Uint8 *palmap = info->table; int c; /* Set up some basic variables */ srcskip += width - (width + 7) / 8; dstskip /= 4; while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (bit != ckey) { *dstp = ((Uint32 *) palmap)[bit]; } byte <<= 1; dstp++; } src += srcskip; dstp += dstskip; } } static void BlitBtoNAlpha(SDL_BlitInfo * info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; Uint8 *dst = info->dst; int srcskip = info->src_skip; int dstskip = info->dst_skip; const SDL_Color *srcpal = info->src_fmt->palette->colors; SDL_PixelFormat *dstfmt = info->dst_fmt; int dstbpp; int c; Uint32 pixel; unsigned sR, sG, sB; unsigned dR, dG, dB, dA; const unsigned A = info->a; /* Set up some basic variables */ dstbpp = dstfmt->BytesPerPixel; srcskip += width - (width + 7) / 8; while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (1) { sR = srcpal[bit].r; sG = srcpal[bit].g; sB = srcpal[bit].b; DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); } byte <<= 1; dst += dstbpp; } src += srcskip; dst += dstskip; } } static void BlitBtoNAlphaKey(SDL_BlitInfo * info) { int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; Uint8 *dst = info->dst; int srcskip = info->src_skip; int dstskip = info->dst_skip; SDL_PixelFormat *srcfmt = info->src_fmt; SDL_PixelFormat *dstfmt = info->dst_fmt; const SDL_Color *srcpal = srcfmt->palette->colors; int dstbpp; int c; Uint32 pixel; unsigned sR, sG, sB; unsigned dR, dG, dB, dA; const unsigned A = info->a; Uint32 ckey = info->colorkey; /* Set up some basic variables */ dstbpp = dstfmt->BytesPerPixel; srcskip += width - (width + 7) / 8; while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { if ((c & 7) == 0) { byte = *src++; } bit = (byte & 0x80) >> 7; if (bit != ckey) { sR = srcpal[bit].r; sG = srcpal[bit].g; sB = srcpal[bit].b; DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); } byte <<= 1; dst += dstbpp; } src += srcskip; dst += dstskip; } } static const SDL_BlitFunc bitmap_blit[] = { (SDL_BlitFunc) NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4 }; static const SDL_BlitFunc colorkey_blit[] = { (SDL_BlitFunc) NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key }; SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface * surface) { int which; if (surface->format->BitsPerPixel != 1) { /* We don't support sub 8-bit packed pixel modes */ return (SDL_BlitFunc) NULL; } if (surface->map->dst->format->BitsPerPixel < 8) { which = 0; } else { which = surface->map->dst->format->BytesPerPixel; } switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) { case 0: return bitmap_blit[which]; case SDL_COPY_COLORKEY: return colorkey_blit[which]; case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: return which >= 2 ? BlitBtoNAlpha : (SDL_BlitFunc) NULL; case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: return which >= 2 ? BlitBtoNAlphaKey : (SDL_BlitFunc) NULL; } return (SDL_BlitFunc) NULL; } /* vi: set ts=4 sw=4 expandtab: */
ad1ac55ee2a38a7c0e3f1469273957ef3ca90705
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/bouffalo_lab/libraries/bl_mcu_sdk/drivers/soc/bl616/std/include/hardware/hbn_reg.h
c06379b28ace233f8f3c64a7d06e5e844643d0e2
[ "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
53,206
h
hbn_reg.h
/** ****************************************************************************** * @file hbn_reg.h * @version V1.0 * @date 2021-11-22 * @brief This file is the description of.IP register ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2020 Bouffalo Lab</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of Bouffalo Lab nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ #ifndef __HBN_REG_H__ #define __HBN_REG_H__ #include "bl616.h" /* 0x0 : HBN_CTL */ #define HBN_CTL_OFFSET (0x0) #define HBN_RTC_CTL HBN_RTC_CTL #define HBN_RTC_CTL_POS (0U) #define HBN_RTC_CTL_LEN (4U) #define HBN_RTC_CTL_MSK (((1U << HBN_RTC_CTL_LEN) - 1) << HBN_RTC_CTL_POS) #define HBN_RTC_CTL_UMSK (~(((1U << HBN_RTC_CTL_LEN) - 1) << HBN_RTC_CTL_POS)) #define HBN_RTC_DLY_OPTION HBN_RTC_DLY_OPTION #define HBN_RTC_DLY_OPTION_POS (4U) #define HBN_RTC_DLY_OPTION_LEN (1U) #define HBN_RTC_DLY_OPTION_MSK (((1U << HBN_RTC_DLY_OPTION_LEN) - 1) << HBN_RTC_DLY_OPTION_POS) #define HBN_RTC_DLY_OPTION_UMSK (~(((1U << HBN_RTC_DLY_OPTION_LEN) - 1) << HBN_RTC_DLY_OPTION_POS)) #define HBN_MODE HBN_MODE #define HBN_MODE_POS (7U) #define HBN_MODE_LEN (1U) #define HBN_MODE_MSK (((1U << HBN_MODE_LEN) - 1) << HBN_MODE_POS) #define HBN_MODE_UMSK (~(((1U << HBN_MODE_LEN) - 1) << HBN_MODE_POS)) #define HBN_TRAP_MODE HBN_TRAP_MODE #define HBN_TRAP_MODE_POS (8U) #define HBN_TRAP_MODE_LEN (1U) #define HBN_TRAP_MODE_MSK (((1U << HBN_TRAP_MODE_LEN) - 1) << HBN_TRAP_MODE_POS) #define HBN_TRAP_MODE_UMSK (~(((1U << HBN_TRAP_MODE_LEN) - 1) << HBN_TRAP_MODE_POS)) #define HBN_PWRDN_HBN_CORE HBN_PWRDN_HBN_CORE #define HBN_PWRDN_HBN_CORE_POS (9U) #define HBN_PWRDN_HBN_CORE_LEN (1U) #define HBN_PWRDN_HBN_CORE_MSK (((1U << HBN_PWRDN_HBN_CORE_LEN) - 1) << HBN_PWRDN_HBN_CORE_POS) #define HBN_PWRDN_HBN_CORE_UMSK (~(((1U << HBN_PWRDN_HBN_CORE_LEN) - 1) << HBN_PWRDN_HBN_CORE_POS)) #define HBN_PWRDN_HBN_RTC HBN_PWRDN_HBN_RTC #define HBN_PWRDN_HBN_RTC_POS (11U) #define HBN_PWRDN_HBN_RTC_LEN (1U) #define HBN_PWRDN_HBN_RTC_MSK (((1U << HBN_PWRDN_HBN_RTC_LEN) - 1) << HBN_PWRDN_HBN_RTC_POS) #define HBN_PWRDN_HBN_RTC_UMSK (~(((1U << HBN_PWRDN_HBN_RTC_LEN) - 1) << HBN_PWRDN_HBN_RTC_POS)) #define HBN_SW_RST HBN_SW_RST #define HBN_SW_RST_POS (12U) #define HBN_SW_RST_LEN (1U) #define HBN_SW_RST_MSK (((1U << HBN_SW_RST_LEN) - 1) << HBN_SW_RST_POS) #define HBN_SW_RST_UMSK (~(((1U << HBN_SW_RST_LEN) - 1) << HBN_SW_RST_POS)) #define HBN_DIS_PWR_OFF_LDO11 HBN_DIS_PWR_OFF_LDO11 #define HBN_DIS_PWR_OFF_LDO11_POS (13U) #define HBN_DIS_PWR_OFF_LDO11_LEN (1U) #define HBN_DIS_PWR_OFF_LDO11_MSK (((1U << HBN_DIS_PWR_OFF_LDO11_LEN) - 1) << HBN_DIS_PWR_OFF_LDO11_POS) #define HBN_DIS_PWR_OFF_LDO11_UMSK (~(((1U << HBN_DIS_PWR_OFF_LDO11_LEN) - 1) << HBN_DIS_PWR_OFF_LDO11_POS)) #define HBN_DIS_PWR_OFF_LDO11_RT HBN_DIS_PWR_OFF_LDO11_RT #define HBN_DIS_PWR_OFF_LDO11_RT_POS (14U) #define HBN_DIS_PWR_OFF_LDO11_RT_LEN (1U) #define HBN_DIS_PWR_OFF_LDO11_RT_MSK (((1U << HBN_DIS_PWR_OFF_LDO11_RT_LEN) - 1) << HBN_DIS_PWR_OFF_LDO11_RT_POS) #define HBN_DIS_PWR_OFF_LDO11_RT_UMSK (~(((1U << HBN_DIS_PWR_OFF_LDO11_RT_LEN) - 1) << HBN_DIS_PWR_OFF_LDO11_RT_POS)) #define HBN_LDO11_RT_VOUT_SEL HBN_LDO11_RT_VOUT_SEL #define HBN_LDO11_RT_VOUT_SEL_POS (15U) #define HBN_LDO11_RT_VOUT_SEL_LEN (4U) #define HBN_LDO11_RT_VOUT_SEL_MSK (((1U << HBN_LDO11_RT_VOUT_SEL_LEN) - 1) << HBN_LDO11_RT_VOUT_SEL_POS) #define HBN_LDO11_RT_VOUT_SEL_UMSK (~(((1U << HBN_LDO11_RT_VOUT_SEL_LEN) - 1) << HBN_LDO11_RT_VOUT_SEL_POS)) #define HBN_LDO11_AON_VOUT_SEL HBN_LDO11_AON_VOUT_SEL #define HBN_LDO11_AON_VOUT_SEL_POS (19U) #define HBN_LDO11_AON_VOUT_SEL_LEN (4U) #define HBN_LDO11_AON_VOUT_SEL_MSK (((1U << HBN_LDO11_AON_VOUT_SEL_LEN) - 1) << HBN_LDO11_AON_VOUT_SEL_POS) #define HBN_LDO11_AON_VOUT_SEL_UMSK (~(((1U << HBN_LDO11_AON_VOUT_SEL_LEN) - 1) << HBN_LDO11_AON_VOUT_SEL_POS)) #define HBN_PU_DCDC18_AON HBN_PU_DCDC18_AON #define HBN_PU_DCDC18_AON_POS (24U) #define HBN_PU_DCDC18_AON_LEN (1U) #define HBN_PU_DCDC18_AON_MSK (((1U << HBN_PU_DCDC18_AON_LEN) - 1) << HBN_PU_DCDC18_AON_POS) #define HBN_PU_DCDC18_AON_UMSK (~(((1U << HBN_PU_DCDC18_AON_LEN) - 1) << HBN_PU_DCDC18_AON_POS)) #define HBN_PWR_ON_OPTION HBN_PWR_ON_OPTION #define HBN_PWR_ON_OPTION_POS (25U) #define HBN_PWR_ON_OPTION_LEN (1U) #define HBN_PWR_ON_OPTION_MSK (((1U << HBN_PWR_ON_OPTION_LEN) - 1) << HBN_PWR_ON_OPTION_POS) #define HBN_PWR_ON_OPTION_UMSK (~(((1U << HBN_PWR_ON_OPTION_LEN) - 1) << HBN_PWR_ON_OPTION_POS)) #define HBN_SRAM_SLP_OPTION HBN_SRAM_SLP_OPTION #define HBN_SRAM_SLP_OPTION_POS (26U) #define HBN_SRAM_SLP_OPTION_LEN (1U) #define HBN_SRAM_SLP_OPTION_MSK (((1U << HBN_SRAM_SLP_OPTION_LEN) - 1) << HBN_SRAM_SLP_OPTION_POS) #define HBN_SRAM_SLP_OPTION_UMSK (~(((1U << HBN_SRAM_SLP_OPTION_LEN) - 1) << HBN_SRAM_SLP_OPTION_POS)) #define HBN_SRAM_SLP HBN_SRAM_SLP #define HBN_SRAM_SLP_POS (27U) #define HBN_SRAM_SLP_LEN (1U) #define HBN_SRAM_SLP_MSK (((1U << HBN_SRAM_SLP_LEN) - 1) << HBN_SRAM_SLP_POS) #define HBN_SRAM_SLP_UMSK (~(((1U << HBN_SRAM_SLP_LEN) - 1) << HBN_SRAM_SLP_POS)) #define HBN_STATE HBN_STATE #define HBN_STATE_POS (28U) #define HBN_STATE_LEN (4U) #define HBN_STATE_MSK (((1U << HBN_STATE_LEN) - 1) << HBN_STATE_POS) #define HBN_STATE_UMSK (~(((1U << HBN_STATE_LEN) - 1) << HBN_STATE_POS)) /* 0x4 : HBN_TIME_L */ #define HBN_TIME_L_OFFSET (0x4) #define HBN_TIME_L HBN_TIME_L #define HBN_TIME_L_POS (0U) #define HBN_TIME_L_LEN (32U) #define HBN_TIME_L_MSK (((1U << HBN_TIME_L_LEN) - 1) << HBN_TIME_L_POS) #define HBN_TIME_L_UMSK (~(((1U << HBN_TIME_L_LEN) - 1) << HBN_TIME_L_POS)) /* 0x8 : HBN_TIME_H */ #define HBN_TIME_H_OFFSET (0x8) #define HBN_TIME_H HBN_TIME_H #define HBN_TIME_H_POS (0U) #define HBN_TIME_H_LEN (8U) #define HBN_TIME_H_MSK (((1U << HBN_TIME_H_LEN) - 1) << HBN_TIME_H_POS) #define HBN_TIME_H_UMSK (~(((1U << HBN_TIME_H_LEN) - 1) << HBN_TIME_H_POS)) /* 0xC : RTC_TIME_L */ #define HBN_RTC_TIME_L_OFFSET (0xC) #define HBN_RTC_TIME_LATCH_L HBN_RTC_TIME_LATCH_L #define HBN_RTC_TIME_LATCH_L_POS (0U) #define HBN_RTC_TIME_LATCH_L_LEN (32U) #define HBN_RTC_TIME_LATCH_L_MSK (((1U << HBN_RTC_TIME_LATCH_L_LEN) - 1) << HBN_RTC_TIME_LATCH_L_POS) #define HBN_RTC_TIME_LATCH_L_UMSK (~(((1U << HBN_RTC_TIME_LATCH_L_LEN) - 1) << HBN_RTC_TIME_LATCH_L_POS)) /* 0x10 : RTC_TIME_H */ #define HBN_RTC_TIME_H_OFFSET (0x10) #define HBN_RTC_TIME_LATCH_H HBN_RTC_TIME_LATCH_H #define HBN_RTC_TIME_LATCH_H_POS (0U) #define HBN_RTC_TIME_LATCH_H_LEN (8U) #define HBN_RTC_TIME_LATCH_H_MSK (((1U << HBN_RTC_TIME_LATCH_H_LEN) - 1) << HBN_RTC_TIME_LATCH_H_POS) #define HBN_RTC_TIME_LATCH_H_UMSK (~(((1U << HBN_RTC_TIME_LATCH_H_LEN) - 1) << HBN_RTC_TIME_LATCH_H_POS)) #define HBN_RTC_TIME_LATCH HBN_RTC_TIME_LATCH #define HBN_RTC_TIME_LATCH_POS (31U) #define HBN_RTC_TIME_LATCH_LEN (1U) #define HBN_RTC_TIME_LATCH_MSK (((1U << HBN_RTC_TIME_LATCH_LEN) - 1) << HBN_RTC_TIME_LATCH_POS) #define HBN_RTC_TIME_LATCH_UMSK (~(((1U << HBN_RTC_TIME_LATCH_LEN) - 1) << HBN_RTC_TIME_LATCH_POS)) /* 0x14 : HBN_IRQ_MODE */ #define HBN_IRQ_MODE_OFFSET (0x14) #define HBN_PIN_WAKEUP_MODE HBN_PIN_WAKEUP_MODE #define HBN_PIN_WAKEUP_MODE_POS (0U) #define HBN_PIN_WAKEUP_MODE_LEN (4U) #define HBN_PIN_WAKEUP_MODE_MSK (((1U << HBN_PIN_WAKEUP_MODE_LEN) - 1) << HBN_PIN_WAKEUP_MODE_POS) #define HBN_PIN_WAKEUP_MODE_UMSK (~(((1U << HBN_PIN_WAKEUP_MODE_LEN) - 1) << HBN_PIN_WAKEUP_MODE_POS)) #define HBN_PIN_WAKEUP_MASK HBN_PIN_WAKEUP_MASK #define HBN_PIN_WAKEUP_MASK_POS (4U) #define HBN_PIN_WAKEUP_MASK_LEN (4U) #define HBN_PIN_WAKEUP_MASK_MSK (((1U << HBN_PIN_WAKEUP_MASK_LEN) - 1) << HBN_PIN_WAKEUP_MASK_POS) #define HBN_PIN_WAKEUP_MASK_UMSK (~(((1U << HBN_PIN_WAKEUP_MASK_LEN) - 1) << HBN_PIN_WAKEUP_MASK_POS)) #define HBN_REG_EN_HW_PU_PD HBN_REG_EN_HW_PU_PD #define HBN_REG_EN_HW_PU_PD_POS (16U) #define HBN_REG_EN_HW_PU_PD_LEN (1U) #define HBN_REG_EN_HW_PU_PD_MSK (((1U << HBN_REG_EN_HW_PU_PD_LEN) - 1) << HBN_REG_EN_HW_PU_PD_POS) #define HBN_REG_EN_HW_PU_PD_UMSK (~(((1U << HBN_REG_EN_HW_PU_PD_LEN) - 1) << HBN_REG_EN_HW_PU_PD_POS)) #define HBN_IRQ_BOR_EN HBN_IRQ_BOR_EN #define HBN_IRQ_BOR_EN_POS (18U) #define HBN_IRQ_BOR_EN_LEN (1U) #define HBN_IRQ_BOR_EN_MSK (((1U << HBN_IRQ_BOR_EN_LEN) - 1) << HBN_IRQ_BOR_EN_POS) #define HBN_IRQ_BOR_EN_UMSK (~(((1U << HBN_IRQ_BOR_EN_LEN) - 1) << HBN_IRQ_BOR_EN_POS)) #define HBN_IRQ_ACOMP0_EN HBN_IRQ_ACOMP0_EN #define HBN_IRQ_ACOMP0_EN_POS (20U) #define HBN_IRQ_ACOMP0_EN_LEN (2U) #define HBN_IRQ_ACOMP0_EN_MSK (((1U << HBN_IRQ_ACOMP0_EN_LEN) - 1) << HBN_IRQ_ACOMP0_EN_POS) #define HBN_IRQ_ACOMP0_EN_UMSK (~(((1U << HBN_IRQ_ACOMP0_EN_LEN) - 1) << HBN_IRQ_ACOMP0_EN_POS)) #define HBN_IRQ_ACOMP1_EN HBN_IRQ_ACOMP1_EN #define HBN_IRQ_ACOMP1_EN_POS (22U) #define HBN_IRQ_ACOMP1_EN_LEN (2U) #define HBN_IRQ_ACOMP1_EN_MSK (((1U << HBN_IRQ_ACOMP1_EN_LEN) - 1) << HBN_IRQ_ACOMP1_EN_POS) #define HBN_IRQ_ACOMP1_EN_UMSK (~(((1U << HBN_IRQ_ACOMP1_EN_LEN) - 1) << HBN_IRQ_ACOMP1_EN_POS)) #define HBN_PIN_WAKEUP_SEL HBN_PIN_WAKEUP_SEL #define HBN_PIN_WAKEUP_SEL_POS (24U) #define HBN_PIN_WAKEUP_SEL_LEN (3U) #define HBN_PIN_WAKEUP_SEL_MSK (((1U << HBN_PIN_WAKEUP_SEL_LEN) - 1) << HBN_PIN_WAKEUP_SEL_POS) #define HBN_PIN_WAKEUP_SEL_UMSK (~(((1U << HBN_PIN_WAKEUP_SEL_LEN) - 1) << HBN_PIN_WAKEUP_SEL_POS)) #define HBN_PIN_WAKEUP_EN HBN_PIN_WAKEUP_EN #define HBN_PIN_WAKEUP_EN_POS (27U) #define HBN_PIN_WAKEUP_EN_LEN (1U) #define HBN_PIN_WAKEUP_EN_MSK (((1U << HBN_PIN_WAKEUP_EN_LEN) - 1) << HBN_PIN_WAKEUP_EN_POS) #define HBN_PIN_WAKEUP_EN_UMSK (~(((1U << HBN_PIN_WAKEUP_EN_LEN) - 1) << HBN_PIN_WAKEUP_EN_POS)) /* 0x18 : HBN_IRQ_STAT */ #define HBN_IRQ_STAT_OFFSET (0x18) #define HBN_IRQ_STAT HBN_IRQ_STAT #define HBN_IRQ_STAT_POS (0U) #define HBN_IRQ_STAT_LEN (32U) #define HBN_IRQ_STAT_MSK (((1U << HBN_IRQ_STAT_LEN) - 1) << HBN_IRQ_STAT_POS) #define HBN_IRQ_STAT_UMSK (~(((1U << HBN_IRQ_STAT_LEN) - 1) << HBN_IRQ_STAT_POS)) /* 0x1C : HBN_IRQ_CLR */ #define HBN_IRQ_CLR_OFFSET (0x1C) #define HBN_IRQ_CLR HBN_IRQ_CLR #define HBN_IRQ_CLR_POS (0U) #define HBN_IRQ_CLR_LEN (32U) #define HBN_IRQ_CLR_MSK (((1U << HBN_IRQ_CLR_LEN) - 1) << HBN_IRQ_CLR_POS) #define HBN_IRQ_CLR_UMSK (~(((1U << HBN_IRQ_CLR_LEN) - 1) << HBN_IRQ_CLR_POS)) /* 0x20 : HBN_PIR_CFG */ #define HBN_PIR_CFG_OFFSET (0x20) #define HBN_PIR_HPF_SEL HBN_PIR_HPF_SEL #define HBN_PIR_HPF_SEL_POS (0U) #define HBN_PIR_HPF_SEL_LEN (2U) #define HBN_PIR_HPF_SEL_MSK (((1U << HBN_PIR_HPF_SEL_LEN) - 1) << HBN_PIR_HPF_SEL_POS) #define HBN_PIR_HPF_SEL_UMSK (~(((1U << HBN_PIR_HPF_SEL_LEN) - 1) << HBN_PIR_HPF_SEL_POS)) #define HBN_PIR_LPF_SEL HBN_PIR_LPF_SEL #define HBN_PIR_LPF_SEL_POS (2U) #define HBN_PIR_LPF_SEL_LEN (1U) #define HBN_PIR_LPF_SEL_MSK (((1U << HBN_PIR_LPF_SEL_LEN) - 1) << HBN_PIR_LPF_SEL_POS) #define HBN_PIR_LPF_SEL_UMSK (~(((1U << HBN_PIR_LPF_SEL_LEN) - 1) << HBN_PIR_LPF_SEL_POS)) #define HBN_PIR_DIS HBN_PIR_DIS #define HBN_PIR_DIS_POS (4U) #define HBN_PIR_DIS_LEN (2U) #define HBN_PIR_DIS_MSK (((1U << HBN_PIR_DIS_LEN) - 1) << HBN_PIR_DIS_POS) #define HBN_PIR_DIS_UMSK (~(((1U << HBN_PIR_DIS_LEN) - 1) << HBN_PIR_DIS_POS)) #define HBN_PIR_EN HBN_PIR_EN #define HBN_PIR_EN_POS (7U) #define HBN_PIR_EN_LEN (1U) #define HBN_PIR_EN_MSK (((1U << HBN_PIR_EN_LEN) - 1) << HBN_PIR_EN_POS) #define HBN_PIR_EN_UMSK (~(((1U << HBN_PIR_EN_LEN) - 1) << HBN_PIR_EN_POS)) #define HBN_GPADC_CS HBN_GPADC_CS #define HBN_GPADC_CS_POS (8U) #define HBN_GPADC_CS_LEN (1U) #define HBN_GPADC_CS_MSK (((1U << HBN_GPADC_CS_LEN) - 1) << HBN_GPADC_CS_POS) #define HBN_GPADC_CS_UMSK (~(((1U << HBN_GPADC_CS_LEN) - 1) << HBN_GPADC_CS_POS)) /* 0x24 : HBN_PIR_VTH */ #define HBN_PIR_VTH_OFFSET (0x24) #define HBN_PIR_VTH HBN_PIR_VTH #define HBN_PIR_VTH_POS (0U) #define HBN_PIR_VTH_LEN (14U) #define HBN_PIR_VTH_MSK (((1U << HBN_PIR_VTH_LEN) - 1) << HBN_PIR_VTH_POS) #define HBN_PIR_VTH_UMSK (~(((1U << HBN_PIR_VTH_LEN) - 1) << HBN_PIR_VTH_POS)) /* 0x28 : HBN_PIR_INTERVAL */ #define HBN_PIR_INTERVAL_OFFSET (0x28) #define HBN_PIR_INTERVAL HBN_PIR_INTERVAL #define HBN_PIR_INTERVAL_POS (0U) #define HBN_PIR_INTERVAL_LEN (12U) #define HBN_PIR_INTERVAL_MSK (((1U << HBN_PIR_INTERVAL_LEN) - 1) << HBN_PIR_INTERVAL_POS) #define HBN_PIR_INTERVAL_UMSK (~(((1U << HBN_PIR_INTERVAL_LEN) - 1) << HBN_PIR_INTERVAL_POS)) /* 0x2C : HBN_BOR_CFG */ #define HBN_BOR_CFG_OFFSET (0x2C) #define HBN_BOD_SEL HBN_BOD_SEL #define HBN_BOD_SEL_POS (0U) #define HBN_BOD_SEL_LEN (1U) #define HBN_BOD_SEL_MSK (((1U << HBN_BOD_SEL_LEN) - 1) << HBN_BOD_SEL_POS) #define HBN_BOD_SEL_UMSK (~(((1U << HBN_BOD_SEL_LEN) - 1) << HBN_BOD_SEL_POS)) #define HBN_BOD_VTH HBN_BOD_VTH #define HBN_BOD_VTH_POS (1U) #define HBN_BOD_VTH_LEN (3U) #define HBN_BOD_VTH_MSK (((1U << HBN_BOD_VTH_LEN) - 1) << HBN_BOD_VTH_POS) #define HBN_BOD_VTH_UMSK (~(((1U << HBN_BOD_VTH_LEN) - 1) << HBN_BOD_VTH_POS)) #define HBN_PU_BOD HBN_PU_BOD #define HBN_PU_BOD_POS (4U) #define HBN_PU_BOD_LEN (1U) #define HBN_PU_BOD_MSK (((1U << HBN_PU_BOD_LEN) - 1) << HBN_PU_BOD_POS) #define HBN_PU_BOD_UMSK (~(((1U << HBN_PU_BOD_LEN) - 1) << HBN_PU_BOD_POS)) #define HBN_R_BOD_OUT HBN_R_BOD_OUT #define HBN_R_BOD_OUT_POS (5U) #define HBN_R_BOD_OUT_LEN (1U) #define HBN_R_BOD_OUT_MSK (((1U << HBN_R_BOD_OUT_LEN) - 1) << HBN_R_BOD_OUT_POS) #define HBN_R_BOD_OUT_UMSK (~(((1U << HBN_R_BOD_OUT_LEN) - 1) << HBN_R_BOD_OUT_POS)) /* 0x30 : HBN_GLB */ #define HBN_GLB_OFFSET (0x30) #define HBN_ROOT_CLK_SEL HBN_ROOT_CLK_SEL #define HBN_ROOT_CLK_SEL_POS (0U) #define HBN_ROOT_CLK_SEL_LEN (2U) #define HBN_ROOT_CLK_SEL_MSK (((1U << HBN_ROOT_CLK_SEL_LEN) - 1) << HBN_ROOT_CLK_SEL_POS) #define HBN_ROOT_CLK_SEL_UMSK (~(((1U << HBN_ROOT_CLK_SEL_LEN) - 1) << HBN_ROOT_CLK_SEL_POS)) #define HBN_UART_CLK_SEL HBN_UART_CLK_SEL #define HBN_UART_CLK_SEL_POS (2U) #define HBN_UART_CLK_SEL_LEN (1U) #define HBN_UART_CLK_SEL_MSK (((1U << HBN_UART_CLK_SEL_LEN) - 1) << HBN_UART_CLK_SEL_POS) #define HBN_UART_CLK_SEL_UMSK (~(((1U << HBN_UART_CLK_SEL_LEN) - 1) << HBN_UART_CLK_SEL_POS)) #define HBN_F32K_SEL HBN_F32K_SEL #define HBN_F32K_SEL_POS (3U) #define HBN_F32K_SEL_LEN (2U) #define HBN_F32K_SEL_MSK (((1U << HBN_F32K_SEL_LEN) - 1) << HBN_F32K_SEL_POS) #define HBN_F32K_SEL_UMSK (~(((1U << HBN_F32K_SEL_LEN) - 1) << HBN_F32K_SEL_POS)) #define HBN_PU_RC32K HBN_PU_RC32K #define HBN_PU_RC32K_POS (5U) #define HBN_PU_RC32K_LEN (1U) #define HBN_PU_RC32K_MSK (((1U << HBN_PU_RC32K_LEN) - 1) << HBN_PU_RC32K_POS) #define HBN_PU_RC32K_UMSK (~(((1U << HBN_PU_RC32K_LEN) - 1) << HBN_PU_RC32K_POS)) #define HBN_RESET_EVENT HBN_RESET_EVENT #define HBN_RESET_EVENT_POS (7U) #define HBN_RESET_EVENT_LEN (5U) #define HBN_RESET_EVENT_MSK (((1U << HBN_RESET_EVENT_LEN) - 1) << HBN_RESET_EVENT_POS) #define HBN_RESET_EVENT_UMSK (~(((1U << HBN_RESET_EVENT_LEN) - 1) << HBN_RESET_EVENT_POS)) #define HBN_UART_CLK_SEL2 HBN_UART_CLK_SEL2 #define HBN_UART_CLK_SEL2_POS (15U) #define HBN_UART_CLK_SEL2_LEN (1U) #define HBN_UART_CLK_SEL2_MSK (((1U << HBN_UART_CLK_SEL2_LEN) - 1) << HBN_UART_CLK_SEL2_POS) #define HBN_UART_CLK_SEL2_UMSK (~(((1U << HBN_UART_CLK_SEL2_LEN) - 1) << HBN_UART_CLK_SEL2_POS)) #define HBN_SW_LDO11SOC_VOUT_SEL_AON HBN_SW_LDO11SOC_VOUT_SEL_AON #define HBN_SW_LDO11SOC_VOUT_SEL_AON_POS (16U) #define HBN_SW_LDO11SOC_VOUT_SEL_AON_LEN (4U) #define HBN_SW_LDO11SOC_VOUT_SEL_AON_MSK (((1U << HBN_SW_LDO11SOC_VOUT_SEL_AON_LEN) - 1) << HBN_SW_LDO11SOC_VOUT_SEL_AON_POS) #define HBN_SW_LDO11SOC_VOUT_SEL_AON_UMSK (~(((1U << HBN_SW_LDO11SOC_VOUT_SEL_AON_LEN) - 1) << HBN_SW_LDO11SOC_VOUT_SEL_AON_POS)) #define HBN_SW_LDO11_RT_VOUT_SEL HBN_SW_LDO11_RT_VOUT_SEL #define HBN_SW_LDO11_RT_VOUT_SEL_POS (24U) #define HBN_SW_LDO11_RT_VOUT_SEL_LEN (4U) #define HBN_SW_LDO11_RT_VOUT_SEL_MSK (((1U << HBN_SW_LDO11_RT_VOUT_SEL_LEN) - 1) << HBN_SW_LDO11_RT_VOUT_SEL_POS) #define HBN_SW_LDO11_RT_VOUT_SEL_UMSK (~(((1U << HBN_SW_LDO11_RT_VOUT_SEL_LEN) - 1) << HBN_SW_LDO11_RT_VOUT_SEL_POS)) #define HBN_SW_LDO11_AON_VOUT_SEL HBN_SW_LDO11_AON_VOUT_SEL #define HBN_SW_LDO11_AON_VOUT_SEL_POS (28U) #define HBN_SW_LDO11_AON_VOUT_SEL_LEN (4U) #define HBN_SW_LDO11_AON_VOUT_SEL_MSK (((1U << HBN_SW_LDO11_AON_VOUT_SEL_LEN) - 1) << HBN_SW_LDO11_AON_VOUT_SEL_POS) #define HBN_SW_LDO11_AON_VOUT_SEL_UMSK (~(((1U << HBN_SW_LDO11_AON_VOUT_SEL_LEN) - 1) << HBN_SW_LDO11_AON_VOUT_SEL_POS)) /* 0x34 : HBN_SRAM */ #define HBN_SRAM_OFFSET (0x34) #define HBN_RETRAM_RET HBN_RETRAM_RET #define HBN_RETRAM_RET_POS (6U) #define HBN_RETRAM_RET_LEN (1U) #define HBN_RETRAM_RET_MSK (((1U << HBN_RETRAM_RET_LEN) - 1) << HBN_RETRAM_RET_POS) #define HBN_RETRAM_RET_UMSK (~(((1U << HBN_RETRAM_RET_LEN) - 1) << HBN_RETRAM_RET_POS)) #define HBN_RETRAM_SLP HBN_RETRAM_SLP #define HBN_RETRAM_SLP_POS (7U) #define HBN_RETRAM_SLP_LEN (1U) #define HBN_RETRAM_SLP_MSK (((1U << HBN_RETRAM_SLP_LEN) - 1) << HBN_RETRAM_SLP_POS) #define HBN_RETRAM_SLP_UMSK (~(((1U << HBN_RETRAM_SLP_LEN) - 1) << HBN_RETRAM_SLP_POS)) /* 0x38 : HBN_PAD_CTRL_0 */ #define HBN_PAD_CTRL_0_OFFSET (0x38) #define HBN_REG_AON_PAD_IE_SMT HBN_REG_AON_PAD_IE_SMT #define HBN_REG_AON_PAD_IE_SMT_POS (0U) #define HBN_REG_AON_PAD_IE_SMT_LEN (4U) #define HBN_REG_AON_PAD_IE_SMT_MSK (((1U << HBN_REG_AON_PAD_IE_SMT_LEN) - 1) << HBN_REG_AON_PAD_IE_SMT_POS) #define HBN_REG_AON_PAD_IE_SMT_UMSK (~(((1U << HBN_REG_AON_PAD_IE_SMT_LEN) - 1) << HBN_REG_AON_PAD_IE_SMT_POS)) #define HBN_REG_AON_LED_SEL HBN_REG_AON_LED_SEL #define HBN_REG_AON_LED_SEL_POS (10U) #define HBN_REG_AON_LED_SEL_LEN (9U) #define HBN_REG_AON_LED_SEL_MSK (((1U << HBN_REG_AON_LED_SEL_LEN) - 1) << HBN_REG_AON_LED_SEL_POS) #define HBN_REG_AON_LED_SEL_UMSK (~(((1U << HBN_REG_AON_LED_SEL_LEN) - 1) << HBN_REG_AON_LED_SEL_POS)) #define HBN_REG_EN_AON_CTRL_GPIO HBN_REG_EN_AON_CTRL_GPIO #define HBN_REG_EN_AON_CTRL_GPIO_POS (20U) #define HBN_REG_EN_AON_CTRL_GPIO_LEN (4U) #define HBN_REG_EN_AON_CTRL_GPIO_MSK (((1U << HBN_REG_EN_AON_CTRL_GPIO_LEN) - 1) << HBN_REG_EN_AON_CTRL_GPIO_POS) #define HBN_REG_EN_AON_CTRL_GPIO_UMSK (~(((1U << HBN_REG_EN_AON_CTRL_GPIO_LEN) - 1) << HBN_REG_EN_AON_CTRL_GPIO_POS)) #define HBN_CR_GPIO_KEEP_EN HBN_CR_GPIO_KEEP_EN #define HBN_CR_GPIO_KEEP_EN_POS (28U) #define HBN_CR_GPIO_KEEP_EN_LEN (3U) #define HBN_CR_GPIO_KEEP_EN_MSK (((1U << HBN_CR_GPIO_KEEP_EN_LEN) - 1) << HBN_CR_GPIO_KEEP_EN_POS) #define HBN_CR_GPIO_KEEP_EN_UMSK (~(((1U << HBN_CR_GPIO_KEEP_EN_LEN) - 1) << HBN_CR_GPIO_KEEP_EN_POS)) #define HBN_REG_AON_GPIO_ISO_MODE HBN_REG_AON_GPIO_ISO_MODE #define HBN_REG_AON_GPIO_ISO_MODE_POS (31U) #define HBN_REG_AON_GPIO_ISO_MODE_LEN (1U) #define HBN_REG_AON_GPIO_ISO_MODE_MSK (((1U << HBN_REG_AON_GPIO_ISO_MODE_LEN) - 1) << HBN_REG_AON_GPIO_ISO_MODE_POS) #define HBN_REG_AON_GPIO_ISO_MODE_UMSK (~(((1U << HBN_REG_AON_GPIO_ISO_MODE_LEN) - 1) << HBN_REG_AON_GPIO_ISO_MODE_POS)) /* 0x3C : HBN_PAD_CTRL_1 */ #define HBN_PAD_CTRL_1_OFFSET (0x3C) #define HBN_REG_AON_PAD_OE HBN_REG_AON_PAD_OE #define HBN_REG_AON_PAD_OE_POS (0U) #define HBN_REG_AON_PAD_OE_LEN (4U) #define HBN_REG_AON_PAD_OE_MSK (((1U << HBN_REG_AON_PAD_OE_LEN) - 1) << HBN_REG_AON_PAD_OE_POS) #define HBN_REG_AON_PAD_OE_UMSK (~(((1U << HBN_REG_AON_PAD_OE_LEN) - 1) << HBN_REG_AON_PAD_OE_POS)) #define HBN_REG_AON_PAD_PD HBN_REG_AON_PAD_PD #define HBN_REG_AON_PAD_PD_POS (10U) #define HBN_REG_AON_PAD_PD_LEN (4U) #define HBN_REG_AON_PAD_PD_MSK (((1U << HBN_REG_AON_PAD_PD_LEN) - 1) << HBN_REG_AON_PAD_PD_POS) #define HBN_REG_AON_PAD_PD_UMSK (~(((1U << HBN_REG_AON_PAD_PD_LEN) - 1) << HBN_REG_AON_PAD_PD_POS)) #define HBN_REG_AON_PAD_PU HBN_REG_AON_PAD_PU #define HBN_REG_AON_PAD_PU_POS (20U) #define HBN_REG_AON_PAD_PU_LEN (4U) #define HBN_REG_AON_PAD_PU_MSK (((1U << HBN_REG_AON_PAD_PU_LEN) - 1) << HBN_REG_AON_PAD_PU_POS) #define HBN_REG_AON_PAD_PU_UMSK (~(((1U << HBN_REG_AON_PAD_PU_LEN) - 1) << HBN_REG_AON_PAD_PU_POS)) /* 0x40 : vbat_ldo */ #define HBN_VBAT_LDO_OFFSET (0x40) #define HBN_LDO33_BM_AON HBN_LDO33_BM_AON #define HBN_LDO33_BM_AON_POS (0U) #define HBN_LDO33_BM_AON_LEN (2U) #define HBN_LDO33_BM_AON_MSK (((1U << HBN_LDO33_BM_AON_LEN) - 1) << HBN_LDO33_BM_AON_POS) #define HBN_LDO33_BM_AON_UMSK (~(((1U << HBN_LDO33_BM_AON_LEN) - 1) << HBN_LDO33_BM_AON_POS)) #define HBN_LDO33_CC_AON HBN_LDO33_CC_AON #define HBN_LDO33_CC_AON_POS (4U) #define HBN_LDO33_CC_AON_LEN (3U) #define HBN_LDO33_CC_AON_MSK (((1U << HBN_LDO33_CC_AON_LEN) - 1) << HBN_LDO33_CC_AON_POS) #define HBN_LDO33_CC_AON_UMSK (~(((1U << HBN_LDO33_CC_AON_LEN) - 1) << HBN_LDO33_CC_AON_POS)) #define HBN_LDO33_OCP_EN_AON HBN_LDO33_OCP_EN_AON #define HBN_LDO33_OCP_EN_AON_POS (7U) #define HBN_LDO33_OCP_EN_AON_LEN (1U) #define HBN_LDO33_OCP_EN_AON_MSK (((1U << HBN_LDO33_OCP_EN_AON_LEN) - 1) << HBN_LDO33_OCP_EN_AON_POS) #define HBN_LDO33_OCP_EN_AON_UMSK (~(((1U << HBN_LDO33_OCP_EN_AON_LEN) - 1) << HBN_LDO33_OCP_EN_AON_POS)) #define HBN_LDO33_OCP_TH_AON HBN_LDO33_OCP_TH_AON #define HBN_LDO33_OCP_TH_AON_POS (8U) #define HBN_LDO33_OCP_TH_AON_LEN (3U) #define HBN_LDO33_OCP_TH_AON_MSK (((1U << HBN_LDO33_OCP_TH_AON_LEN) - 1) << HBN_LDO33_OCP_TH_AON_POS) #define HBN_LDO33_OCP_TH_AON_UMSK (~(((1U << HBN_LDO33_OCP_TH_AON_LEN) - 1) << HBN_LDO33_OCP_TH_AON_POS)) #define HBN_LDO33_SSTART_DELAY_AON HBN_LDO33_SSTART_DELAY_AON #define HBN_LDO33_SSTART_DELAY_AON_POS (12U) #define HBN_LDO33_SSTART_DELAY_AON_LEN (3U) #define HBN_LDO33_SSTART_DELAY_AON_MSK (((1U << HBN_LDO33_SSTART_DELAY_AON_LEN) - 1) << HBN_LDO33_SSTART_DELAY_AON_POS) #define HBN_LDO33_SSTART_DELAY_AON_UMSK (~(((1U << HBN_LDO33_SSTART_DELAY_AON_LEN) - 1) << HBN_LDO33_SSTART_DELAY_AON_POS)) #define HBN_LDO33_SSTART_EN_AON HBN_LDO33_SSTART_EN_AON #define HBN_LDO33_SSTART_EN_AON_POS (15U) #define HBN_LDO33_SSTART_EN_AON_LEN (1U) #define HBN_LDO33_SSTART_EN_AON_MSK (((1U << HBN_LDO33_SSTART_EN_AON_LEN) - 1) << HBN_LDO33_SSTART_EN_AON_POS) #define HBN_LDO33_SSTART_EN_AON_UMSK (~(((1U << HBN_LDO33_SSTART_EN_AON_LEN) - 1) << HBN_LDO33_SSTART_EN_AON_POS)) #define HBN_LDO33_VOUT_SEL_AON HBN_LDO33_VOUT_SEL_AON #define HBN_LDO33_VOUT_SEL_AON_POS (16U) #define HBN_LDO33_VOUT_SEL_AON_LEN (4U) #define HBN_LDO33_VOUT_SEL_AON_MSK (((1U << HBN_LDO33_VOUT_SEL_AON_LEN) - 1) << HBN_LDO33_VOUT_SEL_AON_POS) #define HBN_LDO33_VOUT_SEL_AON_UMSK (~(((1U << HBN_LDO33_VOUT_SEL_AON_LEN) - 1) << HBN_LDO33_VOUT_SEL_AON_POS)) #define HBN_LDO33_VOUT_TRIM_AON HBN_LDO33_VOUT_TRIM_AON #define HBN_LDO33_VOUT_TRIM_AON_POS (20U) #define HBN_LDO33_VOUT_TRIM_AON_LEN (4U) #define HBN_LDO33_VOUT_TRIM_AON_MSK (((1U << HBN_LDO33_VOUT_TRIM_AON_LEN) - 1) << HBN_LDO33_VOUT_TRIM_AON_POS) #define HBN_LDO33_VOUT_TRIM_AON_UMSK (~(((1U << HBN_LDO33_VOUT_TRIM_AON_LEN) - 1) << HBN_LDO33_VOUT_TRIM_AON_POS)) #define HBN_LDO33_OTP_EN_AON HBN_LDO33_OTP_EN_AON #define HBN_LDO33_OTP_EN_AON_POS (24U) #define HBN_LDO33_OTP_EN_AON_LEN (1U) #define HBN_LDO33_OTP_EN_AON_MSK (((1U << HBN_LDO33_OTP_EN_AON_LEN) - 1) << HBN_LDO33_OTP_EN_AON_POS) #define HBN_LDO33_OTP_EN_AON_UMSK (~(((1U << HBN_LDO33_OTP_EN_AON_LEN) - 1) << HBN_LDO33_OTP_EN_AON_POS)) #define HBN_LDO33_OTP_OUT_AON HBN_LDO33_OTP_OUT_AON #define HBN_LDO33_OTP_OUT_AON_POS (25U) #define HBN_LDO33_OTP_OUT_AON_LEN (1U) #define HBN_LDO33_OTP_OUT_AON_MSK (((1U << HBN_LDO33_OTP_OUT_AON_LEN) - 1) << HBN_LDO33_OTP_OUT_AON_POS) #define HBN_LDO33_OTP_OUT_AON_UMSK (~(((1U << HBN_LDO33_OTP_OUT_AON_LEN) - 1) << HBN_LDO33_OTP_OUT_AON_POS)) #define HBN_LDO33_OCP_OUT_AON HBN_LDO33_OCP_OUT_AON #define HBN_LDO33_OCP_OUT_AON_POS (26U) #define HBN_LDO33_OCP_OUT_AON_LEN (1U) #define HBN_LDO33_OCP_OUT_AON_MSK (((1U << HBN_LDO33_OCP_OUT_AON_LEN) - 1) << HBN_LDO33_OCP_OUT_AON_POS) #define HBN_LDO33_OCP_OUT_AON_UMSK (~(((1U << HBN_LDO33_OCP_OUT_AON_LEN) - 1) << HBN_LDO33_OCP_OUT_AON_POS)) #define HBN_TEN_LDO33_AON HBN_TEN_LDO33_AON #define HBN_TEN_LDO33_AON_POS (27U) #define HBN_TEN_LDO33_AON_LEN (1U) #define HBN_TEN_LDO33_AON_MSK (((1U << HBN_TEN_LDO33_AON_LEN) - 1) << HBN_TEN_LDO33_AON_POS) #define HBN_TEN_LDO33_AON_UMSK (~(((1U << HBN_TEN_LDO33_AON_LEN) - 1) << HBN_TEN_LDO33_AON_POS)) #define HBN_LDO33_OTP_TH_AON HBN_LDO33_OTP_TH_AON #define HBN_LDO33_OTP_TH_AON_POS (28U) #define HBN_LDO33_OTP_TH_AON_LEN (3U) #define HBN_LDO33_OTP_TH_AON_MSK (((1U << HBN_LDO33_OTP_TH_AON_LEN) - 1) << HBN_LDO33_OTP_TH_AON_POS) #define HBN_LDO33_OTP_TH_AON_UMSK (~(((1U << HBN_LDO33_OTP_TH_AON_LEN) - 1) << HBN_LDO33_OTP_TH_AON_POS)) #define HBN_LDO33_OTP_SD_AON HBN_LDO33_OTP_SD_AON #define HBN_LDO33_OTP_SD_AON_POS (31U) #define HBN_LDO33_OTP_SD_AON_LEN (1U) #define HBN_LDO33_OTP_SD_AON_MSK (((1U << HBN_LDO33_OTP_SD_AON_LEN) - 1) << HBN_LDO33_OTP_SD_AON_POS) #define HBN_LDO33_OTP_SD_AON_UMSK (~(((1U << HBN_LDO33_OTP_SD_AON_LEN) - 1) << HBN_LDO33_OTP_SD_AON_POS)) /* 0x100 : HBN_RSV0 */ #define HBN_RSV0_OFFSET (0x100) #define HBN_RSV0 HBN_RSV0 #define HBN_RSV0_POS (0U) #define HBN_RSV0_LEN (32U) #define HBN_RSV0_MSK (((1U << HBN_RSV0_LEN) - 1) << HBN_RSV0_POS) #define HBN_RSV0_UMSK (~(((1U << HBN_RSV0_LEN) - 1) << HBN_RSV0_POS)) /* 0x104 : HBN_RSV1 */ #define HBN_RSV1_OFFSET (0x104) #define HBN_RSV1 HBN_RSV1 #define HBN_RSV1_POS (0U) #define HBN_RSV1_LEN (32U) #define HBN_RSV1_MSK (((1U << HBN_RSV1_LEN) - 1) << HBN_RSV1_POS) #define HBN_RSV1_UMSK (~(((1U << HBN_RSV1_LEN) - 1) << HBN_RSV1_POS)) /* 0x108 : HBN_RSV2 */ #define HBN_RSV2_OFFSET (0x108) #define HBN_RSV2 HBN_RSV2 #define HBN_RSV2_POS (0U) #define HBN_RSV2_LEN (32U) #define HBN_RSV2_MSK (((1U << HBN_RSV2_LEN) - 1) << HBN_RSV2_POS) #define HBN_RSV2_UMSK (~(((1U << HBN_RSV2_LEN) - 1) << HBN_RSV2_POS)) /* 0x10C : HBN_RSV3 */ #define HBN_RSV3_OFFSET (0x10C) #define HBN_RSV3 HBN_RSV3 #define HBN_RSV3_POS (0U) #define HBN_RSV3_LEN (32U) #define HBN_RSV3_MSK (((1U << HBN_RSV3_LEN) - 1) << HBN_RSV3_POS) #define HBN_RSV3_UMSK (~(((1U << HBN_RSV3_LEN) - 1) << HBN_RSV3_POS)) /* 0x200 : rc32k_ctrl0 */ #define HBN_RC32K_CTRL0_OFFSET (0x200) #define HBN_RC32K_CAL_DONE HBN_RC32K_CAL_DONE #define HBN_RC32K_CAL_DONE_POS (0U) #define HBN_RC32K_CAL_DONE_LEN (1U) #define HBN_RC32K_CAL_DONE_MSK (((1U << HBN_RC32K_CAL_DONE_LEN) - 1) << HBN_RC32K_CAL_DONE_POS) #define HBN_RC32K_CAL_DONE_UMSK (~(((1U << HBN_RC32K_CAL_DONE_LEN) - 1) << HBN_RC32K_CAL_DONE_POS)) #define HBN_RC32K_RDY HBN_RC32K_RDY #define HBN_RC32K_RDY_POS (1U) #define HBN_RC32K_RDY_LEN (1U) #define HBN_RC32K_RDY_MSK (((1U << HBN_RC32K_RDY_LEN) - 1) << HBN_RC32K_RDY_POS) #define HBN_RC32K_RDY_UMSK (~(((1U << HBN_RC32K_RDY_LEN) - 1) << HBN_RC32K_RDY_POS)) #define HBN_RC32K_CAL_INPROGRESS HBN_RC32K_CAL_INPROGRESS #define HBN_RC32K_CAL_INPROGRESS_POS (2U) #define HBN_RC32K_CAL_INPROGRESS_LEN (1U) #define HBN_RC32K_CAL_INPROGRESS_MSK (((1U << HBN_RC32K_CAL_INPROGRESS_LEN) - 1) << HBN_RC32K_CAL_INPROGRESS_POS) #define HBN_RC32K_CAL_INPROGRESS_UMSK (~(((1U << HBN_RC32K_CAL_INPROGRESS_LEN) - 1) << HBN_RC32K_CAL_INPROGRESS_POS)) #define HBN_RC32K_CAL_DIV HBN_RC32K_CAL_DIV #define HBN_RC32K_CAL_DIV_POS (3U) #define HBN_RC32K_CAL_DIV_LEN (2U) #define HBN_RC32K_CAL_DIV_MSK (((1U << HBN_RC32K_CAL_DIV_LEN) - 1) << HBN_RC32K_CAL_DIV_POS) #define HBN_RC32K_CAL_DIV_UMSK (~(((1U << HBN_RC32K_CAL_DIV_LEN) - 1) << HBN_RC32K_CAL_DIV_POS)) #define HBN_RC32K_CAL_PRECHARGE HBN_RC32K_CAL_PRECHARGE #define HBN_RC32K_CAL_PRECHARGE_POS (5U) #define HBN_RC32K_CAL_PRECHARGE_LEN (1U) #define HBN_RC32K_CAL_PRECHARGE_MSK (((1U << HBN_RC32K_CAL_PRECHARGE_LEN) - 1) << HBN_RC32K_CAL_PRECHARGE_POS) #define HBN_RC32K_CAL_PRECHARGE_UMSK (~(((1U << HBN_RC32K_CAL_PRECHARGE_LEN) - 1) << HBN_RC32K_CAL_PRECHARGE_POS)) #define HBN_RC32K_DIG_CODE_FR_CAL HBN_RC32K_DIG_CODE_FR_CAL #define HBN_RC32K_DIG_CODE_FR_CAL_POS (6U) #define HBN_RC32K_DIG_CODE_FR_CAL_LEN (10U) #define HBN_RC32K_DIG_CODE_FR_CAL_MSK (((1U << HBN_RC32K_DIG_CODE_FR_CAL_LEN) - 1) << HBN_RC32K_DIG_CODE_FR_CAL_POS) #define HBN_RC32K_DIG_CODE_FR_CAL_UMSK (~(((1U << HBN_RC32K_DIG_CODE_FR_CAL_LEN) - 1) << HBN_RC32K_DIG_CODE_FR_CAL_POS)) #define HBN_RC32K_VREF_DLY HBN_RC32K_VREF_DLY #define HBN_RC32K_VREF_DLY_POS (16U) #define HBN_RC32K_VREF_DLY_LEN (2U) #define HBN_RC32K_VREF_DLY_MSK (((1U << HBN_RC32K_VREF_DLY_LEN) - 1) << HBN_RC32K_VREF_DLY_POS) #define HBN_RC32K_VREF_DLY_UMSK (~(((1U << HBN_RC32K_VREF_DLY_LEN) - 1) << HBN_RC32K_VREF_DLY_POS)) #define HBN_RC32K_ALLOW_CAL HBN_RC32K_ALLOW_CAL #define HBN_RC32K_ALLOW_CAL_POS (18U) #define HBN_RC32K_ALLOW_CAL_LEN (1U) #define HBN_RC32K_ALLOW_CAL_MSK (((1U << HBN_RC32K_ALLOW_CAL_LEN) - 1) << HBN_RC32K_ALLOW_CAL_POS) #define HBN_RC32K_ALLOW_CAL_UMSK (~(((1U << HBN_RC32K_ALLOW_CAL_LEN) - 1) << HBN_RC32K_ALLOW_CAL_POS)) #define HBN_RC32K_EXT_CODE_EN HBN_RC32K_EXT_CODE_EN #define HBN_RC32K_EXT_CODE_EN_POS (19U) #define HBN_RC32K_EXT_CODE_EN_LEN (1U) #define HBN_RC32K_EXT_CODE_EN_MSK (((1U << HBN_RC32K_EXT_CODE_EN_LEN) - 1) << HBN_RC32K_EXT_CODE_EN_POS) #define HBN_RC32K_EXT_CODE_EN_UMSK (~(((1U << HBN_RC32K_EXT_CODE_EN_LEN) - 1) << HBN_RC32K_EXT_CODE_EN_POS)) #define HBN_RC32K_CAL_EN HBN_RC32K_CAL_EN #define HBN_RC32K_CAL_EN_POS (20U) #define HBN_RC32K_CAL_EN_LEN (1U) #define HBN_RC32K_CAL_EN_MSK (((1U << HBN_RC32K_CAL_EN_LEN) - 1) << HBN_RC32K_CAL_EN_POS) #define HBN_RC32K_CAL_EN_UMSK (~(((1U << HBN_RC32K_CAL_EN_LEN) - 1) << HBN_RC32K_CAL_EN_POS)) #define HBN_CR_PU_RC32K HBN_CR_PU_RC32K #define HBN_CR_PU_RC32K_POS (21U) #define HBN_CR_PU_RC32K_LEN (1U) #define HBN_CR_PU_RC32K_MSK (((1U << HBN_CR_PU_RC32K_LEN) - 1) << HBN_CR_PU_RC32K_POS) #define HBN_CR_PU_RC32K_UMSK (~(((1U << HBN_CR_PU_RC32K_LEN) - 1) << HBN_CR_PU_RC32K_POS)) #define HBN_RC32K_CODE_FR_EXT HBN_RC32K_CODE_FR_EXT #define HBN_RC32K_CODE_FR_EXT_POS (22U) #define HBN_RC32K_CODE_FR_EXT_LEN (10U) #define HBN_RC32K_CODE_FR_EXT_MSK (((1U << HBN_RC32K_CODE_FR_EXT_LEN) - 1) << HBN_RC32K_CODE_FR_EXT_POS) #define HBN_RC32K_CODE_FR_EXT_UMSK (~(((1U << HBN_RC32K_CODE_FR_EXT_LEN) - 1) << HBN_RC32K_CODE_FR_EXT_POS)) /* 0x204 : xtal32k */ #define HBN_XTAL32K_OFFSET (0x204) #define HBN_XTAL32K_EXT_SEL HBN_XTAL32K_EXT_SEL #define HBN_XTAL32K_EXT_SEL_POS (2U) #define HBN_XTAL32K_EXT_SEL_LEN (1U) #define HBN_XTAL32K_EXT_SEL_MSK (((1U << HBN_XTAL32K_EXT_SEL_LEN) - 1) << HBN_XTAL32K_EXT_SEL_POS) #define HBN_XTAL32K_EXT_SEL_UMSK (~(((1U << HBN_XTAL32K_EXT_SEL_LEN) - 1) << HBN_XTAL32K_EXT_SEL_POS)) #define HBN_XTAL32K_AMP_CTRL HBN_XTAL32K_AMP_CTRL #define HBN_XTAL32K_AMP_CTRL_POS (3U) #define HBN_XTAL32K_AMP_CTRL_LEN (2U) #define HBN_XTAL32K_AMP_CTRL_MSK (((1U << HBN_XTAL32K_AMP_CTRL_LEN) - 1) << HBN_XTAL32K_AMP_CTRL_POS) #define HBN_XTAL32K_AMP_CTRL_UMSK (~(((1U << HBN_XTAL32K_AMP_CTRL_LEN) - 1) << HBN_XTAL32K_AMP_CTRL_POS)) #define HBN_XTAL32K_REG HBN_XTAL32K_REG #define HBN_XTAL32K_REG_POS (5U) #define HBN_XTAL32K_REG_LEN (2U) #define HBN_XTAL32K_REG_MSK (((1U << HBN_XTAL32K_REG_LEN) - 1) << HBN_XTAL32K_REG_POS) #define HBN_XTAL32K_REG_UMSK (~(((1U << HBN_XTAL32K_REG_LEN) - 1) << HBN_XTAL32K_REG_POS)) #define HBN_XTAL32K_OUTBUF_STRE HBN_XTAL32K_OUTBUF_STRE #define HBN_XTAL32K_OUTBUF_STRE_POS (7U) #define HBN_XTAL32K_OUTBUF_STRE_LEN (1U) #define HBN_XTAL32K_OUTBUF_STRE_MSK (((1U << HBN_XTAL32K_OUTBUF_STRE_LEN) - 1) << HBN_XTAL32K_OUTBUF_STRE_POS) #define HBN_XTAL32K_OUTBUF_STRE_UMSK (~(((1U << HBN_XTAL32K_OUTBUF_STRE_LEN) - 1) << HBN_XTAL32K_OUTBUF_STRE_POS)) #define HBN_XTAL32K_OTF_SHORT HBN_XTAL32K_OTF_SHORT #define HBN_XTAL32K_OTF_SHORT_POS (8U) #define HBN_XTAL32K_OTF_SHORT_LEN (1U) #define HBN_XTAL32K_OTF_SHORT_MSK (((1U << HBN_XTAL32K_OTF_SHORT_LEN) - 1) << HBN_XTAL32K_OTF_SHORT_POS) #define HBN_XTAL32K_OTF_SHORT_UMSK (~(((1U << HBN_XTAL32K_OTF_SHORT_LEN) - 1) << HBN_XTAL32K_OTF_SHORT_POS)) #define HBN_XTAL32K_INV_STRE HBN_XTAL32K_INV_STRE #define HBN_XTAL32K_INV_STRE_POS (9U) #define HBN_XTAL32K_INV_STRE_LEN (2U) #define HBN_XTAL32K_INV_STRE_MSK (((1U << HBN_XTAL32K_INV_STRE_LEN) - 1) << HBN_XTAL32K_INV_STRE_POS) #define HBN_XTAL32K_INV_STRE_UMSK (~(((1U << HBN_XTAL32K_INV_STRE_LEN) - 1) << HBN_XTAL32K_INV_STRE_POS)) #define HBN_XTAL32K_CAPBANK HBN_XTAL32K_CAPBANK #define HBN_XTAL32K_CAPBANK_POS (11U) #define HBN_XTAL32K_CAPBANK_LEN (6U) #define HBN_XTAL32K_CAPBANK_MSK (((1U << HBN_XTAL32K_CAPBANK_LEN) - 1) << HBN_XTAL32K_CAPBANK_POS) #define HBN_XTAL32K_CAPBANK_UMSK (~(((1U << HBN_XTAL32K_CAPBANK_LEN) - 1) << HBN_XTAL32K_CAPBANK_POS)) #define HBN_XTAL32K_AC_CAP_SHORT HBN_XTAL32K_AC_CAP_SHORT #define HBN_XTAL32K_AC_CAP_SHORT_POS (17U) #define HBN_XTAL32K_AC_CAP_SHORT_LEN (1U) #define HBN_XTAL32K_AC_CAP_SHORT_MSK (((1U << HBN_XTAL32K_AC_CAP_SHORT_LEN) - 1) << HBN_XTAL32K_AC_CAP_SHORT_POS) #define HBN_XTAL32K_AC_CAP_SHORT_UMSK (~(((1U << HBN_XTAL32K_AC_CAP_SHORT_LEN) - 1) << HBN_XTAL32K_AC_CAP_SHORT_POS)) #define HBN_PU_XTAL32K_BUF HBN_PU_XTAL32K_BUF #define HBN_PU_XTAL32K_BUF_POS (18U) #define HBN_PU_XTAL32K_BUF_LEN (1U) #define HBN_PU_XTAL32K_BUF_MSK (((1U << HBN_PU_XTAL32K_BUF_LEN) - 1) << HBN_PU_XTAL32K_BUF_POS) #define HBN_PU_XTAL32K_BUF_UMSK (~(((1U << HBN_PU_XTAL32K_BUF_LEN) - 1) << HBN_PU_XTAL32K_BUF_POS)) #define HBN_PU_XTAL32K HBN_PU_XTAL32K #define HBN_PU_XTAL32K_POS (19U) #define HBN_PU_XTAL32K_LEN (1U) #define HBN_PU_XTAL32K_MSK (((1U << HBN_PU_XTAL32K_LEN) - 1) << HBN_PU_XTAL32K_POS) #define HBN_PU_XTAL32K_UMSK (~(((1U << HBN_PU_XTAL32K_LEN) - 1) << HBN_PU_XTAL32K_POS)) #define HBN_XTAL32K_LOWV_EN HBN_XTAL32K_LOWV_EN #define HBN_XTAL32K_LOWV_EN_POS (20U) #define HBN_XTAL32K_LOWV_EN_LEN (1U) #define HBN_XTAL32K_LOWV_EN_MSK (((1U << HBN_XTAL32K_LOWV_EN_LEN) - 1) << HBN_XTAL32K_LOWV_EN_POS) #define HBN_XTAL32K_LOWV_EN_UMSK (~(((1U << HBN_XTAL32K_LOWV_EN_LEN) - 1) << HBN_XTAL32K_LOWV_EN_POS)) #define HBN_XTAL32K_HIZ_EN HBN_XTAL32K_HIZ_EN #define HBN_XTAL32K_HIZ_EN_POS (21U) #define HBN_XTAL32K_HIZ_EN_LEN (1U) #define HBN_XTAL32K_HIZ_EN_MSK (((1U << HBN_XTAL32K_HIZ_EN_LEN) - 1) << HBN_XTAL32K_HIZ_EN_POS) #define HBN_XTAL32K_HIZ_EN_UMSK (~(((1U << HBN_XTAL32K_HIZ_EN_LEN) - 1) << HBN_XTAL32K_HIZ_EN_POS)) #define HBN_DTEN_XTAL32K HBN_DTEN_XTAL32K #define HBN_DTEN_XTAL32K_POS (22U) #define HBN_DTEN_XTAL32K_LEN (1U) #define HBN_DTEN_XTAL32K_MSK (((1U << HBN_DTEN_XTAL32K_LEN) - 1) << HBN_DTEN_XTAL32K_POS) #define HBN_DTEN_XTAL32K_UMSK (~(((1U << HBN_DTEN_XTAL32K_LEN) - 1) << HBN_DTEN_XTAL32K_POS)) #define HBN_TEN_XTAL32K HBN_TEN_XTAL32K #define HBN_TEN_XTAL32K_POS (23U) #define HBN_TEN_XTAL32K_LEN (1U) #define HBN_TEN_XTAL32K_MSK (((1U << HBN_TEN_XTAL32K_LEN) - 1) << HBN_TEN_XTAL32K_POS) #define HBN_TEN_XTAL32K_UMSK (~(((1U << HBN_TEN_XTAL32K_LEN) - 1) << HBN_TEN_XTAL32K_POS)) struct hbn_reg { /* 0x0 : HBN_CTL */ union { struct { uint32_t rtc_ctl : 4; /* [ 3: 0], r/w, 0x0 */ uint32_t rtc_dly_option : 1; /* [ 4], r/w, 0x0 */ uint32_t reserved_5_6 : 2; /* [ 6: 5], rsvd, 0x0 */ uint32_t hbn_mode : 1; /* [ 7], w, 0x0 */ uint32_t trap_mode : 1; /* [ 8], r, 0x0 */ uint32_t pwrdn_hbn_core : 1; /* [ 9], r/w, 0x0 */ uint32_t reserved_10 : 1; /* [ 10], rsvd, 0x0 */ uint32_t pwrdn_hbn_rtc : 1; /* [ 11], r/w, 0x0 */ uint32_t sw_rst : 1; /* [ 12], r/w, 0x0 */ uint32_t hbn_dis_pwr_off_ldo11 : 1; /* [ 13], r/w, 0x0 */ uint32_t hbn_dis_pwr_off_ldo11_rt : 1; /* [ 14], r/w, 0x0 */ uint32_t hbn_ldo11_rt_vout_sel : 4; /* [18:15], r/w, 0xa */ uint32_t hbn_ldo11_aon_vout_sel : 4; /* [22:19], r/w, 0xa */ uint32_t reserved_23 : 1; /* [ 23], rsvd, 0x0 */ uint32_t pu_dcdc18_aon : 1; /* [ 24], r/w, 0x1 */ uint32_t pwr_on_option : 1; /* [ 25], r/w, 0x0 */ uint32_t sram_slp_option : 1; /* [ 26], r/w, 0x0 */ uint32_t sram_slp : 1; /* [ 27], r, 0x0 */ uint32_t hbn_state : 4; /* [31:28], r, 0x0 */ } BF; uint32_t WORD; } HBN_CTL; /* 0x4 : HBN_TIME_L */ union { struct { uint32_t hbn_time_l : 32; /* [31: 0], r/w, 0x0 */ } BF; uint32_t WORD; } HBN_TIME_L; /* 0x8 : HBN_TIME_H */ union { struct { uint32_t hbn_time_h : 8; /* [ 7: 0], r/w, 0x0 */ uint32_t reserved_8_31 : 24; /* [31: 8], rsvd, 0x0 */ } BF; uint32_t WORD; } HBN_TIME_H; /* 0xC : RTC_TIME_L */ union { struct { uint32_t rtc_time_latch_l : 32; /* [31: 0], r, 0x0 */ } BF; uint32_t WORD; } RTC_TIME_L; /* 0x10 : RTC_TIME_H */ union { struct { uint32_t rtc_time_latch_h : 8; /* [ 7: 0], r, 0x0 */ uint32_t reserved_8_30 : 23; /* [30: 8], rsvd, 0x0 */ uint32_t rtc_time_latch : 1; /* [ 31], w, 0x0 */ } BF; uint32_t WORD; } RTC_TIME_H; /* 0x14 : HBN_IRQ_MODE */ union { struct { uint32_t hbn_pin_wakeup_mode : 4; /* [ 3: 0], r/w, 0x5 */ uint32_t hbn_pin_wakeup_mask : 4; /* [ 7: 4], r/w, 0x0 */ uint32_t reserved_8_15 : 8; /* [15: 8], rsvd, 0x0 */ uint32_t reg_en_hw_pu_pd : 1; /* [ 16], r/w, 0x1 */ uint32_t reserved_17 : 1; /* [ 17], rsvd, 0x0 */ uint32_t irq_bor_en : 1; /* [ 18], r/w, 0x0 */ uint32_t reserved_19 : 1; /* [ 19], rsvd, 0x0 */ uint32_t irq_acomp0_en : 2; /* [21:20], r/w, 0x0 */ uint32_t irq_acomp1_en : 2; /* [23:22], r/w, 0x0 */ uint32_t pin_wakeup_sel : 3; /* [26:24], r/w, 0x3 */ uint32_t pin_wakeup_en : 1; /* [ 27], r/w, 0x0 */ uint32_t reserved_28_31 : 4; /* [31:28], rsvd, 0x0 */ } BF; uint32_t WORD; } HBN_IRQ_MODE; /* 0x18 : HBN_IRQ_STAT */ union { struct { uint32_t irq_stat : 32; /* [31: 0], r, 0x0 */ } BF; uint32_t WORD; } HBN_IRQ_STAT; /* 0x1C : HBN_IRQ_CLR */ union { struct { uint32_t irq_clr : 32; /* [31: 0], w, 0x0 */ } BF; uint32_t WORD; } HBN_IRQ_CLR; /* 0x20 : HBN_PIR_CFG */ union { struct { uint32_t pir_hpf_sel : 2; /* [ 1: 0], r/w, 0x0 */ uint32_t pir_lpf_sel : 1; /* [ 2], r/w, 0x0 */ uint32_t reserved_3 : 1; /* [ 3], rsvd, 0x0 */ uint32_t pir_dis : 2; /* [ 5: 4], r/w, 0x0 */ uint32_t reserved_6 : 1; /* [ 6], rsvd, 0x0 */ uint32_t pir_en : 1; /* [ 7], r/w, 0x0 */ uint32_t gpadc_cs : 1; /* [ 8], r/w, 0x0 */ uint32_t reserved_9_31 : 23; /* [31: 9], rsvd, 0x0 */ } BF; uint32_t WORD; } HBN_PIR_CFG; /* 0x24 : HBN_PIR_VTH */ union { struct { uint32_t pir_vth : 14; /* [13: 0], r/w, 0x3ff */ uint32_t reserved_14_31 : 18; /* [31:14], rsvd, 0x0 */ } BF; uint32_t WORD; } HBN_PIR_VTH; /* 0x28 : HBN_PIR_INTERVAL */ union { struct { uint32_t pir_interval : 12; /* [11: 0], r/w, 0xa3d */ uint32_t reserved_12_31 : 20; /* [31:12], rsvd, 0x0 */ } BF; uint32_t WORD; } HBN_PIR_INTERVAL; /* 0x2C : HBN_BOR_CFG */ union { struct { uint32_t bod_sel : 1; /* [ 0], r/w, 0x0 */ uint32_t bod_vth : 3; /* [ 3: 1], r/w, 0x5 */ uint32_t pu_bod : 1; /* [ 4], r/w, 0x0 */ uint32_t r_bod_out : 1; /* [ 5], r, 0x0 */ uint32_t reserved_6_31 : 26; /* [31: 6], rsvd, 0x0 */ } BF; uint32_t WORD; } HBN_BOR_CFG; /* 0x30 : HBN_GLB */ union { struct { uint32_t hbn_root_clk_sel : 2; /* [ 1: 0], r/w, 0x0 */ uint32_t hbn_uart_clk_sel : 1; /* [ 2], r/w, 0x0 */ uint32_t hbn_f32k_sel : 2; /* [ 4: 3], r/w, 0x0 */ uint32_t hbn_pu_rc32k : 1; /* [ 5], r/w, 0x1 */ uint32_t reserved_6 : 1; /* [ 6], rsvd, 0x0 */ uint32_t hbn_reset_event : 5; /* [11: 7], r, 0x0 */ uint32_t reserved_12_14 : 3; /* [14:12], rsvd, 0x0 */ uint32_t hbn_uart_clk_sel2 : 1; /* [ 15], r/w, 0x0 */ uint32_t sw_ldo11soc_vout_sel_aon : 4; /* [19:16], r/w, 0xa */ uint32_t reserved_20_23 : 4; /* [23:20], rsvd, 0x0 */ uint32_t sw_ldo11_rt_vout_sel : 4; /* [27:24], r/w, 0xa */ uint32_t sw_ldo11_aon_vout_sel : 4; /* [31:28], r/w, 0xa */ } BF; uint32_t WORD; } HBN_GLB; /* 0x34 : HBN_SRAM */ union { struct { uint32_t reserved_0_5 : 6; /* [ 5: 0], rsvd, 0x0 */ uint32_t retram_ret : 1; /* [ 6], r/w, 0x0 */ uint32_t retram_slp : 1; /* [ 7], r/w, 0x0 */ uint32_t reserved_8_31 : 24; /* [31: 8], rsvd, 0x0 */ } BF; uint32_t WORD; } HBN_SRAM; /* 0x38 : HBN_PAD_CTRL_0 */ union { struct { uint32_t reg_aon_pad_ie_smt : 4; /* [ 3: 0], None, 0x0 */ uint32_t reserved_4_9 : 6; /* [ 9: 4], rsvd, 0x0 */ uint32_t reg_aon_led_sel : 9; /* [18:10], None, 0x0 */ uint32_t reserved_19 : 1; /* [ 19], rsvd, 0x0 */ uint32_t reg_en_aon_ctrl_gpio : 4; /* [23:20], None, 0x0 */ uint32_t reserved_24_27 : 4; /* [27:24], rsvd, 0x0 */ uint32_t cr_gpio_keep_en : 3; /* [30:28], r/w, 0x0 */ uint32_t reg_aon_gpio_iso_mode : 1; /* [ 31], r/w, 0x0 */ } BF; uint32_t WORD; } HBN_PAD_CTRL_0; /* 0x3C : HBN_PAD_CTRL_1 */ union { struct { uint32_t reg_aon_pad_oe : 4; /* [ 3: 0], None, 0x0 */ uint32_t reserved_4_9 : 6; /* [ 9: 4], rsvd, 0x0 */ uint32_t reg_aon_pad_pd : 4; /* [13:10], None, 0x0 */ uint32_t reserved_14_19 : 6; /* [19:14], rsvd, 0x0 */ uint32_t reg_aon_pad_pu : 4; /* [23:20], None, 0x0 */ uint32_t reserved_24_31 : 8; /* [31:24], rsvd, 0x0 */ } BF; uint32_t WORD; } HBN_PAD_CTRL_1; /* 0x40 : vbat_ldo */ union { struct { uint32_t ldo33_bm_aon : 2; /* [ 1: 0], r/w, 0x1 */ uint32_t reserved_2_3 : 2; /* [ 3: 2], rsvd, 0x0 */ uint32_t ldo33_cc_aon : 3; /* [ 6: 4], r/w, 0x1 */ uint32_t ldo33_ocp_en_aon : 1; /* [ 7], r/w, 0x1 */ uint32_t ldo33_ocp_th_aon : 3; /* [10: 8], r/w, 0x5 */ uint32_t reserved_11 : 1; /* [ 11], rsvd, 0x0 */ uint32_t ldo33_sstart_delay_aon : 3; /* [14:12], r/w, 0x3 */ uint32_t ldo33_sstart_en_aon : 1; /* [ 15], r/w, 0x1 */ uint32_t ldo33_vout_sel_aon : 4; /* [19:16], r/w, 0xb */ uint32_t ldo33_vout_trim_aon : 4; /* [23:20], r/w, 0x8 */ uint32_t ldo33_otp_en_aon : 1; /* [ 24], r/w, 0x1 */ uint32_t ldo33_otp_out_aon : 1; /* [ 25], r, 0x0 */ uint32_t ldo33_ocp_out_aon : 1; /* [ 26], r, 0x0 */ uint32_t ten_ldo33_aon : 1; /* [ 27], r/w, 0x0 */ uint32_t ldo33_otp_th_aon : 3; /* [30:28], r/w, 0x7 */ uint32_t ldo33_otp_sd_aon : 1; /* [ 31], r/w, 0x0 */ } BF; uint32_t WORD; } vbat_ldo; /* 0x44 reserved */ uint8_t RESERVED0x44[188]; /* 0x100 : HBN_RSV0 */ union { struct { uint32_t HBN_RSV0 : 32; /* [31: 0], r/w, 0x0 */ } BF; uint32_t WORD; } HBN_RSV0; /* 0x104 : HBN_RSV1 */ union { struct { uint32_t HBN_RSV1 : 32; /* [31: 0], r/w, 0xffffffff */ } BF; uint32_t WORD; } HBN_RSV1; /* 0x108 : HBN_RSV2 */ union { struct { uint32_t HBN_RSV2 : 32; /* [31: 0], r/w, 0x0 */ } BF; uint32_t WORD; } HBN_RSV2; /* 0x10C : HBN_RSV3 */ union { struct { uint32_t HBN_RSV3 : 32; /* [31: 0], r/w, 0xffffffff */ } BF; uint32_t WORD; } HBN_RSV3; /* 0x110 reserved */ uint8_t RESERVED0x110[240]; /* 0x200 : rc32k_ctrl0 */ union { struct { uint32_t rc32k_cal_done : 1; /* [ 0], r, 0x1 */ uint32_t rc32k_rdy : 1; /* [ 1], r, 0x1 */ uint32_t rc32k_cal_inprogress : 1; /* [ 2], r, 0x0 */ uint32_t rc32k_cal_div : 2; /* [ 4: 3], r/w, 0x3 */ uint32_t rc32k_cal_precharge : 1; /* [ 5], r, 0x0 */ uint32_t rc32k_dig_code_fr_cal : 10; /* [15: 6], r, 0x200 */ uint32_t rc32k_vref_dly : 2; /* [17:16], r/w, 0x0 */ uint32_t rc32k_allow_cal : 1; /* [ 18], r/w, 0x0 */ uint32_t rc32k_ext_code_en : 1; /* [ 19], r/w, 0x1 */ uint32_t rc32k_cal_en : 1; /* [ 20], r/w, 0x0 */ uint32_t pu_rc32k : 1; /* [ 21], r/w, 0x1 */ uint32_t rc32k_code_fr_ext : 10; /* [31:22], r/w, 0x12c */ } BF; uint32_t WORD; } rc32k_ctrl0; /* 0x204 : xtal32k */ union { struct { uint32_t reserved_0_1 : 2; /* [ 1: 0], rsvd, 0x0 */ uint32_t xtal32k_ext_sel : 1; /* [ 2], r/w, 0x0 */ uint32_t xtal32k_amp_ctrl : 2; /* [ 4: 3], r/w, 0x1 */ uint32_t xtal32k_reg : 2; /* [ 6: 5], r/w, 0x1 */ uint32_t xtal32k_outbuf_stre : 1; /* [ 7], r/w, 0x0 */ uint32_t xtal32k_otf_short : 1; /* [ 8], r/w, 0x0 */ uint32_t xtal32k_inv_stre : 2; /* [10: 9], r/w, 0x1 */ uint32_t xtal32k_capbank : 6; /* [16:11], r/w, 0x20 */ uint32_t xtal32k_ac_cap_short : 1; /* [ 17], r/w, 0x0 */ uint32_t pu_xtal32k_buf : 1; /* [ 18], r/w, 0x1 */ uint32_t pu_xtal32k : 1; /* [ 19], r/w, 0x0 */ uint32_t xtal32k_lowv_en : 1; /* [ 20], r/w, 0x0 */ uint32_t xtal32k_hiz_en : 1; /* [ 21], r/w, 0x1 */ uint32_t dten_xtal32k : 1; /* [ 22], r/w, 0x0 */ uint32_t ten_xtal32k : 1; /* [ 23], r/w, 0x0 */ uint32_t reserved_24_31 : 8; /* [31:24], rsvd, 0x0 */ } BF; uint32_t WORD; } xtal32k; }; typedef volatile struct hbn_reg hbn_reg_t; #endif /* __HBN_REG_H__ */
d1f9336679b50a26cdc05bf2a58949e38a661bc0
dddb9237fb9ee58832488cb703c59bb5b9acec79
/Core/utils.c
fa5e0a75eb888b043f43573df7f7192c92152a00
[ "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
32,721
c
utils.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 "utils.h" #include "math.h" #define MAXCHAR 1000 /***********************************************************************************************/ float checkParams2D(int *params_switch, int ModelSelected, char *ModelParametersFilename) { /* parameters check which returns 'params_switch' vector with 0/1 values */ params_switch[0] = 1; /* parameters file */ params_switch[1] = 0; /* model */ params_switch[2] = 1; /* components */ params_switch[3] = 1; /* time steps (actual value if > 1)*/ params_switch[4] = 1; /* model types */ params_switch[5] = 1; /* C0 */ params_switch[6] = 1; /* x0 */ params_switch[7] = 1; /* y0 */ params_switch[8] = 1; /* a */ params_switch[9] = 1; /* b */ FILE *fp = fopen(ModelParametersFilename, "r"); // read parameters file int Model=0, Components=0, steps = 0, counter=0, ii; float C0 = 0.0f, x0 = 0.0f, y0 = 0.0f, a = 0.0f, b = 0.0f; if( fp == NULL ) { printf("%s %s\n", "Parameters file does not exist or cannot be read!", ModelParametersFilename); params_switch[0] = 0; return 0; } 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]; 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 { printf("%s \n", "Unexpected the end of the line (Components) in parameters file"); params_switch[0] = 0; 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); params_switch[2] = 0; break; } if (fgets(str, MAXCHAR, fp) != NULL) sscanf(str, "%15s : %21[^;];", tmpstr1, tmpstr2); else { printf("%s \n", "Unexpected the end of the line (TimeSteps) in parameters file"); params_switch[0] = 0; 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); params_switch[3] = 0; break; } else {params_switch[3] = steps;} //printf("%s %i\n", "TimeSteps:", steps); if (steps == 1) { /**************************************************/ // printf("\n %s %i %s \n", "Stationary 2D 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 %15[^;];", tmpstr1, tmpstr2, tmpstr3, tmpstr4, tmpstr5, tmpstr6, tmpstr7, tmpstr8); else { printf("%s \n", "Unexpected the end of the line (objects loop) in parameters file"); params_switch[0] = 0; break; } if (strcmp(tmpstr1,"Object") == 0) { C0 = (float)atof(tmpstr3); /* intensity */ x0 = (float)atof(tmpstr4); /* x0 position */ y0 = (float)atof(tmpstr5); /* y0 position */ a = (float)atof(tmpstr6); /* a - size object */ b = (float)atof(tmpstr7); /* b - size object */ } else { printf("%s \n", "Cannot find 'Object' string in parameters file"); params_switch[0] = 0; break; } if ((strcmp("gaussian",tmpstr2) != 0) && (strcmp("parabola",tmpstr2) != 0) && (strcmp("ellipse",tmpstr2) != 0) && (strcmp("parabola1",tmpstr2) != 0) && (strcmp("cone",tmpstr2) != 0) && (strcmp("rectangle",tmpstr2) != 0) ) { printf("%s %s\n", "Unknown name of the object, the given name is", tmpstr2); params_switch[4] = 0; break; } if (C0 == 0) { printf("%s %f\n", "C0 should not be equal to zero, the given value is", C0); params_switch[5] = 0; break; } if ((x0 < -1) || (x0 > 1)) { printf("%s %f\n", "x0 (object position) must be in [-1,1] range, the given value is", x0); params_switch[6] = 0; break; } if ((y0 < -1) || (y0 > 1)) { printf("%s %f\n", "y0 (object position) must be in [-1,1] range, the given value is", y0); params_switch[7] = 0; break; } if ((a <= 0) || (a > 2)) { printf("%s %f\n", "a (object size) must be positive in [0,2] range, the given value is", a); params_switch[8] = 0; break; } if ((b <= 0) || (b > 2)) { printf("%s %f\n", "b (object size) must be positive in [0,2] range, the given value is", b); params_switch[9] = 0; break; } // printf("\nObject : %s \nC0 : %f \nx0 : %f \ny0 : %f \na : %f \nb : %f \n", tmpstr2, C0, x0, y0, a, b); } } else { /**************************************************/ //printf("\n %s %i %s \n", "Temporal 2D + time model", ModelSelected, " is selected"); /* temporal phantom 2D + time (3D) */ float C1 = 0.0f, x1 = 0.0f, y1 = 0.0f, a1 = 0.0f, b1 = 0.0f; /* loop over all components */ for(ii=0; ii<Components; ii++) { if (fgets(str, MAXCHAR, fp) != NULL) sscanf(str, "%15s : %15s %15s %15s %15s %15s %15s %15[^;];", tmpstr1, tmpstr2, tmpstr3, tmpstr4, tmpstr5, tmpstr6, tmpstr7, tmpstr8); else { printf("%s \n", "Unexpected the end of the line (objects loop) in parameters file"); params_switch[0] = 0; break; } if (strcmp(tmpstr1,"Object") == 0) { C0 = (float)atof(tmpstr3); /* intensity */ x0 = (float)atof(tmpstr4); /* x0 position */ y0 = (float)atof(tmpstr5); /* y0 position */ a = (float)atof(tmpstr6); /* a - size object */ b = (float)atof(tmpstr7); /* b - size object */ } else { printf("%s \n", "Cannot find 'Object' string in parameters file"); params_switch[0] = 0; break; } if ((strcmp("gaussian",tmpstr2) != 0) && (strcmp("parabola",tmpstr2) != 0) && (strcmp("ellipse",tmpstr2) != 0) && (strcmp("parabola1",tmpstr2) != 0) && (strcmp("cone",tmpstr2) != 0) && (strcmp("rectangle",tmpstr2) != 0) ) { printf("%s %s\n", "Unknown name of the object, the given name is", tmpstr2); params_switch[4] = 0; break; } if (C0 == 0) { printf("%s %f\n", "C0 should not be equal to zero, the given value is", C0); params_switch[5] = 0; break; } if ((x0 < -1) || (x0 > 1)) { printf("%s %f\n", "x0 (object position) must be in [-1,1] range, the given value is", x0); params_switch[6] = 0; break; } if ((y0 < -1) || (y0 > 1)) { printf("%s %f\n", "y0 (object position) must be in [-1,1] range, the given value is", y0); params_switch[7] = 0; break; } if ((a <= 0) || (a > 2)) { printf("%s %f\n", "a (object size) must be positive in [0,2] range, the given value is", a); params_switch[8] = 0; break; } if ((b <= 0) || (b > 2)) { printf("%s %f\n", "b (object size) must be positive in [0,2] range, the given value is", b); params_switch[9] = 0; break; } printf("\nObject : %s \nC0 : %f \nx0 : %f \ny0 : %f \na : %f \nb : %f \n", tmpstr2, C0, x0, y0, a, b); /* check Endvar relatedparameters */ if (fgets(str, MAXCHAR, fp) != NULL) sscanf(str, "%15s : %15s %15s %15s %15s %15s %15[^;];", tmpstr1, tmpstr3, tmpstr4, tmpstr5, tmpstr6, tmpstr7, tmpstr8); else { printf("%s \n", "Unexpected the end of the line (Endvar loop) in parameters file"); params_switch[0] = 0; break; } if (strcmp(tmpstr1,"Endvar") == 0) { C1 = (float)atof(tmpstr3); /* intensity */ x1 = (float)atof(tmpstr4); /* x0 position */ y1 = (float)atof(tmpstr5); /* y0 position */ a1 = (float)atof(tmpstr6); /* a - size object */ b1 = (float)atof(tmpstr7); /* b - size object */ } else { printf("%s \n", "Cannot find 'Endvar' string in parameters file"); params_switch[0] = 0; break; } if (C1 == 0) { printf("%s %f\n", "Endvar C1 should not be equal to zero, the given value is", C1); params_switch[5] = 0; break; } if ((x1 < -1) || (x1 > 1)) { printf("%s %f\n", "Endvar x1 (object position) must be in [-1,1] range, the given value is", x1); params_switch[6] = 0; break; } if ((y1 < -1) || (y1 > 1)) { printf("%s %f\n", "Endvar y1 (object position) must be in [-1,1] range, the given value is", y1); params_switch[7] = 0; break; } if ((a1 <= 0) || (a1 > 2)) { printf("%s %f\n", "Endvar a1 (object size) must be positive in [0,2] range, the given value is", a1); params_switch[8] = 0; break; } if ((b1 <= 0) || (b1 > 2)) { printf("%s %f\n", "Endvar b1 (object size) must be positive in [0,2] range, the given value is", b1); params_switch[9] = 0; break; } } /*components loop*/ } params_switch[1] = 1; counter++; } /*model if*/ } } } } if (params_switch[1] == 0) printf("%s %i\n", "No such model available, the given value is", Model); fclose(fp); return *params_switch; } /***********************************************************************************************/ float checkParams3D(int *params_switch, int ModelSelected, char *ModelParametersFilename) { FILE *fp; 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]; params_switch[0] = 1; /* parameters file */ params_switch[1] = 0; /* model */ params_switch[2] = 1; /* components */ params_switch[3] = 1; /* steps (actual value if > 1)*/ params_switch[4] = 1; /* model types */ params_switch[5] = 1; /* C0 */ params_switch[6] = 1; /* x0 */ params_switch[7] = 1; /* y0 */ params_switch[8] = 1; /* z0 */ params_switch[9] = 1; /* a */ params_switch[10] = 1; /* b */ params_switch[11] = 1; /* c */ 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; fp = fopen(ModelParametersFilename, "r"); if (fp == NULL){ printf("Could not open file %s",ModelParametersFilename); params_switch[0] = 0; return 0; } else { 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 { params_switch[0] = 0; printf("%s\n", "Unexpected the end of the line (Components) in parameters file"); break; } if (strcmp(tmpstr1,"Components") == 0) Components = atoi(tmpstr2); //printf("%s %i\n", "Components:", Components); if (Components <= 0) { params_switch[2] = 0; /*checking components*/ 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 { params_switch[0] = 0; printf("%s\n", "Unexpected the end of the line (TimeSteps) in parameters file"); break; } if (strcmp(tmpstr1,"TimeSteps") == 0) steps = atoi(tmpstr2); if (steps <= 0) { params_switch[3] = 0; printf("%s %i\n", "TimeSteps cannot be negative, the given value is", steps); break; } else {params_switch[3] = steps;} //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 { params_switch[0] = 0; printf("%s\n", "Unexpected the end of the line (objecta loop) in parameters file"); 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 */ } else { params_switch[0] = 0; printf("%s\n", "Cannot find 'Object' string in parameters file"); break; } if ((strcmp("gaussian",tmpstr2) != 0) && (strcmp("paraboloid",tmpstr2) != 0) && (strcmp("ellipsoid",tmpstr2) != 0) && (strcmp("cone",tmpstr2) != 0) && (strcmp("cuboid",tmpstr2) != 0) && (strcmp("elliptical_cylinder",tmpstr2) != 0) ) { printf("%s %s\n", "Unknown name of the object, the given name is", tmpstr2); params_switch[4] = 0; break; } if (C0 == 0) { params_switch[5] = 0; printf("%s %f\n", "C0 should not be equal to zero, the given value is", C0); break; } if ((x0 < -1) || (x0 > 1)) { params_switch[6] = 0; printf("%s %f\n", "x0 (object position) must be in [-1,1] range, the given value is", x0); break; } if ((y0 < -1) || (y0 > 1)) { params_switch[7] = 0; printf("%s %f\n", "y0 (object position) must be in [-1,1] range, the given value is", y0); break; } if ((z0 < -1) || (z0 > 1)) { params_switch[8] = 0; printf("%s %f\n", "z0 (object position) must be in [-1,1] range, the given value is", z0); break; } if ((a <= 0) || (a > 2)) { params_switch[9] = 0; printf("%s %f\n", "a (object size) must be positive in [0,2] range, the given value is", a); break; } if ((b <= 0) || (b > 2)) { params_switch[10] = 0; printf("%s %f\n", "b (object size) must be positive in [0,2] range, the given value is", b); break; } if ((c <= 0) || (c > 2)) { params_switch[11] = 0; printf("%s %f\n", "c (object size) must be positive in [0,2] range, the given value is", c); 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); } } else { //printf("\n %s %i %s \n", "Temporal 3D+time 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 { params_switch[0] = 0; printf("%s\n", "Unexpected the end of the line (objecta loop) in parameters file"); 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 */ } else { params_switch[0] = 0; printf("%s\n", "Cannot find 'Object' string in parameters file"); break; } if ((strcmp("gaussian",tmpstr2) != 0) && (strcmp("paraboloid",tmpstr2) != 0) && (strcmp("ellipsoid",tmpstr2) != 0) && (strcmp("cone",tmpstr2) != 0) && (strcmp("cuboid",tmpstr2) != 0) && (strcmp("elliptical_cylinder",tmpstr2) != 0) ) { printf("%s %s\n", "Unknown name of the object, the given name is", tmpstr2); params_switch[4] = 0; break; } if (C0 == 0) { params_switch[5] = 0; printf("%s %f\n", "C0 should not be equal to zero, the given value is", C0); break; } if ((x0 < -1) || (x0 > 1)) { params_switch[6] = 0; printf("%s %f\n", "x0 (object position) must be in [-1,1] range, the given value is", x0); break; } if ((y0 < -1) || (y0 > 1)) { params_switch[7] = 0; printf("%s %f\n", "y0 (object position) must be in [-1,1] range, the given value is", y0); break; } if ((z0 < -1) || (z0 > 1)) { params_switch[8] = 0; printf("%s %f\n", "z0 (object position) must be in [-1,1] range, the given value is", z0); break; } if ((a <= 0) || (a > 2)) { params_switch[9] = 0; printf("%s %f\n", "a (object size) must be positive in [0,2] range, the given value is", a); break; } if ((b <= 0) || (b > 2)) { params_switch[10] = 0; printf("%s %f\n", "b (object size) must be positive in [0,2] range, the given value is", b); break; } if ((c <= 0) || (c > 2)) { params_switch[11] = 0; printf("%s %f\n", "c (object size) must be positive in [0,2] range, the given value is", c); 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 { params_switch[0] = 0; printf("%s\n", "Unexpected the end of the line (Endvar loop) in parameters file"); break; } if (strcmp(tmpstr1,"Endvar") == 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 */ } else { params_switch[0] = 0; printf("%s\n", "Cannot find 'Endvar' string in parameters file"); break; } if (C0 == 0) { params_switch[5] = 0; printf("%s %f\n", "Endvar C0 should not be equal to zero, the given value is", C0); break; } if ((x0 < -1) || (x0 > 1)) { params_switch[6] = 0; printf("%s %f\n", "Endvar x0 (object position) must be in [-1,1] range, the given value is", x0); break; } if ((y0 < -1) || (y0 > 1)) { params_switch[7] = 0; printf("%s %f\n", "Endvar y0 (object position) must be in [-1,1] range, the given value is", y0); break; } if ((z0 < -1) || (z0 > 1)) { params_switch[8] = 0; printf("%s %f\n", "Endvar z0 (object position) must be in [-1,1] range, the given value is", z0); break; } if ((a <= 0) || (a > 2)) { params_switch[9] = 0; printf("%s %f\n", "Endvar a (object size) must be positive in [0,2] range, the given value is", a); break; } if ((b <= 0) || (b > 2)) { params_switch[10] = 0; printf("%s %f\n", "Endvar b (object size) must be positive in [0,2] range, the given value is", b); break; } if ((c <= 0) || (c > 2)) { params_switch[11] = 0; printf("%s %f\n", "Endvar c (object size) must be positive in [0,2] range, the given value is", c); 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); } /*components loop*/ } params_switch[1] = 1; counter++; } } } } } if (params_switch[1] == 0) printf("%s %i\n", "No such model available, the given value is", Model); fclose(fp); return *params_switch; } /***********************************************************************************************/ /* rotation matrix */ float matrot3(float Ad[3][3], float psi1, float psi2, float psi3) { Ad[0][0]=cosf(psi1)*cosf(psi2)*cosf(psi3)-sinf(psi1)*sinf(psi3); Ad[0][1]=sinf(psi1)*cosf(psi2)*cosf(psi3)+cosf(psi1)*sinf(psi3); Ad[0][2]=-sinf(psi2)*cosf(psi3); Ad[1][0]=-cosf(psi1)*cosf(psi2)*sinf(psi3)-sinf(psi1)*cosf(psi3); Ad[1][1]=-sinf(psi1)*cosf(psi2)*sinf(psi3)+cosf(psi1)*cosf(psi3); Ad[1][2]=sinf(psi2)*sinf(psi3); Ad[2][0]=cosf(psi1)*sinf(psi2); Ad[2][1]=sinf(psi1)*sinf(psi2); Ad[2][2]=cosf(psi2); return 1; } /*matrix-vector multiplication*/ float matvet3(float Ad[3][3], float V1[3], float V2[3]) { int l, m; for(l=0; l<3; l++) { V2[l] = 0.0f; for(m=0; m<3; m++) { V2[l] += Ad[l][m]*V1[m]; }} return 1; } /*matrix-matrix multiplication*/ float matmat3(float Am[3][3], float Bm[3][3], float Cm[3][3]) { int i, j, k; for(i=0; i<3; i++) { for(j=0; j<3; j++) { Cm[i][j]=0.0f; for(k=0; k<3; k++) { Cm[i][j] += Am[i][k]*Bm[k][j]; } }} return 1; }
999abe10cf55aaf862d49265002c6000e0be0fc4
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/hpcarm/hpcarm/softintr.c
0ad5a5102d55f5a3551a2692caa7d9913e102890
[]
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
4,905
c
softintr.c
/* $NetBSD: softintr.c,v 1.18 2020/11/21 21:27:09 thorpej Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by IWAMOTO Toshihiro. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> __KERNEL_RCSID(0, "$NetBSD: softintr.c,v 1.18 2020/11/21 21:27:09 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/syslog.h> #include <sys/kmem.h> #include <machine/cpu.h> #include <arm/cpufunc.h> #include <machine/intr.h> void softintr_free(void *); void softintr_dispatch(int); struct softintr_handler { struct softintr_handler *sh_vlink; /* vertical link */ struct softintr_handler *sh_hlink; /* horizontal link */ void (*sh_fun)(void *); void *sh_arg; int sh_level; int sh_pending; }; struct softintr_handler *softintrs; struct softintr_handler *softintr_pending; void * softintr_establish(int level, void (*fun)(void *), void *arg) { struct softintr_handler *sh; sh = kmem_alloc(sizeof(*sh), KM_SLEEP); sh->sh_fun = fun; sh->sh_level = ipl_to_spl(level); sh->sh_arg = arg; sh->sh_pending = 0; return sh; } void softintr_disestablish(void *cookie) { struct softintr_handler *sh = cookie; u_int saved_cpsr; saved_cpsr = SetCPSR(I32_bit, I32_bit); if (sh->sh_pending) { sh->sh_fun = softintr_free; sh->sh_arg = sh; SetCPSR(I32_bit, I32_bit & saved_cpsr); } else { SetCPSR(I32_bit, I32_bit & saved_cpsr); kmem_free(sh, sizeof(*sh)); } } void softintr_free(void *arg) { struct softintr_handler *sh = arg; kmem_free(sh, sizeof(*sh)); } void softintr_schedule(void *cookie) { struct softintr_handler **p, *sh = cookie; register int pending, saved_cpsr; pending = 1; __asm("swp %0, %0, [%1]" : "+r" (pending) : "r" (&sh->sh_pending)); if (pending) return; sh->sh_vlink = NULL; sh->sh_hlink = NULL; #ifdef __GNUC__ __asm volatile("mrs %0, cpsr\n orr r1, %0, %1\n msr cpsr_a;;, r1" : "=r" (saved_cpsr) : "i" (I32_bit) : "r1"); #else saved_cpsr = SetCPSR(I32_bit, I32_bit); #endif p = &softintr_pending; for (;; p = &(*p)->sh_vlink) { if (*p == NULL) goto set_and_exit; if ((*p)->sh_level <= sh->sh_level) break; } if ((*p)->sh_level == sh->sh_level) { sh->sh_hlink = *p; sh->sh_vlink = (*p)->sh_vlink; goto set_and_exit; } sh->sh_vlink = *p; set_and_exit: *p = sh; #ifdef __GNUC__ __asm volatile("msr cpsr_c, %0" : : "r" (saved_cpsr)); #else SetCPSR(I32_bit, I32_bit & saved_cpsr); #endif return; } void softintr_dispatch(int s) { struct softintr_handler *sh, *sh1; register int saved_cpsr; while (1) { /* Protect list operation from interrupts */ #ifdef __GNUC__ __asm volatile("mrs %0, cpsr\n orr r1, %0, %1\n" " msr cpsr_all, r1" : "=r" (saved_cpsr) : "i" (I32_bit) : "r1"); #else saved_cpsr = SetCPSR(I32_bit, I32_bit); #endif if (softintr_pending == NULL || softintr_pending->sh_level <= s) { #ifdef __GNUC__ __asm("msr cpsr_c, %0" : : "r" (saved_cpsr)); #else SetCPSR(I32_bit, I32_bit & saved_cpsr); #endif splx(s); return; } sh = softintr_pending; softintr_pending = softintr_pending->sh_vlink; if (sh->sh_level > current_spl_level) raisespl(sh->sh_level); #ifdef __GNUC__ __asm volatile("msr cpsr_c, %0" : : "r" (saved_cpsr)); #else SetCPSR(I32_bit, I32_bit & saved_cpsr); #endif if (sh->sh_level < current_spl_level) lowerspl(sh->sh_level); while (1) { /* The order is important */ sh1 = sh->sh_hlink; sh->sh_pending = 0; (sh->sh_fun)(sh->sh_arg); if (sh1 == NULL) break; sh = sh1; } } splx(s); }
572e8147c7b1241bdea38aabdf43595952300066
7f6c235b0598353549959c18f69eefd20b766907
/libsrc/games/joystick_type.c
211e02e8976fd5fdbb6acdf846e3016c2e583cc4
[ "ClArtistic" ]
permissive
z88dk/z88dk
46dfd4905f36d99333173cadd0a660839befc9f0
8b07f37cc43c5d9ffe69b563c80763491d8faff7
refs/heads/master
2023-09-04T19:29:49.254958
2023-09-03T20:51:24
2023-09-03T20:51:24
54,035,569
820
263
NOASSERTION
2023-09-05T11:09:04
2016-03-16T13:48:16
Assembly
UTF-8
C
false
false
51
c
joystick_type.c
#define DEFINE_JOYSTICK_TYPE #include <games.h>
20a7954b0be318f0f762d7f8783a2c7c0db6f38a
45bb18e8a90923a46e72177d3e24870eb9e62035
/libinput.c
e980060c7b8d64ec67870fec9154bb759efce7a4
[ "MIT" ]
permissive
project-repo/cagebreak
8a34cac0f63912e25e254d396449f16c964569eb
61e7f8aeffa5eb8695788453a94619476bee0b64
refs/heads/master
2023-09-03T15:28:18.431154
2023-08-21T07:33:36
2023-08-21T07:33:36
241,194,950
212
18
MIT
2023-08-17T17:48:03
2020-02-17T19:54:25
C
UTF-8
C
false
false
11,812
c
libinput.c
// Copyright 2020 - 2023, project-repo and the cagebreak contributors // SPDX-License-Identifier: MIT #include "input.h" #include "input_manager.h" #include "output.h" #include <float.h> #include <libinput.h> #include <libudev.h> #include <limits.h> #include <strings.h> #include <wlr/backend/libinput.h> #include <wlr/util/log.h> static void log_status(enum libinput_config_status status) { if(status != LIBINPUT_CONFIG_STATUS_SUCCESS) { wlr_log(WLR_ERROR, "Failed to apply libinput config: %s", libinput_config_status_to_str(status)); } } static bool set_send_events(struct libinput_device *device, uint32_t mode) { if(libinput_device_config_send_events_get_mode(device) == mode) { return false; } wlr_log(WLR_DEBUG, "send_events_set_mode(%" PRIu32 ")", mode); log_status(libinput_device_config_send_events_set_mode(device, mode)); return true; } static bool set_tap(struct libinput_device *device, enum libinput_config_tap_state tap) { if(libinput_device_config_tap_get_finger_count(device) <= 0 || libinput_device_config_tap_get_enabled(device) == tap) { return false; } wlr_log(WLR_DEBUG, "tap_set_enabled(%d)", tap); log_status(libinput_device_config_tap_set_enabled(device, tap)); return true; } static bool set_tap_button_map(struct libinput_device *device, enum libinput_config_tap_button_map map) { if(libinput_device_config_tap_get_finger_count(device) <= 0 || libinput_device_config_tap_get_button_map(device) == map) { return false; } wlr_log(WLR_DEBUG, "tap_set_button_map(%d)", map); log_status(libinput_device_config_tap_set_button_map(device, map)); return true; } static bool set_tap_drag(struct libinput_device *device, enum libinput_config_drag_state drag) { if(libinput_device_config_tap_get_finger_count(device) <= 0 || libinput_device_config_tap_get_drag_enabled(device) == drag) { return false; } wlr_log(WLR_DEBUG, "tap_set_drag_enabled(%d)", drag); log_status(libinput_device_config_tap_set_drag_enabled(device, drag)); return true; } static bool set_tap_drag_lock(struct libinput_device *device, enum libinput_config_drag_lock_state lock) { if(libinput_device_config_tap_get_finger_count(device) <= 0 || libinput_device_config_tap_get_drag_lock_enabled(device) == lock) { return false; } wlr_log(WLR_DEBUG, "tap_set_drag_lock_enabled(%d)", lock); log_status(libinput_device_config_tap_set_drag_lock_enabled(device, lock)); return true; } static bool set_accel_speed(struct libinput_device *device, double speed) { if(!libinput_device_config_accel_is_available(device) || libinput_device_config_accel_get_speed(device) == speed) { return false; } wlr_log(WLR_DEBUG, "accel_set_speed(%f)", speed); log_status(libinput_device_config_accel_set_speed(device, speed)); return true; } static bool set_accel_profile(struct libinput_device *device, enum libinput_config_accel_profile profile) { if(!libinput_device_config_accel_is_available(device) || libinput_device_config_accel_get_profile(device) == profile) { return false; } wlr_log(WLR_DEBUG, "accel_set_profile(%d)", profile); log_status(libinput_device_config_accel_set_profile(device, profile)); return true; } static bool set_natural_scroll(struct libinput_device *d, bool n) { if(!libinput_device_config_scroll_has_natural_scroll(d) || libinput_device_config_scroll_get_natural_scroll_enabled(d) == n) { return false; } wlr_log(WLR_DEBUG, "scroll_set_natural_scroll(%d)", n); log_status(libinput_device_config_scroll_set_natural_scroll_enabled(d, n)); return true; } static bool set_left_handed(struct libinput_device *device, bool left) { if(!libinput_device_config_left_handed_is_available(device) || libinput_device_config_left_handed_get(device) == left) { return false; } wlr_log(WLR_DEBUG, "left_handed_set(%d)", left); log_status(libinput_device_config_left_handed_set(device, left)); return true; } static bool set_click_method(struct libinput_device *device, enum libinput_config_click_method method) { uint32_t click = libinput_device_config_click_get_methods(device); if((click & ~LIBINPUT_CONFIG_CLICK_METHOD_NONE) == 0 || libinput_device_config_click_get_method(device) == method) { return false; } wlr_log(WLR_DEBUG, "click_set_method(%d)", method); log_status(libinput_device_config_click_set_method(device, method)); return true; } static bool set_middle_emulation(struct libinput_device *dev, enum libinput_config_middle_emulation_state mid) { if(!libinput_device_config_middle_emulation_is_available(dev) || libinput_device_config_middle_emulation_get_enabled(dev) == mid) { return false; } wlr_log(WLR_DEBUG, "middle_emulation_set_enabled(%d)", mid); log_status(libinput_device_config_middle_emulation_set_enabled(dev, mid)); return true; } static bool set_scroll_method(struct libinput_device *device, enum libinput_config_scroll_method method) { uint32_t scroll = libinput_device_config_scroll_get_methods(device); if((scroll & ~LIBINPUT_CONFIG_SCROLL_NO_SCROLL) == 0 || libinput_device_config_scroll_get_method(device) == method) { return false; } wlr_log(WLR_DEBUG, "scroll_set_method(%d)", method); log_status(libinput_device_config_scroll_set_method(device, method)); return true; } static bool set_scroll_button(struct libinput_device *dev, uint32_t button) { uint32_t scroll = libinput_device_config_scroll_get_methods(dev); if((scroll & ~LIBINPUT_CONFIG_SCROLL_NO_SCROLL) == 0 || libinput_device_config_scroll_get_button(dev) == button) { return false; } wlr_log(WLR_DEBUG, "scroll_set_button(%" PRIu32 ")", button); log_status(libinput_device_config_scroll_set_button(dev, button)); return true; } static bool set_dwt(struct libinput_device *device, bool dwt) { if(!libinput_device_config_dwt_is_available(device) || libinput_device_config_dwt_get_enabled(device) == dwt) { return false; } wlr_log(WLR_DEBUG, "dwt_set_enabled(%d)", dwt); log_status(libinput_device_config_dwt_set_enabled(device, dwt)); return true; } static bool set_calibration_matrix(struct libinput_device *dev, float mat[6]) { if(!libinput_device_config_calibration_has_matrix(dev)) { return false; } bool changed = false; float current[6]; libinput_device_config_calibration_get_matrix(dev, current); for(int i = 0; i < 6; i++) { if(current[i] != mat[i]) { changed = true; break; } } if(changed) { wlr_log(WLR_DEBUG, "calibration_set_matrix(%f, %f, %f, %f, %f, %f)", mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); log_status(libinput_device_config_calibration_set_matrix(dev, mat)); } return changed; } void output_get_identifier(char *identifier, size_t len, struct cg_output *output) { struct wlr_output *wlr_output = output->wlr_output; snprintf(identifier, len, "%s %s %s", wlr_output->make, wlr_output->model, wlr_output->serial); } struct cg_output * output_by_name_or_id(const char *name_or_id, struct cg_server *server) { struct cg_output *output = NULL; wl_list_for_each(output, &server->outputs, link) { char identifier[128]; output_get_identifier(identifier, sizeof(identifier), output); if(strcasecmp(identifier, name_or_id) == 0 || strcasecmp(output->wlr_output->name, name_or_id) == 0) { return output; } } return NULL; } static bool device_is_touchpad(struct cg_input_device *device) { if(device->wlr_device->type != WLR_INPUT_DEVICE_POINTER || !wlr_input_device_is_libinput(device->wlr_device)) { return false; } struct libinput_device *libinput_device = wlr_libinput_get_device_handle(device->wlr_device); return libinput_device_config_tap_get_finger_count(libinput_device) > 0; } const char * input_device_get_type(struct cg_input_device *device) { switch(device->wlr_device->type) { case WLR_INPUT_DEVICE_POINTER: if(device_is_touchpad(device)) { return "touchpad"; } else { return "pointer"; } case WLR_INPUT_DEVICE_KEYBOARD: return "keyboard"; case WLR_INPUT_DEVICE_TOUCH: return "touch"; case WLR_INPUT_DEVICE_TABLET_TOOL: return "tablet_tool"; case WLR_INPUT_DEVICE_TABLET_PAD: return "tablet_pad"; case WLR_INPUT_DEVICE_SWITCH: return "switch"; } return "unknown"; } void apply_config_to_device(struct cg_input_config *config, struct cg_input_device *input_device) { if(wlr_input_device_is_libinput(input_device->wlr_device)) { struct libinput_device *device = wlr_libinput_get_device_handle(input_device->wlr_device); if(config->mapped_to_output && !output_by_name_or_id(config->mapped_to_output, input_device->server)) { wlr_log(WLR_DEBUG, "'%s' is mapped to offline output '%s'; disabling input", config->identifier, config->mapped_to_output); set_send_events(device, LIBINPUT_CONFIG_SEND_EVENTS_DISABLED); } else if(config->send_events != INT_MIN) { set_send_events(device, config->send_events); } else { // Have to reset to the default mode here, otherwise if // ic->send_events is unset and a mapped output just came online // after being disabled, we'd remain stuck sending no events. set_send_events( device, libinput_device_config_send_events_get_default_mode(device)); } if(config->tap != INT_MIN) { set_tap(device, config->tap); } if(config->tap_button_map != INT_MIN) { set_tap_button_map(device, config->tap_button_map); } if(config->drag != INT_MIN) { set_tap_drag(device, config->drag); } if(config->drag_lock != INT_MIN) { set_tap_drag_lock(device, config->drag_lock); } if(config->pointer_accel != FLT_MIN) { set_accel_speed(device, config->pointer_accel); } if(config->accel_profile != INT_MIN) { set_accel_profile(device, config->accel_profile); } if(config->natural_scroll != INT_MIN) { set_natural_scroll(device, config->natural_scroll); } if(config->left_handed != INT_MIN) { set_left_handed(device, config->left_handed); } if(config->click_method != INT_MIN) { set_click_method(device, config->click_method); } if(config->middle_emulation != INT_MIN) { set_middle_emulation(device, config->middle_emulation); } if(config->scroll_method != INT_MIN) { set_scroll_method(device, config->scroll_method); } if(config->scroll_button != INT_MIN) { set_scroll_button(device, config->scroll_button); } if(config->dwt != INT_MIN) { set_dwt(device, config->dwt); } if(config->calibration_matrix.configured) { set_calibration_matrix(device, config->calibration_matrix.matrix); } } } void cg_input_configure_libinput_device(struct cg_input_device *input_device) { struct cg_server *server = input_device->server; struct cg_input_config *config = NULL; wl_list_for_each(config, &server->input_config, link) { const char *device_type = input_device_get_type(input_device); if(strcmp(config->identifier, input_device->identifier) == 0 || strcmp(config->identifier, "*") == 0 || (strncmp(config->identifier, "type:", 5) == 0 && strcmp(config->identifier + 5, device_type) == 0)) { apply_config_to_device(config, input_device); } } } bool cg_libinput_device_is_builtin(struct cg_input_device *cg_device) { if(!wlr_input_device_is_libinput(cg_device->wlr_device)) { return false; } struct libinput_device *device = wlr_libinput_get_device_handle(cg_device->wlr_device); struct udev_device *udev_device = libinput_device_get_udev_device(device); if(!udev_device) { return false; } const char *id_path = udev_device_get_property_value(udev_device, "ID_PATH"); if(!id_path) { return false; } const char prefix[] = "platform-"; return strncmp(id_path, prefix, strlen(prefix)) == 0; }
117d10f998cdfccef24e4b106425896ecfcf3222
50dd46b8ece33f3cdd174284b15d1d51f89669d4
/third_party/edk2/StdLib/Include/X64/machine/endian.h
53de9c6ef4cb28391d619ff2531fc3e16d4991b3
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause", "OpenSSL" ]
permissive
google/google-ctf
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
df02323eaf945d15e124801c74abaadca2749dc7
refs/heads/master
2023-08-31T14:30:27.548081
2023-08-29T13:04:20
2023-08-29T13:04:20
131,317,137
4,136
607
Apache-2.0
2023-08-30T22:17:02
2018-04-27T15:56:03
Go
UTF-8
C
false
false
89
h
endian.h
/* $NetBSD: endian.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ #include <sys/endian.h>
4c45e1e28d558eda4062d0f136982f3dc4c27375
e683a0b8dbb87c7ceb99e0d06896174a559d2c67
/Tools/goc/scan.h
fb412039c9f8362f11653bd875af64edba9a1715
[ "Apache-2.0" ]
permissive
bluewaysw/pcgeos
f093d79567d977d992f47065056d14d5a04b9f14
c6ae4c8e77b54b9ff654c3916f2191f8b1a1b65d
refs/heads/master
2023-08-31T00:17:54.481175
2023-08-29T19:00:49
2023-08-29T19:00:49
157,968,410
603
88
Apache-2.0
2023-09-13T07:44:06
2018-11-17T09:09:55
Assembly
UTF-8
C
false
false
7,795
h
scan.h
/*********************************************************************** * PROJECT: PCGEOS * MODULE: goc -- Definitions file for scanner * FILE: scan.h * * AUTHOR: Tony Requist * * DESCRIPTION: * Header file for scanner * * $Id: scan.h,v 1.17 96/07/08 17:38:11 tbradley Exp $ * ***********************************************************************/ #ifndef _SCAN_H_ #define _SCAN_H_ /* Lexical contexts that the scanner can be in */ typedef enum { LC_NONE, /* * Not parsing anything in particular, * just looking for @ to signal goc stuff. * This will send input to yyout until * it detects goc input. */ LC_PARSE, /* Standard parsing, punctuation, syms */ LC_PARSE_NO_LOOKUP, /* Standard parsing, no reserved word lookup */ LC_STRING_SEMI_COLON, /* Parse chars as fakestring until ; */ LC_STRING_COMMA, /* Parse chars as fakestring until , */ LC_STRING_RIGHT_PAREN, /* Parse chars as fakestring until ) */ LC_STRING_COLON, /* for parent/child object destinations */ LC_STRING_CLOSE_BRACE, /* for [asdf] */ LC_CLOSE_CURLY_OR_STRING, /* just for gstrings. returns everything up*/ /* to the next string or '}' as a FAKESTRING */ /* returns a string as STRING. */ /* * The next two are for scanning type declarations and related things. * * these two do the same thing: scan chars as a string up to the next * ',' ';' '=' ')' * in LC_STRING_MATCH_PARENS, scan things surrounded with parentheses too. * in LC_STRING_NO_MATCH_PARENS, '(' is also a delimiter * */ LC_TYPE_STRING_MATCH_PARENS, /* parse a normal type decl or msg_params */ LC_TYPE_STRING_NO_MATCH_PARENS, /* parse a method decl */ /* * This is used to scan parts of an @send/@call (the flags and cast). * * This one reads a list of flags (each prefaced with a comma) and only * returns the flags (NOT the commas). * * After the flags may come a msg cast (e.g. {MSG_FOO}), or the object * dest. if there is a cast, only the MSG is returned, not the * characters '{' '}' that delimit it. * * After scanning the cast and flags, the scanner will switch * lexContexts and enter the PARSE_OBJ_DEST scanning mode to get the * destination of the message. This is necessary because the object * destination is several tokens long. * */ LC_PARSE_OBJ_FLAGS_AND_CAST, /* Used to read the comma separated list of */ /* flags before an object destination. */ /* inserts a ';' into the token stream at */ /* the end of the flag list. */ LC_PARSE_OBJ_DEST, LC_PARSE_CALLSUPER_OBJ_DEST, /* Just like LC_PARSE_OBJ_DEST, but it */ /* first for "()" before looking for and */ /* objdest. This state exists because after */ /* the callsuper, one may either have an */ /* objdest or just "()" to signal the end */ /* before, one used ";" instead of "()", */ /* but that doesn't make sense for: */ /* if(@callsuper;), and besides that form */ /* used to put out a semi-colon too. */ /* So what this context does is look forward*/ /* to see if there is "()" ahead. If so, it */ /* returns them as characters. If those are */ /* not what comes next, it switches into */ /* LC_PARSE_OBJ_DEST to read them as strings*/ /* so " ( )" will get read as '(' and ')', */ /* but "(a),(optr) b:" would get returned as*/ /* FAKESTRING ',' FAKESTRING ':'. */ } LexicalContexts; extern LexicalContexts lexContext; enum tokNum{BEFORE_FILE,FIRST_OF_FILE,AFTER_FIRST_OF_FILE }; extern enum tokNum whichToken; /* * Tells the scanner whether or not it should output newlines or a directive * after scanning a multi-line thing with LC_STRING_XXX. * * Default is TRUE. For @send,@call and @callsuper, which generate function * calls _in_place_, it should be false. */ extern int scannerShouldRealignOutputAndInputAfterLC_STRING; extern char preTokenBuffer[]; extern char yytext[]; extern int parse_TokenStart, parse_TokenEnd; extern Boolean parse_ScanningAChunk; extern Boolean Scan_IdentHadApostropheBeforeIt; extern void Scan_WarnForForwardChunk (char *ident); extern unsigned short Scan_ScanSJISChar(unsigned char **str); extern Boolean Scan_CheckForConditional(void); extern char *OurStrPos(char *str, char *find); extern void SplitTypeString(char *typeDecl,char **ctype,char **id,char **typeSuffix); char *OurStrPos(char *str, char *find); void SplitTypeString(char *typeDecl,char **ctype,char **id,char **typeSuffix); char *Scan_MacroIsUndefForFromFile (char *name,char *file); extern void Scan_OutputMultiByteString(char prefix, char *str); extern void Scan_StartOptimize(void); extern Boolean Scan_MacroIsDefined (char *macroName); extern void Scan_Unput(char c); /* * Structure used for interpolating text into the input stream from macros */ #define MACRO_BLOCK_SIZE 32 #define NUM_MACRO_BLOCKS 20 /* Number of MBlk's to allocate at once */ /* * Structure describing a macro argument. Chained with first arg first in the * list. */ typedef struct _Arg { char *value; int freeIt; struct _Arg *next; } Arg; /* XXX the Mblk structure might point to a MArg structure. XXX */ /* They are the same except for the text field. Tricky */ typedef struct _MBlk { short length; /* Number of characters in the block */ short dynamic; /* Non-zero if block individually allocated * and should be freed if no longer needed */ struct _MBlk *next; char text[MACRO_BLOCK_SIZE]; } MBlk; /* * Record to indicate a macro argument should be interpolated */ typedef struct _MArg { short argNum; /* -Argument number */ short dynamic; /* Nonzero if record should be freed if * no longer needed */ struct _MBlk *next; /* Continuation of macro */ } MArg; /* * Used to hold the three types of macro defns: * * @define FOO text (numParams = -1) * @define FOO() text (numParams = 0) * @define FOO(a,b,c,...) text (numParams = N) */ typedef struct { MBlk *body; /* list of blocks returned by yyreadmacrobody() */ int numParams; /* -1 if macro is a constants, 0 if blank, else n */ char *name; char *fileName; /* file where defined */ int lineNo; /* line where defined */ } Mac; typedef struct _MacState { MBlk *block; /* Block being read */ char *ptr; /* Position in same */ int count; /* # chars remaining */ MBlk **maps; /* Argument maps */ int numMaps; /* # of same */ char *pbBot; /* Bottom of the pushback stack */ struct _MacState *next; /* Next frame in stack */ } MacState; #endif /* _SCAN_H_ */
c3525242956e32a8cfffadded276fd903075e7cd
d61b532db0d3e08818338cfaac530a1ced1ffe3b
/util/opt/getline.c
4fb4c4917a7e49b2c629bd33d3d1ee6f3bc5cfd6
[ "LicenseRef-scancode-other-permissive" ]
permissive
davidgiven/ack
61049c7a8e95ff61a77b1edd3c22bb290720e276
db5a32c68c4a60ca26a3927a799ea662b5b2b0e5
refs/heads/default
2023-08-29T07:33:12.771205
2023-07-08T20:17:27
2023-07-08T20:17:27
37,686,316
376
74
NOASSERTION
2023-07-08T20:17:28
2015-06-18T21:33:42
C
UTF-8
C
false
false
12,398
c
getline.c
/* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". * * Author: Hans van Staveren */ #include <stdlib.h> #include <stdio.h> #include "param.h" #include "types.h" #include "tes.h" #include "line.h" #include "lookup.h" #include "alloc.h" #include "proinf.h" #include <em_spec.h> #include <em_pseu.h> #include <em_flag.h> #include <em_mes.h> #include "ext.h" #include "reg.h" #include "getline.h" #include "util.h" static short tabval; /* temp store for shorts */ static offset tabval2; /* temp store for offsets */ static char string[IDL + 1]; /* temp store for names */ /* * The next constants are close to sp_cend for fast switches */ #define INST 256 /* instruction: number in tabval */ #define PSEU 257 /* pseudo: number in tabval */ #define ILBX 258 /* label: number in tabval */ #define DLBX 259 /* symbol: name in string[] */ #define CSTX1 260 /* short constant: stored in tabval */ #define CSTX2 261 /* offset: value in tabval2 */ #define VALX1 262 /* symbol+short: in string[] and tabval */ #define VALX2 263 /* symbol+offset: in string[] and tabval2 */ #define ATEOF 264 /* bumped into end of file */ #define readbyte getchar /* Other external declarations */ extern void process(void); /* Forward declarations */ static int table2(void); static void tstinpro(void) { if (prodepth == 0) error("This is not allowed outside a procedure"); } short readshort(void) { register int l_byte, h_byte; l_byte = readbyte(); h_byte = readbyte(); if (h_byte >= 128) h_byte -= 256; return l_byte | (h_byte * 256); } #ifdef LONGOFF static offset readoffset(void) { register long l; register int h_byte; l = readbyte(); l |= ((unsigned) readbyte()) * 256; l |= readbyte() * 256L * 256L; h_byte = readbyte(); if (h_byte >= 128) h_byte -= 256; return l | (h_byte * 256L * 256 * 256L); } #endif static void draininput(void) { /* * called when MES ERR is encountered. * Drain input in case it is a pipe. */ while (getchar() != EOF) ; } static short getint(void) { switch (table2()) { default: error("int expected"); case CSTX1: return (tabval); } } static sym_p getsym(int status) { switch (table2()) { default: error("symbol expected"); case DLBX: return (symlookup(string, status, 0)); case sp_pnam: return (symlookup(string, status, SYMPRO)); } } static offset getoff(void) { switch (table2()) { default: error("offset expected"); case CSTX1: return ((offset) tabval); #ifdef LONGOFF case CSTX2: return (tabval2); #endif } } static void make_string(int n) { sprintf(string, ".%u", n); } static void inident(void) { register int n; register char *p = string; register int c; n = getint(); while (n--) { c = readbyte(); if (p < &string[IDL]) *p++ = c; } *p++ = 0; } static int table3(int n) { switch (n) { case sp_ilb1: tabval = readbyte(); return (ILBX); case sp_ilb2: tabval = readshort(); return (ILBX); case sp_dlb1: make_string(readbyte()); return (DLBX); case sp_dlb2: make_string(readshort()); return (DLBX); case sp_dnam: inident(); return (DLBX); case sp_pnam: inident(); return (n); case sp_cst2: tabval = readshort(); return (CSTX1); #ifdef LONGOFF case sp_cst4: tabval2 = readoffset(); return (CSTX2); #endif case sp_doff: if (table2() != DLBX) error("symbol expected"); switch (table2()) { default: error("offset expected"); case CSTX1: return (VALX1); #ifdef LONGOFF case CSTX2: return (VALX2); #endif } default: return (n); } } static int table1(void) { register int n; n = readbyte(); if (n == EOF) return (ATEOF); if ((n <= sp_lmnem) && (n >= sp_fmnem)) { tabval = n; return (INST); } if ((n <= sp_lpseu) && (n >= sp_fpseu)) { tabval = n; return (PSEU); } if ((n < sp_filb0 + sp_nilb0) && (n >= sp_filb0)) { tabval = n - sp_filb0; return (ILBX); } return (table3(n)); } static int table2(void) { register int n; n = readbyte(); if ((n < sp_fcst0 + sp_ncst0) && (n >= sp_fcst0)) { tabval = n - sp_zcst0; return (CSTX1); } return (table3(n)); } static void argstring(offset length, register argb_p abp) { while (length--) { if (abp->ab_index == NARGBYTES) abp = abp->ab_next = newargb(); abp->ab_contents[abp->ab_index++] = readbyte(); } } static line_p arglist(int n) { line_p lnp; register arg_p ap, *app; bool moretocome; offset length; /* * creates an arglist with n elements * if n == 0 the arglist is variable and terminated by sp_cend */ lnp = newline(OPLIST); app = &lnp->l_a.la_arg; moretocome = TRUE; do { switch (table2()) { default: error("unknown byte in arglist"); case CSTX1: tabval2 = (offset) tabval; case CSTX2: *app = ap = newarg(ARGOFF); ap->a_a.a_offset = tabval2; app = &ap->a_next; break; case ILBX: tstinpro(); *app = ap = newarg(ARGNUM); ap->a_a.a_np = numlookup((unsigned) tabval); ap->a_a.a_np->n_flags |= NUMDATA; app = &ap->a_next; break; case DLBX: *app = ap = newarg(ARGSYM); ap->a_a.a_sp = symlookup(string, OCCURRING, 0); app = &ap->a_next; break; case sp_pnam: *app = ap = newarg(ARGSYM); ap->a_a.a_sp = symlookup(string, OCCURRING, SYMPRO); app = &ap->a_next; break; case VALX1: tabval2 = (offset) tabval; case VALX2: *app = ap = newarg(ARGVAL); ap->a_a.a_val.av_sp = symlookup(string, OCCURRING, 0); ap->a_a.a_val.av_offset = tabval2; app = &ap->a_next; break; case sp_scon: *app = ap = newarg(ARGSTR); length = getoff(); argstring(length, &ap->a_a.a_string); app = &ap->a_next; break; case sp_icon: *app = ap = newarg(ARGICN); goto casecon; case sp_ucon: *app = ap = newarg(ARGUCN); goto casecon; case sp_fcon: *app = ap = newarg(ARGFCN); casecon: length = getint(); ap->a_a.a_con.ac_length = (short) length; argstring(getoff(), &ap->a_a.a_con.ac_con); app = &ap->a_next; break; case sp_cend: moretocome = FALSE; } if (n && (--n) == 0) moretocome = FALSE; } while (moretocome); return (lnp); } offset aoff(register arg_p ap, int n) { while (n > 0) { if (ap != (arg_p) 0) ap = ap->a_next; n--; } if (ap == (arg_p) 0) error("too few parameters"); if (ap->a_typ != ARGOFF) error("offset expected"); return (ap->a_a.a_offset); } static int inpseudo(short n) { register line_p lnp, head, tail; short n1, n2; proinf savearea; #ifdef PSEUBETWEEN static int pcount = 0; if (pcount++ >= PSEUBETWEEN && prodepth == 0) { process(); pcount = 0; } #endif switch (n) { default: error("unknown pseudo"); case ps_bss: case ps_hol: lnp = arglist(3); break; case ps_rom: case ps_con: lnp = arglist(0); break; case ps_ina: case ps_inp: case ps_exa: case ps_exp: lnp = newline(OPSYMBOL); lnp->l_a.la_sp = getsym(NOTHING); break; case ps_exc: n1 = getint(); n2 = getint(); if (n1 != 0 && n2 != 0) { tail = curpro.lastline; while (--n2) tail = tail->l_next; head = tail; while (n1--) head = head->l_next; lnp = tail->l_next; tail->l_next = head->l_next; head->l_next = curpro.lastline; curpro.lastline = lnp; } lnp = newline(OPNO); break; case ps_mes: lnp = arglist(0); switch ((int) aoff(lnp->l_a.la_arg, 0)) { case ms_err: draininput(); exit(-1); case ms_opt: nflag = TRUE; break; case ms_emx: wordsize = aoff(lnp->l_a.la_arg, 1); pointersize = aoff(lnp->l_a.la_arg, 2); #ifndef LONGOFF if (wordsize>2) error("This optimizer cannot handle wordsize>2"); #endif break; case ms_gto: curpro.gtoproc = 1; /* Treat as empty mes ms_reg */ case ms_reg: tstinpro(); regvar(lnp->l_a.la_arg->a_next); oldline(lnp); lnp = newline(OPNO); n = ps_exc; /* kludge to force out this line */ break; case ms_tes: tstinpro(); oldline(lnp); lnp = newline(OPNO); n = ps_exc; /* kludge to force out this line */ break; } break; case ps_pro: if (prodepth > 0) savearea = curpro; else process(); curpro.symbol = getsym(DEFINING); switch (table2()) { case sp_cend: curpro.localbytes = (offset) -1; break; case CSTX1: tabval2 = (offset) tabval; case CSTX2: curpro.localbytes = tabval2; break; default: error("bad second arg of PRO"); } prodepth++; curpro.gtoproc = 0; if (prodepth > 1) { register int i; curpro.lastline = (line_p) 0; curpro.freg = (reg_p) 0; for (i = 0; i < NNUMHASH; i++) curpro.numhash[i] = (num_p) 0; getlines(); curpro = savearea; prodepth--; } return (0); case ps_end: if (prodepth == 0) error("END misplaced"); switch (table2()) { case sp_cend: if (curpro.localbytes == (offset) -1) error("bytes for locals still unknown"); break; case CSTX1: tabval2 = (offset) tabval; case CSTX2: if (curpro.localbytes != (offset) -1 && curpro.localbytes != tabval2) error("inconsistency in number of bytes for locals"); curpro.localbytes = tabval2; break; } process(); curpro.symbol = (sym_p) 0; if (prodepth == 1) { prodepth = 0; #ifdef PSEUBETWEEN pcount = 0; #endif return (0); } else return (1); } lnp->l_instr = n; lnp->l_next = curpro.lastline; curpro.lastline = lnp; return (0); } void getlines(void) { register line_p lnp; register int instr; for (;;) { linecount++; switch (table1()) { default: error("unknown instruction byte"); /* NOTREACHED */ case ATEOF: if (prodepth != 0) error("procedure unterminated at eof"); process(); return; case INST: tstinpro(); instr = tabval; break; case DLBX: lnp = newline(OPSYMBOL); lnp->l_instr = ps_sym; lnp->l_a.la_sp = symlookup(string, DEFINING, 0); lnp->l_next = curpro.lastline; curpro.lastline = lnp; continue; case ILBX: tstinpro(); lnp = newline(OPNUMLAB); lnp->l_instr = op_lab; lnp->l_a.la_np = numlookup((unsigned) tabval); if (lnp->l_a.la_np->n_line != (line_p) 0) error("label %u multiple defined", (unsigned) tabval); lnp->l_a.la_np->n_line = lnp; lnp->l_next = curpro.lastline; curpro.lastline = lnp; continue; case PSEU: if (inpseudo(tabval)) return; continue; } /* * Now we have an instruction number in instr * There might be an operand, look for it */ if ((em_flag[instr - sp_fmnem] & EM_PAR) == PAR_NO) { lnp = newline(OPNO); } else switch (table2()) { default: error("unknown offset byte"); case sp_cend: lnp = newline(OPNO); break; case CSTX1: if ((em_flag[instr - sp_fmnem] & EM_PAR) != PAR_B) { if (CANMINI(tabval)) lnp = newline(tabval + Z_OPMINI); else { lnp = newline(OPSHORT); lnp->l_a.la_short = tabval; } } else { lnp = newline(OPNUMLAB); lnp->l_a.la_np = numlookup((unsigned) tabval); } break; #ifdef LONGOFF case CSTX2: lnp = newline(OPOFFSET); lnp->l_a.la_offset = tabval2; break; #endif case ILBX: tstinpro(); lnp = newline(OPNUMLAB); lnp->l_a.la_np = numlookup((unsigned) tabval); break; case DLBX: lnp = newline(OPSYMBOL); lnp->l_a.la_sp = symlookup(string, OCCURRING, 0); break; case sp_pnam: lnp = newline(OPSYMBOL); lnp->l_a.la_sp = symlookup(string, OCCURRING, SYMPRO); break; case VALX1: lnp = newline(OPSVAL); lnp->l_a.la_sval.lasv_sp = symlookup(string, OCCURRING, 0); lnp->l_a.la_sval.lasv_short = tabval; break; #ifdef LONGOFF case VALX2: lnp = newline(OPLVAL); lnp->l_a.la_lval.lalv_sp = symlookup(string, OCCURRING, 0); lnp->l_a.la_lval.lalv_offset = tabval2; break; #endif } lnp->l_instr = instr; lnp->l_next = curpro.lastline; curpro.lastline = lnp; } }
ff71d105db041765a3d6d7c338c029e6b11a73b3
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c
42038e8abd2f58db7f51a6e9f664def89d53c2b7
[ "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
1,201
c
drv_spi_flash.c
/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2018-02-08 RT-Thread the first version */ #include <rtthread.h> #include <rthw.h> #include <rtdevice.h> #define DBG_TAG "FLASH" #define DBG_LVL DBG_LOG #include <rtdbg.h> #define SPI_FLASH_DEVICE_NAME "spi00" #define SPI_FLASH_CHIP "gd25qxx" //#define DEBUG #ifdef DEBUG #define DEBUG_PRINTF(...) rt_kprintf(__VA_ARGS__) #else #define DEBUG_PRINTF(...) #endif #if defined(TINA_USING_SPI_FLASH) && defined(RT_USING_SFUD) #include "spi_flash.h" #include <spi_flash_sfud.h> rt_spi_flash_device_t spi_device; int rt_hw_spi_flash_with_sfud_init(void) { DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__); spi_device = rt_sfud_flash_probe(SPI_FLASH_CHIP, SPI_FLASH_DEVICE_NAME); if (spi_device == NULL) { DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__); return -RT_ERROR; }; DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__); return RT_EOK; } INIT_PREV_EXPORT(rt_hw_spi_flash_with_sfud_init); #endif /* defined(TINA_USING_SPI_FLASH) && defined(RT_USING_SFUD) */
8fb3b8cd8446adc14689ca18cb6e401da118e6ab
e5f4f37d941ceb8145d65f92028cc54658b1ac01
/Code/Editor/EditorEngineProcess/EditorEngineProcessPCH.h
48eecc2e46d1cb4ecf033974993b94ca4025f78e
[ "MIT" ]
permissive
ezEngine/ezEngine
19983d2733a5409fb2665c6c3a0a575dadcefb50
c46e3b4b2cd46798e4abb4938fbca281c054b039
refs/heads/dev
2023-09-06T02:17:28.152665
2023-09-05T18:25:43
2023-09-05T18:25:43
18,179,848
1,050
165
MIT
2023-09-14T21:44:39
2014-03-27T15:02:16
C++
UTF-8
C
false
false
656
h
EditorEngineProcessPCH.h
#include <Core/Input/InputManager.h> #include <Foundation/Application/Application.h> #include <Foundation/Basics.h> #include <Foundation/Communication/GlobalEvent.h> #include <Foundation/Communication/Telemetry.h> #include <Foundation/Configuration/CVar.h> #include <Foundation/Configuration/Startup.h> #include <Foundation/Containers/Deque.h> #include <Foundation/Containers/HashTable.h> #include <Foundation/Containers/Map.h> #include <Foundation/Containers/Set.h> #include <Foundation/IO/OSFile.h> #include <Foundation/Logging/Log.h> #include <Foundation/Reflection/Reflection.h> #include <Foundation/Strings/String.h> #include <Foundation/Time/Time.h>
6e1245f473314e7d0ac82c1f1ac74c8cb012dbc2
ea401c3e792a50364fe11f7cea0f35f99e8f4bde
/hackathon/zhi/NeuronStudio_zhi/std/nsenumeration.c
d610acad9a4efe7062bb8f146f4722fb32bca0bd
[ "MIT" ]
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
988
c
nsenumeration.c
#include "nsenumeration.h" void ns_enumeration_construct( NsEnumeration *e ) { ns_assert( NULL != e ); e->has_more_elements = NULL; e->next_element = NULL; } void ns_enumeration_destruct( NsEnumeration *e ) { ns_assert( NULL != e ); e->has_more_elements = NULL; e->next_element = NULL; } nsboolean ns_enumeration_has_more_elements( const NsEnumeration *e ) { ns_assert( NULL != e ); ns_assert( NULL != e->has_more_elements ); return ( e->has_more_elements )( e ); } nspointer ns_enumeration_next_element( NsEnumeration *e ) { ns_assert( NULL != e ); ns_assert( NULL != e->next_element ); return ( e->next_element )( e ); } nspointer ns_enumeration_get_user_data( const NsEnumeration *e ) { ns_assert( NULL != e ); return ( nspointer )( e->user_data ); } void ns_enumeration_set_user_data( NsEnumeration *e, nspointer user_data ) { ns_assert( NULL != e ); e->user_data = user_data; }
9a705983b7fe41173cacb35f80de3a0adcc953ca
7744859512f027ef0da8b1bde0f8518e631b98eb
/soh/assets/objects/object_dy_obj/object_dy_obj.h
b7f655befd1571037d42cd0c4be68adfd69527c1
[]
no_license
HarbourMasters/Shipwright
7f70b9470e4f9a117f3fe2d6e4deb776b8742182
0e7c6585239c0d7ea2c039b8b8cb7eaedf8928a9
refs/heads/develop
2023-08-31T20:50:56.253521
2023-08-30T17:34:06
2023-08-30T17:34:06
472,575,717
2,104
459
null
2023-09-14T20:29:01
2022-03-22T01:42:52
C
UTF-8
C
false
false
12,372
h
object_dy_obj.h
#pragma once #include "align_asset_macro.h" #define dgGreatFairySkel "__OTR__objects/object_dy_obj/gGreatFairySkel" static const ALIGN_ASSET(2) char gGreatFairySkel[] = dgGreatFairySkel; #define dgGreatFairyWaistDL "__OTR__objects/object_dy_obj/gGreatFairyWaistDL" static const ALIGN_ASSET(2) char gGreatFairyWaistDL[] = dgGreatFairyWaistDL; #define dgGreatFairyLeftThighDL "__OTR__objects/object_dy_obj/gGreatFairyLeftThighDL" static const ALIGN_ASSET(2) char gGreatFairyLeftThighDL[] = dgGreatFairyLeftThighDL; #define dgGreatFairyLeftLegDL "__OTR__objects/object_dy_obj/gGreatFairyLeftLegDL" static const ALIGN_ASSET(2) char gGreatFairyLeftLegDL[] = dgGreatFairyLeftLegDL; #define dgGreatFairyLeftFootDL "__OTR__objects/object_dy_obj/gGreatFairyLeftFootDL" static const ALIGN_ASSET(2) char gGreatFairyLeftFootDL[] = dgGreatFairyLeftFootDL; #define dgGreatFairyRightThighDL "__OTR__objects/object_dy_obj/gGreatFairyRightThighDL" static const ALIGN_ASSET(2) char gGreatFairyRightThighDL[] = dgGreatFairyRightThighDL; #define dgGreatFairyRightLegDL "__OTR__objects/object_dy_obj/gGreatFairyRightLegDL" static const ALIGN_ASSET(2) char gGreatFairyRightLegDL[] = dgGreatFairyRightLegDL; #define dgGreatFairyRightFootDL "__OTR__objects/object_dy_obj/gGreatFairyRightFootDL" static const ALIGN_ASSET(2) char gGreatFairyRightFootDL[] = dgGreatFairyRightFootDL; #define dgGreatFairyTorsoDL "__OTR__objects/object_dy_obj/gGreatFairyTorsoDL" static const ALIGN_ASSET(2) char gGreatFairyTorsoDL[] = dgGreatFairyTorsoDL; #define dgGreatFairyLeftUpperArmDL "__OTR__objects/object_dy_obj/gGreatFairyLeftUpperArmDL" static const ALIGN_ASSET(2) char gGreatFairyLeftUpperArmDL[] = dgGreatFairyLeftUpperArmDL; #define dgGreatFairyLeftForearmDL "__OTR__objects/object_dy_obj/gGreatFairyLeftForearmDL" static const ALIGN_ASSET(2) char gGreatFairyLeftForearmDL[] = dgGreatFairyLeftForearmDL; #define dgGreatFairyLeftHandDL "__OTR__objects/object_dy_obj/gGreatFairyLeftHandDL" static const ALIGN_ASSET(2) char gGreatFairyLeftHandDL[] = dgGreatFairyLeftHandDL; #define dgGreatFairyRightUpperArmDL "__OTR__objects/object_dy_obj/gGreatFairyRightUpperArmDL" static const ALIGN_ASSET(2) char gGreatFairyRightUpperArmDL[] = dgGreatFairyRightUpperArmDL; #define dgGreatFairyRightForearmDL "__OTR__objects/object_dy_obj/gGreatFairyRightForearmDL" static const ALIGN_ASSET(2) char gGreatFairyRightForearmDL[] = dgGreatFairyRightForearmDL; #define dgGreatFairyRightHandDL "__OTR__objects/object_dy_obj/gGreatFairyRightHandDL" static const ALIGN_ASSET(2) char gGreatFairyRightHandDL[] = dgGreatFairyRightHandDL; #define dgGreatFairyHeadDL "__OTR__objects/object_dy_obj/gGreatFairyHeadDL" static const ALIGN_ASSET(2) char gGreatFairyHeadDL[] = dgGreatFairyHeadDL; #define dgGreatFairyMiddleHairLowerPartDL "__OTR__objects/object_dy_obj/gGreatFairyMiddleHairLowerPartDL" static const ALIGN_ASSET(2) char gGreatFairyMiddleHairLowerPartDL[] = dgGreatFairyMiddleHairLowerPartDL; #define dgGreatFairyMiddleHairMiddlePartDL "__OTR__objects/object_dy_obj/gGreatFairyMiddleHairMiddlePartDL" static const ALIGN_ASSET(2) char gGreatFairyMiddleHairMiddlePartDL[] = dgGreatFairyMiddleHairMiddlePartDL; #define dgGreatFairyMiddleHairUpperPartDL "__OTR__objects/object_dy_obj/gGreatFairyMiddleHairUpperPartDL" static const ALIGN_ASSET(2) char gGreatFairyMiddleHairUpperPartDL[] = dgGreatFairyMiddleHairUpperPartDL; #define dgGreatFairyMiddleHairTipDL "__OTR__objects/object_dy_obj/gGreatFairyMiddleHairTipDL" static const ALIGN_ASSET(2) char gGreatFairyMiddleHairTipDL[] = dgGreatFairyMiddleHairTipDL; #define dgGreatFairyLeftHairLowerPartDL "__OTR__objects/object_dy_obj/gGreatFairyLeftHairLowerPartDL" static const ALIGN_ASSET(2) char gGreatFairyLeftHairLowerPartDL[] = dgGreatFairyLeftHairLowerPartDL; #define dgGreatFairyLeftHairMiddlePartDL "__OTR__objects/object_dy_obj/gGreatFairyLeftHairMiddlePartDL" static const ALIGN_ASSET(2) char gGreatFairyLeftHairMiddlePartDL[] = dgGreatFairyLeftHairMiddlePartDL; #define dgGreatFairyLeftHairUpperPartDL "__OTR__objects/object_dy_obj/gGreatFairyLeftHairUpperPartDL" static const ALIGN_ASSET(2) char gGreatFairyLeftHairUpperPartDL[] = dgGreatFairyLeftHairUpperPartDL; #define dgGreatFairyLeftHairTipDL "__OTR__objects/object_dy_obj/gGreatFairyLeftHairTipDL" static const ALIGN_ASSET(2) char gGreatFairyLeftHairTipDL[] = dgGreatFairyLeftHairTipDL; #define dgGreatFairyRightHairLowerPartDL "__OTR__objects/object_dy_obj/gGreatFairyRightHairLowerPartDL" static const ALIGN_ASSET(2) char gGreatFairyRightHairLowerPartDL[] = dgGreatFairyRightHairLowerPartDL; #define dgGreatFairyRightHairMiddlePartDL "__OTR__objects/object_dy_obj/gGreatFairyRightHairMiddlePartDL" static const ALIGN_ASSET(2) char gGreatFairyRightHairMiddlePartDL[] = dgGreatFairyRightHairMiddlePartDL; #define dgGreatFairyRightHairUpperPartDL "__OTR__objects/object_dy_obj/gGreatFairyRightHairUpperPartDL" static const ALIGN_ASSET(2) char gGreatFairyRightHairUpperPartDL[] = dgGreatFairyRightHairUpperPartDL; #define dgGreatFairyRightHairTipDL "__OTR__objects/object_dy_obj/gGreatFairyRightHairTipDL" static const ALIGN_ASSET(2) char gGreatFairyRightHairTipDL[] = dgGreatFairyRightHairTipDL; #define dgGreatFairyBetaDL "__OTR__objects/object_dy_obj/gGreatFairyBetaDL" static const ALIGN_ASSET(2) char gGreatFairyBetaDL[] = dgGreatFairyBetaDL; #define dgGreatFairyFlowerDL "__OTR__objects/object_dy_obj/gGreatFairyFlowerDL" static const ALIGN_ASSET(2) char gGreatFairyFlowerDL[] = dgGreatFairyFlowerDL; #define dgGreatFairyParticleMaterialDL "__OTR__objects/object_dy_obj/gGreatFairyParticleMaterialDL" static const ALIGN_ASSET(2) char gGreatFairyParticleMaterialDL[] = dgGreatFairyParticleMaterialDL; #define dgGreatFairyParticleModelDL "__OTR__objects/object_dy_obj/gGreatFairyParticleModelDL" static const ALIGN_ASSET(2) char gGreatFairyParticleModelDL[] = dgGreatFairyParticleModelDL; #define dgGreatFairySpiralBeamDL "__OTR__objects/object_dy_obj/gGreatFairySpiralBeamDL" static const ALIGN_ASSET(2) char gGreatFairySpiralBeamDL[] = dgGreatFairySpiralBeamDL; #define dgGreatFairyTLUT "__OTR__objects/object_dy_obj/gGreatFairyTLUT" static const ALIGN_ASSET(2) char gGreatFairyTLUT[] = dgGreatFairyTLUT; #define dgGreatFairyParticleTex "__OTR__objects/object_dy_obj/gGreatFairyParticleTex" static const ALIGN_ASSET(2) char gGreatFairyParticleTex[] = dgGreatFairyParticleTex; #define dgGreatFairyBetaGradient1Tex "__OTR__objects/object_dy_obj/gGreatFairyBetaGradient1Tex" static const ALIGN_ASSET(2) char gGreatFairyBetaGradient1Tex[] = dgGreatFairyBetaGradient1Tex; #define dgGreatFairyBetaGradient2Tex "__OTR__objects/object_dy_obj/gGreatFairyBetaGradient2Tex" static const ALIGN_ASSET(2) char gGreatFairyBetaGradient2Tex[] = dgGreatFairyBetaGradient2Tex; #define dgGreatFairyBetaClothesTex "__OTR__objects/object_dy_obj/gGreatFairyBetaClothesTex" static const ALIGN_ASSET(2) char gGreatFairyBetaClothesTex[] = dgGreatFairyBetaClothesTex; #define dgGreatFairyFlowerTex "__OTR__objects/object_dy_obj/gGreatFairyFlowerTex" static const ALIGN_ASSET(2) char gGreatFairyFlowerTex[] = dgGreatFairyFlowerTex; #define dgGreatFairyBootPatternTex "__OTR__objects/object_dy_obj/gGreatFairyBootPatternTex" static const ALIGN_ASSET(2) char gGreatFairyBootPatternTex[] = dgGreatFairyBootPatternTex; #define dgGreatFairyLeavesPattern1Tex "__OTR__objects/object_dy_obj/gGreatFairyLeavesPattern1Tex" static const ALIGN_ASSET(2) char gGreatFairyLeavesPattern1Tex[] = dgGreatFairyLeavesPattern1Tex; #define dgGreatFairySkinGradient "__OTR__objects/object_dy_obj/gGreatFairySkinGradient" static const ALIGN_ASSET(2) char gGreatFairySkinGradient[] = dgGreatFairySkinGradient; #define dgGreatFairyLeavesPattern2Tex "__OTR__objects/object_dy_obj/gGreatFairyLeavesPattern2Tex" static const ALIGN_ASSET(2) char gGreatFairyLeavesPattern2Tex[] = dgGreatFairyLeavesPattern2Tex; #define dgGreatFairyHairTex "__OTR__objects/object_dy_obj/gGreatFairyHairTex" static const ALIGN_ASSET(2) char gGreatFairyHairTex[] = dgGreatFairyHairTex; #define dgGreatFairyEar1Tex "__OTR__objects/object_dy_obj/gGreatFairyEar1Tex" static const ALIGN_ASSET(2) char gGreatFairyEar1Tex[] = dgGreatFairyEar1Tex; #define dgGreatFairyEar2Tex "__OTR__objects/object_dy_obj/gGreatFairyEar2Tex" static const ALIGN_ASSET(2) char gGreatFairyEar2Tex[] = dgGreatFairyEar2Tex; #define dgGreatFairyBackOfHandTex "__OTR__objects/object_dy_obj/gGreatFairyBackOfHandTex" static const ALIGN_ASSET(2) char gGreatFairyBackOfHandTex[] = dgGreatFairyBackOfHandTex; #define dgGreatFairyLeavesPattern3Tex "__OTR__objects/object_dy_obj/gGreatFairyLeavesPattern3Tex" static const ALIGN_ASSET(2) char gGreatFairyLeavesPattern3Tex[] = dgGreatFairyLeavesPattern3Tex; #define dgGreatFairySpiralBeamPatternTex "__OTR__objects/object_dy_obj/gGreatFairySpiralBeamPatternTex" static const ALIGN_ASSET(2) char gGreatFairySpiralBeamPatternTex[] = dgGreatFairySpiralBeamPatternTex; #define dgGreatFairySpiralBeamGradientTex "__OTR__objects/object_dy_obj/gGreatFairySpiralBeamGradientTex" static const ALIGN_ASSET(2) char gGreatFairySpiralBeamGradientTex[] = dgGreatFairySpiralBeamGradientTex; #define dgGreatFairyEyeOpenTex "__OTR__objects/object_dy_obj/gGreatFairyEyeOpenTex" static const ALIGN_ASSET(2) char gGreatFairyEyeOpenTex[] = dgGreatFairyEyeOpenTex; #define dgGreatFairyEyeHalfTex "__OTR__objects/object_dy_obj/gGreatFairyEyeHalfTex" static const ALIGN_ASSET(2) char gGreatFairyEyeHalfTex[] = dgGreatFairyEyeHalfTex; #define dgGreatFairyEyeClosedTex "__OTR__objects/object_dy_obj/gGreatFairyEyeClosedTex" static const ALIGN_ASSET(2) char gGreatFairyEyeClosedTex[] = dgGreatFairyEyeClosedTex; #define dgGreatFairyMouthClosedTex "__OTR__objects/object_dy_obj/gGreatFairyMouthClosedTex" static const ALIGN_ASSET(2) char gGreatFairyMouthClosedTex[] = dgGreatFairyMouthClosedTex; #define dgGreatFairyMouthOpenTex "__OTR__objects/object_dy_obj/gGreatFairyMouthOpenTex" static const ALIGN_ASSET(2) char gGreatFairyMouthOpenTex[] = dgGreatFairyMouthOpenTex; #define dgGreatFairyAnim_000108 "__OTR__objects/object_dy_obj/gGreatFairyAnim_000108" static const ALIGN_ASSET(2) char gGreatFairyAnim_000108[] = dgGreatFairyAnim_000108; #define dgGreatFairySpellFountainSpinShrinkAnim "__OTR__objects/object_dy_obj/gGreatFairySpellFountainSpinShrinkAnim" static const ALIGN_ASSET(2) char gGreatFairySpellFountainSpinShrinkAnim[] = dgGreatFairySpellFountainSpinShrinkAnim; #define dgGreatFairyLayingSidewaysAnim "__OTR__objects/object_dy_obj/gGreatFairyLayingSidewaysAnim" static const ALIGN_ASSET(2) char gGreatFairyLayingSidewaysAnim[] = dgGreatFairyLayingSidewaysAnim; #define dgGreatFairyLayingDownTransitionAnim "__OTR__objects/object_dy_obj/gGreatFairyLayingDownTransitionAnim" static const ALIGN_ASSET(2) char gGreatFairyLayingDownTransitionAnim[] = dgGreatFairyLayingDownTransitionAnim; #define dgGreatFairyAfterSpellAnim "__OTR__objects/object_dy_obj/gGreatFairyAfterSpellAnim" static const ALIGN_ASSET(2) char gGreatFairyAfterSpellAnim[] = dgGreatFairyAfterSpellAnim; #define dgGreatFairyAnim_005810 "__OTR__objects/object_dy_obj/gGreatFairyAnim_005810" static const ALIGN_ASSET(2) char gGreatFairyAnim_005810[] = dgGreatFairyAnim_005810; #define dgGreatFairyJewelFountainSpinShrinkAnim "__OTR__objects/object_dy_obj/gGreatFairyJewelFountainSpinShrinkAnim" static const ALIGN_ASSET(2) char gGreatFairyJewelFountainSpinShrinkAnim[] = dgGreatFairyJewelFountainSpinShrinkAnim; #define dgGreatFairyGivingUpgradeAnim "__OTR__objects/object_dy_obj/gGreatFairyGivingUpgradeAnim" static const ALIGN_ASSET(2) char gGreatFairyGivingUpgradeAnim[] = dgGreatFairyGivingUpgradeAnim; #define dgGreatFairyAfterUpgradeAnim "__OTR__objects/object_dy_obj/gGreatFairyAfterUpgradeAnim" static const ALIGN_ASSET(2) char gGreatFairyAfterUpgradeAnim[] = dgGreatFairyAfterUpgradeAnim; #define dgGreatFairySittingTransitionAnim "__OTR__objects/object_dy_obj/gGreatFairySittingTransitionAnim" static const ALIGN_ASSET(2) char gGreatFairySittingTransitionAnim[] = dgGreatFairySittingTransitionAnim; #define dgGreatFairySittingAnim "__OTR__objects/object_dy_obj/gGreatFairySittingAnim" static const ALIGN_ASSET(2) char gGreatFairySittingAnim[] = dgGreatFairySittingAnim; #define dgGreatFairySpiralBeamVtx "__OTR__objects/object_dy_obj/gGreatFairySpiralBeamVtx" static const ALIGN_ASSET(2) char gGreatFairySpiralBeamVtx[] = dgGreatFairySpiralBeamVtx;
693c6b58f06716fe7264dd16de47e4a12946fda1
89777a38b4db1e70f2cc2410c59656282046e4a2
/capture.h
d11900160439e1fdc23ec5ad3a01b6153ba384d2
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
ataradov/open-5012h
7995bd1f93435783fddcb1a195295273ddedcdcd
bade3db049be36d5c4568b38cb71bbb4a99541f1
refs/heads/master
2021-12-14T10:38:25.954848
2021-11-29T04:14:13
2021-11-29T04:14:13
236,407,274
112
29
null
null
null
null
UTF-8
C
false
false
2,818
h
capture.h
/* * Copyright (c) 2019-2020, Alex Taradov <alex@taradov.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _CAPTURE_H_ #define _CAPTURE_H_ /*- Definitions -------------------------------------------------------------*/ #define BASE_SAMPLE_RATE 125e6 #define BASE_SAMPLE_PERIOD (1e9 / BASE_SAMPLE_RATE) #define CAPTURE_BUFFER_SIZE (128 * 1024) #define TRIGGER_MARGIN_SAMPLES 1024 #define DATA_BUFFER_SIZE 300 /*- Types -------------------------------------------------------------------*/ typedef struct { int size; int min_value; int max_value; int vertical_position; int frequency; int min[DATA_BUFFER_SIZE]; int max[DATA_BUFFER_SIZE]; uint8_t flags[DATA_BUFFER_SIZE]; } DataBuffer; /*- Prototypes --------------------------------------------------------------*/ void capture_init(void); void capture_disable_clock(void); void capture_start(void); void capture_stop(void); void capture_set_vertical_parameters(void); void capture_set_horizontal_parameters(int sr_divider, int trigger_offset); void capture_set_trigger_level(int level); void capture_set_trigger_edge(int edge); void capture_set_trigger_mode(int mode); int capture_get_state(void); bool capture_buffer_updated(void); void capture_get_data(DataBuffer *db); void capture_get_raw_data(int *raw, int size); #endif // _CAPTURE_H_
a805f52dad1084785f0f393267a4bbd99f5ea0e1
0ba9681b235b377b3f57d52532ab7212d4d4cd8a
/intTests/test_llvm_global_fresh_pointer/test.c
77566ce6064ff22fd8e9302497bd2a7f87fbfb9e
[ "BSD-3-Clause" ]
permissive
GaloisInc/saw-script
d9a3eb7b05c1bcbcc319987223cd53b903b55b5d
79ddd800bec59528958ed6d7593304e2b17b7dfb
refs/heads/master
2023-09-01T09:47:31.415255
2023-08-30T11:26:08
2023-08-30T11:26:08
34,082,065
458
82
BSD-3-Clause
2023-09-14T16:23:09
2015-04-16T21:39:32
Haskell
UTF-8
C
false
false
75
c
test.c
int glb; void foo(const int *x) {} void bar(const int *x) { foo(x); }
1ce0554614e70e73c5ec787efd8ce6636074e822
7bc1d8634529eac952490399fb71f10bcedf05cc
/third_party/mbedtls/repo/programs/test/query_config.h
23009c46aa4dfe5fd52a1a85c107a6f05b4b20e2
[ "Apache-2.0", "GPL-2.0-or-later", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-warranty-disclaimer", "BSD-3-Clause" ]
permissive
openthread/openthread
6a9e25d1cd224bde9796d9616f04f423dba27d77
102a631cb3f8938389d0d10199a14c59184039cd
refs/heads/main
2023-08-18T10:46:03.820124
2023-08-17T22:20:55
2023-08-17T22:20:55
55,808,787
3,485
1,296
BSD-3-Clause
2023-09-14T15:50:53
2016-04-08T20:47:41
C++
UTF-8
C
false
false
1,487
h
query_config.h
/* * Query Mbed TLS compile time configurations from config.h * * Copyright The Mbed TLS Contributors * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MBEDTLS_PROGRAMS_TEST_QUERY_CONFIG_H #define MBEDTLS_PROGRAMS_TEST_QUERY_CONFIG_H #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else #include MBEDTLS_CONFIG_FILE #endif /** Check whether a given configuration symbol is enabled. * * \param config The symbol to query (e.g. "MBEDTLS_RSA_C"). * \return \c 0 if the symbol was defined at compile time * (in MBEDTLS_CONFIG_FILE or config.h), * \c 1 otherwise. * * \note This function is defined in `programs/test/query_config.c` * which is automatically generated by * `scripts/generate_query_config.pl`. */ int query_config( const char *config ); #endif /* MBEDTLS_PROGRAMS_TEST_QUERY_CONFIG_H */
50575e34d7463ffd569ce37d2395b078abf99dbf
676acab8ff535019faff7da3afb8eecc3fa127f5
/src/lib/printf/printf_if.c
5a1b27e4afbcb1221942852c62c3f518d8e10e77
[ "Apache-2.0" ]
permissive
Firmament-Autopilot/FMT-Firmware
f8c324577245bd7e91af436954b4ce9421acbb41
0212fe89820376bfbedaded519552f6b011a7b8a
refs/heads/master
2023-09-01T11:37:46.194145
2023-08-29T06:33:10
2023-08-29T06:33:10
402,557,689
351
143
Apache-2.0
2023-09-12T05:28:39
2021-09-02T20:42:56
C
UTF-8
C
false
false
209
c
printf_if.c
#include "module/console/console.h" /** * @brief Implement _putchar, which will be used * by printf_ function * * @param character */ void _putchar(char character) { console_write(&character, 1); }
b48283f73ec84e78efe84fc3164e6749eb985648
7e10520d82c002eb808df28ff0d3d9f4fdb9bda0
/flash/xip_stream/flash_xip_stream.c
51ef7efc38fc3cf49b2b751cec65fc213ef68d64
[ "BSD-3-Clause" ]
permissive
raspberrypi/pico-examples
3229b4320c9fe1acaacb73afba5378921196ab06
eca13acf57916a0bd5961028314006983894fc84
refs/heads/master
2023-09-03T19:53:49.865239
2023-06-11T20:15:45
2023-06-11T20:15:45
331,381,105
2,195
749
BSD-3-Clause
2023-09-14T16:25:25
2021-01-20T17:31:36
C
UTF-8
C
false
false
3,202
c
flash_xip_stream.c
/** * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */ #include <stdio.h> #include <stdlib.h> #include "pico/stdlib.h" #include "hardware/dma.h" #include "hardware/regs/addressmap.h" #include "hardware/structs/xip_ctrl.h" #include "random_test_data.h" // The XIP has some internal hardware that can stream a linear access sequence // to a DMAable FIFO, while the system is still doing random accesses on flash // code + data. uint32_t buf[count_of(random_test_data)]; int main() { stdio_init_all(); for (int i = 0; i < count_of(random_test_data); ++i) buf[i] = 0; // This example won't work with PICO_NO_FLASH builds. Note that XIP stream // can be made to work in these cases, if you enable some XIP mode first // (e.g. via calling flash_enter_cmd_xip() in ROM). However, you will get // much better performance by DMAing directly from the SSI's FIFOs, as in // this way you can clock data continuously on the QSPI bus, rather than a // series of short transfers. if ((uint32_t) &random_test_data[0] >= SRAM_BASE) { printf("You need to run this example from flash!\n"); exit(-1); } // Transfer started by writing nonzero value to stream_ctr. stream_ctr // will count down as the transfer progresses. Can terminate early by // writing 0 to stream_ctr. // It's a good idea to drain the FIFO first! printf("Starting stream from %p\n", random_test_data); /// \tag::start_stream[] while (!(xip_ctrl_hw->stat & XIP_STAT_FIFO_EMPTY)) (void) xip_ctrl_hw->stream_fifo; xip_ctrl_hw->stream_addr = (uint32_t) &random_test_data[0]; xip_ctrl_hw->stream_ctr = count_of(random_test_data); /// \end::start_stream[] // Start DMA transfer from XIP stream FIFO to our buffer in memory. Use // the auxiliary bus slave for the DMA<-FIFO accesses, to avoid stalling // the DMA against general XIP traffic. Doesn't really matter for this // example, but it can have a huge effect on DMA throughput. printf("Starting DMA\n"); /// \tag::start_dma[] const uint dma_chan = 0; dma_channel_config cfg = dma_channel_get_default_config(dma_chan); channel_config_set_read_increment(&cfg, false); channel_config_set_write_increment(&cfg, true); channel_config_set_dreq(&cfg, DREQ_XIP_STREAM); dma_channel_configure( dma_chan, &cfg, (void *) buf, // Write addr (const void *) XIP_AUX_BASE, // Read addr count_of(random_test_data), // Transfer count true // Start immediately! ); /// \end::start_dma[] dma_channel_wait_for_finish_blocking(dma_chan); printf("DMA complete\n"); bool mismatch = false; for (int i = 0; i < count_of(random_test_data); ++i) { if (random_test_data[i] != buf[i]) { printf("Data mismatch: %08x (actual) != %08x (expected)\n", buf[i], random_test_data[i]); mismatch = true; break; } printf("%08x%c", buf[i], i % 8 == 7 ? '\n' : ' '); } if (!mismatch) printf("Data check OK\n"); }
ee13ff3d896804920731283324cab6bf14be3973
bed3ac926beac0f4e0293303d7b2a6031ee476c9
/Modules/ThirdParty/VNL/src/vxl/v3p/netlib/mathews/simpson.c
b72f6932c2db047f3e1c6a4a43177971fe573b00
[ "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
4,110
c
simpson.c
/* mathews/simpson.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" /* NUMERICAL METHODS: FORTRAN Programs, (c) John H. Mathews 1994 */ /* To accompany the text: */ /* NUMERICAL METHODS for Mathematics, Science and Engineering, 2nd Ed, 1992 */ /* Prentice Hall, Englewood Cliffs, New Jersey, 07632, U.S.A. */ /* This free software is complements of the author. */ /* Algorithm 7.2 (Composite Simpson Rule). */ /* Section 7.2, Composite Trapezoidal and Simpson's Rule, Page 365 */ /* comment added by Kongbin Kang */ /* F: integrand function */ /* A: lower integration limit */ /* B: higher integration limit */ /* M: number of intervals. Notice, the subintervals used is 2M */ /* Srule: output parameter to store simpson rule result */ /*< SUBROUTINE SIMPRU(F,A,B,M,Srule) >*/ /* Subroutine */ int simpru_(doublereal (*f)(doublereal*), doublereal *a, doublereal *b, integer *m, doublereal *srule) { /* System generated locals */ integer i__1; /* Local variables */ doublereal h__; integer k; doublereal x, sum, sumodd, sumeven; /*< INTEGER K,M >*/ /*< DOUBLE PRECISION A,B,H,Sum,SumEven,SumOdd,Srule,X >*/ /*< EXTERNAL F >*/ /*< H=(B-A)/(2*M) >*/ h__ = (*b - *a) / (*m << 1); /*< SumEven=0 >*/ sumeven = 0.; /*< DO K=1,(M-1) >*/ i__1 = *m - 1; for (k = 1; k <= i__1; ++k) { /*< X=A+H*2*K >*/ x = *a + h__ * 2 * k; /*< SumEven=SumEven+F(X) >*/ sumeven += (*f)(&x); /*< ENDDO >*/ } /*< SumOdd=0 >*/ sumodd = 0.; /*< DO K=1,M >*/ i__1 = *m; for (k = 1; k <= i__1; ++k) { /*< X=A+H*(2*K-1) >*/ x = *a + h__ * ((k << 1) - 1); /*< SumOdd=SumOdd+F(X) >*/ sumodd += (*f)(&x); /*< ENDDO >*/ } /*< Sum=H*(F(A)+F(B)+2*SumEven+4*SumOdd)/3 >*/ sum = h__ * ((*f)(a) + (*f)(b) + sumeven * 2 + sumodd * 4) / 3; /*< Srule=Sum >*/ *srule = sum; /*< RETURN >*/ return 0; /*< END >*/ } /* simpru_ */ /*< SUBROUTINE XSIMPRU(F,A,B,M,Srule) >*/ /* Subroutine */ int xsimpru_(doublereal (*f)(doublereal*), doublereal *a, doublereal *b, integer * m, doublereal *srule) { /* System generated locals */ integer i__1; /* Local variables */ doublereal h__; integer k; doublereal x, sum, sumodd, sumeven; /* This subroutine uses labeled DO loop(s). */ /*< INTEGER K,M >*/ /*< DOUBLE PRECISION A,B,H,Sum,SumEven,SumOdd,Srule,X >*/ /*< EXTERNAL F >*/ /*< H=(B-A)/(2*M) >*/ h__ = (*b - *a) / (*m << 1); /*< SumEven=0 >*/ sumeven = 0.; /*< DO 10 K=1,(M-1) >*/ i__1 = *m - 1; for (k = 1; k <= i__1; ++k) { /*< X=A+H*2*K >*/ x = *a + h__ * 2 * k; /*< SumEven=SumEven+F(X) >*/ sumeven += (*f)(&x); /*< 10 CONTINUE >*/ /* L10: */ } /*< SumOdd=0 >*/ sumodd = 0.; /*< DO 20 K=1,M >*/ i__1 = *m; for (k = 1; k <= i__1; ++k) { /*< X=A+H*(2*K-1) >*/ x = *a + h__ * ((k << 1) - 1); /*< SumOdd=SumOdd+F(X) >*/ sumodd += (*f)(&x); /*< 20 CONTINUE >*/ /* L20: */ } /*< Sum=H*(F(A)+F(B)+2*SumEven+4*SumOdd)/3 >*/ sum = h__ * ((*f)(a) + (*f)(b) + sumeven * 2 + sumodd * 4) / 3; /*< Srule=Sum >*/ *srule = sum; /*< RETURN >*/ return 0; /*< END >*/ } /* xsimpru_ */ #ifdef __cplusplus } #endif
a592f3888afdbe032e160aa1496e4ef13774ceff
00c64e0967d197d8c6fc3427954e2d0b2ff13ca0
/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vmsltu.c
bcebf3cf5f7854efd30c8be6cc037a42ba9d78f5
[ "Apache-2.0", "LLVM-exception", "NCSA", "LicenseRef-scancode-unknown-license-reference" ]
permissive
triSYCL/sycl
893048e80158cf3359c1ad8912da9ccf493faf69
5a95a7136a11b75f01ef839d9229780032bbeecf
refs/heads/sycl/unified/master
2023-08-23T22:06:46.238209
2023-05-24T22:54:31
2023-05-24T22:54:31
178,923,006
103
17
NOASSERTION
2023-09-12T20:03:26
2019-04-01T18:29:01
null
UTF-8
C
false
false
48,291
c
vmsltu.c
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py // REQUIRES: riscv-registered-target // RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \ // RUN: -target-feature +experimental-zvfh -disable-O0-optnone \ // RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \ // RUN: FileCheck --check-prefix=CHECK-RV64 %s #include <riscv_vector.h> // CHECK-RV64-LABEL: @test_vmsltu_vv_u8mf8_b64_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i8.nxv1i8.i64(<vscale x 1 x i1> poison, <vscale x 1 x i8> [[OP1:%.*]], <vscale x 1 x i8> [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vv_u8mf8_b64_ma(vbool64_t mask, vuint8mf8_t op1, vuint8mf8_t op2, size_t vl) { return vmsltu_vv_u8mf8_b64_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8mf8_b64_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i8.i8.i64(<vscale x 1 x i1> poison, <vscale x 1 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vx_u8mf8_b64_ma(vbool64_t mask, vuint8mf8_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8mf8_b64_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8mf4_b32_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i8.nxv2i8.i64(<vscale x 2 x i1> poison, <vscale x 2 x i8> [[OP1:%.*]], <vscale x 2 x i8> [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vv_u8mf4_b32_ma(vbool32_t mask, vuint8mf4_t op1, vuint8mf4_t op2, size_t vl) { return vmsltu_vv_u8mf4_b32_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8mf4_b32_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i8.i8.i64(<vscale x 2 x i1> poison, <vscale x 2 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vx_u8mf4_b32_ma(vbool32_t mask, vuint8mf4_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8mf4_b32_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8mf2_b16_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i8.nxv4i8.i64(<vscale x 4 x i1> poison, <vscale x 4 x i8> [[OP1:%.*]], <vscale x 4 x i8> [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vv_u8mf2_b16_ma(vbool16_t mask, vuint8mf2_t op1, vuint8mf2_t op2, size_t vl) { return vmsltu_vv_u8mf2_b16_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8mf2_b16_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i8.i8.i64(<vscale x 4 x i1> poison, <vscale x 4 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vx_u8mf2_b16_ma(vbool16_t mask, vuint8mf2_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8mf2_b16_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8m1_b8_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i8.nxv8i8.i64(<vscale x 8 x i1> poison, <vscale x 8 x i8> [[OP1:%.*]], <vscale x 8 x i8> [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vv_u8m1_b8_ma(vbool8_t mask, vuint8m1_t op1, vuint8m1_t op2, size_t vl) { return vmsltu_vv_u8m1_b8_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8m1_b8_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i8.i8.i64(<vscale x 8 x i1> poison, <vscale x 8 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vx_u8m1_b8_ma(vbool8_t mask, vuint8m1_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8m1_b8_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8m2_b4_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i8.nxv16i8.i64(<vscale x 16 x i1> poison, <vscale x 16 x i8> [[OP1:%.*]], <vscale x 16 x i8> [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vv_u8m2_b4_ma(vbool4_t mask, vuint8m2_t op1, vuint8m2_t op2, size_t vl) { return vmsltu_vv_u8m2_b4_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8m2_b4_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i8.i8.i64(<vscale x 16 x i1> poison, <vscale x 16 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vx_u8m2_b4_ma(vbool4_t mask, vuint8m2_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8m2_b4_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8m4_b2_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i1> @llvm.riscv.vmsltu.mask.nxv32i8.nxv32i8.i64(<vscale x 32 x i1> poison, <vscale x 32 x i8> [[OP1:%.*]], <vscale x 32 x i8> [[OP2:%.*]], <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 32 x i1> [[TMP0]] // vbool2_t test_vmsltu_vv_u8m4_b2_ma(vbool2_t mask, vuint8m4_t op1, vuint8m4_t op2, size_t vl) { return vmsltu_vv_u8m4_b2_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8m4_b2_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i1> @llvm.riscv.vmsltu.mask.nxv32i8.i8.i64(<vscale x 32 x i1> poison, <vscale x 32 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 32 x i1> [[TMP0]] // vbool2_t test_vmsltu_vx_u8m4_b2_ma(vbool2_t mask, vuint8m4_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8m4_b2_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8m8_b1_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i1> @llvm.riscv.vmsltu.mask.nxv64i8.nxv64i8.i64(<vscale x 64 x i1> poison, <vscale x 64 x i8> [[OP1:%.*]], <vscale x 64 x i8> [[OP2:%.*]], <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 64 x i1> [[TMP0]] // vbool1_t test_vmsltu_vv_u8m8_b1_ma(vbool1_t mask, vuint8m8_t op1, vuint8m8_t op2, size_t vl) { return vmsltu_vv_u8m8_b1_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8m8_b1_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i1> @llvm.riscv.vmsltu.mask.nxv64i8.i8.i64(<vscale x 64 x i1> poison, <vscale x 64 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 64 x i1> [[TMP0]] // vbool1_t test_vmsltu_vx_u8m8_b1_ma(vbool1_t mask, vuint8m8_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8m8_b1_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16mf4_b64_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i16.nxv1i16.i64(<vscale x 1 x i1> poison, <vscale x 1 x i16> [[OP1:%.*]], <vscale x 1 x i16> [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vv_u16mf4_b64_ma(vbool64_t mask, vuint16mf4_t op1, vuint16mf4_t op2, size_t vl) { return vmsltu_vv_u16mf4_b64_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16mf4_b64_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i16.i16.i64(<vscale x 1 x i1> poison, <vscale x 1 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vx_u16mf4_b64_ma(vbool64_t mask, vuint16mf4_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16mf4_b64_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16mf2_b32_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i16.nxv2i16.i64(<vscale x 2 x i1> poison, <vscale x 2 x i16> [[OP1:%.*]], <vscale x 2 x i16> [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vv_u16mf2_b32_ma(vbool32_t mask, vuint16mf2_t op1, vuint16mf2_t op2, size_t vl) { return vmsltu_vv_u16mf2_b32_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16mf2_b32_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i16.i16.i64(<vscale x 2 x i1> poison, <vscale x 2 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vx_u16mf2_b32_ma(vbool32_t mask, vuint16mf2_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16mf2_b32_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16m1_b16_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i16.nxv4i16.i64(<vscale x 4 x i1> poison, <vscale x 4 x i16> [[OP1:%.*]], <vscale x 4 x i16> [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vv_u16m1_b16_ma(vbool16_t mask, vuint16m1_t op1, vuint16m1_t op2, size_t vl) { return vmsltu_vv_u16m1_b16_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16m1_b16_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i16.i16.i64(<vscale x 4 x i1> poison, <vscale x 4 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vx_u16m1_b16_ma(vbool16_t mask, vuint16m1_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16m1_b16_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16m2_b8_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i16.nxv8i16.i64(<vscale x 8 x i1> poison, <vscale x 8 x i16> [[OP1:%.*]], <vscale x 8 x i16> [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vv_u16m2_b8_ma(vbool8_t mask, vuint16m2_t op1, vuint16m2_t op2, size_t vl) { return vmsltu_vv_u16m2_b8_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16m2_b8_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i16.i16.i64(<vscale x 8 x i1> poison, <vscale x 8 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vx_u16m2_b8_ma(vbool8_t mask, vuint16m2_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16m2_b8_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16m4_b4_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i16.nxv16i16.i64(<vscale x 16 x i1> poison, <vscale x 16 x i16> [[OP1:%.*]], <vscale x 16 x i16> [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vv_u16m4_b4_ma(vbool4_t mask, vuint16m4_t op1, vuint16m4_t op2, size_t vl) { return vmsltu_vv_u16m4_b4_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16m4_b4_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i16.i16.i64(<vscale x 16 x i1> poison, <vscale x 16 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vx_u16m4_b4_ma(vbool4_t mask, vuint16m4_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16m4_b4_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16m8_b2_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i1> @llvm.riscv.vmsltu.mask.nxv32i16.nxv32i16.i64(<vscale x 32 x i1> poison, <vscale x 32 x i16> [[OP1:%.*]], <vscale x 32 x i16> [[OP2:%.*]], <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 32 x i1> [[TMP0]] // vbool2_t test_vmsltu_vv_u16m8_b2_ma(vbool2_t mask, vuint16m8_t op1, vuint16m8_t op2, size_t vl) { return vmsltu_vv_u16m8_b2_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16m8_b2_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i1> @llvm.riscv.vmsltu.mask.nxv32i16.i16.i64(<vscale x 32 x i1> poison, <vscale x 32 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 32 x i1> [[TMP0]] // vbool2_t test_vmsltu_vx_u16m8_b2_ma(vbool2_t mask, vuint16m8_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16m8_b2_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u32mf2_b64_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i32.nxv1i32.i64(<vscale x 1 x i1> poison, <vscale x 1 x i32> [[OP1:%.*]], <vscale x 1 x i32> [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vv_u32mf2_b64_ma(vbool64_t mask, vuint32mf2_t op1, vuint32mf2_t op2, size_t vl) { return vmsltu_vv_u32mf2_b64_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u32mf2_b64_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i32.i32.i64(<vscale x 1 x i1> poison, <vscale x 1 x i32> [[OP1:%.*]], i32 [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vx_u32mf2_b64_ma(vbool64_t mask, vuint32mf2_t op1, uint32_t op2, size_t vl) { return vmsltu_vx_u32mf2_b64_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u32m1_b32_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i32.nxv2i32.i64(<vscale x 2 x i1> poison, <vscale x 2 x i32> [[OP1:%.*]], <vscale x 2 x i32> [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vv_u32m1_b32_ma(vbool32_t mask, vuint32m1_t op1, vuint32m1_t op2, size_t vl) { return vmsltu_vv_u32m1_b32_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u32m1_b32_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i32.i32.i64(<vscale x 2 x i1> poison, <vscale x 2 x i32> [[OP1:%.*]], i32 [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vx_u32m1_b32_ma(vbool32_t mask, vuint32m1_t op1, uint32_t op2, size_t vl) { return vmsltu_vx_u32m1_b32_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u32m2_b16_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i32.nxv4i32.i64(<vscale x 4 x i1> poison, <vscale x 4 x i32> [[OP1:%.*]], <vscale x 4 x i32> [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vv_u32m2_b16_ma(vbool16_t mask, vuint32m2_t op1, vuint32m2_t op2, size_t vl) { return vmsltu_vv_u32m2_b16_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u32m2_b16_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i32.i32.i64(<vscale x 4 x i1> poison, <vscale x 4 x i32> [[OP1:%.*]], i32 [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vx_u32m2_b16_ma(vbool16_t mask, vuint32m2_t op1, uint32_t op2, size_t vl) { return vmsltu_vx_u32m2_b16_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u32m4_b8_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i32.nxv8i32.i64(<vscale x 8 x i1> poison, <vscale x 8 x i32> [[OP1:%.*]], <vscale x 8 x i32> [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vv_u32m4_b8_ma(vbool8_t mask, vuint32m4_t op1, vuint32m4_t op2, size_t vl) { return vmsltu_vv_u32m4_b8_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u32m4_b8_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i32.i32.i64(<vscale x 8 x i1> poison, <vscale x 8 x i32> [[OP1:%.*]], i32 [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vx_u32m4_b8_ma(vbool8_t mask, vuint32m4_t op1, uint32_t op2, size_t vl) { return vmsltu_vx_u32m4_b8_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u32m8_b4_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i32.nxv16i32.i64(<vscale x 16 x i1> poison, <vscale x 16 x i32> [[OP1:%.*]], <vscale x 16 x i32> [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vv_u32m8_b4_ma(vbool4_t mask, vuint32m8_t op1, vuint32m8_t op2, size_t vl) { return vmsltu_vv_u32m8_b4_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u32m8_b4_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i32.i32.i64(<vscale x 16 x i1> poison, <vscale x 16 x i32> [[OP1:%.*]], i32 [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vx_u32m8_b4_ma(vbool4_t mask, vuint32m8_t op1, uint32_t op2, size_t vl) { return vmsltu_vx_u32m8_b4_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u64m1_b64_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i64.nxv1i64.i64(<vscale x 1 x i1> poison, <vscale x 1 x i64> [[OP1:%.*]], <vscale x 1 x i64> [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vv_u64m1_b64_ma(vbool64_t mask, vuint64m1_t op1, vuint64m1_t op2, size_t vl) { return vmsltu_vv_u64m1_b64_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u64m1_b64_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i64.i64.i64(<vscale x 1 x i1> poison, <vscale x 1 x i64> [[OP1:%.*]], i64 [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vx_u64m1_b64_ma(vbool64_t mask, vuint64m1_t op1, uint64_t op2, size_t vl) { return vmsltu_vx_u64m1_b64_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u64m2_b32_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i64.nxv2i64.i64(<vscale x 2 x i1> poison, <vscale x 2 x i64> [[OP1:%.*]], <vscale x 2 x i64> [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vv_u64m2_b32_ma(vbool32_t mask, vuint64m2_t op1, vuint64m2_t op2, size_t vl) { return vmsltu_vv_u64m2_b32_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u64m2_b32_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i64.i64.i64(<vscale x 2 x i1> poison, <vscale x 2 x i64> [[OP1:%.*]], i64 [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vx_u64m2_b32_ma(vbool32_t mask, vuint64m2_t op1, uint64_t op2, size_t vl) { return vmsltu_vx_u64m2_b32_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u64m4_b16_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i64.nxv4i64.i64(<vscale x 4 x i1> poison, <vscale x 4 x i64> [[OP1:%.*]], <vscale x 4 x i64> [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vv_u64m4_b16_ma(vbool16_t mask, vuint64m4_t op1, vuint64m4_t op2, size_t vl) { return vmsltu_vv_u64m4_b16_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u64m4_b16_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i64.i64.i64(<vscale x 4 x i1> poison, <vscale x 4 x i64> [[OP1:%.*]], i64 [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vx_u64m4_b16_ma(vbool16_t mask, vuint64m4_t op1, uint64_t op2, size_t vl) { return vmsltu_vx_u64m4_b16_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u64m8_b8_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i64.nxv8i64.i64(<vscale x 8 x i1> poison, <vscale x 8 x i64> [[OP1:%.*]], <vscale x 8 x i64> [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vv_u64m8_b8_ma(vbool8_t mask, vuint64m8_t op1, vuint64m8_t op2, size_t vl) { return vmsltu_vv_u64m8_b8_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u64m8_b8_ma( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i64.i64.i64(<vscale x 8 x i1> poison, <vscale x 8 x i64> [[OP1:%.*]], i64 [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vx_u64m8_b8_ma(vbool8_t mask, vuint64m8_t op1, uint64_t op2, size_t vl) { return vmsltu_vx_u64m8_b8_ma(mask, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8mf8_b64_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i8.nxv1i8.i64(<vscale x 1 x i1> [[MASKEDOFF:%.*]], <vscale x 1 x i8> [[OP1:%.*]], <vscale x 1 x i8> [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vv_u8mf8_b64_mu(vbool64_t mask, vbool64_t maskedoff, vuint8mf8_t op1, vuint8mf8_t op2, size_t vl) { return vmsltu_vv_u8mf8_b64_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8mf8_b64_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i8.i8.i64(<vscale x 1 x i1> [[MASKEDOFF:%.*]], <vscale x 1 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vx_u8mf8_b64_mu(vbool64_t mask, vbool64_t maskedoff, vuint8mf8_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8mf8_b64_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8mf4_b32_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i8.nxv2i8.i64(<vscale x 2 x i1> [[MASKEDOFF:%.*]], <vscale x 2 x i8> [[OP1:%.*]], <vscale x 2 x i8> [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vv_u8mf4_b32_mu(vbool32_t mask, vbool32_t maskedoff, vuint8mf4_t op1, vuint8mf4_t op2, size_t vl) { return vmsltu_vv_u8mf4_b32_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8mf4_b32_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i8.i8.i64(<vscale x 2 x i1> [[MASKEDOFF:%.*]], <vscale x 2 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vx_u8mf4_b32_mu(vbool32_t mask, vbool32_t maskedoff, vuint8mf4_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8mf4_b32_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8mf2_b16_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i8.nxv4i8.i64(<vscale x 4 x i1> [[MASKEDOFF:%.*]], <vscale x 4 x i8> [[OP1:%.*]], <vscale x 4 x i8> [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vv_u8mf2_b16_mu(vbool16_t mask, vbool16_t maskedoff, vuint8mf2_t op1, vuint8mf2_t op2, size_t vl) { return vmsltu_vv_u8mf2_b16_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8mf2_b16_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i8.i8.i64(<vscale x 4 x i1> [[MASKEDOFF:%.*]], <vscale x 4 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vx_u8mf2_b16_mu(vbool16_t mask, vbool16_t maskedoff, vuint8mf2_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8mf2_b16_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8m1_b8_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i8.nxv8i8.i64(<vscale x 8 x i1> [[MASKEDOFF:%.*]], <vscale x 8 x i8> [[OP1:%.*]], <vscale x 8 x i8> [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vv_u8m1_b8_mu(vbool8_t mask, vbool8_t maskedoff, vuint8m1_t op1, vuint8m1_t op2, size_t vl) { return vmsltu_vv_u8m1_b8_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8m1_b8_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i8.i8.i64(<vscale x 8 x i1> [[MASKEDOFF:%.*]], <vscale x 8 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vx_u8m1_b8_mu(vbool8_t mask, vbool8_t maskedoff, vuint8m1_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8m1_b8_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8m2_b4_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i8.nxv16i8.i64(<vscale x 16 x i1> [[MASKEDOFF:%.*]], <vscale x 16 x i8> [[OP1:%.*]], <vscale x 16 x i8> [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vv_u8m2_b4_mu(vbool4_t mask, vbool4_t maskedoff, vuint8m2_t op1, vuint8m2_t op2, size_t vl) { return vmsltu_vv_u8m2_b4_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8m2_b4_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i8.i8.i64(<vscale x 16 x i1> [[MASKEDOFF:%.*]], <vscale x 16 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vx_u8m2_b4_mu(vbool4_t mask, vbool4_t maskedoff, vuint8m2_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8m2_b4_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8m4_b2_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i1> @llvm.riscv.vmsltu.mask.nxv32i8.nxv32i8.i64(<vscale x 32 x i1> [[MASKEDOFF:%.*]], <vscale x 32 x i8> [[OP1:%.*]], <vscale x 32 x i8> [[OP2:%.*]], <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 32 x i1> [[TMP0]] // vbool2_t test_vmsltu_vv_u8m4_b2_mu(vbool2_t mask, vbool2_t maskedoff, vuint8m4_t op1, vuint8m4_t op2, size_t vl) { return vmsltu_vv_u8m4_b2_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8m4_b2_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i1> @llvm.riscv.vmsltu.mask.nxv32i8.i8.i64(<vscale x 32 x i1> [[MASKEDOFF:%.*]], <vscale x 32 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 32 x i1> [[TMP0]] // vbool2_t test_vmsltu_vx_u8m4_b2_mu(vbool2_t mask, vbool2_t maskedoff, vuint8m4_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8m4_b2_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u8m8_b1_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i1> @llvm.riscv.vmsltu.mask.nxv64i8.nxv64i8.i64(<vscale x 64 x i1> [[MASKEDOFF:%.*]], <vscale x 64 x i8> [[OP1:%.*]], <vscale x 64 x i8> [[OP2:%.*]], <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 64 x i1> [[TMP0]] // vbool1_t test_vmsltu_vv_u8m8_b1_mu(vbool1_t mask, vbool1_t maskedoff, vuint8m8_t op1, vuint8m8_t op2, size_t vl) { return vmsltu_vv_u8m8_b1_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u8m8_b1_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i1> @llvm.riscv.vmsltu.mask.nxv64i8.i8.i64(<vscale x 64 x i1> [[MASKEDOFF:%.*]], <vscale x 64 x i8> [[OP1:%.*]], i8 [[OP2:%.*]], <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 64 x i1> [[TMP0]] // vbool1_t test_vmsltu_vx_u8m8_b1_mu(vbool1_t mask, vbool1_t maskedoff, vuint8m8_t op1, uint8_t op2, size_t vl) { return vmsltu_vx_u8m8_b1_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16mf4_b64_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i16.nxv1i16.i64(<vscale x 1 x i1> [[MASKEDOFF:%.*]], <vscale x 1 x i16> [[OP1:%.*]], <vscale x 1 x i16> [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vv_u16mf4_b64_mu(vbool64_t mask, vbool64_t maskedoff, vuint16mf4_t op1, vuint16mf4_t op2, size_t vl) { return vmsltu_vv_u16mf4_b64_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16mf4_b64_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i16.i16.i64(<vscale x 1 x i1> [[MASKEDOFF:%.*]], <vscale x 1 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vx_u16mf4_b64_mu(vbool64_t mask, vbool64_t maskedoff, vuint16mf4_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16mf4_b64_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16mf2_b32_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i16.nxv2i16.i64(<vscale x 2 x i1> [[MASKEDOFF:%.*]], <vscale x 2 x i16> [[OP1:%.*]], <vscale x 2 x i16> [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vv_u16mf2_b32_mu(vbool32_t mask, vbool32_t maskedoff, vuint16mf2_t op1, vuint16mf2_t op2, size_t vl) { return vmsltu_vv_u16mf2_b32_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16mf2_b32_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i16.i16.i64(<vscale x 2 x i1> [[MASKEDOFF:%.*]], <vscale x 2 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vx_u16mf2_b32_mu(vbool32_t mask, vbool32_t maskedoff, vuint16mf2_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16mf2_b32_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16m1_b16_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i16.nxv4i16.i64(<vscale x 4 x i1> [[MASKEDOFF:%.*]], <vscale x 4 x i16> [[OP1:%.*]], <vscale x 4 x i16> [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vv_u16m1_b16_mu(vbool16_t mask, vbool16_t maskedoff, vuint16m1_t op1, vuint16m1_t op2, size_t vl) { return vmsltu_vv_u16m1_b16_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16m1_b16_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i16.i16.i64(<vscale x 4 x i1> [[MASKEDOFF:%.*]], <vscale x 4 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vx_u16m1_b16_mu(vbool16_t mask, vbool16_t maskedoff, vuint16m1_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16m1_b16_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16m2_b8_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i16.nxv8i16.i64(<vscale x 8 x i1> [[MASKEDOFF:%.*]], <vscale x 8 x i16> [[OP1:%.*]], <vscale x 8 x i16> [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vv_u16m2_b8_mu(vbool8_t mask, vbool8_t maskedoff, vuint16m2_t op1, vuint16m2_t op2, size_t vl) { return vmsltu_vv_u16m2_b8_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16m2_b8_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i16.i16.i64(<vscale x 8 x i1> [[MASKEDOFF:%.*]], <vscale x 8 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vx_u16m2_b8_mu(vbool8_t mask, vbool8_t maskedoff, vuint16m2_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16m2_b8_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16m4_b4_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i16.nxv16i16.i64(<vscale x 16 x i1> [[MASKEDOFF:%.*]], <vscale x 16 x i16> [[OP1:%.*]], <vscale x 16 x i16> [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vv_u16m4_b4_mu(vbool4_t mask, vbool4_t maskedoff, vuint16m4_t op1, vuint16m4_t op2, size_t vl) { return vmsltu_vv_u16m4_b4_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16m4_b4_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i16.i16.i64(<vscale x 16 x i1> [[MASKEDOFF:%.*]], <vscale x 16 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vx_u16m4_b4_mu(vbool4_t mask, vbool4_t maskedoff, vuint16m4_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16m4_b4_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u16m8_b2_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i1> @llvm.riscv.vmsltu.mask.nxv32i16.nxv32i16.i64(<vscale x 32 x i1> [[MASKEDOFF:%.*]], <vscale x 32 x i16> [[OP1:%.*]], <vscale x 32 x i16> [[OP2:%.*]], <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 32 x i1> [[TMP0]] // vbool2_t test_vmsltu_vv_u16m8_b2_mu(vbool2_t mask, vbool2_t maskedoff, vuint16m8_t op1, vuint16m8_t op2, size_t vl) { return vmsltu_vv_u16m8_b2_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u16m8_b2_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i1> @llvm.riscv.vmsltu.mask.nxv32i16.i16.i64(<vscale x 32 x i1> [[MASKEDOFF:%.*]], <vscale x 32 x i16> [[OP1:%.*]], i16 [[OP2:%.*]], <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 32 x i1> [[TMP0]] // vbool2_t test_vmsltu_vx_u16m8_b2_mu(vbool2_t mask, vbool2_t maskedoff, vuint16m8_t op1, uint16_t op2, size_t vl) { return vmsltu_vx_u16m8_b2_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u32mf2_b64_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i32.nxv1i32.i64(<vscale x 1 x i1> [[MASKEDOFF:%.*]], <vscale x 1 x i32> [[OP1:%.*]], <vscale x 1 x i32> [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vv_u32mf2_b64_mu(vbool64_t mask, vbool64_t maskedoff, vuint32mf2_t op1, vuint32mf2_t op2, size_t vl) { return vmsltu_vv_u32mf2_b64_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u32mf2_b64_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i32.i32.i64(<vscale x 1 x i1> [[MASKEDOFF:%.*]], <vscale x 1 x i32> [[OP1:%.*]], i32 [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vx_u32mf2_b64_mu(vbool64_t mask, vbool64_t maskedoff, vuint32mf2_t op1, uint32_t op2, size_t vl) { return vmsltu_vx_u32mf2_b64_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u32m1_b32_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i32.nxv2i32.i64(<vscale x 2 x i1> [[MASKEDOFF:%.*]], <vscale x 2 x i32> [[OP1:%.*]], <vscale x 2 x i32> [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vv_u32m1_b32_mu(vbool32_t mask, vbool32_t maskedoff, vuint32m1_t op1, vuint32m1_t op2, size_t vl) { return vmsltu_vv_u32m1_b32_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u32m1_b32_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i32.i32.i64(<vscale x 2 x i1> [[MASKEDOFF:%.*]], <vscale x 2 x i32> [[OP1:%.*]], i32 [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vx_u32m1_b32_mu(vbool32_t mask, vbool32_t maskedoff, vuint32m1_t op1, uint32_t op2, size_t vl) { return vmsltu_vx_u32m1_b32_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u32m2_b16_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i32.nxv4i32.i64(<vscale x 4 x i1> [[MASKEDOFF:%.*]], <vscale x 4 x i32> [[OP1:%.*]], <vscale x 4 x i32> [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vv_u32m2_b16_mu(vbool16_t mask, vbool16_t maskedoff, vuint32m2_t op1, vuint32m2_t op2, size_t vl) { return vmsltu_vv_u32m2_b16_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u32m2_b16_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i32.i32.i64(<vscale x 4 x i1> [[MASKEDOFF:%.*]], <vscale x 4 x i32> [[OP1:%.*]], i32 [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vx_u32m2_b16_mu(vbool16_t mask, vbool16_t maskedoff, vuint32m2_t op1, uint32_t op2, size_t vl) { return vmsltu_vx_u32m2_b16_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u32m4_b8_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i32.nxv8i32.i64(<vscale x 8 x i1> [[MASKEDOFF:%.*]], <vscale x 8 x i32> [[OP1:%.*]], <vscale x 8 x i32> [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vv_u32m4_b8_mu(vbool8_t mask, vbool8_t maskedoff, vuint32m4_t op1, vuint32m4_t op2, size_t vl) { return vmsltu_vv_u32m4_b8_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u32m4_b8_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i32.i32.i64(<vscale x 8 x i1> [[MASKEDOFF:%.*]], <vscale x 8 x i32> [[OP1:%.*]], i32 [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vx_u32m4_b8_mu(vbool8_t mask, vbool8_t maskedoff, vuint32m4_t op1, uint32_t op2, size_t vl) { return vmsltu_vx_u32m4_b8_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u32m8_b4_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i32.nxv16i32.i64(<vscale x 16 x i1> [[MASKEDOFF:%.*]], <vscale x 16 x i32> [[OP1:%.*]], <vscale x 16 x i32> [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vv_u32m8_b4_mu(vbool4_t mask, vbool4_t maskedoff, vuint32m8_t op1, vuint32m8_t op2, size_t vl) { return vmsltu_vv_u32m8_b4_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u32m8_b4_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i1> @llvm.riscv.vmsltu.mask.nxv16i32.i32.i64(<vscale x 16 x i1> [[MASKEDOFF:%.*]], <vscale x 16 x i32> [[OP1:%.*]], i32 [[OP2:%.*]], <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 16 x i1> [[TMP0]] // vbool4_t test_vmsltu_vx_u32m8_b4_mu(vbool4_t mask, vbool4_t maskedoff, vuint32m8_t op1, uint32_t op2, size_t vl) { return vmsltu_vx_u32m8_b4_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u64m1_b64_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i64.nxv1i64.i64(<vscale x 1 x i1> [[MASKEDOFF:%.*]], <vscale x 1 x i64> [[OP1:%.*]], <vscale x 1 x i64> [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vv_u64m1_b64_mu(vbool64_t mask, vbool64_t maskedoff, vuint64m1_t op1, vuint64m1_t op2, size_t vl) { return vmsltu_vv_u64m1_b64_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u64m1_b64_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i1> @llvm.riscv.vmsltu.mask.nxv1i64.i64.i64(<vscale x 1 x i1> [[MASKEDOFF:%.*]], <vscale x 1 x i64> [[OP1:%.*]], i64 [[OP2:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 1 x i1> [[TMP0]] // vbool64_t test_vmsltu_vx_u64m1_b64_mu(vbool64_t mask, vbool64_t maskedoff, vuint64m1_t op1, uint64_t op2, size_t vl) { return vmsltu_vx_u64m1_b64_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u64m2_b32_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i64.nxv2i64.i64(<vscale x 2 x i1> [[MASKEDOFF:%.*]], <vscale x 2 x i64> [[OP1:%.*]], <vscale x 2 x i64> [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vv_u64m2_b32_mu(vbool32_t mask, vbool32_t maskedoff, vuint64m2_t op1, vuint64m2_t op2, size_t vl) { return vmsltu_vv_u64m2_b32_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u64m2_b32_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i1> @llvm.riscv.vmsltu.mask.nxv2i64.i64.i64(<vscale x 2 x i1> [[MASKEDOFF:%.*]], <vscale x 2 x i64> [[OP1:%.*]], i64 [[OP2:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 2 x i1> [[TMP0]] // vbool32_t test_vmsltu_vx_u64m2_b32_mu(vbool32_t mask, vbool32_t maskedoff, vuint64m2_t op1, uint64_t op2, size_t vl) { return vmsltu_vx_u64m2_b32_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u64m4_b16_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i64.nxv4i64.i64(<vscale x 4 x i1> [[MASKEDOFF:%.*]], <vscale x 4 x i64> [[OP1:%.*]], <vscale x 4 x i64> [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vv_u64m4_b16_mu(vbool16_t mask, vbool16_t maskedoff, vuint64m4_t op1, vuint64m4_t op2, size_t vl) { return vmsltu_vv_u64m4_b16_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u64m4_b16_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i1> @llvm.riscv.vmsltu.mask.nxv4i64.i64.i64(<vscale x 4 x i1> [[MASKEDOFF:%.*]], <vscale x 4 x i64> [[OP1:%.*]], i64 [[OP2:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 4 x i1> [[TMP0]] // vbool16_t test_vmsltu_vx_u64m4_b16_mu(vbool16_t mask, vbool16_t maskedoff, vuint64m4_t op1, uint64_t op2, size_t vl) { return vmsltu_vx_u64m4_b16_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vv_u64m8_b8_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i64.nxv8i64.i64(<vscale x 8 x i1> [[MASKEDOFF:%.*]], <vscale x 8 x i64> [[OP1:%.*]], <vscale x 8 x i64> [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vv_u64m8_b8_mu(vbool8_t mask, vbool8_t maskedoff, vuint64m8_t op1, vuint64m8_t op2, size_t vl) { return vmsltu_vv_u64m8_b8_mu(mask, maskedoff, op1, op2, vl); } // CHECK-RV64-LABEL: @test_vmsltu_vx_u64m8_b8_mu( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i1> @llvm.riscv.vmsltu.mask.nxv8i64.i64.i64(<vscale x 8 x i1> [[MASKEDOFF:%.*]], <vscale x 8 x i64> [[OP1:%.*]], i64 [[OP2:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: ret <vscale x 8 x i1> [[TMP0]] // vbool8_t test_vmsltu_vx_u64m8_b8_mu(vbool8_t mask, vbool8_t maskedoff, vuint64m8_t op1, uint64_t op2, size_t vl) { return vmsltu_vx_u64m8_b8_mu(mask, maskedoff, op1, op2, vl); }
eb5fcbb94532af2431d40a154bd1ba53be68f678
321d11eaee885ceb3a74db0a062f9bbdf282148c
/include/openssl/bioerr.h
e4fdb64974fc064e7486d67c61212f364b3c507b
[ "Apache-2.0", "OpenSSL", "LicenseRef-scancode-proprietary-license" ]
permissive
openssl/openssl
75691ebaae957793f2ff0673f77545277dfb3988
5318c012885a5382eadbf95aa9c1d35664bca819
refs/heads/master
2023-09-03T15:22:52.727123
2023-09-01T07:10:49
2023-09-02T14:30:01
7,634,677
24,148
11,569
Apache-2.0
2023-09-14T19:48:11
2013-01-15T22:34:48
C
UTF-8
C
false
false
3,515
h
bioerr.h
/* * Generated by util/mkerr.pl DO NOT EDIT * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #ifndef OPENSSL_BIOERR_H # define OPENSSL_BIOERR_H # pragma once # include <openssl/opensslconf.h> # include <openssl/symhacks.h> # include <openssl/cryptoerr_legacy.h> /* * BIO reason codes. */ # define BIO_R_ACCEPT_ERROR 100 # define BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET 141 # define BIO_R_AMBIGUOUS_HOST_OR_SERVICE 129 # define BIO_R_BAD_FOPEN_MODE 101 # define BIO_R_BROKEN_PIPE 124 # define BIO_R_CONNECT_ERROR 103 # define BIO_R_CONNECT_TIMEOUT 147 # define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 # define BIO_R_GETSOCKNAME_ERROR 132 # define BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS 133 # define BIO_R_GETTING_SOCKTYPE 134 # define BIO_R_INVALID_ARGUMENT 125 # define BIO_R_INVALID_SOCKET 135 # define BIO_R_IN_USE 123 # define BIO_R_LENGTH_TOO_LONG 102 # define BIO_R_LISTEN_V6_ONLY 136 # define BIO_R_LOCAL_ADDR_NOT_AVAILABLE 111 # define BIO_R_LOOKUP_RETURNED_NOTHING 142 # define BIO_R_MALFORMED_HOST_OR_SERVICE 130 # define BIO_R_NBIO_CONNECT_ERROR 110 # define BIO_R_NON_FATAL 112 # define BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED 143 # define BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED 144 # define BIO_R_NO_PORT_DEFINED 113 # define BIO_R_NO_SUCH_FILE 128 # define BIO_R_NULL_PARAMETER 115 /* unused */ # define BIO_R_TFO_DISABLED 106 # define BIO_R_TFO_NO_KERNEL_SUPPORT 108 # define BIO_R_TRANSFER_ERROR 104 # define BIO_R_TRANSFER_TIMEOUT 105 # define BIO_R_UNABLE_TO_BIND_SOCKET 117 # define BIO_R_UNABLE_TO_CREATE_SOCKET 118 # define BIO_R_UNABLE_TO_KEEPALIVE 137 # define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 # define BIO_R_UNABLE_TO_NODELAY 138 # define BIO_R_UNABLE_TO_REUSEADDR 139 # define BIO_R_UNABLE_TO_TFO 109 # define BIO_R_UNAVAILABLE_IP_FAMILY 145 # define BIO_R_UNINITIALIZED 120 # define BIO_R_UNKNOWN_INFO_TYPE 140 # define BIO_R_UNSUPPORTED_IP_FAMILY 146 # define BIO_R_UNSUPPORTED_METHOD 121 # define BIO_R_UNSUPPORTED_PROTOCOL_FAMILY 131 # define BIO_R_WRITE_TO_READ_ONLY_BIO 126 # define BIO_R_WSASTARTUP 122 # define BIO_R_PORT_MISMATCH 150 # define BIO_R_PEER_ADDR_NOT_AVAILABLE 151 #endif
0834adcbe5d827191a3fcbc54877a29df2744ee9
67eac20379df329d55d74f4e36ac206f7d50ec75
/code_examples/SPI_TLF_1_KIT_TC397_TFT/TLF35584.c
6af6cb5f59befe73c090baefc8e39bf939da7221
[]
no_license
Infineon/AURIX_code_examples
d0adb2daa86df1eae52aac6451fd5a9d4ba1b5eb
a1623634511d4463537aac33bf791c37fbb17f1c
refs/heads/master
2023-04-13T01:31:03.043401
2023-04-03T11:53:03
2023-04-03T11:53:03
192,314,276
365
278
null
null
null
null
UTF-8
C
false
false
9,503
c
TLF35584.c
/********************************************************************************************************************** * \file TLF35584.c * \copyright Copyright (C) Infineon Technologies AG 2019 * * Use of this file is subject to the terms of use agreed between (i) you or the company in which ordinary course of * business you are acting and (ii) Infineon Technologies AG or its licensees. If and as long as no such terms of use * are agreed, use of this file is subject to following: * * Boost Software License - Version 1.0 - August 17th, 2003 * * Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and * accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, * and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the * Software is furnished to do so, all subject to the following: * * The copyright notices in the Software and this entire statement, including the above license grant, this restriction * and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all * derivative works of the Software, unless such copies or derivative works are solely in the form of * machine-executable object code generated by a source language processor. * * 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE * COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. *********************************************************************************************************************/ /*********************************************************************************************************************/ /*-----------------------------------------------------Includes------------------------------------------------------*/ /*********************************************************************************************************************/ #include "TLF35584.h" /*********************************************************************************************************************/ /*------------------------------------------------Function Prototypes------------------------------------------------*/ /*********************************************************************************************************************/ void unlockRegisterTLF35584(void); void lockRegisterTLF35584(void); void disableWindowWatchdogTLF35584(tlf35584 *tlfDevice); void enableWindowWatchdogTLF35584(tlf35584 *tlfDevice); void disableErrPinMonitorTLF35584(tlf35584 *tlfDevice); void enableErrPinMonitorTLF35584(tlf35584 *tlfDevice); void enableVoltageSupplyRails(tlf35584 *tlfDevice); uint8 getSpiStatusFlagsTLF35584(tlf35584 *tlfDevice); void clearSpiStatusFlagsTLF35584(tlf35584 *tlfDevice); IFX_EXTERN uint16 transferDataTLF35584(spiCommandType cmd, tlf35584RegAddr addr, uint8 data); /*********************************************************************************************************************/ /*----------------------------------------------Function Implementations---------------------------------------------*/ /*********************************************************************************************************************/ void unlockRegisterTLF35584(void) { transferDataTLF35584(SpiCommand_write, ProtcfgRegAddr, UnlockKey1); transferDataTLF35584(SpiCommand_write, ProtcfgRegAddr, UnlockKey2); transferDataTLF35584(SpiCommand_write, ProtcfgRegAddr, UnlockKey3); transferDataTLF35584(SpiCommand_write, ProtcfgRegAddr, UnlockKey4); } void lockRegisterTLF35584(void) { transferDataTLF35584(SpiCommand_write, ProtcfgRegAddr, LockKey1); transferDataTLF35584(SpiCommand_write, ProtcfgRegAddr, LockKey2); transferDataTLF35584(SpiCommand_write, ProtcfgRegAddr, LockKey3); transferDataTLF35584(SpiCommand_write, ProtcfgRegAddr, LockKey4); } void disableWindowWatchdogTLF35584(tlf35584 *tlfDevice) { tlf35584SpiFrameType spiFrame; /* Get the value of RWDCFG0 to check the current window watchdog setting */ spiFrame.U = transferDataTLF35584(SpiCommand_read, Rwdcfg0RegAddr, (uint8)DUMMY_DATA); /* Refresh local value of TLF register */ tlfDevice->WDCFG0.U = spiFrame.B.data; if(tlfDevice->WDCFG0.B.WWDEN == WindowWatchdog_enabled) { tlfDevice->WDCFG0.B.WWDEN = WindowWatchdog_disabled; transferDataTLF35584(SpiCommand_write, Wdcfg0RegAddr, tlfDevice->WDCFG0.U); } } void enableWindowWatchdogTLF35584(tlf35584 *tlfDevice) { tlf35584SpiFrameType spiFrame; /* Get the value of RWDCFG0 to check the current window watchdog setting */ spiFrame.U = transferDataTLF35584(SpiCommand_read, Rwdcfg0RegAddr, (uint8)DUMMY_DATA); /* Refresh local value of TLF register */ tlfDevice->RWDCFG0.U = spiFrame.B.data; if(tlfDevice->RWDCFG0.B.WWDEN == WindowWatchdog_disabled) { tlfDevice->WDCFG0.B.WWDEN = WindowWatchdog_enabled; transferDataTLF35584(SpiCommand_write, Wdcfg0RegAddr, tlfDevice->WDCFG0.U); } } void disableErrPinMonitorTLF35584(tlf35584 *tlfDevice) { tlf35584SpiFrameType spiFrame; /* Get the value of RSYSPCFG1 to check the current error pin monitoring setting */ spiFrame.U = transferDataTLF35584(SpiCommand_read, Rsyspcfg1RegAddr, (uint8)DUMMY_DATA); /* Refresh local value of TLF register */ tlfDevice->SYSPCFG1.U = spiFrame.B.data; if(tlfDevice->SYSPCFG1.B.ERREN == ErrPinMonitor_enabled) { tlfDevice->SYSPCFG1.B.ERREN = ErrPinMonitor_disabled; transferDataTLF35584(SpiCommand_write, Syspcfg1RegAddr, tlfDevice->SYSPCFG1.U); } } void enableErrPinMonitorTLF35584(tlf35584 *tlfDevice) { tlf35584SpiFrameType spiFrame; /* Get the value of RSYSPCFG1 to check the current error pin monitoring setting */ spiFrame.U = transferDataTLF35584(SpiCommand_read, Rsyspcfg1RegAddr, (uint8)DUMMY_DATA); /* Refresh local value of TLF register */ tlfDevice->SYSPCFG1.U = spiFrame.B.data; if(tlfDevice->SYSPCFG1.B.ERREN == ErrPinMonitor_disabled) { tlfDevice->SYSPCFG1.B.ERREN = ErrPinMonitor_enabled; transferDataTLF35584(SpiCommand_write, Syspcfg1RegAddr, tlfDevice->SYSPCFG1.U); } } void enableVoltageSupplyRails(tlf35584 *tlfDevice) { tlf35584SpiFrameType spiFrame; spiFrame.U = transferDataTLF35584(SpiCommand_read, DevctrlRegAddr, (uint8)DUMMY_DATA); /* Refresh local value of TLF register */ tlfDevice->DEVCTRL.U = spiFrame.B.data; /* Enable all voltage supply rails */ tlfDevice->DEVCTRL.B.COMEN = CommunicationLdoVoltage_enabled; tlfDevice->DEVCTRL.B.VREFEN = VoltageReferenceQVR_enabled; /* Update device register values */ transferDataTLF35584(SpiCommand_write, DevctrlRegAddr, tlfDevice->DEVCTRL.U); transferDataTLF35584(SpiCommand_write, DevctrlnRegAddr, ~tlfDevice->DEVCTRL.U); } void setStateTransitionTLF35584(tlf35584 *tlfDevice, statereqType requestedStateTransition) { tlf35584SpiFrameType spiFrame; spiFrame.U = transferDataTLF35584(SpiCommand_read, DevctrlRegAddr, (uint8)DUMMY_DATA); /* Refresh local value of TLF register */ tlfDevice->DEVCTRL.U = spiFrame.B.data; /* Set the requested state transition of TLF device locally */ tlfDevice->DEVCTRL.B.STATEREQ = requestedStateTransition; /* Update device register values */ transferDataTLF35584(SpiCommand_write, DevctrlRegAddr, tlfDevice->DEVCTRL.U); transferDataTLF35584(SpiCommand_write, DevctrlnRegAddr, ~tlfDevice->DEVCTRL.U); } stateStatusType getCurrentStateTLF35584(tlf35584 *tlfDevice) { tlf35584SpiFrameType spiFrame; spiFrame.U = transferDataTLF35584(SpiCommand_read, DevstatRegAddr, (uint8)DUMMY_DATA); tlfDevice->DEVSTAT.U = spiFrame.B.data; return tlfDevice->DEVSTAT.B.STATE; } uint8 getSystemStatusFlagsTLF35584(tlf35584 *tlfDevice) { tlf35584SpiFrameType spiFrame; spiFrame.U = transferDataTLF35584(SpiCommand_read, SyssfRegAddr, (uint8)DUMMY_DATA); tlfDevice->SYSSF.U = spiFrame.B.data; return tlfDevice->SYSSF.U; } void clearSystemStatusFlagsTLF35584(tlf35584 *tlfDevice) { tlfDevice->SYSSF.U = CLEAR_STATUS_FLAGS; transferDataTLF35584(SpiCommand_write, SyssfRegAddr, tlfDevice->SYSSF.U); } uint8 getSpiStatusFlagsTLF35584(tlf35584 *tlfDevice) { tlf35584SpiFrameType spiFrame; spiFrame.U = transferDataTLF35584(SpiCommand_read, SpisfRegAddr, (uint8)DUMMY_DATA); tlfDevice->SPISF.U = spiFrame.B.data; return tlfDevice->SPISF.U; } void clearSpiStatusFlagsTLF35584(tlf35584 *tlfDevice) { tlfDevice->SPISF.U = CLEAR_STATUS_FLAGS; transferDataTLF35584(SpiCommand_write, SpisfRegAddr, tlfDevice->SPISF.U); } /* This function initializes the TLF35584 device */ void initTLF35584(tlf35584 *tlfDevice) { unlockRegisterTLF35584(); disableWindowWatchdogTLF35584(tlfDevice); disableErrPinMonitorTLF35584(tlfDevice); lockRegisterTLF35584(); /* Enable voltage supply rails to prevent External Voltage Regulator (EVR) under-voltage alarm activation */ enableVoltageSupplyRails(tlfDevice); }
03fcef1ceb97f7e85eabc094fad7ecd0948b6339
0744dcc5394cebf57ebcba343747af6871b67017
/external/audiocodec/aacdec/fxp_mul32_arm_v5.h
43279542a2bed6fb4e641b8861c82432a0cdbb9c
[ "MIT", "Apache-2.0" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C
false
false
11,524
h
fxp_mul32_arm_v5.h
/****************************************************************** * * Copyright 2018 Samsung Electronics All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************/ /* ------------------------------------------------------------------ * Copyright (C) 1998-2009 PacketVideo * * 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. * ------------------------------------------------------------------- */ /* Pathname: ./c/include/fxp_mul32_arm_v5.h ------------------------------------------------------------------------------ REVISION HISTORY Who: Date: Description: ------------------------------------------------------------------------------ INCLUDE DESCRIPTION ------------------------------------------------------------------------------ */ #ifndef FXP_MUL32_ARM_V5 #define FXP_MUL32_ARM_V5 #ifdef __cplusplus extern "C" { #endif #include "pv_audio_type_defs.h" #if defined(PV_ARM_V5) //#undef EXTENDED_ASM #define EXTENDED_ASM #define _ARM_V5_ __inline Int32 shft_lft_1(Int32 L_var1) { __asm { qadd L_var1, L_var1, L_var1 } return L_var1; } __inline Int32 fxp_mul_16_by_16(Int32 L_var1, Int32 L_var2) { __asm { smulbb L_var1, L_var1, L_var2 } return L_var1; } __inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2) { __asm { smulbb L_var1, L_var1, L_var2 } return L_var1; } __inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2) { __asm { smultb L_var1, L_var1, L_var2 } return L_var1; } __inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2) { __asm { smultt L_var1, L_var1, L_var2 } return L_var1; } __inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2) { __asm { smulbt L_var1, L_var1, L_var2 } return L_var1; } __inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add) { __asm { smlabb L_add, L_var1, L_var2, L_add } return (L_add); } __inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, Int32 L_var2, Int32 L_add) { __asm { smlabb L_add, L_var1, L_var2, L_add } return L_add; } __inline Int32 fxp_mac_16_by_16_bt(const Int32 L_var1, Int32 L_var2, Int32 L_add) { __asm { smlabt L_add, L_var1, L_var2, L_add } return L_add; } __inline Int32 fxp_mac_16_by_16_tb(const Int32 L_var1, Int32 L_var2, Int32 L_add) { __asm { smlatb L_add, L_var1, L_var2, L_add } return L_add; } __inline Int32 fxp_mac_16_by_16_tt(const Int32 L_var1, Int32 L_var2, Int32 L_add) { __asm { smlatt L_add, L_var1, L_var2, L_add } return L_add; } __inline Int32 fxp_mac32_by_16(Int32 L_var1, const Int32 L_var2, Int32 L_add) { __asm { smlawb L_add, L_var1, L_var2, L_add } return (L_add); } __inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2) { uint32 b = (UInt32)(sum); int32 c = Int32(sum >> 32); __asm { smlal b, c, L_var1, L_var2 } return (((int64(c)) << 32) | b); } __inline Int32 fxp_mac32_Q31(Int32 L_add, Int32 L_var1, const Int32 L_var2) { __asm { smlal L_var1, L_add, L_var2, L_var1 } return L_add; } __inline Int32 fxp_msu32_Q31(Int32 L_sub, Int32 L_var1, const Int32 L_var2) { __asm { rsb L_var1, L_var1, #0 smlal L_var1, L_sub, L_var2, L_var1 } return L_sub; } __inline Int32 fxp_mul32_Q31(Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; __asm { smull L_var1, result64_hi, L_var2, L_var1 } return (result64_hi); } __inline Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 mov result64_hi, result64_hi, asl #2 #ifdef EXTENDED_ASM mov result64_lo, result64_lo, lsr #30 orr result64_hi, result64_lo, result64_hi #else orr result64_hi, result64_hi, result64_lo, lsr #30 #endif } return (result64_hi); } __inline Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 add L_add, L_add, result64_hi, asl #2 add L_add, L_add, result64_lo, lsr #30 } return (L_add); } __inline Int32 fxp_mul32_Q29(const Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 mov result64_hi, result64_hi, asl #3 #ifdef EXTENDED_ASM mov result64_lo, result64_lo, lsr #29 orr result64_hi, result64_lo, result64_hi #else orr result64_hi, result64_hi, result64_lo, lsr #29 #endif } return (result64_hi); } __inline Int32 fxp_mac32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_add) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 add L_add, L_add, result64_hi, asl #3 add L_add, L_add, result64_lo, lsr #29 } return (L_add); } __inline Int32 fxp_msu32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_sub) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 sub L_sub, L_sub, result64_hi, asl #3 sub L_sub, L_sub, result64_lo, lsr #29 } return (L_sub); } __inline Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 mov result64_hi, result64_hi, asl #4 #ifdef EXTENDED_ASM mov result64_lo, result64_lo, lsr #28 orr result64_hi, result64_lo, result64_hi #else orr result64_hi, result64_hi, result64_lo, lsr #28 #endif } return (result64_hi); } __inline Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 mov result64_hi, result64_hi, asl #5 #ifdef EXTENDED_ASM mov result64_lo, result64_lo, lsr #27 orr result64_hi, result64_lo, result64_hi #else orr result64_hi, result64_hi, result64_lo, lsr #27 #endif } return (result64_hi); } __inline Int32 fxp_mul32_Q26(const Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 mov result64_hi, result64_hi, asl #6 #ifdef EXTENDED_ASM mov result64_lo, result64_lo, lsr #26 orr result64_hi, result64_lo, result64_hi #else orr result64_hi, result64_hi, result64_lo, lsr #26 #endif } return (result64_hi); } __inline Int32 fxp_mul32_Q20(const Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 mov result64_hi, result64_hi, asl #12 #ifdef EXTENDED_ASM mov result64_lo, result64_lo, lsr #20 orr result64_hi, result64_lo, result64_hi #else orr result64_hi, result64_hi, result64_lo, lsr #20 #endif } return (result64_hi); } __inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; __asm { smulwb result64_hi, L_var1, L_var2 } return (result64_hi); } #define fxp_mul32_by_16b( a, b) fxp_mul32_by_16(a, b) __inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; __asm { smulwt result64_hi, L_var1, L_var2 } return (result64_hi); } __inline Int32 fxp_mul32_Q15(const Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 mov result64_hi, result64_hi, asl #17 #ifdef EXTENDED_ASM mov result64_lo, result64_lo, lsr #15 orr result64_hi, result64_lo, result64_hi #else orr result64_hi, result64_hi, result64_lo, lsr #15 #endif } return (result64_hi); } __inline Int32 cmplx_mul32_by_16(Int32 L_var1, const Int32 L_var2, const Int32 cmplx) { Int32 result64_hi; __asm { smulwt result64_hi, L_var1, cmplx smlawb result64_hi, L_var2, cmplx, result64_hi } return (result64_hi); } __inline Int32 fxp_mul32_Q14(const Int32 L_var1, const Int32 L_var2) { Int32 result64_hi; Int32 result64_lo; __asm { smull result64_lo, result64_hi, L_var2, L_var1 mov result64_hi, result64_hi, asl #18 #ifdef EXTENDED_ASM mov result64_lo, result64_lo, lsr #14 orr result64_hi, result64_lo, result64_hi #else orr result64_hi, result64_hi, result64_lo, lsr #14 #endif } return (result64_hi); } #define preload_cache( a) #endif #ifdef __cplusplus } #endif #endif /* FXP_MUL32 */
3bf1db16181637b1bde331a303cf1937d78a91f5
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/wasi/libc-bottom-half/headers/private/threads.h
b51ef0d80d3f4f238d90985e22ec908e26cebf9a
[ "MIT", "LLVM-exception", "Apache-2.0", "NCSA", "BSD-2-Clause" ]
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
62
h
threads.h
#ifndef __cplusplus #define thread_local _Thread_local #endif
b8392c3c2c84c7162c1b86b4473c98653dc126b5
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/infiniband/hw/ipath/ipath_qp.c
0857a9c3cd3d3ca4e731091b5b9ef129cf5024f1
[ "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
26,688
c
ipath_qp.c
/* * Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved. * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE 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 <linux/err.h> #include <linux/sched.h> #include <linux/slab.h> #include <linux/vmalloc.h> #include "ipath_verbs.h" #include "ipath_kernel.h" #define BITS_PER_PAGE (PAGE_SIZE*BITS_PER_BYTE) #define BITS_PER_PAGE_MASK (BITS_PER_PAGE-1) #define mk_qpn(qpt, map, off) (((map) - (qpt)->map) * BITS_PER_PAGE + \ (off)) #define find_next_offset(map, off) find_next_zero_bit((map)->page, \ BITS_PER_PAGE, off) /* * Convert the AETH credit code into the number of credits. */ static u32 credit_table[31] = { 0, /* 0 */ 1, /* 1 */ 2, /* 2 */ 3, /* 3 */ 4, /* 4 */ 6, /* 5 */ 8, /* 6 */ 12, /* 7 */ 16, /* 8 */ 24, /* 9 */ 32, /* A */ 48, /* B */ 64, /* C */ 96, /* D */ 128, /* E */ 192, /* F */ 256, /* 10 */ 384, /* 11 */ 512, /* 12 */ 768, /* 13 */ 1024, /* 14 */ 1536, /* 15 */ 2048, /* 16 */ 3072, /* 17 */ 4096, /* 18 */ 6144, /* 19 */ 8192, /* 1A */ 12288, /* 1B */ 16384, /* 1C */ 24576, /* 1D */ 32768 /* 1E */ }; static void get_map_page(struct ipath_qp_table *qpt, struct qpn_map *map) { unsigned long page = get_zeroed_page(GFP_KERNEL); unsigned long flags; /* * Free the page if someone raced with us installing it. */ spin_lock_irqsave(&qpt->lock, flags); if (map->page) free_page(page); else map->page = (void *)page; spin_unlock_irqrestore(&qpt->lock, flags); } static int alloc_qpn(struct ipath_qp_table *qpt, enum ib_qp_type type) { u32 i, offset, max_scan, qpn; struct qpn_map *map; u32 ret = -1; if (type == IB_QPT_SMI) ret = 0; else if (type == IB_QPT_GSI) ret = 1; if (ret != -1) { map = &qpt->map[0]; if (unlikely(!map->page)) { get_map_page(qpt, map); if (unlikely(!map->page)) { ret = -ENOMEM; goto bail; } } if (!test_and_set_bit(ret, map->page)) atomic_dec(&map->n_free); else ret = -EBUSY; goto bail; } qpn = qpt->last + 1; if (qpn >= QPN_MAX) qpn = 2; offset = qpn & BITS_PER_PAGE_MASK; map = &qpt->map[qpn / BITS_PER_PAGE]; max_scan = qpt->nmaps - !offset; for (i = 0;;) { if (unlikely(!map->page)) { get_map_page(qpt, map); if (unlikely(!map->page)) break; } if (likely(atomic_read(&map->n_free))) { do { if (!test_and_set_bit(offset, map->page)) { atomic_dec(&map->n_free); qpt->last = qpn; ret = qpn; goto bail; } offset = find_next_offset(map, offset); qpn = mk_qpn(qpt, map, offset); /* * This test differs from alloc_pidmap(). * If find_next_offset() does find a zero * bit, we don't need to check for QPN * wrapping around past our starting QPN. * We just need to be sure we don't loop * forever. */ } while (offset < BITS_PER_PAGE && qpn < QPN_MAX); } /* * In order to keep the number of pages allocated to a * minimum, we scan the all existing pages before increasing * the size of the bitmap table. */ if (++i > max_scan) { if (qpt->nmaps == QPNMAP_ENTRIES) break; map = &qpt->map[qpt->nmaps++]; offset = 0; } else if (map < &qpt->map[qpt->nmaps]) { ++map; offset = 0; } else { map = &qpt->map[0]; offset = 2; } qpn = mk_qpn(qpt, map, offset); } ret = -ENOMEM; bail: return ret; } static void free_qpn(struct ipath_qp_table *qpt, u32 qpn) { struct qpn_map *map; map = qpt->map + qpn / BITS_PER_PAGE; if (map->page) clear_bit(qpn & BITS_PER_PAGE_MASK, map->page); atomic_inc(&map->n_free); } /** * ipath_alloc_qpn - allocate a QP number * @qpt: the QP table * @qp: the QP * @type: the QP type (IB_QPT_SMI and IB_QPT_GSI are special) * * Allocate the next available QPN and put the QP into the hash table. * The hash table holds a reference to the QP. */ static int ipath_alloc_qpn(struct ipath_qp_table *qpt, struct ipath_qp *qp, enum ib_qp_type type) { unsigned long flags; int ret; ret = alloc_qpn(qpt, type); if (ret < 0) goto bail; qp->ibqp.qp_num = ret; /* Add the QP to the hash table. */ spin_lock_irqsave(&qpt->lock, flags); ret %= qpt->max; qp->next = qpt->table[ret]; qpt->table[ret] = qp; atomic_inc(&qp->refcount); spin_unlock_irqrestore(&qpt->lock, flags); ret = 0; bail: return ret; } /** * ipath_free_qp - remove a QP from the QP table * @qpt: the QP table * @qp: the QP to remove * * Remove the QP from the table so it can't be found asynchronously by * the receive interrupt routine. */ static void ipath_free_qp(struct ipath_qp_table *qpt, struct ipath_qp *qp) { struct ipath_qp *q, **qpp; unsigned long flags; spin_lock_irqsave(&qpt->lock, flags); /* Remove QP from the hash table. */ qpp = &qpt->table[qp->ibqp.qp_num % qpt->max]; for (; (q = *qpp) != NULL; qpp = &q->next) { if (q == qp) { *qpp = qp->next; qp->next = NULL; atomic_dec(&qp->refcount); break; } } spin_unlock_irqrestore(&qpt->lock, flags); } /** * ipath_free_all_qps - check for QPs still in use * @qpt: the QP table to empty * * There should not be any QPs still in use. * Free memory for table. */ unsigned ipath_free_all_qps(struct ipath_qp_table *qpt) { unsigned long flags; struct ipath_qp *qp; u32 n, qp_inuse = 0; spin_lock_irqsave(&qpt->lock, flags); for (n = 0; n < qpt->max; n++) { qp = qpt->table[n]; qpt->table[n] = NULL; for (; qp; qp = qp->next) qp_inuse++; } spin_unlock_irqrestore(&qpt->lock, flags); for (n = 0; n < ARRAY_SIZE(qpt->map); n++) if (qpt->map[n].page) free_page((unsigned long) qpt->map[n].page); return qp_inuse; } /** * ipath_lookup_qpn - return the QP with the given QPN * @qpt: the QP table * @qpn: the QP number to look up * * The caller is responsible for decrementing the QP reference count * when done. */ struct ipath_qp *ipath_lookup_qpn(struct ipath_qp_table *qpt, u32 qpn) { unsigned long flags; struct ipath_qp *qp; spin_lock_irqsave(&qpt->lock, flags); for (qp = qpt->table[qpn % qpt->max]; qp; qp = qp->next) { if (qp->ibqp.qp_num == qpn) { atomic_inc(&qp->refcount); break; } } spin_unlock_irqrestore(&qpt->lock, flags); return qp; } /** * ipath_reset_qp - initialize the QP state to the reset state * @qp: the QP to reset * @type: the QP type */ static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type) { qp->remote_qpn = 0; qp->qkey = 0; qp->qp_access_flags = 0; atomic_set(&qp->s_dma_busy, 0); qp->s_flags &= IPATH_S_SIGNAL_REQ_WR; qp->s_hdrwords = 0; qp->s_wqe = NULL; qp->s_pkt_delay = 0; qp->s_draining = 0; qp->s_psn = 0; qp->r_psn = 0; qp->r_msn = 0; if (type == IB_QPT_RC) { qp->s_state = IB_OPCODE_RC_SEND_LAST; qp->r_state = IB_OPCODE_RC_SEND_LAST; } else { qp->s_state = IB_OPCODE_UC_SEND_LAST; qp->r_state = IB_OPCODE_UC_SEND_LAST; } qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE; qp->r_nak_state = 0; qp->r_aflags = 0; qp->r_flags = 0; qp->s_rnr_timeout = 0; qp->s_head = 0; qp->s_tail = 0; qp->s_cur = 0; qp->s_last = 0; qp->s_ssn = 1; qp->s_lsn = 0; memset(qp->s_ack_queue, 0, sizeof(qp->s_ack_queue)); qp->r_head_ack_queue = 0; qp->s_tail_ack_queue = 0; qp->s_num_rd_atomic = 0; if (qp->r_rq.wq) { qp->r_rq.wq->head = 0; qp->r_rq.wq->tail = 0; } } /** * ipath_error_qp - put a QP into the error state * @qp: the QP to put into the error state * @err: the receive completion error to signal if a RWQE is active * * Flushes both send and receive work queues. * Returns true if last WQE event should be generated. * The QP s_lock should be held and interrupts disabled. * If we are already in error state, just return. */ int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err) { struct ipath_ibdev *dev = to_idev(qp->ibqp.device); struct ib_wc wc; int ret = 0; if (qp->state == IB_QPS_ERR) goto bail; qp->state = IB_QPS_ERR; spin_lock(&dev->pending_lock); if (!list_empty(&qp->timerwait)) list_del_init(&qp->timerwait); if (!list_empty(&qp->piowait)) list_del_init(&qp->piowait); spin_unlock(&dev->pending_lock); /* Schedule the sending tasklet to drain the send work queue. */ if (qp->s_last != qp->s_head) ipath_schedule_send(qp); memset(&wc, 0, sizeof(wc)); wc.qp = &qp->ibqp; wc.opcode = IB_WC_RECV; if (test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags)) { wc.wr_id = qp->r_wr_id; wc.status = err; ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); } wc.status = IB_WC_WR_FLUSH_ERR; if (qp->r_rq.wq) { struct ipath_rwq *wq; u32 head; u32 tail; spin_lock(&qp->r_rq.lock); /* sanity check pointers before trusting them */ wq = qp->r_rq.wq; head = wq->head; if (head >= qp->r_rq.size) head = 0; tail = wq->tail; if (tail >= qp->r_rq.size) tail = 0; while (tail != head) { wc.wr_id = get_rwqe_ptr(&qp->r_rq, tail)->wr_id; if (++tail >= qp->r_rq.size) tail = 0; ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); } wq->tail = tail; spin_unlock(&qp->r_rq.lock); } else if (qp->ibqp.event_handler) ret = 1; bail: return ret; } /** * ipath_modify_qp - modify the attributes of a queue pair * @ibqp: the queue pair who's attributes we're modifying * @attr: the new attributes * @attr_mask: the mask of attributes to modify * @udata: user data for ipathverbs.so * * Returns 0 on success, otherwise returns an errno. */ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, struct ib_udata *udata) { struct ipath_ibdev *dev = to_idev(ibqp->device); struct ipath_qp *qp = to_iqp(ibqp); enum ib_qp_state cur_state, new_state; int lastwqe = 0; int ret; spin_lock_irq(&qp->s_lock); cur_state = attr_mask & IB_QP_CUR_STATE ? attr->cur_qp_state : qp->state; new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state; if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask)) goto inval; if (attr_mask & IB_QP_AV) { if (attr->ah_attr.dlid == 0 || attr->ah_attr.dlid >= IPATH_MULTICAST_LID_BASE) goto inval; if ((attr->ah_attr.ah_flags & IB_AH_GRH) && (attr->ah_attr.grh.sgid_index > 1)) goto inval; } if (attr_mask & IB_QP_PKEY_INDEX) if (attr->pkey_index >= ipath_get_npkeys(dev->dd)) goto inval; if (attr_mask & IB_QP_MIN_RNR_TIMER) if (attr->min_rnr_timer > 31) goto inval; if (attr_mask & IB_QP_PORT) if (attr->port_num == 0 || attr->port_num > ibqp->device->phys_port_cnt) goto inval; /* * don't allow invalid Path MTU values or greater than 2048 * unless we are configured for a 4KB MTU */ if ((attr_mask & IB_QP_PATH_MTU) && (ib_mtu_enum_to_int(attr->path_mtu) == -1 || (attr->path_mtu > IB_MTU_2048 && !ipath_mtu4096))) goto inval; if (attr_mask & IB_QP_PATH_MIG_STATE) if (attr->path_mig_state != IB_MIG_MIGRATED && attr->path_mig_state != IB_MIG_REARM) goto inval; if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) if (attr->max_dest_rd_atomic > IPATH_MAX_RDMA_ATOMIC) goto inval; switch (new_state) { case IB_QPS_RESET: if (qp->state != IB_QPS_RESET) { qp->state = IB_QPS_RESET; spin_lock(&dev->pending_lock); if (!list_empty(&qp->timerwait)) list_del_init(&qp->timerwait); if (!list_empty(&qp->piowait)) list_del_init(&qp->piowait); spin_unlock(&dev->pending_lock); qp->s_flags &= ~IPATH_S_ANY_WAIT; spin_unlock_irq(&qp->s_lock); /* Stop the sending tasklet */ tasklet_kill(&qp->s_task); wait_event(qp->wait_dma, !atomic_read(&qp->s_dma_busy)); spin_lock_irq(&qp->s_lock); } ipath_reset_qp(qp, ibqp->qp_type); break; case IB_QPS_SQD: qp->s_draining = qp->s_last != qp->s_cur; qp->state = new_state; break; case IB_QPS_SQE: if (qp->ibqp.qp_type == IB_QPT_RC) goto inval; qp->state = new_state; break; case IB_QPS_ERR: lastwqe = ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR); break; default: qp->state = new_state; break; } if (attr_mask & IB_QP_PKEY_INDEX) qp->s_pkey_index = attr->pkey_index; if (attr_mask & IB_QP_DEST_QPN) qp->remote_qpn = attr->dest_qp_num; if (attr_mask & IB_QP_SQ_PSN) { qp->s_psn = qp->s_next_psn = attr->sq_psn; qp->s_last_psn = qp->s_next_psn - 1; } if (attr_mask & IB_QP_RQ_PSN) qp->r_psn = attr->rq_psn; if (attr_mask & IB_QP_ACCESS_FLAGS) qp->qp_access_flags = attr->qp_access_flags; if (attr_mask & IB_QP_AV) { qp->remote_ah_attr = attr->ah_attr; qp->s_dmult = ipath_ib_rate_to_mult(attr->ah_attr.static_rate); } if (attr_mask & IB_QP_PATH_MTU) qp->path_mtu = attr->path_mtu; if (attr_mask & IB_QP_RETRY_CNT) qp->s_retry = qp->s_retry_cnt = attr->retry_cnt; if (attr_mask & IB_QP_RNR_RETRY) { qp->s_rnr_retry = attr->rnr_retry; if (qp->s_rnr_retry > 7) qp->s_rnr_retry = 7; qp->s_rnr_retry_cnt = qp->s_rnr_retry; } if (attr_mask & IB_QP_MIN_RNR_TIMER) qp->r_min_rnr_timer = attr->min_rnr_timer; if (attr_mask & IB_QP_TIMEOUT) qp->timeout = attr->timeout; if (attr_mask & IB_QP_QKEY) qp->qkey = attr->qkey; if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) qp->r_max_rd_atomic = attr->max_dest_rd_atomic; if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC) qp->s_max_rd_atomic = attr->max_rd_atomic; spin_unlock_irq(&qp->s_lock); if (lastwqe) { struct ib_event ev; ev.device = qp->ibqp.device; ev.element.qp = &qp->ibqp; ev.event = IB_EVENT_QP_LAST_WQE_REACHED; qp->ibqp.event_handler(&ev, qp->ibqp.qp_context); } ret = 0; goto bail; inval: spin_unlock_irq(&qp->s_lock); ret = -EINVAL; bail: return ret; } int ipath_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, struct ib_qp_init_attr *init_attr) { struct ipath_qp *qp = to_iqp(ibqp); attr->qp_state = qp->state; attr->cur_qp_state = attr->qp_state; attr->path_mtu = qp->path_mtu; attr->path_mig_state = 0; attr->qkey = qp->qkey; attr->rq_psn = qp->r_psn; attr->sq_psn = qp->s_next_psn; attr->dest_qp_num = qp->remote_qpn; attr->qp_access_flags = qp->qp_access_flags; attr->cap.max_send_wr = qp->s_size - 1; attr->cap.max_recv_wr = qp->ibqp.srq ? 0 : qp->r_rq.size - 1; attr->cap.max_send_sge = qp->s_max_sge; attr->cap.max_recv_sge = qp->r_rq.max_sge; attr->cap.max_inline_data = 0; attr->ah_attr = qp->remote_ah_attr; memset(&attr->alt_ah_attr, 0, sizeof(attr->alt_ah_attr)); attr->pkey_index = qp->s_pkey_index; attr->alt_pkey_index = 0; attr->en_sqd_async_notify = 0; attr->sq_draining = qp->s_draining; attr->max_rd_atomic = qp->s_max_rd_atomic; attr->max_dest_rd_atomic = qp->r_max_rd_atomic; attr->min_rnr_timer = qp->r_min_rnr_timer; attr->port_num = 1; attr->timeout = qp->timeout; attr->retry_cnt = qp->s_retry_cnt; attr->rnr_retry = qp->s_rnr_retry_cnt; attr->alt_port_num = 0; attr->alt_timeout = 0; init_attr->event_handler = qp->ibqp.event_handler; init_attr->qp_context = qp->ibqp.qp_context; init_attr->send_cq = qp->ibqp.send_cq; init_attr->recv_cq = qp->ibqp.recv_cq; init_attr->srq = qp->ibqp.srq; init_attr->cap = attr->cap; if (qp->s_flags & IPATH_S_SIGNAL_REQ_WR) init_attr->sq_sig_type = IB_SIGNAL_REQ_WR; else init_attr->sq_sig_type = IB_SIGNAL_ALL_WR; init_attr->qp_type = qp->ibqp.qp_type; init_attr->port_num = 1; return 0; } /** * ipath_compute_aeth - compute the AETH (syndrome + MSN) * @qp: the queue pair to compute the AETH for * * Returns the AETH. */ __be32 ipath_compute_aeth(struct ipath_qp *qp) { u32 aeth = qp->r_msn & IPATH_MSN_MASK; if (qp->ibqp.srq) { /* * Shared receive queues don't generate credits. * Set the credit field to the invalid value. */ aeth |= IPATH_AETH_CREDIT_INVAL << IPATH_AETH_CREDIT_SHIFT; } else { u32 min, max, x; u32 credits; struct ipath_rwq *wq = qp->r_rq.wq; u32 head; u32 tail; /* sanity check pointers before trusting them */ head = wq->head; if (head >= qp->r_rq.size) head = 0; tail = wq->tail; if (tail >= qp->r_rq.size) tail = 0; /* * Compute the number of credits available (RWQEs). * XXX Not holding the r_rq.lock here so there is a small * chance that the pair of reads are not atomic. */ credits = head - tail; if ((int)credits < 0) credits += qp->r_rq.size; /* * Binary search the credit table to find the code to * use. */ min = 0; max = 31; for (;;) { x = (min + max) / 2; if (credit_table[x] == credits) break; if (credit_table[x] > credits) max = x; else if (min == x) break; else min = x; } aeth |= x << IPATH_AETH_CREDIT_SHIFT; } return cpu_to_be32(aeth); } /** * ipath_create_qp - create a queue pair for a device * @ibpd: the protection domain who's device we create the queue pair for * @init_attr: the attributes of the queue pair * @udata: unused by InfiniPath * * Returns the queue pair on success, otherwise returns an errno. * * Called by the ib_create_qp() core verbs function. */ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, struct ib_qp_init_attr *init_attr, struct ib_udata *udata) { struct ipath_qp *qp; int err; struct ipath_swqe *swq = NULL; struct ipath_ibdev *dev; size_t sz; size_t sg_list_sz; struct ib_qp *ret; if (init_attr->create_flags) { ret = ERR_PTR(-EINVAL); goto bail; } if (init_attr->cap.max_send_sge > ib_ipath_max_sges || init_attr->cap.max_send_wr > ib_ipath_max_qp_wrs) { ret = ERR_PTR(-EINVAL); goto bail; } /* Check receive queue parameters if no SRQ is specified. */ if (!init_attr->srq) { if (init_attr->cap.max_recv_sge > ib_ipath_max_sges || init_attr->cap.max_recv_wr > ib_ipath_max_qp_wrs) { ret = ERR_PTR(-EINVAL); goto bail; } if (init_attr->cap.max_send_sge + init_attr->cap.max_send_wr + init_attr->cap.max_recv_sge + init_attr->cap.max_recv_wr == 0) { ret = ERR_PTR(-EINVAL); goto bail; } } switch (init_attr->qp_type) { case IB_QPT_UC: case IB_QPT_RC: case IB_QPT_UD: case IB_QPT_SMI: case IB_QPT_GSI: sz = sizeof(struct ipath_sge) * init_attr->cap.max_send_sge + sizeof(struct ipath_swqe); swq = vmalloc((init_attr->cap.max_send_wr + 1) * sz); if (swq == NULL) { ret = ERR_PTR(-ENOMEM); goto bail; } sz = sizeof(*qp); sg_list_sz = 0; if (init_attr->srq) { struct ipath_srq *srq = to_isrq(init_attr->srq); if (srq->rq.max_sge > 1) sg_list_sz = sizeof(*qp->r_sg_list) * (srq->rq.max_sge - 1); } else if (init_attr->cap.max_recv_sge > 1) sg_list_sz = sizeof(*qp->r_sg_list) * (init_attr->cap.max_recv_sge - 1); qp = kmalloc(sz + sg_list_sz, GFP_KERNEL); if (!qp) { ret = ERR_PTR(-ENOMEM); goto bail_swq; } if (sg_list_sz && (init_attr->qp_type == IB_QPT_UD || init_attr->qp_type == IB_QPT_SMI || init_attr->qp_type == IB_QPT_GSI)) { qp->r_ud_sg_list = kmalloc(sg_list_sz, GFP_KERNEL); if (!qp->r_ud_sg_list) { ret = ERR_PTR(-ENOMEM); goto bail_qp; } } else qp->r_ud_sg_list = NULL; if (init_attr->srq) { sz = 0; qp->r_rq.size = 0; qp->r_rq.max_sge = 0; qp->r_rq.wq = NULL; init_attr->cap.max_recv_wr = 0; init_attr->cap.max_recv_sge = 0; } else { qp->r_rq.size = init_attr->cap.max_recv_wr + 1; qp->r_rq.max_sge = init_attr->cap.max_recv_sge; sz = (sizeof(struct ib_sge) * qp->r_rq.max_sge) + sizeof(struct ipath_rwqe); qp->r_rq.wq = vmalloc_user(sizeof(struct ipath_rwq) + qp->r_rq.size * sz); if (!qp->r_rq.wq) { ret = ERR_PTR(-ENOMEM); goto bail_sg_list; } } /* * ib_create_qp() will initialize qp->ibqp * except for qp->ibqp.qp_num. */ spin_lock_init(&qp->s_lock); spin_lock_init(&qp->r_rq.lock); atomic_set(&qp->refcount, 0); init_waitqueue_head(&qp->wait); init_waitqueue_head(&qp->wait_dma); tasklet_init(&qp->s_task, ipath_do_send, (unsigned long)qp); INIT_LIST_HEAD(&qp->piowait); INIT_LIST_HEAD(&qp->timerwait); qp->state = IB_QPS_RESET; qp->s_wq = swq; qp->s_size = init_attr->cap.max_send_wr + 1; qp->s_max_sge = init_attr->cap.max_send_sge; if (init_attr->sq_sig_type == IB_SIGNAL_REQ_WR) qp->s_flags = IPATH_S_SIGNAL_REQ_WR; else qp->s_flags = 0; dev = to_idev(ibpd->device); err = ipath_alloc_qpn(&dev->qp_table, qp, init_attr->qp_type); if (err) { ret = ERR_PTR(err); vfree(qp->r_rq.wq); goto bail_sg_list; } qp->ip = NULL; qp->s_tx = NULL; ipath_reset_qp(qp, init_attr->qp_type); break; default: /* Don't support raw QPs */ ret = ERR_PTR(-ENOSYS); goto bail; } init_attr->cap.max_inline_data = 0; /* * Return the address of the RWQ as the offset to mmap. * See ipath_mmap() for details. */ if (udata && udata->outlen >= sizeof(__u64)) { if (!qp->r_rq.wq) { __u64 offset = 0; err = ib_copy_to_udata(udata, &offset, sizeof(offset)); if (err) { ret = ERR_PTR(err); goto bail_ip; } } else { u32 s = sizeof(struct ipath_rwq) + qp->r_rq.size * sz; qp->ip = ipath_create_mmap_info(dev, s, ibpd->uobject->context, qp->r_rq.wq); if (!qp->ip) { ret = ERR_PTR(-ENOMEM); goto bail_ip; } err = ib_copy_to_udata(udata, &(qp->ip->offset), sizeof(qp->ip->offset)); if (err) { ret = ERR_PTR(err); goto bail_ip; } } } spin_lock(&dev->n_qps_lock); if (dev->n_qps_allocated == ib_ipath_max_qps) { spin_unlock(&dev->n_qps_lock); ret = ERR_PTR(-ENOMEM); goto bail_ip; } dev->n_qps_allocated++; spin_unlock(&dev->n_qps_lock); if (qp->ip) { spin_lock_irq(&dev->pending_lock); list_add(&qp->ip->pending_mmaps, &dev->pending_mmaps); spin_unlock_irq(&dev->pending_lock); } ret = &qp->ibqp; goto bail; bail_ip: if (qp->ip) kref_put(&qp->ip->ref, ipath_release_mmap_info); else vfree(qp->r_rq.wq); ipath_free_qp(&dev->qp_table, qp); free_qpn(&dev->qp_table, qp->ibqp.qp_num); bail_sg_list: kfree(qp->r_ud_sg_list); bail_qp: kfree(qp); bail_swq: vfree(swq); bail: return ret; } /** * ipath_destroy_qp - destroy a queue pair * @ibqp: the queue pair to destroy * * Returns 0 on success. * * Note that this can be called while the QP is actively sending or * receiving! */ int ipath_destroy_qp(struct ib_qp *ibqp) { struct ipath_qp *qp = to_iqp(ibqp); struct ipath_ibdev *dev = to_idev(ibqp->device); /* Make sure HW and driver activity is stopped. */ spin_lock_irq(&qp->s_lock); if (qp->state != IB_QPS_RESET) { qp->state = IB_QPS_RESET; spin_lock(&dev->pending_lock); if (!list_empty(&qp->timerwait)) list_del_init(&qp->timerwait); if (!list_empty(&qp->piowait)) list_del_init(&qp->piowait); spin_unlock(&dev->pending_lock); qp->s_flags &= ~IPATH_S_ANY_WAIT; spin_unlock_irq(&qp->s_lock); /* Stop the sending tasklet */ tasklet_kill(&qp->s_task); wait_event(qp->wait_dma, !atomic_read(&qp->s_dma_busy)); } else spin_unlock_irq(&qp->s_lock); ipath_free_qp(&dev->qp_table, qp); if (qp->s_tx) { atomic_dec(&qp->refcount); if (qp->s_tx->txreq.flags & IPATH_SDMA_TXREQ_F_FREEBUF) kfree(qp->s_tx->txreq.map_addr); spin_lock_irq(&dev->pending_lock); list_add(&qp->s_tx->txreq.list, &dev->txreq_free); spin_unlock_irq(&dev->pending_lock); qp->s_tx = NULL; } wait_event(qp->wait, !atomic_read(&qp->refcount)); /* all user's cleaned up, mark it available */ free_qpn(&dev->qp_table, qp->ibqp.qp_num); spin_lock(&dev->n_qps_lock); dev->n_qps_allocated--; spin_unlock(&dev->n_qps_lock); if (qp->ip) kref_put(&qp->ip->ref, ipath_release_mmap_info); else vfree(qp->r_rq.wq); kfree(qp->r_ud_sg_list); vfree(qp->s_wq); kfree(qp); return 0; } /** * ipath_init_qp_table - initialize the QP table for a device * @idev: the device who's QP table we're initializing * @size: the size of the QP table * * Returns 0 on success, otherwise returns an errno. */ int ipath_init_qp_table(struct ipath_ibdev *idev, int size) { int i; int ret; idev->qp_table.last = 1; /* QPN 0 and 1 are special. */ idev->qp_table.max = size; idev->qp_table.nmaps = 1; idev->qp_table.table = kzalloc(size * sizeof(*idev->qp_table.table), GFP_KERNEL); if (idev->qp_table.table == NULL) { ret = -ENOMEM; goto bail; } for (i = 0; i < ARRAY_SIZE(idev->qp_table.map); i++) { atomic_set(&idev->qp_table.map[i].n_free, BITS_PER_PAGE); idev->qp_table.map[i].page = NULL; } ret = 0; bail: return ret; } /** * ipath_get_credit - flush the send work queue of a QP * @qp: the qp who's send work queue to flush * @aeth: the Acknowledge Extended Transport Header * * The QP s_lock should be held. */ void ipath_get_credit(struct ipath_qp *qp, u32 aeth) { u32 credit = (aeth >> IPATH_AETH_CREDIT_SHIFT) & IPATH_AETH_CREDIT_MASK; /* * If the credit is invalid, we can send * as many packets as we like. Otherwise, we have to * honor the credit field. */ if (credit == IPATH_AETH_CREDIT_INVAL) qp->s_lsn = (u32) -1; else if (qp->s_lsn != (u32) -1) { /* Compute new LSN (i.e., MSN + credit) */ credit = (aeth + credit_table[credit]) & IPATH_MSN_MASK; if (ipath_cmp24(credit, qp->s_lsn) > 0) qp->s_lsn = credit; } /* Restart sending if it was blocked due to lack of credits. */ if ((qp->s_flags & IPATH_S_WAIT_SSN_CREDIT) && qp->s_cur != qp->s_head && (qp->s_lsn == (u32) -1 || ipath_cmp24(get_swqe_ptr(qp, qp->s_cur)->ssn, qp->s_lsn + 1) <= 0)) ipath_schedule_send(qp); }
6cb3d603eff162ce01d8cc80dd2dcf3a4617af49
6a434bb467e50f793100b8abfdcba8f832d6844e
/src/CrossWindow/CrossWindow.h
1ee8c85ba06f114ad66cc874d961bb8b832bbf03
[ "MIT", "Apache-2.0" ]
permissive
alaingalvan/CrossWindow
0f40faaa7bd916696c132f96531aee4c3f5d4da7
5f744aa904d78fc43650f6efb01976b9561f628a
refs/heads/master
2023-06-08T20:29:12.223329
2023-03-31T02:33:25
2023-03-31T02:33:25
129,943,511
492
56
MIT
2023-09-03T22:34:49
2018-04-17T17:48:40
C++
UTF-8
C
false
false
125
h
CrossWindow.h
#pragma once /** * CrossWindow * * A basic cross platform window/input abstraction layer. */ #include "Common/Window.h"
e4bfe951fb902cb45c4bc15e38beace6b438d608
b1616c5d7a75cf3a4500ebd9324021c375f4a9de
/src/platform/pic32/fs_support/app_device_msd.c
7deccecc2a7633eea9cfaad3f75a6fe38ef6630a
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
openxc/vi-firmware
0d2929cc716f9bf67989353710ebc5ec6b69cf7c
006ab45007918a98d1b2462b745bbf1d12e222e2
refs/heads/master
2023-02-16T20:53:03.452846
2021-08-19T18:29:10
2021-08-19T18:29:10
2,616,979
155
95
BSD-3-Clause
2023-02-11T23:15:42
2011-10-20T23:29:52
C++
UTF-8
C
false
false
9,408
c
app_device_msd.c
/******************************************************************** Software License Agreement: The software supplied herewith by Microchip Technology Incorporated (the "Company") for its PIC(R) Microcontroller is intended and supplied to you, the Company's customer, for use solely and exclusively on Microchip PIC Microcontroller products. The software is owned by the Company and/or its supplier, and is protected under applicable copyright laws. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license. THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. *******************************************************************/ #include "platform_profile.h" #include "USB/usb.h" #include "USB/usb_function_msd.h" #include "MDD File System/SD-SPI.h" #include "MDD File System/FSIO.h" #include <stdint.h> #include <stdbool.h> #include "usersd.h" #ifdef FS_SUPPORT //The LUN variable definition is critical to the MSD function driver. This // array is a structure of function pointers that are the functions that // will take care of each of the physical media. For each additional LUN // that is added to the system, an entry into this array needs to be added // so that the stack can know where to find the physical layer functions. // In this example the media initialization function is named // "MediaInitialize", the read capacity function is named "ReadCapacity", // etc. LUN_FUNCTIONS LUN[MAX_LUN + 1] = { { &MDD_SDSPI_MediaInitialize, &MDD_SDSPI_ReadCapacity, &MDD_SDSPI_ReadSectorSize, &User_MDD_SDSPI_MediaDetect, &MDD_SDSPI_SectorRead, &User_MDD_SDSPI_WriteProtectState, &MDD_SDSPI_SectorWrite } }; /* Standard Response to INQUIRY command stored in ROM */ const InquiryResponse inq_resp = { 0x00, // peripheral device is connected, direct access block device 0x80, // removable 0x04, // version = 00=> does not conform to any standard, 4=> SPC-2 0x02, // response is in format specified by SPC-2 0x20, // n-4 = 36-4=32= 0x20 0x00, // sccs etc. 0x00, // bque=1 and cmdque=0,indicates simple queueing 00 is obsolete, // but as in case of other device, we are just using 00 0x00, // 00 obsolete, 0x80 for basic task queueing 'M','i','c','r','o','c','h','p', // this is the T10 assigned Vendor ID 'M','a','s','s',' ','S','t','o','r','a','g','e',' ',' ',' ',' ', '0','0','0','1' }; /********************************************************************* * Function: void APP_DeviceMSDInitialize(void); * * Overview: Initializes the Custom HID demo code * * PreCondition: None * * Input: None * * Output: None * ********************************************************************/ void APP_DeviceMSDInitialize(void) { #if (MSD_DATA_IN_EP == MSD_DATA_OUT_EP) USBEnableEndpoint(MSD_DATA_IN_EP,USB_IN_ENABLED|USB_OUT_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP); #else USBEnableEndpoint(MSD_DATA_IN_EP,USB_IN_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP); USBEnableEndpoint(MSD_DATA_OUT_EP,USB_OUT_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP); #endif USBMSDInit(); } /********************************************************************* * Function: void APP_DeviceMSDTasks(void); * * Overview: Keeps the Custom HID demo running. * * PreCondition: The demo should have been initialized and started via * the APP_DeviceMSDInitialize() and APP_DeviceMSDStart() demos * respectively. * * Input: None * * Output: None * ********************************************************************/ void APP_DeviceMSDTasks(void) { MSDTasks(); } void MSDActivity(void){ #if defined(USB_POLLING) // Interrupt or polling method. If using polling, must call // this function periodically. This function will take care // of processing and responding to SETUP transactions // (such as during the enumeration process when you first // plug in). USB hosts require that USB devices should accept // and process SETUP packets in a timely fashion. Therefore, // when using polling, this function should be called // regularly (such as once every 1.8ms or faster** [see // inline code comments in usb_device.c for explanation when // "or faster" applies]) In most cases, the USBDeviceTasks() // function does not take very long to execute (ex: <100 // instruction cycles) before it returns. USBDeviceTasks(); #endif if( USBGetDeviceState() < CONFIGURED_STATE ) { return; } /* If we are currently suspended, then we need to see if we need to * issue a remote wakeup. In either case, we shouldn't process any * keyboard commands since we aren't currently communicating to the host * thus just continue back to the start of the while loop. */ if( USBIsDeviceSuspended() == 1 ) { return; } APP_DeviceMSDTasks(); } /******************************************************************* * Function: bool USER_USB_CALLBACK_EVENT_HANDLER( * USB_EVENT event, void *pdata, uint16_t size) * * PreCondition: None * * Input: USB_EVENT event - the type of event * void *pdata - pointer to the event data * uint16_t size - size of the event data * * Output: None * * Side Effects: None * * Overview: This function is called from the USB stack to * notify a user application that a USB event * occured. This callback is in interrupt context * when the USB_INTERRUPT option is selected. * * Note: None *******************************************************************/ BOOL USER_USB_CALLBACK_EVENT_HANDLER_MSD(USB_EVENT event, void *pdata, uint16_t size) { switch((int)event) { case EVENT_TRANSFER: //Add application specific callback task or callback function here if desired. break; case EVENT_SOF: break; case EVENT_SUSPEND: break; case EVENT_RESUME: break; case EVENT_CONFIGURED: /* When the device is configured, we can (re)initialize the demo * code. */ APP_DeviceMSDInitialize(); break; case EVENT_SET_DESCRIPTOR: break; case EVENT_EP0_REQUEST: /* We have received a non-standard USB request. The MSD driver * needs to check to see if the request was for it. */ USBCheckMSDRequest(); break; case EVENT_BUS_ERROR: break; case EVENT_TRANSFER_TERMINATED: //Add application specific callback task or callback function here if desired. //The EVENT_TRANSFER_TERMINATED event occurs when the host performs a CLEAR //FEATURE (endpoint halt) request on an application endpoint which was //previously armed (UOWN was = 1). Here would be a good place to: //1. Determine which endpoint the transaction that just got terminated was // on, by checking the handle value in the *pdata. //2. Re-arm the endpoint if desired (typically would be the case for OUT // endpoints). //Check if the host recently did a clear endpoint halt on the MSD OUT endpoint. //In this case, we want to re-arm the MSD OUT endpoint, so we are prepared //to receive the next CBW that the host might want to send. //Note: If however the STALL was due to a CBW not valid condition, //then we are required to have a persistent STALL, where it cannot //be cleared (until MSD reset recovery takes place). See MSD BOT //specs v1.0, section 6.6.1. // if(MSDWasLastCBWValid() == false) // { // //Need to re-stall the endpoints, for persistent STALL behavior. // USBStallEndpoint(MSD_DATA_IN_EP, IN_TO_HOST); // USBStallEndpoint(MSD_DATA_OUT_EP, OUT_FROM_HOST); // } // else // { //Check if the host cleared halt on the bulk out endpoint. In this //case, we should re-arm the endpoint, so we can receive the next CBW. // if((USB_HANDLE)pdata == USBGetNextHandle(MSD_DATA_OUT_EP, OUT_FROM_HOST)) // { // USBMSDOutHandle = USBRxOnePacket(MSD_DATA_OUT_EP, (uint8_t*)&msd_cbw, MSD_OUT_EP_SIZE); // } //} break; default: break; } return 1; } #endif
c82e609c589a4414498fe5d3bd8096b68502cd57
605ffde7e9c7df934b8895a660723841efc0bdba
/src/kernel/core/string.c
c8b31543083d7966fd1e79f2369ce1a3c578b29a
[]
no_license
brian-carroll/elm_c_wasm
b3333a8ea341ccfa1f8c1a5267df81f55d1f3871
ef192b016c78061e0f9b40db671a38aad3726fef
refs/heads/master
2021-11-08T21:29:19.529503
2021-09-25T09:46:03
2021-09-25T09:46:03
152,922,428
192
4
null
2021-08-08T11:33:03
2018-10-13T23:19:14
C
UTF-8
C
false
false
15,388
c
string.c
#include <stdbool.h> #include <stddef.h> #include <stdlib.h> #include "./gc/internals.h" #include "core.h" #define IS_LEADING_SURROGATE(word) (0xD800 <= word && word <= 0xDBFF) #define IS_TRAILING_SURROGATE(word) (0xDC00 <= word && word <= 0xDFFF) #define MAX_FLOAT_LEN 25 size_t code_units(ElmString* s) { u32 size = s->header.size; size_t* words = (size_t*)s; size_t* after = words + size; u16* last_code_unit = ((u16*)after) - 1; while ((*last_code_unit == 0) && (last_code_unit >= s->words16)) { last_code_unit--; } size_t units = last_code_unit + 1 - s->words16; return units; } #if 0 void debug_print_chars(char* label, void* start, void* after) { char buf[1024]; char* c = buf; for (u16* p = (u16*)start; p < (u16*)after; p++, c++) { *c = *p; } *c = 0; safe_printf("%s: '%s'\n", label, buf); } #endif #define not_aligned_64(ptr) ((size_t)ptr & (sizeof(u64) - 1)) static u16* copy_chars(u16* to16, u16* from16, u16* after16) { while (not_aligned_64(to16) && (from16 < after16) && *from16) { *to16++ = *from16++; } u64* to64 = (u64*)to16; u64* from64 = (u64*)from16; ptrdiff_t len64 = (after16 - from16) / 4; u64* after64 = from64 + len64; while (from64 < after64 && *from64) { // zero check prevents a bug in optimised build *to64++ = *from64++; } to16 = (u16*)to64; from16 = (u16*)from64; while ((from16 < after16) && *from16) { *to16++ = *from16++; } return to16; } #undef not_aligned_64 u16* String_copy(u16* to, ElmString* s) { return copy_chars(to, s->words16, s->words16 + code_units(s)); } ptrdiff_t find_reverse(u16* sub, u16* str, size_t sub_len, ptrdiff_t str_idx) { for (;;) { // Match last char of substring ptrdiff_t sub_idx = sub_len - 1; while (str_idx >= 0 && sub_idx >= 0 && str[str_idx] != sub[sub_idx]) { str_idx--; } if (str_idx < 0) return -1; // not found // Partial match. If the rest fails, retry from next. ptrdiff_t retry_idx = str_idx - 1; // Match remaining chars of substring do { str_idx--; sub_idx--; } while (str_idx >= 0 && sub_idx >= 0 && str[str_idx] == sub[sub_idx]); if (sub_idx < 0) return str_idx + 1; // Found it! if (str_idx < 0) return -1; // Matched some more chars then ran out => not found. str_idx = retry_idx; // Only a partial match. Backtrack and try again. } } ptrdiff_t find_forward(u16* sub, u16* str, size_t sub_len, size_t str_len) { ptrdiff_t str_idx = 0; for (;;) { // Match first char of substring ptrdiff_t sub_idx = 0; while (str_idx < str_len && sub_idx < sub_len && str[str_idx] != sub[0]) { str_idx++; } if (str_idx >= str_len) return -1; // not found // Partial match. If the rest fails, retry from next. ptrdiff_t retry_idx = str_idx + 1; // Match remaining chars of substring while (str_idx < str_len && sub_idx < sub_len && str[str_idx] == sub[sub_idx]) { str_idx++; sub_idx++; } if (sub_idx >= sub_len) return str_idx - sub_len; // Found it! if (str_idx >= str_len) return -1; // Reached end without full match str_idx = retry_idx; // Only a partial match. Backtrack and try again. } } /* * String.uncons */ void* eval_String_uncons(void* args[]) { ElmString* string = args[0]; size_t len = code_units(string); if (len == 0) { return &g_elm_core_Maybe_Nothing; } u16 word = string->words16[0]; u32 codepoint = (u32)word; size_t char_units; if (IS_LEADING_SURROGATE(word)) { char_units = 2; codepoint |= (string->words16[1] << 16); } else { char_units = 1; } ElmChar* c = newElmChar(codepoint); ElmString* s = newElmString(len - char_units); copy_chars(s->words16, string->words16 + char_units, string->words16 + len); return A1(&g_elm_core_Maybe_Just, newTuple2(c, s)); } Closure String_uncons = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_uncons, .max_values = 1, }; /* * String.append */ void* eval_String_append(void* args[]) { ElmString* a = args[0]; ElmString* b = args[1]; size_t len_a = code_units(a); size_t len_b = code_units(b); ElmString* s = newElmString(len_a + len_b); copy_chars(s->words16, a->words16, a->words16 + len_a); copy_chars(s->words16 + len_a, b->words16, b->words16 + len_b); return s; } Closure String_append = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_append, .max_values = 2, }; /* * String.length */ void* eval_String_length(void* args[]) { size_t len = code_units(args[0]); return newElmInt((i32)len); } Closure String_length = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_length, .max_values = 1, }; /* * String.foldr */ void* eval_String_foldr(void* args[]) { Closure* func = args[0]; void* state = args[1]; ElmString* string = args[2]; size_t i = code_units(string); while (i--) { u32 word = string->words16[i]; if (0xDC00 <= word && word <= 0xDFFF) { i--; word = (word << 16) | string->words16[i]; } ElmChar* c = newElmChar(word); state = A2(func, c, state); } return state; } Closure String_foldr = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_foldr, .max_values = 3, }; /* * String.split */ void* eval_String_split(void* args[]) { ElmString* sep = args[0]; ElmString* str = args[1]; size_t sep_len = code_units(sep); size_t str_len = code_units(str); Cons* result = &Nil; ptrdiff_t str_idx = str_len - 1; ptrdiff_t match_idx; ptrdiff_t substr_idx; ptrdiff_t substr_len; ElmString* substr; do { match_idx = find_reverse(sep->words16, str->words16, sep_len, str_idx); substr_idx = (match_idx < 0) ? 0 : (match_idx + sep_len); substr_len = 1 + str_idx - substr_idx; substr = newElmString(substr_len); copy_chars(substr->words16, str->words16 + substr_idx, str->words16 + substr_idx + substr_len); result = newCons(substr, result); str_idx = match_idx - 1; } while (substr_idx > 0); return result; } Closure String_split = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_split, .max_values = 2, }; /* * String.join */ void* eval_String_join(void* args[]) { ElmString* sep = args[0]; Cons* strs = args[1]; if (strs == &Nil) { return newElmString(0); } size_t sep_len = code_units(sep); size_t len16 = 0; for (Cons* cell = strs; cell != &Nil; cell = cell->tail) { ElmString* s = cell->head; len16 += code_units(s); if (cell->tail != pNil) { len16 += sep_len; } } ElmString* result = newElmString(len16); u16* cursor = result->words16; for (Cons* cell = strs; cell != &Nil; cell = cell->tail) { ElmString* s = cell->head; cursor = String_copy(cursor, s); if (cell->tail != &Nil) { cursor = String_copy(cursor, sep); } } ASSERT_EQUAL(cursor, result->words16 + len16); return result; } Closure String_join = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_join, .max_values = 2, }; /* * String.slice */ static size_t slice_wrap_index(i32 n, i32 len) { if (n <= -len) { return 0; } else if (n < 0) { return n + len; } else if (n > len) { return len; } else { return n; } } void* eval_String_slice(void* args[]) { ElmInt* argStart = args[0]; ElmInt* argEnd = args[1]; ElmString* str = args[2]; size_t len = code_units(str); i32 start = slice_wrap_index(argStart->value, (i32)len); i32 end = slice_wrap_index(argEnd->value, (i32)len); if (start > end) { return newElmString(0); } ElmString* result = newElmString(end - start); copy_chars(result->words16, str->words16 + start, str->words16 + end); return result; } Closure String_slice = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_slice, .max_values = 3, }; bool is_whitespace(u16 c) { // https://tc39.es/ecma262/#sec-string.prototype.trim // https://tc39.es/ecma262/#prod-WhiteSpace // https://www.compart.com/en/unicode/category/Zs // https://tc39.es/ecma262/#prod-LineTerminator // Naive implementation would do 25 comparisons for non-whitespace u8 upper = c >> 8; if (upper == 0x00) { if (c > 0x20) { // 223 chars: 3 comparisons return c == 0xA0; } else { // Check in order of (guessed) frequency return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\f'; } } else if (upper == 0x20) { if (c > 0x205F) { // 160 non-whitespace: 3 comparisons return false; } else if (c > 0x2029) { // 52 non-whitespace: 6 comparisons // 2 whitespace: 4-6 comparisons return c == 0x202F || c == 0x205F; } else { // 35 non-whitespace: 7 comparisons // 13 whitespace: 5-7 comparisons return c <= 0x200A || c == 0x2028 || c == 0x2029; } } else { // 65021 non-whitespace: 5 comparisons // 3 whitespace: 3-5 comparisons return c == 0x1680 || c == 0x3000 || c == 0xFEFF; } } /** * String.trim */ void* eval_String_trim(void* args[]) { ElmString* str = args[0]; size_t len = code_units(str); u16* start = str->words16; u16* end = start + len - 1; while (is_whitespace(*start) && start <= end) { start++; } while (is_whitespace(*end) && end > start) { end--; } ptrdiff_t n_units = end + 1 - start; ElmString* result = newElmString(n_units); if (n_units > 0) { copy_chars(result->words16, start, end + 1); } return result; } Closure String_trim = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_trim, .max_values = 1, }; /** * String.trimLeft */ void* eval_String_trimLeft(void* args[]) { ElmString* str = args[0]; size_t len = code_units(str); u16* start = str->words16; u16* end = start + len - 1; while (is_whitespace(*start) && start <= end) { start++; } ptrdiff_t n_units = end + 1 - start; ElmString* result = newElmString(n_units); if (n_units > 0) { copy_chars(result->words16, start, end + 1); } return result; } Closure String_trimLeft = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_trimLeft, .max_values = 1, }; /** * String.trimRight */ void* eval_String_trimRight(void* args[]) { ElmString* str = args[0]; size_t len = code_units(str); u16* start = str->words16; u16* end = start + len - 1; while (is_whitespace(*end) && end >= start) { end--; } ptrdiff_t n_units = end + 1 - start; ElmString* result = newElmString(n_units); if (n_units > 0) { copy_chars(result->words16, start, end + 1); } return result; } Closure String_trimRight = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_trimRight, .max_values = 1, }; /* * String.all */ void* eval_String_all(void* args[]) { Closure* isGood = args[0]; ElmString* s = args[1]; size_t len = code_units(s); ElmChar* c = newElmChar(0); for (size_t i = 0; i < len; i++) { u16 word = s->words16[i]; u32 codepoint = (u32)word; if (IS_LEADING_SURROGATE(word)) { i++; codepoint |= (s->words16[i] << 16); } c->value = codepoint; if (A1(isGood, c) == &False) { return &False; } } return &True; } Closure String_all = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_all, .max_values = 2, }; /** * String.contains */ void* eval_String_contains(void* args[]) { ElmString* sub = args[0]; ElmString* str = args[1]; size_t lsub = code_units(sub); if (lsub == 0) return &True; size_t lstr = code_units(str); if (lsub > lstr) return &False; ptrdiff_t idx = find_forward(sub->words16, str->words16, lsub, lstr); return (idx == -1) ? &False : &True; } Closure String_contains = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_contains, .max_values = 2, }; /** * String.startsWith */ void* eval_String_startsWith(void* args[]) { ElmString* sub = args[0]; ElmString* str = args[1]; size_t lsub = code_units(sub); if (lsub == 0) return &True; size_t lstr = code_units(str); if (lsub > lstr) return &False; for (size_t i = 0; i < lsub; i++) { if (str->words16[i] != sub->words16[i]) { return &False; } } return &True; } Closure String_startsWith = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_startsWith, .max_values = 2, }; /** * String.endsWith */ void* eval_String_endsWith(void* args[]) { ElmString* sub = args[0]; ElmString* str = args[1]; size_t lsub = code_units(sub); if (lsub == 0) return &True; size_t lstr = code_units(str); if (lsub > lstr) return &False; for (size_t i = 0; i < lsub; i++) { if (str->words16[lstr - 1 - i] != sub->words16[lsub - 1 - i]) { return &False; } } return &True; } Closure String_endsWith = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_endsWith, .max_values = 2, }; /** * String.indexes */ void* eval_String_indexes(void* args[]) { ElmString* sub = args[0]; ElmString* str = args[1]; size_t sub_len = code_units(sub); if (sub_len == 0) { return &Nil; } size_t str_len = code_units(str); Cons* result = &Nil; ptrdiff_t str_idx = str_len - 1; ptrdiff_t match_idx; for (;;) { match_idx = find_reverse(sub->words16, str->words16, sub_len, str_idx); if (match_idx < 0) { return result; } result = newCons(newElmInt((i32)match_idx), result); str_idx = match_idx - 1; } } Closure String_indexes = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_indexes, .max_values = 2, }; /* * String.fromNumber */ void* String_fromNumber_eval(void* args[]) { Number* box = args[0]; char buf[MAX_FLOAT_LEN]; int n_chars; if (box->i.header.tag == Tag_Int) { n_chars = stbsp_snprintf(buf, sizeof(buf), "%ld", (i64)box->i.value); } else { n_chars = stbsp_snprintf(buf, sizeof(buf), "%.16g", box->f.value); } ElmString* s = newElmString(n_chars); for (int i = 0; i < n_chars; i++) { s->words16[i] = (u16)buf[i]; } return s; } Closure String_fromNumber = { .header = HEADER_CLOSURE(0), .evaluator = &String_fromNumber_eval, .max_values = 1, }; /* * String.toInt */ void* eval_String_toInt(void* args[]) { ElmString* str = args[0]; size_t len = code_units(str); u16 code0 = str->words16[0]; i32 total = 0; size_t start = (code0 == '+' || code0 == '-'); size_t i; for (i = start; i < len; ++i) { u16 code = str->words16[i]; if (code < 0x30 || 0x39 < code) { return &g_elm_core_Maybe_Nothing; } total = 10 * total + code - 0x30; } return i == start ? &g_elm_core_Maybe_Nothing : A1(&g_elm_core_Maybe_Just, newElmInt(code0 == 0x2D ? -total : total)); } Closure String_toInt = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_toInt, .max_values = 1, }; /* * String.toFloat */ void* eval_String_toFloat(void* args[]) { ElmString* s = args[0]; size_t len = code_units(s); if (len >= MAX_FLOAT_LEN) { len = MAX_FLOAT_LEN - 1; } f64 value = parseFloat(s->words16, len); return isnan(value) ? &g_elm_core_Maybe_Nothing : A1(&g_elm_core_Maybe_Just, newElmFloat(value)); } Closure String_toFloat = { .header = HEADER_CLOSURE(0), .evaluator = &eval_String_toFloat, .max_values = 1, };
68f697a4543fb5b4c5cb21bc5e5c1c9292c68566
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
/libc/nt/comms.h
02b702f08c18b6fe2357efb10371f85ba9f990de
[ "ISC" ]
permissive
jart/cosmopolitan
fb11b5658939023977060a7c6c71a74093d9cb44
0d748ad58e1063dd1f8560f18a0c75293b9415b7
refs/heads/master
2023-09-06T09:17:29.303607
2023-09-02T03:49:13
2023-09-02T03:50:18
272,457,606
11,887
435
ISC
2023-09-14T17:47:58
2020-06-15T14:16:13
C
UTF-8
C
false
false
3,671
h
comms.h
#ifndef COSMOPOLITAN_LIBC_NT_COMMS_H_ #define COSMOPOLITAN_LIBC_NT_COMMS_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ /* ░░░░ ▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░ ▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░ ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░ ▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█ ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓ ░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█ ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓ ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒ ▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█ ▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓ ░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█ ▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓ ░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓ ▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████ ▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███ ▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███ ▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██ ▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██ ▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███ ░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██ ╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗ │ cosmopolitan § new technology » communications ─╬─│┼ ╚────────────────────────────────────────────────────────────────────────────│*/ bool32 PurgeComm(int64_t hFile, uint32_t dwFlags); bool32 TransmitCommChar(int64_t hFile, char cChar); bool32 ClearCommBreak(int64_t hFile); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_NT_COMMS_H_ */
94ef9de729d6497d49a4947ae1a562ddbabb38b1
50e95229b9a1161ac294137120aaba94c9eb06bc
/sources/ippcp/pcpgfpmethod_521r1.c
a30345d9da48fe0f0ffe7952979451f693e66178
[ "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
7,492
c
pcpgfpmethod_521r1.c
/******************************************************************************* * Copyright (C) 2016 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. * *******************************************************************************/ /* // Intel(R) Integrated Performance Primitives. Cryptography Primitives. // GF(p) methods // */ #include "owndefs.h" #include "owncp.h" #include "pcpbnumisc.h" #include "gsmodstuff.h" #include "pcpgfpstuff.h" #include "pcpgfpmethod.h" #include "pcpbnuarith.h" #include "pcpecprime.h" #include "ecnist/ifma_arith_method_p521.h" //tbcd: temporary excluded: #include <assert.h> #if(_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7) /* arithmetic over P-521r1 NIST modulus */ #define p521r1_add OWNAPI(p521r1_add) IPP_OWN_DECL (BNU_CHUNK_T*, p521r1_add, (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE)) #define p521r1_sub OWNAPI(p521r1_sub) IPP_OWN_DECL (BNU_CHUNK_T*, p521r1_sub, (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE)) #define p521r1_neg OWNAPI(p521r1_neg) IPP_OWN_DECL (BNU_CHUNK_T*, p521r1_neg, (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE)) #define p521r1_div_by_2 OWNAPI(p521r1_div_by_2) IPP_OWN_DECL (BNU_CHUNK_T*, p521r1_div_by_2, (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE)) #define p521r1_mul_by_2 OWNAPI(p521r1_mul_by_2) IPP_OWN_DECL (BNU_CHUNK_T*, p521r1_mul_by_2, (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE)) #define p521r1_mul_by_3 OWNAPI(p521r1_mul_by_3) IPP_OWN_DECL (BNU_CHUNK_T*, p521r1_mul_by_3, (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE)) #if(_IPP_ARCH ==_IPP_ARCH_EM64T) //BNU_CHUNK_T* p521r1_to_mont (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE); //BNU_CHUNK_T* p521r1_mont_back(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE); //BNU_CHUNK_T* p521r1_mul_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE); //BNU_CHUNK_T* p521r1_sqr_montl(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE); //BNU_CHUNK_T* p521r1_mul_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE); //BNU_CHUNK_T* p521r1_sqr_montx(BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE); #endif #define p521r1_mred OWNAPI(p521r1_mred) IPP_OWN_DECL (BNU_CHUNK_T*, p521r1_mred, (BNU_CHUNK_T* res, BNU_CHUNK_T* product)) #if(_IPP_ARCH ==_IPP_ARCH_IA32) #define p521r1_mul_mont_slm OWNAPI(p521r1_mul_mont_slm) IPP_OWN_DECL (BNU_CHUNK_T*, p521r1_mul_mont_slm, (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, const BNU_CHUNK_T* b, gsEngine* pGFE)) #define p521r1_sqr_mont_slm OWNAPI(p521r1_sqr_mont_slm) IPP_OWN_DECL (BNU_CHUNK_T*, p521r1_sqr_mont_slm, (BNU_CHUNK_T* res, const BNU_CHUNK_T* a, gsEngine* pGFE)) #endif #define OPERAND_BITSIZE (521) #define LEN_P521 (BITS_BNU_CHUNK(OPERAND_BITSIZE)) /* // multiplicative methods */ IPP_OWN_DEFN (static BNU_CHUNK_T*, p521r1_mul_montl, (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFE)) { BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE); //tbcd: temporary excluded: assert(NULL!=product); cpMul_BNU_school(product, pA,LEN_P521, pB,LEN_P521); p521r1_mred(pR, product); cpGFpReleasePool(2, pGFE); return pR; } IPP_OWN_DEFN (static BNU_CHUNK_T*, p521r1_sqr_montl, (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)) { BNU_CHUNK_T* product = cpGFpGetPool(2, pGFE); //tbcd: temporary excluded: assert(NULL!=product); cpSqr_BNU_school(product, pA,LEN_P521); p521r1_mred(pR, product); cpGFpReleasePool(2, pGFE); return pR; } /* // Montgomery domain conversion constants */ static BNU_CHUNK_T RR[] = { #if(_IPP_ARCH == _IPP_ARCH_EM64T) 0x0000000000000000,0x0000400000000000,0x0000000000000000, 0x0000000000000000,0x0000000000000000,0x0000000000000000, 0x0000000000000000,0x0000000000000000,0x0000000000000000}; #elif(_IPP_ARCH == _IPP_ARCH_IA32) 0x00000000,0x00004000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000}; #endif static BNU_CHUNK_T one[] = { #if(_IPP_ARCH == _IPP_ARCH_EM64T) 1,0,0,0,0,0,0,0,0}; #elif(_IPP_ARCH == _IPP_ARCH_IA32) 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; #endif IPP_OWN_DEFN (static BNU_CHUNK_T*, p521r1_to_mont, (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)) { return p521r1_mul_montl(pR, pA, (BNU_CHUNK_T*)RR, pGFE); } IPP_OWN_DEFN (static BNU_CHUNK_T*, p521r1_mont_back, (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)) { return p521r1_mul_montl(pR, pA, (BNU_CHUNK_T*)one, pGFE); } #if (_ADCOX_NI_ENABLING_==_FEATURE_ON_) || (_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_) //BNU_CHUNK_T* p521r1_mul_montx(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFE) //BNU_CHUNK_T* p521r1_sqr_montx(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, gsEngine* pGFE) #endif #if(_IPP_ARCH ==_IPP_ARCH_IA32) IPP_OWN_DEFN (static BNU_CHUNK_T*, p521r1_to_mont_slm, (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)) { return p521r1_mul_mont_slm(pR, pA, (BNU_CHUNK_T*)RR, pGFE); } IPP_OWN_DEFN (static BNU_CHUNK_T*, p521r1_mont_back_slm, (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, gsEngine* pGFE)) { return p521r1_mul_mont_slm(pR, pA, (BNU_CHUNK_T*)one, pGFE); } #endif /* _IPP_ARCH ==_IPP_ARCH_IA32*/ /* // return specific gf p521r1 arith methods, // p521r1 = 2^521 -1 (NIST P521r1) */ static gsModMethod* gsArithGF_p521r1 (void) { static gsModMethod m = { p521r1_to_mont, p521r1_mont_back, p521r1_mul_montl, p521r1_sqr_montl, NULL, p521r1_add, p521r1_sub, p521r1_neg, p521r1_div_by_2, p521r1_mul_by_2, p521r1_mul_by_3, }; #if(_IPP_ARCH==_IPP_ARCH_IA32) if(IsFeatureEnabled(ippCPUID_SSSE3|ippCPUID_MOVBE) && !IsFeatureEnabled(ippCPUID_AVX)) { m.mul = p521r1_mul_mont_slm; m.sqr = p521r1_sqr_mont_slm; m.encode = p521r1_to_mont_slm; m.decode = p521r1_mont_back_slm; } #endif return &m; } #endif /* (_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7) */ /*F* // Name: ippsGFpMethod_p521r1 // // Purpose: Returns a reference to an implementation of // arithmetic operations over GF(q). // // Returns: Pointer to a structure containing an implementation of arithmetic // operations over GF(q). q = 2^521 - 1 *F*/ IPPFUN( const IppsGFpMethod*, ippsGFpMethod_p521r1, (void) ) { static IppsGFpMethod method = { cpID_PrimeP521r1, 521, secp521r1_p, NULL, NULL }; #if (_IPP >= _IPP_P8) || (_IPP32E >= _IPP32E_M7) method.arith = gsArithGF_p521r1(); #else method.arith = gsArithGFp(); #endif #if (_IPP32E >= _IPP32E_K1) if (IsFeatureEnabled(ippCPUID_AVX512IFMA)) { method.arith_alt = gsArithGF_p521r1_avx512(); } #endif return &method; } #undef LEN_P521 #undef OPERAND_BITSIZE
d943187eee494c2476ba01fbdae7007b1201c613
6e8226bff5369d52885ab75c95f78e155d6afb48
/include/morn_math.h
c8982e2e6f4279905fb7268f519266d21aa1bc32
[ "Apache-2.0" ]
permissive
jingweizhanghuai/Morn
a26fc8747fd82c10a94003759a9adc44a60a8353
b9ee92c26190dec03a6726b9ac9d18fb570b7a70
refs/heads/master
2023-03-03T12:02:06.835741
2023-02-17T14:16:34
2023-02-17T14:16:34
187,427,750
257
64
null
null
null
null
UTF-8
C
false
false
23,488
h
morn_math.h
/* Copyright (C) 2019-2020 JingWeiZhangHuai <jingweizhanghuai@163.com> Licensed under the Apache License, Version 2.0; you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef _MORN_MATH_H_ #define _MORN_MATH_H_ #include "morn_util.h" #ifdef __cplusplus extern "C" { #endif #define MORN_DEFAULT -1 #define MORN_PI 3.141592653589793238462643383279502884197169399375105820974944592308 #define MORN_E 2.718281828459045235360287471352662497757247093699959574966967627724 #ifndef PI #define PI MORN_PI #endif #define mMathABS(x) (((x)>0)?(x):(-(x))) #define mMathABSDiff(x,y) (((x)>(y))?((x)-(y)):((y)-(x))) #define mMathFLoatABS(pin,pout) {*((int *)(pout)) =(*((int *)(pin)))&0x7FFFFFFF;} #define mMathIntABS(pin,pout) {*pout = mMathABS(*pin);} #define mLinearInterp(x1,l1,x2,l2,l) (((x1)*((l2)-(l))+(x2)*((l)-(l1)))/((l2)-(l1))) double mSin(double a); double mCos(double a); double mTan(double a); double mCot(double a); double mSec(double a); double mCsc(double a); double mSinh(double x); double mCosh(double a); double mTanh(double a); double mCoth(double a); double mSech(double a); double mCsch(double a); double mLn(double a); double mLoga(double a,double b); double mLg(double a); double mExp(double a); double mPow(double a,double b); double mSqrt(double a); double mCurt(double a); double mSigmoid(double x); double mDsigmoid(double x); double m_Gaussian(double a,double mean,double variance); #define mGaussian(...) (\ (VANumber(__VA_ARGS__)==1)?m_Gaussian((double)VA0(__VA_ARGS__),0.0,1.0):(\ (VANumber(__VA_ARGS__)==3)?m_Gaussian((double)VA0(__VA_ARGS__),(double)VA1(__VA_ARGS__),(double)VA2(__VA_ARGS__)):(\ DFLT))\ ) void mMean(float *in,int num,float *sum,float *mean); void mVariance(float *in,int num,float *mean,float *variance); void mCovariance(float *in1,float *in2,int num,float *mean1,float *mean2,float *covariance); uint64_t mBinaryCeil(uint64_t data); uint64_t mBinaryFloor(uint64_t data); uint64_t mBinaryRound(uint64_t data); uint64_t mDecimalCeil(uint64_t data); uint64_t mDecimalFloor(uint64_t data); uint64_t mDecimalRound(uint64_t data); int GreatestCommonDivisor(int n,...); #define mGCD(...) GreatestCommonDivisor(VANumber(__VA_ARGS__),__VA_ARGS__) int LowestCommonMultiple(int n,...); #define mLCM(...) LowestCommonMultiple(VANumber(__VA_ARGS__),__VA_ARGS__) // static inline float mSup() {float a=0.0f;return 1.0f/a;} // static inline float mInf() {float a=0.0f;return -1.0f/a;} // #define mIsSup(A) (isinf(A)&&(A>0)) // #define mIsInf(A) (isinf(A)&&(A<0)) extern char morn_float_sup[8];// = {0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f}; #define mSup() (*((double *)morn_float_sup)) extern char morn_float_inf[8];// = {0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe}; #define mInf() (*((double *)morn_float_inf)) #ifdef NAN #define mNan() NAN #else #define mNan() nan(NULL) #endif #define mIsSup(A) (A>=mSup()) #define mIsInf(A) (A<=mInf()) #define mIsNan(A) isnan(A) #define mIsInteger(A) (ABS(A-((int)(A+0.5f)))<0.00001f) MList *m_Permutation(MList *list,int num); #define mPermutation(...) (\ (VANumber(__VA_ARGS__)==1)?m_Permutation(VA0(__VA_ARGS__),DFLT):(\ (VANumber(__VA_ARGS__)==2)?m_Permutation(VA0(__VA_ARGS__),VA1(__VA_ARGS__)):(\ NULL))\ ) MList *mCombination(MList *list,int n); typedef struct MVector{ int size; float *data; }MVector; #define INVALID_VEC(Vec) ((((Vec) ==NULL)||((intptr_t)(Vec) == -1))?1:(((Vec)->size <= 0)||((intptr_t)((Vec)->data) <= 0))) MVector *VectorCreate(int size,float *data); #define mVectorCreate(...) (\ (VANumber(__VA_ARGS__)==0)?VectorCreate(DFLT,NULL):(\ (VANumber(__VA_ARGS__)==1)?VectorCreate(VA0(__VA_ARGS__),NULL):(\ (VANumber(__VA_ARGS__)==2)?VectorCreate(VA0(__VA_ARGS__),(float *)VA1(__VA_ARGS__)):(\ NULL)))\ ) void VectorRedefine(MVector *vec,int size,float *data); #define mVectorRedefine(Vec,...) do{\ int N=VANumber(__VA_ARGS__);\ if(N==1) VectorRedefine(Vec,VA0(__VA_ARGS__),(Vec)->data);\ else if(N==2) VectorRedefine(Vec,VA0(__VA_ARGS__),(float *)VA1(__VA_ARGS__));\ else mException(1,EXIT,"invalid input para");\ }while(0) void mVectorRelease(MVector *vec); #define mVectorData(Vec,Data) do{\ float *Buff;if(Vec->dev==MORN_HOST_CPU) Buff=Vec->data; else Buff=mMalloc(Vec->size*sizeof(float));\ for(int I=0;I<Vec->size;I++) Buff[I]=(float)(Data[I]);\ if(Buff!=Vec->data) {MemCopy(Vec->data,Vec->dev,Buff,MORN_HOST_CPU,Vec->size);mFree(Buff);}\ }while(0) #define mVectorExchange(Vec1,Vec2) mObjectExchange(Vec1,Vec2,MVector) typedef struct MMatrix{ int row; int col; float **data; }MMatrix; #define INVALID_MAT(Mat) ((((Mat) ==NULL)||((intptr_t)(Mat) == -1))?1:(((Mat)->data == NULL)||((intptr_t)((Mat)->data) <= 0)\ ||((Mat)->col <= 0)\ ||((Mat)->row <= 0))) void _PrintMat(char *name,MMatrix *mat); #define PrintMat(Mat) _PrintMat(#Mat,Mat) MMatrix * MatrixCreate(int row,int col,float **data); #define mMatrixCreate(...) (\ (VANumber(__VA_ARGS__)==0)?MatrixCreate(DFLT,DFLT,NULL):(\ (VANumber(__VA_ARGS__)==2)?MatrixCreate(VA0(__VA_ARGS__),VA1(__VA_ARGS__),NULL):(\ (VANumber(__VA_ARGS__)==3)?MatrixCreate(VA0(__VA_ARGS__),VA1(__VA_ARGS__),(float **)VA2(__VA_ARGS__)):(\ NULL)))\ ) void mMatrixRelease(MMatrix *mat); void MatrixRedefine(MMatrix *mat,int row,int col,float **data); #define mMatrixRedefine(Mat,...) do{\ int N=VANumber(__VA_ARGS__);\ if(N==2) MatrixRedefine(Mat,VA0(__VA_ARGS__),VA1(__VA_ARGS__),(Mat)->data);\ else if(N==3) MatrixRedefine(Mat,VA0(__VA_ARGS__),VA1(__VA_ARGS__),(float **)VA2(__VA_ARGS__));\ else mException(1,EXIT,"invalid input para");\ }while(0) void m_UnitMatrix(MMatrix *mat,int size); #define mUnitMatrix(...) do{\ if(VANumber(__VA_ARGS__)==1) m_UnitMatrix(VA0(__VA_ARGS__),DFLT);\ else m_UnitMatrix(VA0(__VA_ARGS__),VA1(__VA_ARGS__));\ }while(0) #define mMatrixExchange(Mat1,Mat2) mObjectExchange(Mat1,Mat2,MMatrix) void mMATWrite(MFile *file,MMatrix *mat,char *matname); void mMATRead(MFile *file,char *matname,MMatrix *mat); #define mMatrixData(Mat,Data) do{\ int N=0;for(int J=0;J<Mat->row;J++)for(int I=0;I<Mat->col;I++) Mat->data[J][I]=Data[N++];\ int Dev=MORN_HOST; mPropertyRead( Mat,"device",&Dev);\ if(Dev!=MORN_HOST) mPropertyWrite(Mat,"device",&Dev);\ }while(0) void mVectorAdd(MVector *vec1,MVector *vec2,MVector *dst); float mVectorMul(MVector *vec1,MVector *vec2); void mMatrixVectorMul(MMatrix *mat,MVector *vec,MVector *dst); void mVectorMatrixMul(MVector *vec,MMatrix *mat,MVector *dst); void m_MatrixMul(MMatrix *mat1,MMatrix *mat2,MMatrix *dst); #define mMatrixMul(Mat,...) do{\ if(VANumber(__VA_ARGS__)==2) m_MatrixMul(Mat,VA0(__VA_ARGS__),(MMatrix *)((intptr_t)VA1(__VA_ARGS__)));\ else m_MatrixMul(Mat,VA0(__VA_ARGS__),Mat);\ }while(0) void m_MatrixTranspose(MMatrix *mat,MMatrix *dst); #define mMatrixTranspose(...) do{\ if(VANumber(__VA_ARGS__)==2) m_MatrixTranspose(VA0(__VA_ARGS__),(MMatrix *)((intptr_t)VA1(__VA_ARGS__)));\ else m_MatrixTranspose(VA0(__VA_ARGS__),VA0(__VA_ARGS__));\ }while(0) float mMatrixDetValue(MMatrix *mat); int mMatrixInverse(MMatrix *mat,MMatrix *inv); float m_MatrixMaxElement(MMatrix *src,int *x,int *y); float m_MatrixMinElement(MMatrix *src,int *x,int *y); #define mMatrixMaxElement(...) ((VANumber(__VA_ARGS__)==1)?m_MatrixMaxElement(VA0(__VA_ARGS__),NULL,NULL):m_MatrixMaxElement(VA0(__VA_ARGS__),VA1(__VA_ARGS__),VA2(__VA_ARGS__))) #define mMatrixMinElement(...) ((VANumber(__VA_ARGS__)==1)?m_MatrixMinElement(VA0(__VA_ARGS__),NULL,NULL):m_MatrixMinElement(VA0(__VA_ARGS__),VA1(__VA_ARGS__),VA2(__VA_ARGS__))) void mMatrixEigenValue(MMatrix *src,MList *eigenvalue,MList *eigenvector); int mLinearEquation(MMatrix *mat,float *answer); void mLinearFitLSM(float *XIn,float *YIn,int N,float *A); void mParabolaFitLSM(float *XIn,float *YIn,int N,float *A); void mPolyFitLSM(float *XIn,float *YIn,int N,float *A,int k); void mLinearFitWeight(float *XIn,float *YIn,float *WIn,int N,float *A); void mParabolaFitWeight(float *XIn,float *YIn,float *WIn,int N,float *A); void mPolyFitWeight(float *XIn,float *YIn,float *WIn,int N,float *A,int k); void mLinearFit(float *XIn,float *YIn,int N,float *A); void mParabolaFit(float *XIn,float *YIn,int N,float *A); void mPolyFit(float *XIn,float *YIn,int N,float *A,int k); void mAscSortU8 (U8 *data_in,int *index_in,U8 *data_out,int *index_out,int num); void mAscSortS8 (S8 *data_in,int *index_in,S8 *data_out,int *index_out,int num); void mAscSortU16(U16 *data_in,int *index_in,U16 *data_out,int *index_out,int num); void mAscSortS16(S16 *data_in,int *index_in,S16 *data_out,int *index_out,int num); void mAscSortU32(U32 *data_in,int *index_in,U32 *data_out,int *index_out,int num); void mAscSortS32(S32 *data_in,int *index_in,S32 *data_out,int *index_out,int num); void mAscSortU64(U64 *data_in,int *index_in,U64 *data_out,int *index_out,int num); void mAscSortS64(S64 *data_in,int *index_in,S64 *data_out,int *index_out,int num); void mAscSortF32(F32 *data_in,int *index_in,F32 *data_out,int *index_out,int num); void mAscSortD64(D64 *data_in,int *index_in,D64 *data_out,int *index_out,int num); #define m_AscSort(DataIn,IndexIn,DataOut,IndexOut,Num) do{\ int Type=mDataType((DataIn)[0]);\ if(Type==MORN_TYPE_U8 ) mAscSortU8 ((U8 *)(DataIn),IndexIn,(U8 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_S8 ) mAscSortS8 ((S8 *)(DataIn),IndexIn,(S8 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_U16) mAscSortU16((U16 *)(DataIn),IndexIn,(U16 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_S16) mAscSortS16((S16 *)(DataIn),IndexIn,(S16 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_U32) mAscSortU32((U32 *)(DataIn),IndexIn,(U32 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_S32) mAscSortS32((S32 *)(DataIn),IndexIn,(S32 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_U64) mAscSortU64((U64 *)(DataIn),IndexIn,(U64 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_S64) mAscSortS64((S64 *)(DataIn),IndexIn,(S64 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_F32) mAscSortF32((F32 *)(DataIn),IndexIn,(F32 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_D64) mAscSortD64((D64 *)(DataIn),IndexIn,(D64 *)DataOut,IndexOut,Num);\ else mException(1,EXIT,"invalid input dD64ata type");\ }while(0) #define mAscSort(...) do{\ int VAN=VANumber(__VA_ARGS__);\ intptr_t VA1=(intptr_t)VA1(__VA_ARGS__),VA2=(intptr_t)VA2(__VA_ARGS__),VA3=(intptr_t)VA3(__VA_ARGS__),VA4=(intptr_t)VA4(__VA_ARGS__);\ if(VAN==2) m_AscSort(VA0(__VA_ARGS__), NULL, NULL, NULL,(int)VA1);\ else if(VAN==3) m_AscSort(VA0(__VA_ARGS__), NULL,(void *)VA1, NULL,(int)VA2);\ else if(VAN==4) m_AscSort(VA0(__VA_ARGS__), NULL,(void *)VA1,(int *)VA2,(int)VA3);\ else if(VAN==5) m_AscSort(VA0(__VA_ARGS__),(int *)VA1,(void *)VA2,(int *)VA3,(int)VA4);\ else mException(1,EXIT,"invalid input");\ }while(0) void mDescSortU8 (U8 *data_in,int *index_in,U8 *data_out,int *index_out,int num); void mDescSortS8 (S8 *data_in,int *index_in,S8 *data_out,int *index_out,int num); void mDescSortU16(U16 *data_in,int *index_in,U16 *data_out,int *index_out,int num); void mDescSortS16(S16 *data_in,int *index_in,S16 *data_out,int *index_out,int num); void mDescSortU32(U32 *data_in,int *index_in,U32 *data_out,int *index_out,int num); void mDescSortS32(S32 *data_in,int *index_in,S32 *data_out,int *index_out,int num); void mDescSortU64(U64 *data_in,int *index_in,U64 *data_out,int *index_out,int num); void mDescSortS64(S64 *data_in,int *index_in,S64 *data_out,int *index_out,int num); void mDescSortF32(F32 *data_in,int *index_in,F32 *data_out,int *index_out,int num); void mDescSortD64(D64 *data_in,int *index_in,D64 *data_out,int *index_out,int num); #define m_DescSort(DataIn,IndexIn,DataOut,IndexOut,Num) do{\ int Type=mDataType((DataIn)[0]);\ if(Type==MORN_TYPE_U8 ) mDescSortU8 ((U8 *)(DataIn),IndexIn,(U8 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_S8 ) mDescSortS8 ((S8 *)(DataIn),IndexIn,(S8 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_U16) mDescSortU16((U16 *)(DataIn),IndexIn,(U16 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_S16) mDescSortS16((S16 *)(DataIn),IndexIn,(S16 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_U32) mDescSortU32((U32 *)(DataIn),IndexIn,(U32 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_S32) mDescSortS32((S32 *)(DataIn),IndexIn,(S32 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_U64) mDescSortU64((U64 *)(DataIn),IndexIn,(U64 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_S64) mDescSortS64((S64 *)(DataIn),IndexIn,(S64 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_F32) mDescSortF32((F32 *)(DataIn),IndexIn,(F32 *)DataOut,IndexOut,Num);\ else if(Type==MORN_TYPE_D64) mDescSortD64((D64 *)(DataIn),IndexIn,(D64 *)DataOut,IndexOut,Num);\ else mException(1,EXIT,"invalid input data type");\ }while(0) #define mDescSort(...) do{\ int VAN=VANumber(__VA_ARGS__);\ intptr_t VA1=(intptr_t)VA1(__VA_ARGS__),VA2=(intptr_t)VA2(__VA_ARGS__),VA3=(intptr_t)VA3(__VA_ARGS__),VA4=(intptr_t)VA4(__VA_ARGS__);\ if(VAN==2) m_DescSort(VA0(__VA_ARGS__), NULL, NULL, NULL,(int)VA1);\ else if(VAN==3) m_DescSort(VA0(__VA_ARGS__), NULL,(void *)VA1, NULL,(int)VA2);\ else if(VAN==4) m_DescSort(VA0(__VA_ARGS__), NULL,(void *)VA1,(int *)VA2,(int)VA3);\ else if(VAN==5) m_DescSort(VA0(__VA_ARGS__),(int *)VA1,(void *)VA2,(int *)VA3,(int)VA4);\ else mException(1,EXIT,"invalid input");\ }while(0) U8 mMinSubsetU8 (U8 *data_in,int *index_in,int num_in,U8 *data_out,int *index_out,int num_out); S8 mMinSubsetS8 (S8 *data_in,int *index_in,int num_in,S8 *data_out,int *index_out,int num_out); U16 mMinSubsetU16(U16 *data_in,int *index_in,int num_in,U16 *data_out,int *index_out,int num_out); S16 mMinSubsetS16(S16 *data_in,int *index_in,int num_in,S16 *data_out,int *index_out,int num_out); U32 mMinSubsetU32(U32 *data_in,int *index_in,int num_in,U32 *data_out,int *index_out,int num_out); S32 mMinSubsetS32(S32 *data_in,int *index_in,int num_in,S32 *data_out,int *index_out,int num_out); U64 mMinSubsetU64(U64 *data_in,int *index_in,int num_in,U64 *data_out,int *index_out,int num_out); S64 mMinSubsetS64(S64 *data_in,int *index_in,int num_in,S64 *data_out,int *index_out,int num_out); F32 mMinSubsetF32(F32 *data_in,int *index_in,int num_in,F32 *data_out,int *index_out,int num_out); D64 mMinSubsetD64(D64 *data_in,int *index_in,int num_in,D64 *data_out,int *index_out,int num_out); #define m_MinSubset(DataIn,IndexIn,NumIn,DataOut,IndexOut,NumOut) (\ (mDataType((DataIn)[0])==MORN_TYPE_U8 )?mMinSubsetU8 ((U8 *)(DataIn),IndexIn,NumIn,(U8 *)DataOut,IndexOut,NumOut):(\ (morn_data_type==MORN_TYPE_S8 )?mMinSubsetS8 ((S8 *)(DataIn),IndexIn,NumIn,(S8 *)DataOut,IndexOut,NumOut):(\ (morn_data_type==MORN_TYPE_U16)?mMinSubsetU16((U16 *)(DataIn),IndexIn,NumIn,(U16 *)DataOut,IndexOut,NumOut):(\ (morn_data_type==MORN_TYPE_S16)?mMinSubsetS16((S16 *)(DataIn),IndexIn,NumIn,(S16 *)DataOut,IndexOut,NumOut):(\ (morn_data_type==MORN_TYPE_U32)?mMinSubsetU32((U32 *)(DataIn),IndexIn,NumIn,(U32 *)DataOut,IndexOut,NumOut):(\ (morn_data_type==MORN_TYPE_S32)?mMinSubsetS32((S32 *)(DataIn),IndexIn,NumIn,(S32 *)DataOut,IndexOut,NumOut):(\ (morn_data_type==MORN_TYPE_U64)?mMinSubsetU64((U64 *)(DataIn),IndexIn,NumIn,(U64 *)DataOut,IndexOut,NumOut):(\ (morn_data_type==MORN_TYPE_S64)?mMinSubsetS64((S64 *)(DataIn),IndexIn,NumIn,(S64 *)DataOut,IndexOut,NumOut):(\ (morn_data_type==MORN_TYPE_F32)?mMinSubsetF32((F32 *)(DataIn),IndexIn,NumIn,(F32 *)DataOut,IndexOut,NumOut):(\ (morn_data_type==MORN_TYPE_D64)?mMinSubsetD64((D64 *)(DataIn),IndexIn,NumIn,(D64 *)DataOut,IndexOut,NumOut):DFLT)))))))))\ ) #define mMinSubset(...) (\ (VANumber(__VA_ARGS__)==3)?m_MinSubset(VA0(__VA_ARGS__), NULL,(int)((intptr_t)VA1(__VA_ARGS__)), NULL, NULL,(int)((intptr_t)VA2(__VA_ARGS__))):(\ (VANumber(__VA_ARGS__)==4)?m_MinSubset(VA0(__VA_ARGS__), NULL,(int)((intptr_t)VA1(__VA_ARGS__)),(intptr_t)VA2(__VA_ARGS__), NULL,(int)((intptr_t)VA3(__VA_ARGS__))):(\ (VANumber(__VA_ARGS__)==5)?m_MinSubset(VA0(__VA_ARGS__), NULL,(int)((intptr_t)VA1(__VA_ARGS__)),(intptr_t)VA2(__VA_ARGS__),(int *)((intptr_t)VA3(__VA_ARGS__)),(int)((intptr_t)VA4(__VA_ARGS__))):(\ (VANumber(__VA_ARGS__)==6)?m_MinSubset(VA0(__VA_ARGS__),(int *)((intptr_t)VA1(__VA_ARGS__)),(int)((intptr_t)VA2(__VA_ARGS__)),(intptr_t)VA3(__VA_ARGS__),(int *)((intptr_t)VA4(__VA_ARGS__)),(int)((intptr_t)VA5(__VA_ARGS__))): \ DFLT)))\ ) U8 mMaxSubsetU8 (U8 *data_in,int *index_in,int num_in,U8 *data_out,int *index_out,int num_out); S8 mMaxSubsetS8 (S8 *data_in,int *index_in,int num_in,S8 *data_out,int *index_out,int num_out); U16 mMaxSubsetU16(U16 *data_in,int *index_in,int num_in,U16 *data_out,int *index_out,int num_out); S16 mMaxSubsetS16(S16 *data_in,int *index_in,int num_in,S16 *data_out,int *index_out,int num_out); U32 mMaxSubsetU32(U32 *data_in,int *index_in,int num_in,U32 *data_out,int *index_out,int num_out); S32 mMaxSubsetS32(S32 *data_in,int *index_in,int num_in,S32 *data_out,int *index_out,int num_out); U64 mMaxSubsetU64(U64 *data_in,int *index_in,int num_in,U64 *data_out,int *index_out,int num_out); S64 mMaxSubsetS64(S64 *data_in,int *index_in,int num_in,S64 *data_out,int *index_out,int num_out); F32 mMaxSubsetF32(F32 *data_in,int *index_in,int num_in,F32 *data_out,int *index_out,int num_out); D64 mMaxSubsetD64(D64 *data_in,int *index_in,int num_in,D64 *data_out,int *index_out,int num_out); #define m_MaxSubset(DataIn,IndexIn,NumIn,DataOut,IndexOut,NumOut) (\ (mDataType((DataIn)[0])==MORN_TYPE_U8 )?mMaxSubsetU8 ((U8 *)(DataIn),IndexIn,(int)NumIn,(U8 *)DataOut,IndexOut,(int)NumOut):(\ (morn_data_type==MORN_TYPE_S8 )?mMaxSubsetS8 ((S8 *)(DataIn),IndexIn,(int)NumIn,(S8 *)DataOut,IndexOut,(int)NumOut):(\ (morn_data_type==MORN_TYPE_U16)?mMaxSubsetU16((U16 *)(DataIn),IndexIn,(int)NumIn,(U16 *)DataOut,IndexOut,(int)NumOut):(\ (morn_data_type==MORN_TYPE_S16)?mMaxSubsetS16((S16 *)(DataIn),IndexIn,(int)NumIn,(S16 *)DataOut,IndexOut,(int)NumOut):(\ (morn_data_type==MORN_TYPE_U32)?mMaxSubsetU32((U32 *)(DataIn),IndexIn,(int)NumIn,(U32 *)DataOut,IndexOut,(int)NumOut):(\ (morn_data_type==MORN_TYPE_S32)?mMaxSubsetS32((S32 *)(DataIn),IndexIn,(int)NumIn,(S32 *)DataOut,IndexOut,(int)NumOut):(\ (morn_data_type==MORN_TYPE_U64)?mMaxSubsetU64((U64 *)(DataIn),IndexIn,(int)NumIn,(U64 *)DataOut,IndexOut,(int)NumOut):(\ (morn_data_type==MORN_TYPE_S64)?mMaxSubsetS64((S64 *)(DataIn),IndexIn,(int)NumIn,(S64 *)DataOut,IndexOut,(int)NumOut):(\ (morn_data_type==MORN_TYPE_F32)?mMaxSubsetF32((F32 *)(DataIn),IndexIn,(int)NumIn,(F32 *)DataOut,IndexOut,(int)NumOut):(\ (morn_data_type==MORN_TYPE_D64)?mMaxSubsetD64((D64 *)(DataIn),IndexIn,(int)NumIn,(D64 *)DataOut,IndexOut,(int)NumOut):DFLT)))))))))\ ) #define mMaxSubset(...) (\ (VANumber(__VA_ARGS__)==3)?m_MaxSubset(VA0(__VA_ARGS__), NULL,(int)((intptr_t)VA1(__VA_ARGS__)), NULL, NULL,(int)((intptr_t)VA2(__VA_ARGS__))):(\ (VANumber(__VA_ARGS__)==4)?m_MaxSubset(VA0(__VA_ARGS__), NULL,(int)((intptr_t)VA1(__VA_ARGS__)),(intptr_t)VA2(__VA_ARGS__), NULL,(int)((intptr_t)VA3(__VA_ARGS__))):(\ (VANumber(__VA_ARGS__)==5)?m_MaxSubset(VA0(__VA_ARGS__), NULL,(int)((intptr_t)VA1(__VA_ARGS__)),(intptr_t)VA2(__VA_ARGS__),(int *)((intptr_t)VA3(__VA_ARGS__)),(int)((intptr_t)VA4(__VA_ARGS__))):(\ (VANumber(__VA_ARGS__)==6)?m_MaxSubset(VA0(__VA_ARGS__),(int *)((intptr_t)VA1(__VA_ARGS__)),(int)((intptr_t)VA2(__VA_ARGS__)),(intptr_t)VA3(__VA_ARGS__),(int *)((intptr_t)VA4(__VA_ARGS__)),(int)((intptr_t)VA5(__VA_ARGS__))): \ DFLT)))\ ) #define MAX_TENSOR_BATCH 32 double mCalculate(char *str); void m_CalculateFunction(const char *name,void *func); #define mCalculateFunction(Func,...) do{\ int VA=VANumber(__VA_ARGS__);\ if(VA==0) m_CalculateFunction(#Func,(void *)Func);\ else m_CalculateFunction((const char*)Func,(void *)VA0(__VA_ARGS__));\ }while(0) // unsigned int mHash(const char *in,int size); void mIntToLInt(MArray *a,int64_t in); int64_t mLIntToInt(MArray *a); int mLIntCompare(MArray *a,MArray *b); void m_LIntAdd(MArray *a,MArray *b,MArray *c); void m_LIntAddInt(MArray *a,int64_t b,MArray *c); #define _LIntAdd(A,B,C) (((intptr_t)((B)+1)==((intptr_t)(B))+1)?m_LIntAddInt(A,(int32_t)((intptr_t)(B)),C):m_LIntAdd(A,(MArray *)((intptr_t)(B)),C)) #define mLIntAdd(A,B,...) ((VANumber(__VA_ARGS__)==0)?_LIntAdd(A,B,A):_LIntAdd(A,B,VA0(__VA_ARGS__))) void m_LIntSub(MArray *a,MArray *b,MArray *c); void m_LIntSubInt(MArray *a,int64_t b,MArray *c); #define _LIntSub(A,B,C) (((intptr_t)((B)+1)==((intptr_t)(B))+1)?m_LIntSubInt(A,(int32_t)((intptr_t)(B)),C):m_LIntSub(A,(MArray *)((intptr_t)(B)),C)) #define mLIntSub(A,B,...) ((VANumber(__VA_ARGS__)==0)?_LIntSub(A,B,A):_LIntSub(A,B,VA0(__VA_ARGS__))) void m_LIntMul(MArray *a,MArray *b,MArray *c); void m_LIntMulInt(MArray *a,int64_t b,MArray *c); #define _LIntMul(A,B,C) (((intptr_t)((B)+1)==((intptr_t)(B))+1)?m_LIntMulInt(A,(int32_t)((intptr_t)(B)),C):m_LIntMul(A,(MArray *)((intptr_t)(B)),C)) #define mLIntMul(A,B,...) ((VANumber(__VA_ARGS__)==0)?_LIntMul(A,B,A):_LIntMul(A,B,VA0(__VA_ARGS__))) void m_LIntDivInt(MArray *a,int b,MArray *c,int *remainder); void m_LIntDiv(MArray *a,MArray *b,MArray *c,MArray *remainder); #define _LIntDiv(A,B,C,D) (((intptr_t)((B)+1)==((intptr_t)(B))+1)?m_LIntDivInt(A,(int32_t)((intptr_t)(B)),C,D):m_LIntDiv(A,(MArray *)((intptr_t)(B)),C,D)) #define mLIntDiv(A,B,...) do{\ int VAN=VANumber(__VA_ARGS__);\ if(VAN==0) _LIntDiv(A,B,A,NULL);\ else if(VAN==1) _LIntDiv(A,B,VA0(__VA_ARGS__),NULL);\ else _LIntDiv(A,B,VA0(__VA_ARGS__),VA1(__VA_ARGS__));\ }while(0) void mFactorial(MArray *array,int n); void mLIntToString(MArray *a,char *str); void mStringToLInt(MArray *a,const char *str); void mLinearRegression(float **x,float *y,int n,int m,float *A); void mPointInterpolation(MList *curve,MList *list,float k1,float k2); #define MORN_NO_TRANS 0 #define MORN_TRANS 1 void mSgemm(int device,int a_trans,int b_trans,int m,int n,int k,float alpha,MMemoryBlock *a,int sa,MMemoryBlock *b,int sb,float beta,MMemoryBlock *c,int sc); void mSaxpby(int device,int n,float alpha,MMemoryBlock *a,int sa,float beta,MMemoryBlock *b,int sb); #ifdef __cplusplus } #endif #endif
fd9f2f8e4a2f5ad26798a7961be8a4959c34070e
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/net/bridge/netfilter/ebtable_nat.c
10871bc77908ec8799a482636995771fd47a6b03
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
3,036
c
ebtable_nat.c
/* * ebtable_nat * * Authors: * Bart De Schuymer <bdschuym@pandora.be> * * April, 2002 * */ #include <linux/netfilter_bridge/ebtables.h> #include <linux/module.h> #define NAT_VALID_HOOKS ((1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_OUT) | \ (1 << NF_BR_POST_ROUTING)) static struct ebt_entries initial_chains[] = { { .name = "PREROUTING", .policy = EBT_ACCEPT, }, { .name = "OUTPUT", .policy = EBT_ACCEPT, }, { .name = "POSTROUTING", .policy = EBT_ACCEPT, } }; static struct ebt_replace_kernel initial_table = { .name = "nat", .valid_hooks = NAT_VALID_HOOKS, .entries_size = 3 * sizeof(struct ebt_entries), .hook_entry = { [NF_BR_PRE_ROUTING] = &initial_chains[0], [NF_BR_LOCAL_OUT] = &initial_chains[1], [NF_BR_POST_ROUTING] = &initial_chains[2], }, .entries = (char *)initial_chains, }; static int check(const struct ebt_table_info *info, unsigned int valid_hooks) { if (valid_hooks & ~NAT_VALID_HOOKS) return -EINVAL; return 0; } static struct ebt_table frame_nat = { .name = "nat", .table = &initial_table, .valid_hooks = NAT_VALID_HOOKS, .check = check, .me = THIS_MODULE, }; static unsigned int ebt_nat_in(unsigned int hook, struct sk_buff *skb, const struct net_device *in , const struct net_device *out, int (*okfn)(struct sk_buff *)) { return ebt_do_table(hook, skb, in, out, dev_net(in)->xt.frame_nat); } static unsigned int ebt_nat_out(unsigned int hook, struct sk_buff *skb, const struct net_device *in , const struct net_device *out, int (*okfn)(struct sk_buff *)) { return ebt_do_table(hook, skb, in, out, dev_net(out)->xt.frame_nat); } static struct nf_hook_ops ebt_ops_nat[] __read_mostly = { { .hook = ebt_nat_out, .owner = THIS_MODULE, .pf = NFPROTO_BRIDGE, .hooknum = NF_BR_LOCAL_OUT, .priority = NF_BR_PRI_NAT_DST_OTHER, }, { .hook = ebt_nat_out, .owner = THIS_MODULE, .pf = NFPROTO_BRIDGE, .hooknum = NF_BR_POST_ROUTING, .priority = NF_BR_PRI_NAT_SRC, }, { .hook = ebt_nat_in, .owner = THIS_MODULE, .pf = NFPROTO_BRIDGE, .hooknum = NF_BR_PRE_ROUTING, .priority = NF_BR_PRI_NAT_DST_BRIDGED, }, }; static int __net_init frame_nat_net_init(struct net *net) { net->xt.frame_nat = ebt_register_table(net, &frame_nat); return PTR_RET(net->xt.frame_nat); } static void __net_exit frame_nat_net_exit(struct net *net) { ebt_unregister_table(net, net->xt.frame_nat); } static struct pernet_operations frame_nat_net_ops = { .init = frame_nat_net_init, .exit = frame_nat_net_exit, }; static int __init ebtable_nat_init(void) { int ret; ret = register_pernet_subsys(&frame_nat_net_ops); if (ret < 0) return ret; ret = nf_register_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat)); if (ret < 0) unregister_pernet_subsys(&frame_nat_net_ops); return ret; } static void __exit ebtable_nat_fini(void) { nf_unregister_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat)); unregister_pernet_subsys(&frame_nat_net_ops); } module_init(ebtable_nat_init); module_exit(ebtable_nat_fini); MODULE_LICENSE("GPL");
f4df2a789db451baa4891ba0ed7b656f01e7389d
c26d7b0ed875357278e61627da2da0650da77986
/include/vmf.h
ed2a503093a39868d8491c98616fb020d2ff6365
[ "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
2,306
h
vmf.h
/* Program Name: vmf.h * Author: S.M. Schultz * * ----------- Modification History ------------ * Version Date Reason For Modification * 1.0 01Jan80 1. Initial release. * 2.0 31Mar83 2. Cleanup. * 3.0 08Sep93 3. Change v_foffset to off_t instead of int. * 3.1 21Oct93 4. Create union member of structure to * make 'int' or 'char' access to data easy. * Define segment+offset and modified macros. * Place into the public domain. * -------------------------------------------------- */ #include <sys/types.h> #define MAXSEGNO 16384 /* max number of segments in a space */ #define BYTESPERSEG 1024 /* must be power of two! */ #define LOG2BPS 10 /* log2(BYTESPERSEG) */ #define WORDSPERSEG (BYTESPERSEG/sizeof (int)) struct vspace { int v_fd; /* file for swapping */ off_t v_foffset; /* offset for computing file addresses */ int v_maxsegno; /* number of segments in this space */ }; struct dlink { /* general double link structure */ struct dlink *fwd; /* forward link */ struct dlink *back; /* back link */ }; struct vseg { /* structure of a segment in memory */ struct dlink s_link; /* for linking into lru list */ int s_segno; /* segment number */ struct vspace *s_vspace; /* which virtual space */ int s_lock_count; int s_flags; union { int _winfo[WORDSPERSEG]; /* the actual segment */ char _cinfo[BYTESPERSEG]; } v_un; }; #define s_winfo v_un._winfo #define s_cinfo v_un._cinfo /* masks for s_flags */ #define S_DIRTY 01 /* segment has been modified */ long nswaps; /* number of swaps */ long nmapsegs; /* number of mapseg calls */ int vminit(), vmopen(); struct vseg *vmmapseg(); void vmlock(), vmunlock(), vmclrseg(), vmmodify(); void vmflush(), vmclose(); typedef long VADDR; #define VMMODIFY(seg) (seg->s_flags |= S_DIRTY) #define VSEG(va) ((short)(va >> LOG2BPS)) #define VOFF(va) ((u_short)va % BYTESPERSEG)
c7522f0e7375e71b7c5e89bd63889cd8d83fcca8
eecd5e4c50d8b78a769bcc2675250576bed34066
/src/snes/tests/ex15.c
b636ae4074ce1230776e874c8bbfcdfc442b6191
[ "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
24,410
c
ex15.c
static char help[] = "Mixed element discretization of the Poisson equation.\n\n\n"; #include <petscdmplex.h> #include <petscdmswarm.h> #include <petscds.h> #include <petscsnes.h> #include <petscconvest.h> #include <petscbag.h> /* The Poisson equation -\Delta\phi = f can be rewritten in first order form q - \nabla\phi &= 0 -\nabla \cdot q &= f */ typedef enum { SIGMA, NUM_CONSTANTS } ConstantType; typedef struct { PetscReal sigma; /* Nondimensional charge per length in x */ } Parameter; typedef enum { SOL_CONST, SOL_LINEAR, SOL_QUADRATIC, SOL_TRIG, SOL_TRIGX, SOL_PARTICLES, NUM_SOL_TYPES } SolType; static const char *solTypes[] = {"const", "linear", "quadratic", "trig", "trigx", "particles"}; typedef struct { SolType solType; /* MMS solution type */ PetscBag bag; /* Problem parameters */ PetscBool particleRHS; PetscInt Np; } AppCtx; /* SOLUTION CONST: \phi = 1, q = 0, f = 0 */ static PetscErrorCode const_phi(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { *u = 1.0; return PETSC_SUCCESS; } static PetscErrorCode const_q(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { for (PetscInt d = 0; d < dim; ++d) u[d] = 0.0; return PETSC_SUCCESS; } /* SOLUTION LINEAR: \phi = 2y, q = <0, 2>, f = 0 */ static PetscErrorCode linear_phi(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = 2. * x[1]; return PETSC_SUCCESS; } static PetscErrorCode linear_q(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = 0.; u[1] = 2.; return PETSC_SUCCESS; } /* SOLUTION QUADRATIC: \phi = x (2\pi - x) + (1 + y) (1 - y), q = <2\pi - 2 x, - 2 y> = <2\pi, 0> - 2 x, f = -4 */ static PetscErrorCode quadratic_phi(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = x[0] * (6.283185307179586 - x[0]) + (1. + x[1]) * (1. - x[1]); return PETSC_SUCCESS; } static PetscErrorCode quadratic_q(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = 6.283185307179586 - 2. * x[0]; u[1] = -2. * x[1]; return PETSC_SUCCESS; } static PetscErrorCode quadratic_q_bc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = x[1] > 0. ? -2. * x[1] : 2. * x[1]; return PETSC_SUCCESS; } static void f0_quadratic_phi(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) { for (PetscInt d = 0; d < dim; ++d) f0[0] -= -2.0; } /* SOLUTION TRIG: \phi = sin(x) + (1/3 - y^2), q = <cos(x), -2 y>, f = sin(x) + 2 */ static PetscErrorCode trig_phi(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = PetscSinReal(x[0]) + (1. / 3. - x[1] * x[1]); return PETSC_SUCCESS; } static PetscErrorCode trig_q(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = PetscCosReal(x[0]); u[1] = -2. * x[1]; return PETSC_SUCCESS; } static PetscErrorCode trig_q_bc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = x[1] > 0. ? -2. * x[1] : 2. * x[1]; return PETSC_SUCCESS; } static void f0_trig_phi(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) { f0[0] += PetscSinReal(x[0]) + 2.; } /* SOLUTION TRIGX: \phi = sin(x), q = <cos(x), 0>, f = sin(x) */ static PetscErrorCode trigx_phi(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = PetscSinReal(x[0]); return PETSC_SUCCESS; } static PetscErrorCode trigx_q(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = PetscCosReal(x[0]); u[1] = 0.; return PETSC_SUCCESS; } static PetscErrorCode trigx_q_bc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = x[1] > 0. ? -2. * x[1] : 2. * x[1]; return PETSC_SUCCESS; } static void f0_trigx_phi(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) { f0[0] += PetscSinReal(x[0]); } static void f0_q(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) { for (PetscInt d = 0; d < dim; ++d) f0[d] += u[uOff[0] + d]; } static void f1_q(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[]) { for (PetscInt d = 0; d < dim; ++d) f1[d * dim + d] = u[uOff[1]]; } static void f0_phi(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) { for (PetscInt d = 0; d < dim; ++d) f0[0] += u_x[uOff_x[0] + d * dim + d]; } static void f0_phi_backgroundCharge(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) { f0[0] += constants[SIGMA]; for (PetscInt d = 0; d < dim; ++d) f0[0] += u_x[uOff_x[0] + d * dim + d]; } static void g0_qq(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) { for (PetscInt d = 0; d < dim; ++d) g0[d * dim + d] = 1.0; } static void g2_qphi(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]) { for (PetscInt d = 0; d < dim; ++d) g2[d * dim + d] = 1.0; } static void g1_phiq(PetscInt dim, PetscInt Nf, PetscInt NfAux, const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]) { for (PetscInt d = 0; d < dim; ++d) g1[d * dim + d] = 1.0; } /* SOLUTION PARTICLES: \phi = sigma, q = <cos(x), 0>, f = sin(x) */ static PetscErrorCode particles_phi(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = 0.0795775; return PETSC_SUCCESS; } static PetscErrorCode particles_q(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) { u[0] = 0.; u[1] = 0.; return PETSC_SUCCESS; } static PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options) { PetscInt sol; PetscFunctionBeginUser; options->solType = SOL_CONST; options->particleRHS = PETSC_FALSE; options->Np = 100; PetscOptionsBegin(comm, "", "Mixed Poisson Options", "DMPLEX"); PetscCall(PetscOptionsBool("-particleRHS", "Flag to user particle RHS and background charge", "ex9.c", options->particleRHS, &options->particleRHS, NULL)); sol = options->solType; PetscCall(PetscOptionsEList("-sol_type", "The MMS solution type", "ex12.c", solTypes, NUM_SOL_TYPES, solTypes[sol], &sol, NULL)); options->solType = (SolType)sol; PetscOptionsEnd(); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user, DM *dm) { PetscFunctionBeginUser; PetscCall(DMCreate(comm, dm)); PetscCall(DMSetType(*dm, DMPLEX)); PetscCall(DMSetFromOptions(*dm)); PetscCall(DMSetApplicationContext(*dm, user)); PetscCall(DMViewFromOptions(*dm, NULL, "-dm_view")); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode SetupPrimalProblem(DM dm, AppCtx *user) { PetscDS ds; PetscWeakForm wf; DMLabel label; const PetscInt id = 1; PetscFunctionBeginUser; PetscCall(DMGetDS(dm, &ds)); PetscCall(PetscDSGetWeakForm(ds, &wf)); PetscCall(DMGetLabel(dm, "marker", &label)); PetscCall(PetscDSSetResidual(ds, 0, f0_q, f1_q)); if (user->particleRHS) { PetscCall(PetscDSSetResidual(ds, 1, f0_phi_backgroundCharge, NULL)); } else { PetscCall(PetscDSSetResidual(ds, 1, f0_phi, NULL)); } PetscCall(PetscDSSetJacobian(ds, 0, 0, g0_qq, NULL, NULL, NULL)); PetscCall(PetscDSSetJacobian(ds, 0, 1, NULL, NULL, g2_qphi, NULL)); PetscCall(PetscDSSetJacobian(ds, 1, 0, NULL, g1_phiq, NULL, NULL)); switch (user->solType) { case SOL_CONST: PetscCall(PetscDSSetExactSolution(ds, 0, const_q, user)); PetscCall(PetscDSSetExactSolution(ds, 1, const_phi, user)); break; case SOL_LINEAR: PetscCall(PetscDSSetExactSolution(ds, 0, linear_q, user)); PetscCall(PetscDSSetExactSolution(ds, 1, linear_phi, user)); break; case SOL_QUADRATIC: PetscCall(PetscWeakFormAddResidual(wf, NULL, 0, 1, 0, f0_quadratic_phi, NULL)); PetscCall(PetscDSSetExactSolution(ds, 0, quadratic_q, user)); PetscCall(PetscDSSetExactSolution(ds, 1, quadratic_phi, user)); PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall", label, 1, &id, 0, 0, NULL, (void (*)(void))quadratic_q_bc, NULL, user, NULL)); break; case SOL_TRIG: PetscCall(PetscWeakFormAddResidual(wf, NULL, 0, 1, 0, f0_trig_phi, NULL)); PetscCall(PetscDSSetExactSolution(ds, 0, trig_q, user)); PetscCall(PetscDSSetExactSolution(ds, 1, trig_phi, user)); PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall", label, 1, &id, 0, 0, NULL, (void (*)(void))trig_q_bc, NULL, user, NULL)); break; case SOL_TRIGX: PetscCall(PetscWeakFormAddResidual(wf, NULL, 0, 1, 0, f0_trigx_phi, NULL)); PetscCall(PetscDSSetExactSolution(ds, 0, trigx_q, user)); PetscCall(PetscDSSetExactSolution(ds, 1, trigx_phi, user)); PetscCall(DMAddBoundary(dm, DM_BC_ESSENTIAL, "wall", label, 1, &id, 0, 0, NULL, (void (*)(void))trigx_q_bc, NULL, user, NULL)); break; case SOL_PARTICLES: PetscCall(PetscDSSetExactSolution(ds, 0, particles_q, user)); PetscCall(PetscDSSetExactSolution(ds, 1, particles_phi, user)); break; default: SETERRQ(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_OUTOFRANGE, "Invalid solution type: %d", user->solType); } PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode SetupDiscretization(DM dm, PetscInt Nf, const char *names[], PetscErrorCode (*setup)(DM, AppCtx *), AppCtx *user) { DM cdm = dm; PetscFE fe; DMPolytopeType ct; PetscInt dim, cStart; char prefix[PETSC_MAX_PATH_LEN]; PetscFunctionBeginUser; PetscCall(DMGetDimension(dm, &dim)); PetscCall(DMPlexGetHeightStratum(dm, 0, &cStart, NULL)); PetscCall(DMPlexGetCellType(dm, cStart, &ct)); for (PetscInt f = 0; f < Nf; ++f) { PetscCall(PetscSNPrintf(prefix, PETSC_MAX_PATH_LEN, "%s_", names[f])); PetscCall(PetscFECreateByCell(PETSC_COMM_SELF, dim, 1, ct, prefix, -1, &fe)); PetscCall(PetscObjectSetName((PetscObject)fe, names[f])); if (f > 0) { PetscFE fe0; PetscCall(DMGetField(dm, 0, NULL, (PetscObject *)&fe0)); PetscCall(PetscFECopyQuadrature(fe0, fe)); } PetscCall(DMSetField(dm, f, NULL, (PetscObject)fe)); PetscCall(PetscFEDestroy(&fe)); } PetscCall(DMCreateDS(dm)); PetscCall((*setup)(dm, user)); while (cdm) { PetscCall(DMCopyDisc(dm, cdm)); PetscCall(DMGetCoarseDM(cdm, &cdm)); } PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode InitializeParticlesAndWeights(DM sw, AppCtx *user) { DM dm; PetscScalar *weight; PetscInt Np, Npc, p, dim, c, cStart, cEnd, q, *cellid; PetscReal weightsum = 0.0; PetscMPIInt size, rank; Parameter *param; PetscFunctionBegin; PetscCallMPI(MPI_Comm_size(PetscObjectComm((PetscObject)sw), &size)); PetscCallMPI(MPI_Comm_rank(PetscObjectComm((PetscObject)sw), &rank)); PetscOptionsBegin(PetscObjectComm((PetscObject)sw), "", "DMSwarm Options", "DMSWARM"); PetscCall(PetscOptionsInt("-dm_swarm_num_particles", "The target number of particles", "", user->Np, &user->Np, NULL)); PetscOptionsEnd(); Np = user->Np; PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Np = %" PetscInt_FMT "\n", Np)); PetscCall(DMGetDimension(sw, &dim)); PetscCall(DMSwarmGetCellDM(sw, &dm)); PetscCall(DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd)); PetscCall(PetscBagGetData(user->bag, (void **)&param)); PetscCall(DMSwarmSetLocalSizes(sw, Np, 0)); Npc = Np / (cEnd - cStart); PetscCall(DMSwarmGetField(sw, DMSwarmPICField_cellid, NULL, NULL, (void **)&cellid)); for (c = 0, p = 0; c < cEnd - cStart; ++c) { for (q = 0; q < Npc; ++q, ++p) cellid[p] = c; } PetscCall(DMSwarmRestoreField(sw, DMSwarmPICField_cellid, NULL, NULL, (void **)&cellid)); PetscCall(DMSwarmGetField(sw, "w_q", NULL, NULL, (void **)&weight)); PetscCall(DMSwarmSortGetAccess(sw)); for (p = 0; p < Np; ++p) { weight[p] = 1.0 / Np; weightsum += PetscRealPart(weight[p]); } PetscCall(PetscPrintf(PETSC_COMM_WORLD, "weightsum = %1.10f\n", (double)weightsum)); PetscCall(DMSwarmSortRestoreAccess(sw)); PetscCall(DMSwarmRestoreField(sw, "w_q", NULL, NULL, (void **)&weight)); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode CreateSwarm(DM dm, AppCtx *user, DM *sw) { PetscInt dim; PetscFunctionBeginUser; PetscCall(DMGetDimension(dm, &dim)); PetscCall(DMCreate(PetscObjectComm((PetscObject)dm), sw)); PetscCall(DMSetType(*sw, DMSWARM)); PetscCall(DMSetDimension(*sw, dim)); PetscCall(DMSwarmSetType(*sw, DMSWARM_PIC)); PetscCall(DMSwarmSetCellDM(*sw, dm)); PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "w_q", 1, PETSC_SCALAR)); PetscCall(DMSwarmFinalizeFieldRegister(*sw)); PetscCall(InitializeParticlesAndWeights(*sw, user)); PetscCall(DMSetFromOptions(*sw)); PetscCall(DMSetApplicationContext(*sw, user)); PetscCall(PetscObjectSetName((PetscObject)*sw, "Particles")); PetscCall(DMViewFromOptions(*sw, NULL, "-sw_view")); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode SetupParameters(MPI_Comm comm, AppCtx *ctx) { PetscBag bag; Parameter *p; PetscFunctionBeginUser; /* setup PETSc parameter bag */ PetscCall(PetscBagGetData(ctx->bag, (void **)&p)); PetscCall(PetscBagSetName(ctx->bag, "par", "Parameters")); bag = ctx->bag; PetscCall(PetscBagRegisterScalar(bag, &p->sigma, 1.0, "sigma", "Charge per unit area, C/m^3")); PetscCall(PetscBagSetFromOptions(bag)); { PetscViewer viewer; PetscViewerFormat format; PetscBool flg; PetscCall(PetscOptionsGetViewer(comm, NULL, NULL, "-param_view", &viewer, &format, &flg)); if (flg) { PetscCall(PetscViewerPushFormat(viewer, format)); PetscCall(PetscBagView(bag, viewer)); PetscCall(PetscViewerFlush(viewer)); PetscCall(PetscViewerPopFormat(viewer)); PetscCall(PetscViewerDestroy(&viewer)); } } PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode InitializeConstants(DM sw, AppCtx *user) { DM dm; PetscReal *weight, totalCharge, totalWeight = 0., gmin[3], gmax[3]; PetscInt Np, p, dim; PetscFunctionBegin; PetscCall(DMSwarmGetCellDM(sw, &dm)); PetscCall(DMGetDimension(sw, &dim)); PetscCall(DMSwarmGetLocalSize(sw, &Np)); PetscCall(DMGetBoundingBox(dm, gmin, gmax)); PetscCall(DMSwarmGetField(sw, "w_q", NULL, NULL, (void **)&weight)); for (p = 0; p < Np; ++p) totalWeight += weight[p]; totalCharge = -1.0 * totalWeight; PetscCall(DMSwarmRestoreField(sw, "w_q", NULL, NULL, (void **)&weight)); { Parameter *param; PetscReal Area; PetscCall(PetscBagGetData(user->bag, (void **)&param)); switch (dim) { case 1: Area = (gmax[0] - gmin[0]); break; case 2: Area = (gmax[0] - gmin[0]) * (gmax[1] - gmin[1]); break; case 3: Area = (gmax[0] - gmin[0]) * (gmax[1] - gmin[1]) * (gmax[2] - gmin[2]); break; default: SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Dimension %" PetscInt_FMT " not supported", dim); } PetscCall(PetscPrintf(PETSC_COMM_WORLD, "dim = %" PetscInt_FMT "\ttotalWeight = %f\ttotalCharge = %f, Total Area = %f\n", dim, (double)totalWeight, (double)totalCharge, (double)Area)); param->sigma = PetscAbsReal(totalCharge / (Area)); PetscCall(PetscPrintf(PETSC_COMM_SELF, "sigma: %g\n", (double)param->sigma)); } /* Setup Constants */ { PetscDS ds; Parameter *param; PetscCall(PetscBagGetData(user->bag, (void **)&param)); PetscScalar constants[NUM_CONSTANTS]; constants[SIGMA] = param->sigma; PetscCall(DMGetDS(dm, &ds)); PetscCall(PetscDSSetConstants(ds, NUM_CONSTANTS, constants)); } PetscFunctionReturn(PETSC_SUCCESS); } int main(int argc, char **argv) { DM dm, sw; SNES snes; Vec u; AppCtx user; const char *names[] = {"q", "phi"}; PetscFunctionBeginUser; PetscCall(PetscInitialize(&argc, &argv, NULL, help)); PetscCall(ProcessOptions(PETSC_COMM_WORLD, &user)); PetscCall(CreateMesh(PETSC_COMM_WORLD, &user, &dm)); PetscCall(SNESCreate(PETSC_COMM_WORLD, &snes)); PetscCall(SNESSetDM(snes, dm)); PetscCall(SetupDiscretization(dm, 2, names, SetupPrimalProblem, &user)); if (user.particleRHS) { PetscCall(PetscBagCreate(PETSC_COMM_SELF, sizeof(Parameter), &user.bag)); PetscCall(CreateSwarm(dm, &user, &sw)); PetscCall(SetupParameters(PETSC_COMM_WORLD, &user)); PetscCall(InitializeConstants(sw, &user)); } PetscCall(DMCreateGlobalVector(dm, &u)); PetscCall(PetscObjectSetName((PetscObject)u, "solution")); PetscCall(SNESSetFromOptions(snes)); PetscCall(DMPlexSetSNESLocalFEM(dm, &user, &user, &user)); PetscCall(DMSNESCheckFromOptions(snes, u)); if (user.particleRHS) { DM potential_dm; IS potential_IS; Mat M_p; Vec rho, f, temp_rho; PetscInt fields = 1; PetscCall(DMGetGlobalVector(dm, &rho)); PetscCall(PetscObjectSetName((PetscObject)rho, "rho")); PetscCall(DMCreateSubDM(dm, 1, &fields, &potential_IS, &potential_dm)); PetscCall(DMCreateMassMatrix(sw, potential_dm, &M_p)); PetscCall(MatViewFromOptions(M_p, NULL, "-mp_view")); PetscCall(DMGetGlobalVector(potential_dm, &temp_rho)); PetscCall(DMSwarmCreateGlobalVectorFromField(sw, "w_q", &f)); PetscCall(PetscObjectSetName((PetscObject)f, "particle weight")); PetscCall(VecViewFromOptions(f, NULL, "-weights_view")); PetscCall(MatMultTranspose(M_p, f, temp_rho)); PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, "w_q", &f)); PetscCall(MatDestroy(&M_p)); PetscCall(PetscObjectSetName((PetscObject)rho, "rho")); PetscCall(VecViewFromOptions(rho, NULL, "-poisson_rho_view")); PetscCall(VecISCopy(rho, potential_IS, SCATTER_FORWARD, temp_rho)); PetscCall(VecViewFromOptions(temp_rho, NULL, "-rho_view")); PetscCall(DMRestoreGlobalVector(potential_dm, &temp_rho)); PetscCall(DMDestroy(&potential_dm)); PetscCall(ISDestroy(&potential_IS)); PetscCall(SNESSolve(snes, rho, u)); PetscCall(DMRestoreGlobalVector(dm, &rho)); } else { PetscCall(SNESSolve(snes, NULL, u)); } PetscCall(VecDestroy(&u)); PetscCall(SNESDestroy(&snes)); PetscCall(DMDestroy(&dm)); if (user.particleRHS) { PetscCall(DMDestroy(&sw)); PetscCall(PetscBagDestroy(&user.bag)); } PetscCall(PetscFinalize()); return PETSC_SUCCESS; } /*TEST # RT1-P0 on quads testset: args: -dm_plex_simplex 0 -dm_plex_box_bd periodic,none -dm_plex_box_faces 3,1 \ -dm_plex_box_lower 0,-1 -dm_plex_box_upper 6.283185307179586,1\ -phi_petscspace_degree 0 \ -phi_petscdualspace_lagrange_use_moments \ -phi_petscdualspace_lagrange_moment_order 2 \ -q_petscfe_default_quadrature_order 1 \ -q_petscspace_type sum \ -q_petscspace_variables 2 \ -q_petscspace_components 2 \ -q_petscspace_sum_spaces 2 \ -q_petscspace_sum_concatenate true \ -q_sumcomp_0_petscspace_variables 2 \ -q_sumcomp_0_petscspace_type tensor \ -q_sumcomp_0_petscspace_tensor_spaces 2 \ -q_sumcomp_0_petscspace_tensor_uniform false \ -q_sumcomp_0_tensorcomp_0_petscspace_degree 1 \ -q_sumcomp_0_tensorcomp_1_petscspace_degree 0 \ -q_sumcomp_1_petscspace_variables 2 \ -q_sumcomp_1_petscspace_type tensor \ -q_sumcomp_1_petscspace_tensor_spaces 2 \ -q_sumcomp_1_petscspace_tensor_uniform false \ -q_sumcomp_1_tensorcomp_0_petscspace_degree 0 \ -q_sumcomp_1_tensorcomp_1_petscspace_degree 1 \ -q_petscdualspace_form_degree -1 \ -q_petscdualspace_order 1 \ -q_petscdualspace_lagrange_trimmed true \ -ksp_error_if_not_converged \ -pc_type fieldsplit -pc_fieldsplit_type schur \ -pc_fieldsplit_schur_fact_type full -pc_fieldsplit_schur_precondition full # The Jacobian test is meaningless here test: suffix: quad_hdiv_0 args: -dmsnes_check filter: sed -e "s/Taylor approximation converging at order.*''//" # The Jacobian test is meaningless here test: suffix: quad_hdiv_1 args: -sol_type linear -dmsnes_check filter: sed -e "s/Taylor approximation converging at order.*''//" test: suffix: quad_hdiv_2 args: -sol_type quadratic -dmsnes_check \ -fieldsplit_q_pc_type lu -fieldsplit_phi_pc_type svd test: suffix: quad_hdiv_3 args: -sol_type trig \ -fieldsplit_q_pc_type lu -fieldsplit_phi_pc_type svd test: suffix: quad_hdiv_4 requires: !single args: -sol_type trigx \ -fieldsplit_q_pc_type lu -fieldsplit_phi_pc_type svd test: suffix: particle_hdiv_5 requires: !complex args: -dm_swarm_num_particles 100 -particleRHS -sol_type particles \ -fieldsplit_q_pc_type lu -fieldsplit_phi_pc_type svd TEST*/
47952356a72ee4111b4145d6b4835929d386cdd6
dcc65ef9fbeea547abc5f6809e2c22dbdc3eb0e9
/thirdparty/espresso/src/set.h
7ecfdf14c9577bbea664dd00b21e434330b95602
[ "BSD-2-Clause" ]
permissive
cjdrake/pyeda
60cbb1966edf6388111eb626999f35d0dec68fd1
56fc29d71a6645e18dd37f5f03c8206a4c83ab29
refs/heads/main
2023-08-31T11:34:58.882973
2023-08-30T00:32:34
2023-08-30T00:32:34
4,689,577
257
49
BSD-2-Clause
2023-08-30T00:32:40
2012-06-17T04:18:44
Python
UTF-8
C
false
false
2,096
h
set.h
// Filename: set.h #include <stdio.h> bool set_andp(set *r, set *a, set *b); bool set_orp(set *r, set *a, set *b); bool setp_disjoint(set *a, set *b); bool setp_empty(set *a); bool setp_equal(set *a, set *b); bool setp_full(set *a, int size); bool setp_implies(set *a, set *b); int *sf_count(set_family_t *A); int *sf_count_restricted(set_family_t *A, set *r); int bit_index(unsigned int a); int set_dist(set *a, set *b); int set_ord(set *a); void set_adjcnt(set *a, int *count, int weight); set *set_and(set *r, set *a, set *b); set *set_clear(set *r, int size); set *set_copy(set *r, set *a); set *set_diff(set *r, set *a, set *b); set *set_fill(set *r, int size); set *set_merge(set *r, set *a, set *b, set *mask); set *set_or(set *r, set *a, set *b); set *set_xor(set *r, set *a, set *b); set *sf_and(set_family_t *A); set *sf_or(set_family_t *A); set_family_t *sf_active(set_family_t *A); set_family_t *sf_addcol(set_family_t *A, int firstcol, int n); set_family_t *sf_addset(set_family_t *A, set *s); set_family_t *sf_append(set_family_t *A, set_family_t *B); set_family_t *sf_bm_read(FILE *fp); set_family_t *sf_compress(set_family_t *A, set *c); set_family_t *sf_copy(set_family_t *R, set_family_t *A); set_family_t *sf_copy_col(set_family_t *dst, int dstcol, set_family_t *src, int srccol); set_family_t *sf_delc(set_family_t *A, int first, int last); set_family_t *sf_delcol(set_family_t *A, int firstcol, int n); set_family_t *sf_inactive(set_family_t *A); set_family_t *sf_join(set_family_t *A, set_family_t *B); set_family_t *sf_new(int num, int size); set_family_t *sf_permute(set_family_t *A, int *permute, int npermute); set_family_t *sf_read(FILE *fp); set_family_t *sf_save(set_family_t *A); set_family_t *sf_transpose(set_family_t *A); void set_write(FILE *fp, set *a); void sf_bm_print(set_family_t *A); void sf_cleanup(void); void sf_delset(set_family_t *A, int i); void sf_free(set_family_t *A); void sf_print(set_family_t *A); void sf_write(FILE *fp, set_family_t *A); int sf_equal(set_family_t *F1, set_family_t *F2); void print_cover(set_family_t *F, char *name);
2d1cab25753dc4aaa83e032de6193ece1a78a086
1873690f92fb432936397c24e5b900a31711c140
/test/correctness/smhasher/vhash4smhasher.c
3f3d83ff73be528d1870012d2af13a2022cb5b9c
[ "Apache-2.0", "MIT", "LicenseRef-scancode-public-domain" ]
permissive
lemire/StronglyUniversalStringHashing
328ca976259228c717fbbfe032fdfa2ff02f35bb
a80e04fc75d34885b5c31ae714c4f24e5ea49be9
refs/heads/master
2023-08-18T23:59:54.136257
2020-10-15T13:26:08
2020-10-15T13:26:08
10,040,230
126
10
Apache-2.0
2020-10-15T13:03:02
2013-05-13T20:13:50
C++
UTF-8
C
false
false
1,259
c
vhash4smhasher.c
#include <stdlib.h> #include <string.h> #include "mersenne.h" #include "VHASH/vmac.h" uint64_t vrandoms[140]; vmac_ctx_t ctx; void init_vhash( uint32_t seed) { ZRandom zr; initZRandom(&zr,seed); for (int i=0; i < 140; ++i) vrandoms[i] = getValue(&zr) | ( ((uint64_t) getValue(&zr)) << 32); vmac_set_key((unsigned char *)vrandoms, &ctx); } uint64_t vhash4smhasher( const void *key, int lengthInBytes) { uint64_t tagl;// I think that this is useless but I am not sure, still needed due to API size_t inputlengthinbytes = lengthInBytes; if((inputlengthinbytes % VMAC_NHBYTES) == 0) { return vhash((unsigned char *)key, inputlengthinbytes, &tagl, &ctx); } size_t roundedlength = inputlengthinbytes/VMAC_NHBYTES*VMAC_NHBYTES; if(roundedlength > 0) vhash_update((unsigned char*)key, roundedlength, &ctx); unsigned char lastBlock[VMAC_NHBYTES + 16]; unsigned char *alignedptr = (unsigned char*)(((uintptr_t)lastBlock+15) & ~ (uintptr_t)0x0F); size_t remaining = inputlengthinbytes - roundedlength; memcpy(alignedptr, (unsigned char*)key + roundedlength, remaining); memset(alignedptr + remaining, 0, VMAC_NHBYTES - remaining ); return vhash(alignedptr, remaining, &tagl, &ctx); }
a6b52d09b21671471e69ae2fb694decb045b6b4e
d169de4c5c6b281984df35536430dcc931a957a9
/source/shell/sys/linux/vsf_linux.h
4e3624087ca1ad744b6c84d8047a654dd6c0baee
[ "LGPL-2.1-only", "Apache-2.0" ]
permissive
vsfteam/vsf
2ba968ba2ef53b036668019c6c6746149a63c38a
522a52ff2ee4ed149b52789a5bd366f80c08c458
refs/heads/master
2023-08-27T07:32:08.339123
2023-08-26T17:46:07
2023-08-26T17:46:07
181,911,464
273
83
Apache-2.0
2023-08-29T03:08:36
2019-04-17T14:43:42
C
UTF-8
C
false
false
21,280
h
vsf_linux.h
/***************************************************************************** * Copyright(C)2009-2022 by VSF Team * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * ****************************************************************************/ #ifndef __VSF_LINUX_INTERNAL_H__ #define __VSF_LINUX_INTERNAL_H__ /*============================ INCLUDES ======================================*/ #include "vsf.h" #include "./vsf_linux_cfg.h" #if VSF_USE_LINUX == ENABLED #if VSF_LINUX_CFG_RELATIVE_PATH == ENABLED # include "./include/signal.h" # include "./include/dirent.h" # include "./include/termios.h" # include "./include/sys/time.h" # include "./include/linux/limits.h" #else # include <signal.h> # include <dirent.h> # include <termios.h> # include <sys/time.h> # include <linux/limits.h> #endif #include "./kernel/fs/vsf_linux_fs.h" #if defined(__VSF_LINUX_CLASS_IMPLEMENT) # define __VSF_CLASS_IMPLEMENT__ #elif defined(__VSF_LINUX_CLASS_INHERIT__) # define __VSF_CLASS_INHERIT__ #endif #include "utilities/ooc_class.h" #ifdef __cplusplus extern "C" { #endif /*============================ MACROS ========================================*/ #if VSF_KERNEL_CFG_EDA_SUPPORT_ON_TERMINATE != ENABLED # error VSF_KERNEL_CFG_EDA_SUPPORT_ON_TERMINATE MUST be enabled to use vsf_linux #endif #if VSF_USE_SIMPLE_STREAM != ENABLED # error VSF_USE_SIMPLE_STREAM MUST be enabled to use vsf_linux #endif #ifndef VSF_LINUX_CFG_STACKSIZE # if defined(VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE) && defined(VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE) # if (VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE + VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE) < 1024 # define VSF_LINUX_CFG_STACKSIZE 1024 # else # define VSF_LINUX_CFG_STACKSIZE (VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE + VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE) # endif # else # define VSF_LINUX_CFG_STACKSIZE 1024 # endif #endif #if VSF_LINUX_CFG_STACKSIZE > 0xFFFF # if VSF_KERNEL_CFG_THREAD_STACK_LARGE != ENABLED # error stacks should be 16-bit if VSF_KERNEL_CFG_THREAD_STACK_LARGE is not enabled # endif #endif #if (VSF_LINUX_CFG_STACKSIZE < (VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE + VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE))\ || (VSF_LINUX_CFG_STACKSIZE & (VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE - 1)) # error invalid VSF_LINUX_CFG_STACKSIZE #endif /*============================ MACROFIED FUNCTIONS ===========================*/ #define vsf_linux_thread_get_priv(__thread) (void *)(&(((vsf_linux_thread_t *)(__thread))[1])) /*============================ TYPES =========================================*/ vsf_dcl_class(vsf_linux_process_t) vsf_dcl_class(vsf_linux_thread_t) typedef struct vsf_linux_process_arg_t { int argc; char const **argv; } vsf_linux_process_arg_t; typedef int (*vsf_linux_main_entry_t)(int, char **); typedef int (*vsf_linux_process_arg_parser_t)(vsf_linux_process_arg_t *arg); typedef struct vsf_linux_thread_op_t { int priv_size; void (*on_run)(vsf_thread_cb_t *cb); void (*on_terminate)(vsf_linux_thread_t *thread); } vsf_linux_thread_op_t; typedef struct vsf_linux_process_ctx_t { vsf_linux_process_arg_t arg; vsf_linux_main_entry_t entry; } vsf_linux_process_ctx_t; #if VSF_LINUX_CFG_PLS_NUM > 0 || VSF_LINUX_CFG_TLS_NUM > 0 typedef struct vsf_linux_localstorage_t { void *data; void (*destructor)(void *data); } vsf_linux_localstorage_t; typedef struct vsf_linux_dynlib_mod_t { int *lib_idx; uint16_t mod_idx; uint16_t module_num; uint32_t bss_size; uint32_t mod_size; void (*init)(void *ctx); } vsf_linux_dynlib_mod_t; typedef struct vsf_linux_dynlib_t { uint16_t module_num; uint32_t bss_size; uint32_t bss_brk; int * lib_idx; // just make iar happy, which does not support zla void * modules[1]; } vsf_linux_dynlib_t; #endif vsf_class(vsf_linux_trigger_t) { public_member( implement(vsf_trig_t) ) #if VSF_LINUX_CFG_SUPPORT_SIG == ENABLED private_member( vsf_dlist_node_t node; vsf_linux_process_t *pending_process; int sig; ) #endif }; #if VSF_LINUX_CFG_PLS_NUM > 0 dcl_vsf_bitmap(vsf_linux_pls_bitmap, VSF_LINUX_CFG_PLS_NUM); #endif #if VSF_LINUX_CFG_TLS_NUM > 0 dcl_vsf_bitmap(vsf_linux_tls_bitmap, VSF_LINUX_CFG_TLS_NUM); #endif vsf_class(vsf_linux_thread_t) { public_member( implement(vsf_thread_t) implement(vsf_thread_cb_t) const vsf_linux_thread_op_t *op; int __errno; // for gethostbyname, etc int __h_errno; ) protected_member( pid_t pid_exited; // used in wait int retval; pid_t tid; vsf_linux_thread_t *thread_pending; #if VSF_LINUX_CFG_TLS_NUM > 0 vsf_linux_localstorage_t tls[VSF_LINUX_CFG_TLS_NUM]; #endif #if VSF_ARCH_USE_THREAD_REG == ENABLED \ && VSF_LINUX_USE_SIMPLE_LIBC == ENABLED && VSF_LINUX_USE_SIMPLE_STDLIB == ENABLED\ && VSF_LINUX_APPLET_USE_LIBC_STDLIB == ENABLED && !defined(__VSF_APPLET__) union { // used to save compar parameter for bsearch and qsort void *tmp_ptr; } process_reg_backup; #endif char name[16]; ) private_member( vsf_linux_process_t *process; vsf_dlist_node_t thread_node; ) }; typedef struct vsf_linux_sig_handler_t { vsf_dlist_node_t node; uint8_t sig; uint32_t flags; sigset_t mask; union { sighandler_t sighandler; void (*sigaction_handler)(int, siginfo_t *, void *); }; } vsf_linux_sig_handler_t; typedef struct vsf_linux_stdio_stream_t { vsf_stream_t *in; vsf_stream_t *out; vsf_stream_t *err; } vsf_linux_stdio_stream_t; #if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED typedef struct vsf_linux_timer_t { struct itimerspec value; struct sigevent evt; int overrun; vsf_callback_timer_t timer; vsf_systimer_tick_t start; } vsf_linux_timer_t; #endif dcl_vsf_bitmap(vsf_linux_fd_bitmap, VSF_LINUX_CFG_FD_BITMAP_SIZE); #if VSF_LINUX_USE_SIMPLE_LIBC == ENABLED && VSF_LINUX_USE_SIMPLE_STDLIB == ENABLED\ && VSF_LINUX_SIMPLE_STDLIB_CFG_HEAP_MONITOR == ENABLED typedef struct vsf_linux_heap_info_t { size_t usage; int balance; } vsf_linux_heap_info_t; typedef struct vsf_liunx_heap_node_t { void *ptr; size_t size; const char *file; const char *func; int line; } vsf_liunx_heap_node_t; # if VSF_LINUX_SIMPLE_STDLIB_HEAP_MONITOR_TRACE_DEPTH > 0 dcl_vsf_bitmap(vsf_linux_heap_nodes_bitmap, VSF_LINUX_SIMPLE_STDLIB_HEAP_MONITOR_TRACE_DEPTH); # endif typedef struct vsf_linux_heap_monitor_t { vsf_linux_heap_info_t info; # if VSF_LINUX_SIMPLE_STDLIB_HEAP_MONITOR_TRACE_DEPTH > 0 vsf_bitmap(vsf_linux_heap_nodes_bitmap) bitmap; vsf_liunx_heap_node_t nodes[VSF_LINUX_SIMPLE_STDLIB_HEAP_MONITOR_TRACE_DEPTH]; # endif } vsf_linux_heap_monitor_t; #endif vsf_class(vsf_linux_process_t) { public_member( vsf_linux_process_ctx_t ctx; #if VSF_LINUX_LIBC_USE_ENVIRON == ENABLED char **__environ; #endif #if VSF_LINUX_USE_VFORK == ENABLED jmp_buf __vfork_jmpbuf; #endif ) protected_member( #if VSF_ARCH_USE_THREAD_REG == ENABLED uintptr_t reg; #endif int status; int exit_status; vsf_linux_process_t *shell_process; // thread pending child process vsf_linux_thread_t *thread_pending_child; struct { pid_t pid; pid_t ppid; pid_t gid; } id; #if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED vsf_linux_timer_t timers[ITIMER_NUM]; #endif #if VSF_LINUX_USE_SIMPLE_LIBC == ENABLED && VSF_LINUX_USE_SIMPLE_STDLIB == ENABLED\ && VSF_LINUX_SIMPLE_STDLIB_CFG_HEAP_MONITOR == ENABLED vsf_linux_heap_monitor_t heap_monitor; #endif int fn_atexit_num; void (*fn_atexit[VSF_LINUX_CFG_ATEXIT_NUM])(void); char *working_dir; #define __VSF_LINUX_PROCESS_HAS_PATH (VSF_LINUX_USE_PROCFS == ENABLED || VSF_LINUX_USE_APPLET == ENABLED || VSF_LINUX_USE_SCRIPT == ENABLED) #if __VSF_LINUX_PROCESS_HAS_PATH char path[PATH_MAX]; #endif #if VSF_USE_LOADER == ENABLED void *loader; #endif ) private_member( vsf_dlist_node_t process_node; vsf_dlist_t thread_list; vsf_dlist_t fd_list; // thread pending this process vsf_linux_thread_t *thread_pending; vsf_bitmap(vsf_linux_fd_bitmap) fd_bitmap; struct { sigset_t pending; sigset_t mask; #if VSF_LINUX_CFG_SUPPORT_SIG == ENABLED vsf_dlist_t handler_list; vsf_linux_thread_t *sighandler_thread; vsf_dlist_t trigger_list; #endif } sig; vsf_prio_t prio; vsf_linux_thread_t *thread_pending_exit; vsf_linux_process_t *parent_process; vsf_dlist_t child_list; vsf_dlist_node_t child_node; vsf_heap_t *heap; #if VSF_LINUX_USE_VFORK == ENABLED vsf_linux_process_t *vfork_child; bool is_vforking; #endif #if VSF_LINUX_CFG_PLS_NUM > 0 struct { vsf_bitmap(vsf_linux_pls_bitmap) dynlib_bitmap; vsf_linux_localstorage_t storage[VSF_LINUX_CFG_PLS_NUM]; } pls; #endif #if VSF_LINUX_CFG_TLS_NUM > 0 struct { vsf_bitmap(vsf_linux_tls_bitmap) bitmap; } tls; #endif ) }; /*============================ GLOBAL VARIABLES ==============================*/ /*============================ LOCAL VARIABLES ===============================*/ /*============================ PROTOTYPES ====================================*/ #if VSF_LINUX_USE_APPLET == ENABLED typedef struct vsf_linux_fundmental_vplt_t { vsf_vplt_info_t info; #if VSF_LINUX_CFG_PLS_NUM > 0 VSF_APPLET_VPLT_ENTRY_FUNC_DEF(vsf_linux_dynlib_ctx_get); VSF_APPLET_VPLT_ENTRY_FUNC_DEF(vsf_linux_dynlib_ctx_set); #endif VSF_APPLET_VPLT_ENTRY_FUNC_DEF(vsf_linux_get_cur_process); } vsf_linux_fundmental_vplt_t; # ifndef __VSF_APPLET__ extern __VSF_VPLT_DECORATOR__ vsf_linux_fundmental_vplt_t vsf_linux_fundmental_vplt; # endif #endif #if defined(__VSF_APPLET__) && (defined(__VSF_APPLET_LIB__) || defined(__VSF_APPLET_LINUX_FUNDMENTAL_LIB__))\ && VSF_APPLET_CFG_ABI_PATCH != ENABLED && VSF_LINUX_USE_APPLET == ENABLED #ifndef VSF_LINUX_APPLET_FUNDMENTAL_VPLT # if VSF_LINUX_USE_APPLET == ENABLED # define VSF_LINUX_APPLET_FUNDMENTAL_VPLT \ ((vsf_linux_fundmental_vplt_t *)(VSF_LINUX_APPLET_VPLT->fundmental_vplt)) # else # define VSF_LINUX_APPLET_FUNDMENTAL_VPLT \ ((vsf_linux_fundmental_vplt_t *)vsf_vplt((void *)0)) # endif #endif #define VSF_LINUX_APPLET_FUNDMENTAL_ENTRY(__NAME) \ VSF_APPLET_VPLT_ENTRY_FUNC_ENTRY(VSF_LINUX_APPLET_FUNDMENTAL_VPLT, __NAME) #define VSF_LINUX_APPLET_FUNDMENTAL_IMP(...) \ VSF_APPLET_VPLT_ENTRY_FUNC_IMP(VSF_LINUX_APPLET_FUNDMENTAL_VPLT, __VA_ARGS__) #if VSF_LINUX_CFG_PLS_NUM > 0 VSF_LINUX_APPLET_FUNDMENTAL_IMP(vsf_linux_dynlib_ctx_get, void *, const vsf_linux_dynlib_mod_t *mod) { VSF_APPLET_VPLT_ENTRY_FUNC_TRACE(); return VSF_LINUX_APPLET_FUNDMENTAL_ENTRY(vsf_linux_dynlib_ctx_get)(mod); } VSF_LINUX_APPLET_FUNDMENTAL_IMP(vsf_linux_dynlib_ctx_set, int, const vsf_linux_dynlib_mod_t *mod, void *ctx) { VSF_APPLET_VPLT_ENTRY_FUNC_TRACE(); return VSF_LINUX_APPLET_FUNDMENTAL_ENTRY(vsf_linux_dynlib_ctx_set)(mod, ctx); } #endif VSF_LINUX_APPLET_FUNDMENTAL_IMP(vsf_linux_get_cur_process, vsf_linux_process_t *, void) { VSF_APPLET_VPLT_ENTRY_FUNC_TRACE(); return VSF_LINUX_APPLET_FUNDMENTAL_ENTRY(vsf_linux_get_cur_process)(); } #else #if VSF_LINUX_CFG_PLS_NUM > 0 extern void * vsf_linux_dynlib_ctx_get(const vsf_linux_dynlib_mod_t *mod); extern int vsf_linux_dynlib_ctx_set(const vsf_linux_dynlib_mod_t *mod, void *ctx); // for backward compatibility #define vsf_linux_dynlib_ctx vsf_linux_dynlib_ctx_get #endif // open vsf_linux_get_cur_process for process-related variables like optarg, etc extern vsf_linux_process_t * vsf_linux_get_cur_process(void); #endif // IMPORTANT: priority of stdio_stream MUST be within scheduler priorities extern vsf_err_t vsf_linux_init(vsf_linux_stdio_stream_t *stdio_stream); extern vsf_systimer_tick_t vsf_linux_sleep(vsf_systimer_tick_t ticks); // used for dynamic libraries, allocate/free memory from resources_process extern vsf_linux_process_t * vsf_linux_resources_process(void); extern size_t vsf_linux_process_heap_size(vsf_linux_process_t *process, void *buffer); extern void * vsf_linux_process_heap_realloc(vsf_linux_process_t *process, void *buffer, uint_fast32_t size); extern void * vsf_linux_process_heap_malloc_aligned(vsf_linux_process_t *process, uint_fast32_t size, uint_fast32_t alignment); extern void * vsf_linux_process_heap_malloc(vsf_linux_process_t *process, size_t size); extern void * vsf_linux_process_heap_calloc(vsf_linux_process_t *process, size_t n, size_t size); extern void vsf_linux_process_heap_free(vsf_linux_process_t *process, void *buffer); extern char * vsf_linux_process_heap_strdup(vsf_linux_process_t *process, char *str); #if VSF_LINUX_SIMPLE_STDLIB_CFG_HEAP_MONITOR == ENABLED extern void __free_ex(vsf_linux_process_t *process, void *ptr); # define __malloc_ex(__process, __size) ____malloc_ex((__process), (__size), __FILE__, __FUNCTION__, __LINE__) # define __calloc_ex(__process, __n, __size) ____calloc_ex((__process), (__n), (__size), __FILE__, __FUNCTION__, __LINE__) # define __realloc_ex(__process, __ptr, __size) ____realloc_ex((__process), (__ptr), (__size), __FILE__, __FUNCTION__, __LINE__) # define __strdup_ex(__process, __str) ____strdup_ex((__process), (char *)(__str), __FILE__, __FUNCTION__, __LINE__) #else # define __malloc_ex(__process, __size) vsf_linux_process_heap_malloc((__process), (__size)) # define __calloc_ex(__process, __n, __size) vsf_linux_process_heap_calloc((__process), (__n), (__size)) # define __free_ex(__process, __ptr) vsf_linux_process_heap_free((__process), (__ptr)) # define __realloc_ex(__process, __ptr, __size) vsf_linux_process_heap_realloc((__process), (__ptr), (__size)) # define __strdup_ex(__process, __str) vsf_linux_process_heap_strdup((__process), (char *)(__str)) #endif extern void * vsf_linux_malloc_res(size_t size); extern void vsf_linux_free_res(void *ptr); extern int vsf_linux_generate_path(char *path_out, int path_out_lenlen, char *dir, char *path_in); extern int vsf_linux_chdir(vsf_linux_process_t *process, char *working_dir); extern int vsf_linux_fd_bind_executable(int fd, vsf_linux_main_entry_t entry); extern int vsf_linux_fs_bind_executable(char *path, vsf_linux_main_entry_t entry); extern int vsf_linux_expandenv(const char *str, char *output, size_t bufflen); #if VSF_LINUX_CFG_PLS_NUM > 0 extern vsf_err_t vsf_linux_library_init(int *lib_idx, void *lib_ctx, void (*destructor)(void *)); extern void * vsf_linux_library_ctx(int lib_idx); extern vsf_err_t vsf_linux_dynlib_init(int *lib_idx, int module_num, int bss_size); #endif #if defined(__VSF_LINUX_CLASS_IMPLEMENT) || defined(__VSF_LINUX_CLASS_INHERIT__) # if VSF_LINUX_CFG_PLS_NUM > 0 extern int vsf_linux_pls_alloc(void); extern void vsf_linux_pls_free(int idx); extern vsf_linux_localstorage_t * vsf_linux_pls_get(int idx); # endif # if VSF_LINUX_CFG_TLS_NUM > 0 extern int vsf_linux_tls_alloc(void (*destructor)(void *)); extern void vsf_linux_tls_free(int idx); extern vsf_linux_localstorage_t * vsf_linux_tls_get(int idx); # endif extern bool vsf_linux_is_inited(void); // will get vfork_child is current process is vforking extern vsf_linux_process_t * vsf_linux_get_real_process(vsf_linux_process_t *process); #define __vsf_linux_start_process_internal3(__entry, __argv, __stack_size, __prio)\ __vsf_linux_start_process_internal((__entry), (__argv), (__stack_size), (__prio)) #define __vsf_linux_start_process_internal2(__entry, __argv, __stack_size) \ __vsf_linux_start_process_internal3((__entry), (__argv), (__stack_size), VSF_LINUX_CFG_PRIO_LOWEST) #define __vsf_linux_start_process_internal1(__entry, __argv) \ __vsf_linux_start_process_internal2((__entry), (__argv), 0) #define __vsf_linux_start_process_internal0(__entry) \ __vsf_linux_start_process_internal1(__entry, NULL) // prototype: vsf_linux_process_t * vsf_linux_start_process_internal(vsf_linux_main_entry_t *entry, // char * const * argv = NULL, int stack_size = 0, vsf_prio_t prio = VSF_LINUX_CFG_PRIO_LOWEST); #define vsf_linux_start_process_internal(__entry, ...) \ __PLOOC_EVAL(__vsf_linux_start_process_internal, __VA_ARGS__)((__entry), ##__VA_ARGS__) extern vsf_linux_process_t * __vsf_linux_start_process_internal( vsf_linux_main_entry_t entry, char * const * argv, int stack_size, vsf_prio_t prio); extern vsf_linux_main_entry_t * vsf_linux_fd_get_executable(int fd); extern int vsf_linux_fs_get_executable(const char *pathname, vsf_linux_main_entry_t *entry); // delete unstarted/existed process extern vsf_linux_process_t * vsf_linux_create_process(int stack_size, int heap_size, int priv_size); extern void vsf_linux_delete_process(vsf_linux_process_t *process); extern int vsf_linux_start_process(vsf_linux_process_t *process); extern void vsf_linux_exit_process(int status, bool _exit); #if VSF_ARCH_USE_THREAD_REG == ENABLED extern uintptr_t vsf_linux_set_process_reg(uintptr_t reg); #endif extern void vsf_linux_cleanup_process(vsf_linux_process_t *process); extern void vsf_linux_detach_process(vsf_linux_process_t *process); extern void vsf_linux_detach_thread(vsf_linux_thread_t *thread); extern int vsf_linux_wait_thread(int tid, int *retval); extern vsf_linux_thread_t * vsf_linux_create_thread(vsf_linux_process_t *process, const vsf_linux_thread_op_t *op, int stack_size, void *stack); extern int vsf_linux_start_thread(vsf_linux_thread_t *thread, vsf_prio_t priority); extern void vsf_linux_thread_on_terminate(vsf_linux_thread_t *thread); extern vsf_linux_thread_t * vsf_linux_get_thread(pid_t pid, int tid); extern vsf_linux_process_t * vsf_linux_get_process(pid_t pid); extern void __vsf_linux_process_free_arg(vsf_linux_process_t *process); extern int __vsf_linux_process_parse_arg(vsf_linux_process_t *process, vsf_linux_process_arg_t *arg, char * const * argv); extern int vsf_linux_merge_env(vsf_linux_process_t *process, char **env); extern void vsf_linux_free_env(vsf_linux_process_t *process); extern void vsf_linux_trigger_init(vsf_linux_trigger_t *trig); // return value: // < 0 : triggered by signals, returns the minus signal // 0 : triggered normally // > 0 : triggered because of timeout extern int vsf_linux_trigger_pend(vsf_linux_trigger_t *trig, vsf_timeout_tick_t timeout); extern int vsf_linux_trigger_signal(vsf_linux_trigger_t *trig, int sig); #endif // open vsf_linux_get_cur_thread for thread-related variables like errno, etc extern vsf_linux_thread_t * vsf_linux_get_cur_thread(void); extern int vsf_linux_get_errno(void); extern void vsf_linux_set_errno(int err); #ifdef __cplusplus } #endif #undef __VSF_LINUX_CLASS_IMPLEMENT #undef __VSF_LINUX_CLASS_INHERIT__ #endif // VSF_USE_LINUX #endif // __VSF_LINUX_INTERNAL_H__ /* EOF */
8eb9bb5eb1d72bfc855c443a86019f4f45bf03fc
7b1bb311237a79373ecbb16a3efb6a05c571eacf
/src/tests/ejdb_test1.c
6c99518ada899cd8ca9f171075dbc3207bb7ed1f
[ "MIT" ]
permissive
Softmotions/ejdb
b095b34cca69a5b6e00998a44bc92d2659db1b35
6f0b19de9cd0e4baed8ac0d511df385ca1953042
refs/heads/master
2023-08-31T14:43:28.015011
2023-07-18T15:48:56
2023-07-18T15:48:56
6,427,744
846
103
MIT
2023-09-11T15:37:39
2012-10-28T13:30:23
C
UTF-8
C
false
false
8,210
c
ejdb_test1.c
#include "ejdb2.h" #include "ejdb_test.h" #include <iowow/iwxstr.h> #include <CUnit/Basic.h> int init_suite() { int rc = ejdb_init(); return rc; } int clean_suite() { return 0; } void ejdb_test1_3() { EJDB_OPTS opts = { .kv = { .path = "ejdb_test1_3.db", .oflags = IWKV_TRUNC }, .no_wal = true }; EJDB db; JBL jbl; int64_t id = 0; iwrc rc = ejdb_open(&opts, &db); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = put_json2(db, "c1", "{'foo':'bar'}", &id); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_TRUE_FATAL(id > 0); rc = patch_json(db, "c1", "[ { 'op': 'add', 'path': '/baz', 'value': 'qux' } ]", id); if (rc) { iwlog_ecode_error3(rc); } CU_ASSERT_EQUAL_FATAL(rc, 0); // Now check the result rc = ejdb_get(db, "c1", id, &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); IWXSTR *xstr = iwxstr_new(); CU_ASSERT_PTR_NOT_NULL_FATAL(xstr); rc = jbl_as_json(jbl, jbl_xstr_json_printer, xstr, 0); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(iwxstr_ptr(xstr), "{\"foo\":\"bar\",\"baz\":\"qux\"}"); rc = ejdb_close(&db); CU_ASSERT_EQUAL_FATAL(rc, 0); iwxstr_destroy(xstr); jbl_destroy(&jbl); } void ejdb_test1_2() { EJDB_OPTS opts = { .kv = { .path = "ejdb_test1_2.db", .oflags = IWKV_TRUNC }, .no_wal = true }; EJDB db; JBL jbl, at, meta; int64_t llv = 0, llv2; iwrc rc = ejdb_open(&opts, &db); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = jbl_from_json(&jbl, "{\"foo\":22}"); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_put_new(db, "foocoll", jbl, &llv); CU_ASSERT_EQUAL_FATAL(rc, 0); jbl_destroy(&jbl); CU_ASSERT_TRUE(llv > 0); rc = ejdb_get(db, "foocoll", llv, &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = jbl_at(jbl, "/foo", &at); CU_ASSERT_EQUAL_FATAL(rc, 0); llv2 = jbl_get_i64(at); CU_ASSERT_EQUAL(llv2, 22); jbl_destroy(&at); jbl_destroy(&jbl); rc = ejdb_del(db, "foocoll", llv); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_get(db, "foocoll", llv, &jbl); CU_ASSERT_EQUAL(rc, IWKV_ERROR_NOTFOUND); CU_ASSERT_PTR_NULL(jbl); rc = jbl_from_json(&jbl, "{\"foo\":22}"); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_put_new(db, "foocoll", jbl, &llv); CU_ASSERT_EQUAL_FATAL(rc, 0); jbl_destroy(&jbl); CU_ASSERT_TRUE(llv > 0); // Ensure indexes rc = ejdb_ensure_index(db, "col1", "/foo/bar", EJDB_IDX_I64 | EJDB_IDX_UNIQUE); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_ensure_index(db, "col1", "/foo/baz", EJDB_IDX_STR); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_ensure_index(db, "col1", "/foo/gaz", EJDB_IDX_STR | EJDB_IDX_UNIQUE); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_get_meta(db, &meta); CU_ASSERT_EQUAL_FATAL(rc, 0); // fprintf(stderr, "\n"); // rc = jbl_as_json(meta, jbl_fstream_json_printer, stderr, JBL_PRINT_PRETTY); // CU_ASSERT_EQUAL_FATAL(rc, 0); // fprintf(stderr, "\n"); // "version": "2.0.0", // "file": "ejdb_test1_2.db", // "size": 8192, // "collections": [ // { // "name": "col1", // "dbid": 3, // "indexes": [ // { // "ptr": "/foo/bar", // "mode": 9, // "idbf": 2, // "dbid": 4, // "auxdbid": 0 // }, // { // "ptr": "/foo/baz", // "mode": 4, // "idbf": 8, // "dbid": 5, // "auxdbid": 0 // } // ] // }, // { // "name": "foocoll", // "dbid": 2, // "indexes": [] // } // ] rc = jbl_at(meta, "/collections/0/name", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "col1"); jbl_destroy(&jbl); rc = jbl_at(meta, "/collections/0/indexes/0/ptr", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "/foo/gaz"); jbl_destroy(&jbl); rc = jbl_at(meta, "/collections/1/name", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "foocoll"); jbl_destroy(&jbl); rc = jbl_at(meta, "/collections/0/indexes/1/ptr", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "/foo/baz"); jbl_destroy(&jbl); rc = ejdb_close(&db); CU_ASSERT_EQUAL_FATAL(rc, 0); jbl_destroy(&meta); // Now reopen db and check indexes opts.kv.oflags &= ~IWKV_TRUNC; rc = ejdb_open(&opts, &db); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_get_meta(db, &meta); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = jbl_at(meta, "/collections/0/name", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "col1"); jbl_destroy(&jbl); rc = jbl_at(meta, "/collections/0/indexes/0/ptr", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "/foo/gaz"); jbl_destroy(&jbl); rc = jbl_at(meta, "/collections/1/name", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "foocoll"); jbl_destroy(&jbl); rc = jbl_at(meta, "/collections/1/rnum", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_EQUAL(jbl_get_i64(jbl), 1); jbl_destroy(&jbl); rc = jbl_at(meta, "/collections/0/indexes/1/ptr", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "/foo/baz"); jbl_destroy(&jbl); jbl_destroy(&meta); rc = ejdb_remove_index(db, "col1", "/foo/baz", EJDB_IDX_STR); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_remove_index(db, "col1", "/foo/gaz", EJDB_IDX_STR); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_get_meta(db, &meta); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = jbl_at(meta, "/collections/1/indexes/0/ptr", &jbl); CU_ASSERT_EQUAL_FATAL(rc, JBL_ERROR_PATH_NOTFOUND); rc = jbl_at(meta, "/collections/2/indexes/0/ptr", &jbl); CU_ASSERT_EQUAL_FATAL(rc, JBL_ERROR_PATH_NOTFOUND); rc = jbl_at(meta, "/collections/0/indexes/0/ptr", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "/foo/bar"); jbl_destroy(&jbl); rc = ejdb_close(&db); CU_ASSERT_EQUAL_FATAL(rc, 0); jbl_destroy(&meta); } void ejdb_test1_1() { EJDB_OPTS opts = { .kv = { .path = "ejdb_test1_1.db", .oflags = IWKV_TRUNC }, .no_wal = true }; EJDB db; JBL meta, jbl; iwrc rc = ejdb_open(&opts, &db); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_ensure_collection(db, "foo"); CU_ASSERT_EQUAL_FATAL(rc, 0); // Meta: { // "version": "2.0.0", // "file": "ejdb_test1_1.db", // "size": 8192, // "collections": [ // { // "name": "foo", // "dbid": 2 // } // ] //} rc = ejdb_get_meta(db, &meta); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = jbl_at(meta, "/file", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "ejdb_test1_1.db"); jbl_destroy(&jbl); rc = jbl_at(meta, "/collections/0/name", &jbl); CU_ASSERT_EQUAL_FATAL(rc, 0); CU_ASSERT_STRING_EQUAL(jbl_get_str(jbl), "foo"); jbl_destroy(&jbl); jbl_destroy(&meta); rc = ejdb_close(&db); CU_ASSERT_EQUAL_FATAL(rc, 0); // Now reopen database then load collection opts.kv.oflags &= ~IWKV_TRUNC; rc = ejdb_open(&opts, &db); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_remove_collection(db, "foo"); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = ejdb_get_meta(db, &meta); CU_ASSERT_EQUAL_FATAL(rc, 0); rc = jbl_at(meta, "/collections/0/name", &jbl); // No collections CU_ASSERT_EQUAL_FATAL(rc, JBL_ERROR_PATH_NOTFOUND); jbl_destroy(&meta); rc = ejdb_close(&db); CU_ASSERT_EQUAL_FATAL(rc, 0); } int main() { CU_pSuite pSuite = NULL; if (CUE_SUCCESS != CU_initialize_registry()) { return CU_get_error(); } pSuite = CU_add_suite("ejdb_test1", init_suite, clean_suite); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } if ( (NULL == CU_add_test(pSuite, "ejdb_test1_1", ejdb_test1_1)) || (NULL == CU_add_test(pSuite, "ejdb_test1_2", ejdb_test1_2)) || (NULL == CU_add_test(pSuite, "ejdb_test1_3", ejdb_test1_3))) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); int ret = CU_get_error() || CU_get_number_of_failures(); CU_cleanup_registry(); return ret; }
0156d216922714446d8324b9d7872ec43a658e51
bb38c44037a99d0a12a12d92059678f2faebbc80
/src/bin/pgevent/pgmsgevent.h
8ffc7a49a46fdbd36ce2e318ee29a3b53879eab7
[ "LicenseRef-scancode-mulanpsl-2.0-en", "LicenseRef-scancode-unknown-license-reference", "PostgreSQL", "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-unicode", "LicenseRef-scancode-warranty-disclaimer", "curl", "GPL-1.0-or-later", "LGPL-2.1-or-later", "LGPL-2.1-only", "CC-BY-4.0", "LicenseRef-scancode-protobuf", "OpenSSL", "LicenseRef-scancode-generic-export-compliance", "X11-distribute-modifications-variant", "LicenseRef-scancode-other-permissive", "MIT", "NCSA", "Python-2.0", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "CC-BY-3.0", "LicenseRef-scancode-other-copyleft", "GPL-2.0-only", "BSL-1.0", "Apache-2.0", "LGPL-2.0-only", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Zlib" ]
permissive
opengauss-mirror/openGauss-server
a9c5a62908643492347830826c56da49f0942796
310e84631c68c8bf37b004148b66f94064f701e4
refs/heads/master
2023-07-26T19:29:12.495484
2023-07-17T12:23:32
2023-07-17T12:23:32
276,117,477
591
208
MulanPSL-2.0
2023-04-28T12:30:18
2020-06-30T14:08:59
C++
UTF-8
C
false
false
1,076
h
pgmsgevent.h
/* src/bin/pgevent/pgmsgevent.h */ /* */ /* Values are 32 bit values laid out as follows: */ /* */ /* 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 */ /* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 */ /* +---+-+-+-----------------------+-------------------------------+ */ /* |Sev|C|R| Facility | Code | */ /* +---+-+-+-----------------------+-------------------------------+ */ /* */ /* where */ /* */ /* Sev - is the severity code */ /* */ /* 00 - Success */ /* 01 - Informational */ /* 10 - Warning */ /* 11 - Error */ /* */ /* C - is the Customer code flag */ /* */ /* R - is a reserved bit */ /* */ /* Facility - is the facility code */ /* */ /* Code - is the facility's status code */ /* */ /* */ /* Define the facility codes */ /* */ /* */ /* Define the severity codes */ /* */ /* */ /* MessageId: PGWIN32_EVENTLOG_MSG */ /* */ /* MessageText: */ /* */ /* %1 */ /* */ #ifndef PGEVENT_PGMSGEVENT_H #define PGEVENT_PGMSGEVENT_H #define PGWIN32_EVENTLOG_MSG 0x00000000L #endif /* PGEVENT_PGMSGEVENT_H */
5aebcc8bcf80a10790357b38a1e8997d4253e16c
3816f1ba0ff7eca9cc324f4ad5ac8c5b54028eeb
/source/src/ports/nvdata/nvtcpip.h
a2659b9fd59d877ae9e716118e1c2ecef64f35ee
[ "BSD-3-Clause" ]
permissive
EIPStackGroup/OpENer
d70064ad8d99406afab648a5985aacf3f3ef38fe
fc0179e9969a85a20fb907e3043062755b7a38d2
refs/heads/master
2023-08-26T10:09:49.085224
2022-03-08T21:05:02
2023-07-11T16:57:43
12,129,915
573
263
NOASSERTION
2023-09-03T21:47:47
2013-08-15T08:22:41
C
UTF-8
C
false
false
562
h
nvtcpip.h
/******************************************************************************* * Copyright (c) 2019, Rockwell Automation, Inc. * All rights reserved. * ******************************************************************************/ /** @file nvtcpip.h * @brief This file provides the interface to handle TCP/IP object's NV data. * */ #ifndef _NVTCPIP_H_ #define _NVTCPIP_H_ #include "typedefs.h" #include "ciptcpipinterface.h" int NvTcpipLoad(CipTcpIpObject *p_tcp_ip); int NvTcpipStore(const CipTcpIpObject *p_tcp_ip); #endif /* _NVTCPIP_H_ */
4b0dcdb00cc208cbb8bee5c492576ccf1af60a7a
b14db9403f921df7ff32b884de73dad877243552
/src/h264.c
64d1df8879e813d7b98ac9814a6871589fe69887
[ "MIT" ]
permissive
elFarto/nvidia-vaapi-driver
a91d91e927779ea9c59a52b0b1a4bd3a44924127
cd54d4029490d6703de5a9080f1475e40efc242a
refs/heads/master
2023-09-04T11:47:26.834407
2023-08-26T20:47:20
2023-08-26T20:47:20
428,422,859
951
60
NOASSERTION
2023-09-11T07:11:32
2021-11-15T21:11:36
C
UTF-8
C
false
false
7,649
c
h264.c
#include "vabackend.h" #include <string.h> static void copyH264PicParam(NVContext *ctx, NVBuffer* buffer, CUVIDPICPARAMS *picParams) { VAPictureParameterBufferH264* buf = (VAPictureParameterBufferH264*) buffer->ptr; picParams->PicWidthInMbs = buf->picture_width_in_mbs_minus1 + 1; //int picParams->FrameHeightInMbs = buf->picture_height_in_mbs_minus1 + 1; //int ctx->renderTarget->progressiveFrame = !buf->pic_fields.bits.field_pic_flag; picParams->field_pic_flag = buf->pic_fields.bits.field_pic_flag; picParams->bottom_field_flag = (buf->CurrPic.flags & VA_PICTURE_H264_BOTTOM_FIELD) != 0; picParams->second_field = (buf->CurrPic.flags & VA_PICTURE_H264_TOP_FIELD) != 0 && (buf->CurrPic.flags & VA_PICTURE_H264_BOTTOM_FIELD) != 0; picParams->ref_pic_flag = buf->pic_fields.bits.reference_pic_flag; picParams->intra_pic_flag = 1; //this is set to 0 in copyH264SliceParam picParams->CodecSpecific.h264.log2_max_frame_num_minus4 = buf->seq_fields.bits.log2_max_frame_num_minus4; picParams->CodecSpecific.h264.pic_order_cnt_type = buf->seq_fields.bits.pic_order_cnt_type; picParams->CodecSpecific.h264.log2_max_pic_order_cnt_lsb_minus4 = buf->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4; picParams->CodecSpecific.h264.delta_pic_order_always_zero_flag = buf->seq_fields.bits.delta_pic_order_always_zero_flag; picParams->CodecSpecific.h264.frame_mbs_only_flag = buf->seq_fields.bits.frame_mbs_only_flag; picParams->CodecSpecific.h264.direct_8x8_inference_flag = buf->seq_fields.bits.direct_8x8_inference_flag; picParams->CodecSpecific.h264.num_ref_frames = buf->num_ref_frames; picParams->CodecSpecific.h264.residual_colour_transform_flag = buf->seq_fields.bits.residual_colour_transform_flag; picParams->CodecSpecific.h264.bit_depth_luma_minus8 = buf->bit_depth_luma_minus8; picParams->CodecSpecific.h264.bit_depth_chroma_minus8 = buf->bit_depth_chroma_minus8; picParams->CodecSpecific.h264.entropy_coding_mode_flag = buf->pic_fields.bits.entropy_coding_mode_flag; picParams->CodecSpecific.h264.pic_order_present_flag = buf->pic_fields.bits.pic_order_present_flag; picParams->CodecSpecific.h264.weighted_pred_flag = buf->pic_fields.bits.weighted_pred_flag; picParams->CodecSpecific.h264.weighted_bipred_idc = buf->pic_fields.bits.weighted_bipred_idc; picParams->CodecSpecific.h264.pic_init_qp_minus26 = buf->pic_init_qp_minus26; picParams->CodecSpecific.h264.deblocking_filter_control_present_flag = buf->pic_fields.bits.deblocking_filter_control_present_flag; picParams->CodecSpecific.h264.redundant_pic_cnt_present_flag = buf->pic_fields.bits.redundant_pic_cnt_present_flag; picParams->CodecSpecific.h264.transform_8x8_mode_flag = buf->pic_fields.bits.transform_8x8_mode_flag; picParams->CodecSpecific.h264.MbaffFrameFlag = buf->seq_fields.bits.mb_adaptive_frame_field_flag && !picParams->field_pic_flag; picParams->CodecSpecific.h264.constrained_intra_pred_flag = buf->pic_fields.bits.constrained_intra_pred_flag; picParams->CodecSpecific.h264.chroma_qp_index_offset = buf->chroma_qp_index_offset; picParams->CodecSpecific.h264.second_chroma_qp_index_offset = buf->second_chroma_qp_index_offset; picParams->CodecSpecific.h264.ref_pic_flag = buf->pic_fields.bits.reference_pic_flag; picParams->CodecSpecific.h264.frame_num = buf->frame_num; picParams->CodecSpecific.h264.CurrFieldOrderCnt[0] = buf->CurrPic.TopFieldOrderCnt; picParams->CodecSpecific.h264.CurrFieldOrderCnt[1] = buf->CurrPic.BottomFieldOrderCnt; for (int i = 0; i < 16; i++) { if (!(buf->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID)) { picParams->CodecSpecific.h264.dpb[i].PicIdx = pictureIdxFromSurfaceId(ctx->drv, buf->ReferenceFrames[i].picture_id); picParams->CodecSpecific.h264.dpb[i].FrameIdx = buf->ReferenceFrames[i].frame_idx; picParams->CodecSpecific.h264.dpb[i].FieldOrderCnt[0] = buf->ReferenceFrames[i].TopFieldOrderCnt; picParams->CodecSpecific.h264.dpb[i].FieldOrderCnt[1] = buf->ReferenceFrames[i].BottomFieldOrderCnt; picParams->CodecSpecific.h264.dpb[i].is_long_term = (buf->ReferenceFrames[i].flags & VA_PICTURE_H264_LONG_TERM_REFERENCE) != 0; picParams->CodecSpecific.h264.dpb[i].not_existing = 0; int tmp = 0; if ((buf->ReferenceFrames[i].flags & VA_PICTURE_H264_TOP_FIELD) != 0) tmp |= 1; if ((buf->ReferenceFrames[i].flags & VA_PICTURE_H264_BOTTOM_FIELD) != 0) tmp |= 2; if (tmp == 0) { tmp = 3; //TODO seems to look better with a hardcoded 3 } picParams->CodecSpecific.h264.dpb[i].used_for_reference = tmp; } else { picParams->CodecSpecific.h264.dpb[i].PicIdx = -1; } } } static void copyH264SliceParam(NVContext *ctx, NVBuffer* buffer, CUVIDPICPARAMS *picParams) { VASliceParameterBufferH264* buf = (VASliceParameterBufferH264*) buffer->ptr; picParams->CodecSpecific.h264.num_ref_idx_l0_active_minus1 = buf->num_ref_idx_l0_active_minus1; picParams->CodecSpecific.h264.num_ref_idx_l1_active_minus1 = buf->num_ref_idx_l1_active_minus1; if (buf->slice_type != 2 && buf->slice_type != 4) { // != I && != SI picParams->intra_pic_flag = 0; } ctx->lastSliceParams = buffer->ptr; ctx->lastSliceParamsCount = buffer->elements; picParams->nNumSlices += buffer->elements; } static void copyH264SliceData(NVContext *ctx, NVBuffer* buf, CUVIDPICPARAMS *picParams) { for (unsigned int i = 0; i < ctx->lastSliceParamsCount; i++) { static const uint8_t header[] = { 0, 0, 1 }; //1 as a 24-bit Big Endian VASliceParameterBufferH264 *sliceParams = &((VASliceParameterBufferH264*) ctx->lastSliceParams)[i]; uint32_t offset = (uint32_t) ctx->bitstreamBuffer.size; appendBuffer(&ctx->sliceOffsets, &offset, sizeof(offset)); appendBuffer(&ctx->bitstreamBuffer, header, sizeof(header)); appendBuffer(&ctx->bitstreamBuffer, PTROFF(buf->ptr, sliceParams->slice_data_offset), sliceParams->slice_data_size); picParams->nBitstreamDataLen += sliceParams->slice_data_size + 3; } } static void copyH264IQMatrix(NVContext *ctx, NVBuffer* buf, CUVIDPICPARAMS *picParams) { VAIQMatrixBufferH264 *iq = (VAIQMatrixBufferH264*) buf->ptr; memcpy(picParams->CodecSpecific.h264.WeightScale4x4, iq->ScalingList4x4, sizeof(iq->ScalingList4x4)); memcpy(picParams->CodecSpecific.h264.WeightScale8x8, iq->ScalingList8x8, sizeof(iq->ScalingList8x8)); } static cudaVideoCodec computeH264CudaCodec(VAProfile profile) { //cudaVideoCodec_H264_SVC missing in VA-API? if (profile == VAProfileH264ConstrainedBaseline || profile == VAProfileH264Main || profile == VAProfileH264High) { return cudaVideoCodec_H264; } //if (profile == VAProfileH264StereoHigh || profile == VAProfileH264MultiviewHigh) { // return cudaVideoCodec_H264_MVC; //} return cudaVideoCodec_NONE; } static const VAProfile h264SupportedProfiles[] = { VAProfileH264ConstrainedBaseline, VAProfileH264Main, VAProfileH264High, }; const DECLARE_CODEC(h264Codec) = { .computeCudaCodec = computeH264CudaCodec, .handlers = { [VAPictureParameterBufferType] = copyH264PicParam, [VAIQMatrixBufferType] = copyH264IQMatrix, [VASliceParameterBufferType] = copyH264SliceParam, [VASliceDataBufferType] = copyH264SliceData, }, .supportedProfileCount = ARRAY_SIZE(h264SupportedProfiles), .supportedProfiles = h264SupportedProfiles, };
befc04e342bbef6e730a7095dfbb2dc300ce99cb
e08313883c08d4f41ed3dafd5394f408f309aa92
/swf/avm1_globals.c
6fe8577352191f5a30194aca0a048240536f4637
[ "CC0-1.0" ]
permissive
lieff/lvg
b48276d0e21a994baf6a2522c028509c7c20516d
753c17187e66ac4456202fdac3568467153a6c20
refs/heads/master
2022-09-10T03:48:43.768487
2022-08-16T13:51:38
2022-08-16T14:29:54
64,092,051
115
10
null
null
null
null
UTF-8
C
false
false
31,368
c
avm1_globals.c
#include "avm1.h" #include <assert.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <platform/platform.h> ASMember g_stage_members[] = { // properties { "align", { { "" }, ASVAL_STRING } }, { "displayState", { { "" }, ASVAL_STRING } }, { "fullScreenSourceRect", { { .str = 0 }, ASVAL_CLASS } }, { "height", { { .ui32 = 150 }, ASVAL_INT } }, { "scaleMode", { { "showAll" }, ASVAL_STRING } }, { "showMenu", { { .boolean = 0 }, ASVAL_BOOL } }, { "width", { { .ui32 = 200 }, ASVAL_INT } }, // events { "onFullScreen", { { .str = 0 }, ASVAL_FUNCTION } }, { "onResize", { { .str = 0 }, ASVAL_FUNCTION } }, // static methods { "addListener", { { .str = 0 }, ASVAL_NATIVE_FN } }, { "removeListener", { { .str = 0 }, ASVAL_NATIVE_FN } }, }; ASClass g_stage = { "Stage", &g_stage_members[0], 0, sizeof(g_stage_members)/sizeof(g_stage_members[0]), 0 }; static void math_abs(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, fabs(va)); } static void math_acos(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, acos(va)); } static void math_asin(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, asin(va)); } static void math_atan(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, atan(va)); } static void math_atan2(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; ASVal *se_b = se_a + 1; ctx->stack_ptr++; double va = to_double(ctx, se_a); double vb = to_double(ctx, se_b); ASVal *res = &ctx->stack[ctx->stack_ptr]; SET_DOUBLE(res, atan2(va, vb)); } static void math_ceil(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, ceil(va)); } static void math_cos(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, cos(va)); } static void math_exp(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, exp(va)); } static void math_floor(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, floor(va)); } static void math_log(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, exp(va)); } static void math_max(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; ASVal *se_b = se_a + 1; ctx->stack_ptr++; double va = to_double(ctx, se_a); double vb = to_double(ctx, se_b); ASVal *res = &ctx->stack[ctx->stack_ptr]; SET_DOUBLE(res, fmax(va, vb)); } static void math_min(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; ASVal *se_b = se_a + 1; ctx->stack_ptr++; double va = to_double(ctx, se_a); double vb = to_double(ctx, se_b); ASVal *res = &ctx->stack[ctx->stack_ptr]; SET_DOUBLE(res, fmin(va, vb)); } static void math_pow(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; ASVal *se_b = se_a + 1; ctx->stack_ptr++; double va = to_double(ctx, se_a); double vb = to_double(ctx, se_b); ASVal *res = &ctx->stack[ctx->stack_ptr]; SET_DOUBLE(res, pow(va, vb)); } static void math_random(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ctx->stack_ptr--; ASVal *res = &ctx->stack[ctx->stack_ptr]; SET_DOUBLE(res, (double)rand()/(double)RAND_MAX); } static void math_round(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, floor(va + 0.5)); } static void math_sin(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, sin(va)); } static void math_sqrt(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, sin(va)); } static void math_tan(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_a = &ctx->stack[ctx->stack_ptr]; double va = to_double(ctx, se_a); SET_DOUBLE(se_a, sin(va)); } ASMember g_math_members[] = { // properties { "E", { { .d_int = M_E }, ASVAL_DOUBLE } }, { "LN10", { { .d_int = M_LN10 }, ASVAL_DOUBLE } }, { "LN2", { { .d_int = M_LN2 }, ASVAL_DOUBLE } }, { "LOG10E", { { .d_int = M_LOG10E }, ASVAL_DOUBLE } }, { "LOG2E", { { .d_int = M_LOG2E }, ASVAL_DOUBLE } }, { "PI", { { .d_int = M_PI }, ASVAL_DOUBLE } }, { "SQRT1_2", { { .d_int = M_SQRT1_2 }, ASVAL_DOUBLE } }, { "SQRT2", { { .d_int = M_SQRT2 }, ASVAL_DOUBLE } }, // static methods { "abs", { { .fn = math_abs }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "acos", { { .fn = math_acos }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "asin", { { .fn = math_asin }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "atan", { { .fn = math_atan }, ASVAL_NATIVE_FN } }, //(tangent:Number) : Number { "atan2", { { .fn = math_atan2 }, ASVAL_NATIVE_FN } }, //(y:Number, x:Number) : Number { "ceil", { { .fn = math_ceil }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "cos", { { .fn = math_cos }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "exp", { { .fn = math_exp }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "floor", { { .fn = math_floor }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "log", { { .fn = math_log }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "max", { { .fn = math_max }, ASVAL_NATIVE_FN } }, //(x:Number, y:Number) : Number { "min", { { .fn = math_min }, ASVAL_NATIVE_FN } }, //(x:Number, y:Number) : Number { "pow", { { .fn = math_pow }, ASVAL_NATIVE_FN } }, //(x:Number, y:Number) : Number { "random", { { .fn = math_random }, ASVAL_NATIVE_FN } }, //() : Number { "round", { { .fn = math_round }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "sin", { { .fn = math_sin }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "sqrt", { { .fn = math_sqrt }, ASVAL_NATIVE_FN } }, //(x:Number) : Number { "tan", { { .fn = math_tan }, ASVAL_NATIVE_FN } }, //(x:Number) : Number }; ASClass g_math = { "Math", &g_math_members[0], 0, sizeof(g_math_members)/sizeof(g_math_members[0]), 0 }; static void string_length(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { assert(1 == nargs); ASVal *res = &ctx->stack[ctx->stack_ptr]; const char *str = (const char *)cls; SET_INT(res, strlen(str)); } static void string_substr(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { assert(2 == nargs); ASVal *se_start = &ctx->stack[ctx->stack_ptr]; //ASVal *se_len = se_start + 1; ctx->stack_ptr += 1; ASVal *res = &ctx->stack[ctx->stack_ptr]; uint32_t start = to_int(se_start); //uint32_t len = to_int(se_len); const char *str = (const char *)cls; uint32_t max_len = strlen(str); if (start > max_len) start = max_len; SET_STRING(res, str + start); // TODO: allocate new string and use len } ASMember g_string_members[] = { // properties { "length", { { .fn = string_length }, ASVAL_NATIVE_FN } }, // methods { "charAt", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(index: Number) : String { "charCodeAt", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(index: Number) : Number { "concat", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(value: Object) : String { "fromCharCode", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //() : String { "indexOf", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(value: String, [startIndex: Number]) : Number { "lastIndexOf", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(value: String, [startIndex: Number]) : Number { "slice", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(start: Number, end: Number) : String { "split", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(delimiter: String, [limit: Number]) : Array { "substr", { { .fn = string_substr }, ASVAL_NATIVE_FN } }, //(start: Number, length: Number) : String { "substring", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(start: Number, end: Number) : String { "toLowerCase", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //() : String { "toString", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //() : String { "toUpperCase", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //() : String { "valueOf", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //() : String }; ASClass g_string = { "String", &g_string_members[0], 0, sizeof(g_string_members)/sizeof(g_string_members[0]), 0 }; ASMember g_number_members[] = { // properties { "MAX_VALUE", { { .d_int = 0 }, ASVAL_DOUBLE } }, //: Number { "MIN_VALUE", { { .d_int = 0 }, ASVAL_DOUBLE } }, //: Number { "NaN", { { .d_int = NAN }, ASVAL_DOUBLE } }, //: Number { "NEGATIVE_INFINITY", { { .d_int = -INFINITY }, ASVAL_DOUBLE } }, //: Number { "POSITIVE_INFINITY", { { .d_int = INFINITY }, ASVAL_DOUBLE } }, //: Number // methods { "toString", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(radix: Number) : String { "valueOf", { { .fn = 0 }, ASVAL_NATIVE_FN } } //() : Number }; ASClass g_number = { "Number", &g_number_members[0], 0, sizeof(g_number_members)/sizeof(g_number_members[0]), 0 }; ASMember g_key_members[] = { // properties { "BACKSPACE", { { .ui32 = 8 }, ASVAL_INT } }, //: Number { "CAPSLOCK", { { .ui32 = 20 }, ASVAL_INT } }, //: Number { "CONTROL", { { .ui32 = 17 }, ASVAL_INT } }, //: Number { "DELETEKEY", { { .ui32 = 46 }, ASVAL_INT } }, //: Number { "DOWN", { { .ui32 = 40 }, ASVAL_INT } }, //: Number { "END", { { .ui32 = 35 }, ASVAL_INT } }, //: Number { "ENTER", { { .ui32 = 13 }, ASVAL_INT } }, //: Number { "ESCAPE", { { .ui32 = 27 }, ASVAL_INT } }, //: Number { "HOME", { { .ui32 = 36 }, ASVAL_INT } }, //: Number { "INSERT", { { .ui32 = 45 }, ASVAL_INT } }, //: Number { "LEFT", { { .ui32 = 37 }, ASVAL_INT } }, //: Number { "_listeners", { { .ui32 = 0 }, ASVAL_INT } }, //: Array [read-only] { "PGDN", { { .ui32 = 34 }, ASVAL_INT } }, //: Number { "PGUP", { { .ui32 = 33 }, ASVAL_INT } }, //: Number { "RIGHT", { { .ui32 = 39 }, ASVAL_INT } }, //: Number { "SHIFT", { { .ui32 = 16 }, ASVAL_INT } }, //: Number { "SPACE", { { .ui32 = 32 }, ASVAL_INT } }, //: Number { "TAB", { { .ui32 = 9 }, ASVAL_INT } }, //: Number { "UP", { { .ui32 = 38 }, ASVAL_INT } }, //: Number // methods { "addListener", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(listener: Object) : Void { "getAscii", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //() : Number { "getCode", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //() : Number { "isAccessible", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //() : Boolean { "isDown", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(code: Number) : Boolean { "isToggled", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(code: Number) : Boolean { "removeListener", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(listener: Object) : Boolean // events { "onKeyDown", { { .fn = 0 }, ASVAL_FUNCTION } }, // = function() {} { "onKeyUp", { { .fn = 0 }, ASVAL_FUNCTION } } // = function() {} }; ASClass g_key = { "Key", &g_key_members[0], 0, sizeof(g_key_members)/sizeof(g_key_members[0]), 0 }; ASMember g_object_members[] = { // properties { "constructor", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //: Object { "__proto__", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //: Object { "prototype", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //: Object { "__resolve", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //: Object // methods { "addProperty", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(name: String, getter: Function, setter: Function) : Boolean { "hasOwnProperty", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(name: String) : Boolean { "isPropertyEnumerable", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(name: String) : Boolean { "isPrototypeOf", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(theClass: Object) : Boolean { "registerClass", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(name: String, theClass: Function) : Boolean { "toString", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //() : String { "unwatch", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(name: String) : Boolean { "valueOf", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //() : Object { "watch", { { .fn = 0 }, ASVAL_NATIVE_FN } }, //(name: String, callback: Function, [userData: Object]) : Boolean }; ASClass g_object = { "Object", &g_object_members[0], 0, sizeof(g_object_members)/sizeof(g_object_members[0]), 0 }; ASVal g_classes[] = { { { .cls = &g_object }, ASVAL_CLASS }, { { .cls = &g_stage }, ASVAL_CLASS }, { { .cls = &g_math }, ASVAL_CLASS }, { { .cls = &g_number }, ASVAL_CLASS }, { { .cls = &g_key }, ASVAL_CLASS } }; int g_num_classes = sizeof(g_classes)/sizeof(g_classes[0]); static void createEmptyMovieClip(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { ASVal *se_name = &ctx->stack[ctx->stack_ptr]; #ifdef _DEBUG ASVal *se_depth = se_name + 1; assert(ASVAL_INT == se_depth->type || ASVAL_DOUBLE == se_depth->type || ASVAL_FLOAT == se_depth->type); #endif assert(ASVAL_STRING == se_name->type); ASVal *loc = create_local(ctx, THIS, se_name->str); loc->type = ASVAL_UNDEFINED; loc->str = 0; ASVal *res = result_val(ctx, nargs); *res = *loc; } static void getBytesLoaded(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { assert(0 == nargs); ASVal *res = result_val(ctx, nargs); SET_DOUBLE(res, 100.0); } static void do_gotoAndPlay(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { assert(1 == nargs); ASVal *se_frame = &ctx->stack[ctx->stack_ptr]; assert(ASVAL_INT == se_frame->type || ASVAL_DOUBLE == se_frame->type || ASVAL_FLOAT == se_frame->type || ASVAL_STRING == se_frame->type); LVGMovieClipGroupState *groupstate = ctx->clip->groupstates + (size_t)cls->priv; LVGMovieClipGroup *group = ctx->clip->groups + groupstate->group_num; uint32_t frame = -1; if (ASVAL_STRING == se_frame->type) { LVGFrameLabel *l = group->labels; for (int i = 0; i < group->num_labels; i++) if (0 == strcasecmp(l[i].name, se_frame->str)) { frame = l[i].frame_num; break; } if (frame == (uint32_t)-1) return; } else frame = to_int(se_frame); groupstate->cur_frame = frame % group->num_frames; } static void gotoAndPlay(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { do_gotoAndPlay(ctx, cls, a, nargs); LVGMovieClipGroupState *groupstate = ctx->clip->groupstates + (size_t)cls->priv; groupstate->play_state = LVG_PLAYING; handle_frame_change(ctx, groupstate); } static void gotoAndStop(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { do_gotoAndPlay(ctx, cls, a, nargs); LVGMovieClipGroupState *groupstate = ctx->clip->groupstates + (size_t)cls->priv; groupstate->play_state = LVG_STOPPED; handle_frame_change(ctx, groupstate); } static void play(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { assert(0 == nargs); ASVal *res = result_val(ctx, nargs); SET_UNDEF(res); LVGMovieClipGroupState *groupstate = ctx->clip->groupstates + (size_t)cls->priv; groupstate->play_state = LVG_PLAYING; handle_frame_change(ctx, groupstate); } static void stop(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { assert(0 == nargs); ASVal *res = result_val(ctx, nargs); SET_UNDEF(res); LVGMovieClipGroupState *groupstate = ctx->clip->groupstates + (size_t)cls->priv; groupstate->play_state = LVG_STOPPED; handle_frame_change(ctx, groupstate); } ASMember g_movieclip_members[] = { // properties { "_alpha", { { .d_int = 1.0 }, ASVAL_DOUBLE } }, //Number { "blendMode", { { "normal" }, ASVAL_STRING } }, //Object { "cacheAsBitmap", { { "" }, ASVAL_STRING } }, //Boolean { "_currentframe", { { .ui32 = 0 }, ASVAL_INT } }, //Number [read-only] { "_droptarget", { { "" }, ASVAL_STRING } }, //String [read-only] { "enabled", { { "" }, ASVAL_STRING } }, //Boolean { "filters", { { "" }, ASVAL_STRING } }, //Array { "focusEnabled", { { "" }, ASVAL_STRING } }, //Boolean { "_focusrect", { { "" }, ASVAL_STRING } }, //Boolean { "forceSmoothing", { { "" }, ASVAL_STRING } }, //Boolean { "_framesloaded", { { .ui32 = 0 }, ASVAL_INT } }, //Number [read-only] { "_height", { { "" }, ASVAL_STRING } }, //Number { "_highquality", { { "" }, ASVAL_STRING } }, //Number { "hitArea", { { "" }, ASVAL_STRING } }, //Object { "_lockroot", { { "" }, ASVAL_STRING } }, //Boolean { "menu", { { "" }, ASVAL_STRING } }, //ContextMenu { "_name", { { "" }, ASVAL_STRING } }, //String { "opaqueBackground", { { "" }, ASVAL_STRING } }, //Number { "_parent", { { "" }, ASVAL_STRING } }, //MovieClip { "_quality", { { "" }, ASVAL_STRING } }, //String { "_rotation", { { "" }, ASVAL_STRING } }, //Number { "scale9Grid", { { "" }, ASVAL_STRING } }, //Rectangle { "scrollRect", { { "" }, ASVAL_STRING } }, //Object { "_soundbuftime", { { "" }, ASVAL_STRING } }, //Number { "tabChildren", { { "" }, ASVAL_STRING } }, //Boolean { "tabEnabled", { { "" }, ASVAL_STRING } }, //Boolean { "tabIndex", { { "" }, ASVAL_STRING } }, //Number { "_target", { { "" }, ASVAL_STRING } }, //String [read-only] { "_totalframes", { { .ui32 = 0 }, ASVAL_INT } }, //Number [read-only] { "trackAsMenu", { { "" }, ASVAL_STRING } }, //Boolean { "transform" , { { "" }, ASVAL_STRING } }, //Transform { "_url", { { "" }, ASVAL_STRING } }, //String [read-only] { "useHandCursor", { { "" }, ASVAL_STRING } }, //Boolean { "_visible", { { .boolean = 1 }, ASVAL_BOOL } }, //Boolean { "_width", { { "" }, ASVAL_STRING } }, //Number { "_x", { { "" }, ASVAL_STRING } }, //Number { "_xmouse", { { "" }, ASVAL_STRING } }, //Number [read-only] { "_xscale", { { .i32 = 100 }, ASVAL_INT } }, //Number { "_y", { { "" }, ASVAL_STRING } }, //Number { "_ymouse", { { "" }, ASVAL_STRING } }, //Number [read-only] { "_yscale", { { "" }, ASVAL_STRING } }, //Number // events { "onData", { { .str = 0 }, ASVAL_FUNCTION } }, { "onDragOut", { { .str = 0 }, ASVAL_FUNCTION } }, { "onDragOver", { { .str = 0 }, ASVAL_FUNCTION } }, { "onEnterFrame", { { .str = 0 }, ASVAL_FUNCTION } }, { "onKeyDown", { { .str = 0 }, ASVAL_FUNCTION } }, { "onKeyUp", { { .str = 0 }, ASVAL_FUNCTION } }, { "onKillFocus", { { .str = 0 }, ASVAL_FUNCTION } }, { "onLoad", { { .str = 0 }, ASVAL_FUNCTION } }, { "onMouseDown", { { .str = 0 }, ASVAL_FUNCTION } }, { "onMouseMove", { { .str = 0 }, ASVAL_FUNCTION } }, { "onMouseUp", { { .str = 0 }, ASVAL_FUNCTION } }, { "onPress", { { .str = 0 }, ASVAL_FUNCTION } }, { "onRelease", { { .str = 0 }, ASVAL_FUNCTION } }, { "onReleaseOutside", { { .str = 0 }, ASVAL_FUNCTION } }, { "onRollOut", { { .str = 0 }, ASVAL_FUNCTION } }, { "onRollOver", { { .str = 0 }, ASVAL_FUNCTION } }, { "onSetFocus", { { .str = 0 }, ASVAL_FUNCTION } }, { "onUnload", { { .str = 0 }, ASVAL_FUNCTION } }, // methods { "attachAudio", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(id: Object) : Void { "attachBitmap", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(bmp: BitmapData, depth: Number, [pixelSnapping: String], [smoothing: Boolean]) : Void { "attachMovie", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(id: String, name: String, depth: Number, [initObject: Object]) : MovieClip { "beginBitmapFill", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(bmp: BitmapData, [matrix: Matrix], [repeat: Boolean], [smoothing: Boolean]) : Void { "beginFill", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(rgb: Number, [alpha: Number]) : Void { "beginGradientFill", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(fillType: String, colors: Array, alphas: Array, ratios: Array, matrix: Object, [spreadMethod: String], [interpolationMethod: String], [focalPointRatio: Number]) : Void { "clear", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Void { "createEmptyMovieClip", { { .fn = createEmptyMovieClip }, ASVAL_NATIVE_FN } }, //(name: String, depth: Number) : MovieClip { "createTextField", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(instanceName: String, depth: Number, x: Number, y: Number, width: Number, height: Number) : TextField { "curveTo", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(controlX: Number, controlY: Number, anchorX: Number, anchorY: Number) : Void { "duplicateMovieClip", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(name: String, depth: Number, [initObject: Object]) : MovieClip { "endFill", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Void { "getBounds", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(bounds: Object) : Object { "getBytesLoaded", { { .fn = getBytesLoaded }, ASVAL_NATIVE_FN } }, //() : Number { "getBytesTotal", { { .fn = getBytesLoaded }, ASVAL_NATIVE_FN } }, //() : Number { "getDepth", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Number { "getInstanceAtDepth", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(depth: Number) : MovieClip { "getNextHighestDepth", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Number { "getRect", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(bounds: Object) : Object { "getSWFVersion", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Number { "getTextSnapshot", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : TextSnapshot { "getURL", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(url: String, [window: String], [method: String]) : Void { "globalToLocal", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(pt: Object) : Void { "gotoAndPlay", { { .fn = gotoAndPlay }, ASVAL_NATIVE_FN } }, //(frame: Object) : Void { "gotoAndStop", { { .fn = gotoAndStop }, ASVAL_NATIVE_FN } }, //(frame: Object) : Void { "hitTest", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Boolean { "lineGradientStyle", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(fillType: String, colors: Array, alphas: Array, ratios: Array, matrix: Object, [spreadMethod: String], [interpolationMethod: String], [focalPointRatio: Number]) : Void { "lineStyle", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(thickness: Number, rgb: Number, alpha: Number, pixelHinting: Boolean, noScale: String, capsStyle: String, jointStyle: String, miterLimit: Number) : Void { "lineTo", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(x: Number, y: Number) : Void { "loadMovie", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(url: String, [method: String]) : Void { "loadVariables", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(url: String, [method: String]) : Void { "localToGlobal", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(pt: Object) : Void { "moveTo", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(x: Number, y: Number) : Void { "nextFrame", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Void { "play", { { .fn = play }, ASVAL_NATIVE_FN } }, //() : Void { "prevFrame", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Void { "removeMovieClip", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Void { "setMask", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(mc: Object) : Void { "startDrag", { { .str = 0 }, ASVAL_NATIVE_FN } }, //([lockCenter: Boolean], [left: Number], [top: Number], [right: Number], [bottom: Number]) : Void { "stop", { { .fn = stop }, ASVAL_NATIVE_FN } }, //() : Void { "stopDrag", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Void { "swapDepths", { { .str = 0 }, ASVAL_NATIVE_FN } }, //(target: Object) : Void { "unloadMovie", { { .str = 0 }, ASVAL_NATIVE_FN } }, //() : Void }; ASClass g_movieclip = { "MovieClip", &g_movieclip_members[0], 0, sizeof(g_movieclip_members)/sizeof(g_movieclip_members[0]), 0 }; ASMember g_button_members[] = { // properties { "_alpha", { { .d_int = 1.0 }, ASVAL_DOUBLE } }, //: Number { "blendMode", { { "normal" }, ASVAL_STRING } }, //: Object { "cacheAsBitmap", { { "" }, ASVAL_STRING } }, //: Boolean { "enabled", { { "" }, ASVAL_STRING } }, //: Boolean { "filters", { { "" }, ASVAL_STRING } }, //: Array { "_focusrect", { { "" }, ASVAL_STRING } }, //: Boolean { "_height", { { "" }, ASVAL_STRING } }, //: Number { "_highquality", { { "" }, ASVAL_STRING } }, //: Number { "menu", { { "" }, ASVAL_STRING } }, //: ContextMenu { "_name", { { "" }, ASVAL_STRING } }, //: String { "_parent", { { "" }, ASVAL_STRING } }, //: MovieClip { "_quality", { { "" }, ASVAL_STRING } }, //: String { "_rotation", { { "" }, ASVAL_STRING } }, //: Number { "scale9Grid", { { "" }, ASVAL_STRING } }, //: Rectangle { "_soundbuftime", { { "" }, ASVAL_STRING } }, //: Number { "tabEnabled", { { "" }, ASVAL_STRING } }, //: Boolean { "tabIndex", { { "" }, ASVAL_STRING } }, //: Number { "_target", { { "" }, ASVAL_STRING } }, //: String [read-only] { "trackAsMenu", { { "" }, ASVAL_STRING } }, //: Boolean { "_url", { { "" }, ASVAL_STRING } }, //: String [read-only] { "useHandCursor", { { "" }, ASVAL_STRING } }, //: Boolean { "_visible", { { .boolean = 1 }, ASVAL_BOOL } }, //: Boolean { "_width", { { "" }, ASVAL_STRING } }, //: Number { "_x", { { "" }, ASVAL_STRING } }, //: Number { "_xmouse", { { "" }, ASVAL_STRING } }, //: Number [read-only] { "_xscale", { { "" }, ASVAL_STRING } }, //: Number { "_y", { { "" }, ASVAL_STRING } }, //: Number { "_ymouse", { { "" }, ASVAL_STRING } }, //: Number [read-only] { "_yscale", { { "" }, ASVAL_STRING } }, //: Number // events { "onDragOut", { { .str = 0 }, ASVAL_FUNCTION } }, // = function() {} { "onDragOver", { { .str = 0 }, ASVAL_FUNCTION } }, // = function() {} { "onKeyDown", { { .str = 0 }, ASVAL_FUNCTION } }, // = function() {} { "onKeyUp", { { .str = 0 }, ASVAL_FUNCTION } }, // = function() {} { "onKillFocus", { { .str = 0 }, ASVAL_FUNCTION } }, // = function(newFocus: Object) {} { "onPress", { { .str = 0 }, ASVAL_FUNCTION } }, // = function() {} { "onRelease", { { .str = 0 }, ASVAL_FUNCTION } }, // = function() {} { "onReleaseOutside", { { .str = 0 }, ASVAL_FUNCTION } }, // = function() {} { "onRollOut", { { .str = 0 }, ASVAL_FUNCTION } }, // = function() {} { "onRollOver", { { .str = 0 }, ASVAL_FUNCTION } }, // = function() {} { "onSetFocus", { { .str = 0 }, ASVAL_FUNCTION } }, // = function(oldFocus: Object) {} // methods { "getDepth", { { .ui32 = 0 }, ASVAL_INT } } //() : Number }; ASClass g_button = { "Button", &g_button_members[0], 0, sizeof(g_button_members)/sizeof(g_button_members[0]), 0 }; static void setInterval(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { assert(2 == nargs); ASVal *se_func = &ctx->stack[ctx->stack_ptr]; ASVal *se_timeout = se_func + 1; assert(ASVAL_FUNCTION == se_func->type); assert(ASVAL_INT == se_timeout->type || ASVAL_DOUBLE == se_timeout->type || ASVAL_FLOAT == se_timeout->type); if (ctx->groupstate->num_timers > 10) { ASVal *res = result_val(ctx, nargs); SET_INT(res, 0); return; } ctx->groupstate->timers = realloc(ctx->groupstate->timers, (ctx->groupstate->num_timers + 1)*sizeof(ctx->groupstate->timers[0])); LVGTimer *t = ctx->groupstate->timers + ctx->groupstate->num_timers++; t->func = (uint8_t *)se_func->str; t->last_time = ctx->e->params.time; t->timeout = to_double(ctx, se_timeout); static int counter = 0; t->id = ++counter; ASVal *res = result_val(ctx, nargs); SET_INT(res, t->id); } static void clearInterval(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs) { assert(1 == nargs); ASVal *se_id = &ctx->stack[ctx->stack_ptr]; assert(ASVAL_INT == se_id->type || ASVAL_DOUBLE == se_id->type || ASVAL_FLOAT == se_id->type); int id = to_int(se_id); for (int i = 0; i < ctx->groupstate->num_timers; i++) if (ctx->groupstate->timers[i].id == id) { memmove(&ctx->groupstate->timers[i], &ctx->groupstate->timers[i + 1], (ctx->groupstate->num_timers - i - 1)*sizeof(ctx->groupstate->timers[0])); ctx->groupstate->num_timers--; ASVal *res = result_val(ctx, nargs); SET_UNDEF(res); return; } assert(0); } ASMember g_properties[] = { { "this", { { .str = 0 }, ASVAL_CLASS } }, { "_root", { { .str = 0 }, ASVAL_CLASS } }, { "_level0", { { .str = 0 }, ASVAL_CLASS } }, { "_accProps", { { .str = 0 }, ASVAL_CLASS } }, { "_focusrect", { { .str = 0 }, ASVAL_CLASS } }, { "_global", { { .str = 0 }, ASVAL_CLASS } }, { "_highquality", { { .str = 0 }, ASVAL_CLASS } }, { "_level", { { .str = 0 }, ASVAL_CLASS } }, { "maxscroll", { { .str = 0 }, ASVAL_CLASS } }, { "_parent", { { .str = 0 }, ASVAL_CLASS } }, { "_quality", { { .str = 0 }, ASVAL_CLASS } }, { "scroll", { { .str = 0 }, ASVAL_CLASS } }, { "_soundbuftime", { { .str = 0 }, ASVAL_CLASS } }, // math { "Infinity", { { .d_int = INFINITY }, ASVAL_DOUBLE } }, { "NaN", { { .d_int = NAN }, ASVAL_DOUBLE } }, // global functions { "setInterval", { { .fn = setInterval }, ASVAL_NATIVE_FN } }, { "clearInterval", { { .fn = clearInterval }, ASVAL_NATIVE_FN } } }; int g_num_properties = sizeof(g_properties)/sizeof(g_properties[0]);
0d3cb796bc004c037d417867b4a79cd8827f87d4
0f5244a66dd11060f9c35d49f22ca026d171e29c
/test/unit-test/vendor/ceedling/plugins/fake_function_framework/examples/fff_example/src/event_processor.h
a79e68c569a58c5a54ede0a8781bce4ab3015822
[ "MIT" ]
permissive
hathach/tinyusb
b5557037f1cb1763b280f308829ceea94d31f3ae
1fdf29075d4e613eacfa881166015263797db0f6
refs/heads/master
2023-08-22T10:14:47.526256
2023-08-16T09:01:16
2023-08-16T09:01:16
6,860,771
4,096
918
MIT
2023-09-14T07:22:16
2012-11-26T06:24:00
C
UTF-8
C
false
false
342
h
event_processor.h
#include <stdbool.h> void event_deviceReset(void); void event_volumeKnobMaxed(void); void event_powerReadingUpdate(int powerReading); void event_modeSelectButtonPressed(void); void event_devicePoweredOn(void); void event_keyboardCheckTimerExpired(void); void event_newDataAvailable(int data); bool eventProcessor_isLastEventComplete(void);
4fa2f49dcde47f238ddde3c072d71821b7bbd4bc
da1500e0d3040497614d5327d2461a22e934b4d8
/third_party/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
c7b6e842c9fac27b2885242d6c2cd48797bfe799
[ "NCSA", "MIT", "LLVM-exception", "Apache-2.0", "BSD-3-Clause", "GPL-1.0-or-later", "LGPL-2.0-or-later" ]
permissive
youtube/cobalt
34085fc93972ebe05b988b15410e99845efd1968
acefdaaadd3ef46f10f63d1acae2259e4024d383
refs/heads/main
2023-09-01T13:09:47.225174
2023-09-01T08:54:54
2023-09-01T08:54:54
50,049,789
169
80
BSD-3-Clause
2023-09-14T21:50:50
2016-01-20T18:11:34
null
UTF-8
C
false
false
3,880
c
InstrProfilingPlatformOther.c
/*===- InstrProfilingPlatformOther.c - Profile data default platform ------===*\ |* |* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |* See https://llvm.org/LICENSE.txt for license information. |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |* \*===----------------------------------------------------------------------===*/ #if !defined(__APPLE__) && !defined(__linux__) && !defined(__FreeBSD__) && \ !defined(__Fuchsia__) && !(defined(__sun__) && defined(__svr4__)) && \ !defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX) #include <stdlib.h> #include <stdio.h> #include "InstrProfiling.h" #include "InstrProfilingInternal.h" static const __llvm_profile_data *DataFirst = NULL; static const __llvm_profile_data *DataLast = NULL; static const char *NamesFirst = NULL; static const char *NamesLast = NULL; static char *CountersFirst = NULL; static char *CountersLast = NULL; static uint32_t *OrderFileFirst = NULL; static const void *getMinAddr(const void *A1, const void *A2) { return A1 < A2 ? A1 : A2; } static const void *getMaxAddr(const void *A1, const void *A2) { return A1 > A2 ? A1 : A2; } /*! * \brief Register an instrumented function. * * Calls to this are emitted by clang with -fprofile-instr-generate. Such * calls are only required (and only emitted) on targets where we haven't * implemented linker magic to find the bounds of the sections. */ COMPILER_RT_VISIBILITY void __llvm_profile_register_function(void *Data_) { /* TODO: Only emit this function if we can't use linker magic. */ const __llvm_profile_data *Data = (__llvm_profile_data *)Data_; if (!DataFirst) { DataFirst = Data; DataLast = Data + 1; CountersFirst = (char *)((uintptr_t)Data_ + Data->CounterPtr); CountersLast = CountersFirst + Data->NumCounters * __llvm_profile_counter_entry_size(); return; } DataFirst = (const __llvm_profile_data *)getMinAddr(DataFirst, Data); CountersFirst = (char *)getMinAddr( CountersFirst, (char *)((uintptr_t)Data_ + Data->CounterPtr)); DataLast = (const __llvm_profile_data *)getMaxAddr(DataLast, Data + 1); CountersLast = (char *)getMaxAddr( CountersLast, (char *)((uintptr_t)Data_ + Data->CounterPtr) + Data->NumCounters * __llvm_profile_counter_entry_size()); } COMPILER_RT_VISIBILITY void __llvm_profile_register_names_function(void *NamesStart, uint64_t NamesSize) { if (!NamesFirst) { NamesFirst = (const char *)NamesStart; NamesLast = (const char *)NamesStart + NamesSize; return; } NamesFirst = (const char *)getMinAddr(NamesFirst, NamesStart); NamesLast = (const char *)getMaxAddr(NamesLast, (const char *)NamesStart + NamesSize); } COMPILER_RT_VISIBILITY const __llvm_profile_data *__llvm_profile_begin_data(void) { return DataFirst; } COMPILER_RT_VISIBILITY const __llvm_profile_data *__llvm_profile_end_data(void) { return DataLast; } COMPILER_RT_VISIBILITY const char *__llvm_profile_begin_names(void) { return NamesFirst; } COMPILER_RT_VISIBILITY const char *__llvm_profile_end_names(void) { return NamesLast; } COMPILER_RT_VISIBILITY char *__llvm_profile_begin_counters(void) { return CountersFirst; } COMPILER_RT_VISIBILITY char *__llvm_profile_end_counters(void) { return CountersLast; } /* TODO: correctly set up OrderFileFirst. */ COMPILER_RT_VISIBILITY uint32_t *__llvm_profile_begin_orderfile(void) { return OrderFileFirst; } COMPILER_RT_VISIBILITY ValueProfNode *__llvm_profile_begin_vnodes(void) { return 0; } COMPILER_RT_VISIBILITY ValueProfNode *__llvm_profile_end_vnodes(void) { return 0; } COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = 0; COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = 0; COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) { return 0; } #endif
8dc5964cf2799cdc2d5cbefa8825058f3f874e8a
e5ec9a33aaca93a653df46e7d3c351ece1b4abc5
/3rdparty/include/mkl/mkl_trans.h
7c682f3ac6a05ab7a13577cf9a05cf996ffa1a77
[ "MIT" ]
permissive
zuoqing1988/ZQCNN
0b0dbe79acf3094c252e6016dca0dbf37134ce37
9c89e94debaa9a241d2ac0cbc7d32c7bb8436490
refs/heads/master
2022-08-28T08:09:58.698706
2022-08-22T04:20:27
2022-08-22T04:20:27
132,091,868
2,152
487
MIT
2020-10-23T07:37:06
2018-05-04T05:30:54
Objective-C
UTF-8
C
false
false
6,161
h
mkl_trans.h
/******************************************************************************* * Copyright (c) 2007-2018, Intel Corporation * 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 Intel Corporation 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. *******************************************************************************/ /* ! Content: ! Intel(R) Math Kernel Library (Intel(R) MKL) include for transposition routines !******************************************************************************/ #if !defined(_MKL_TRANS_H) #define _MKL_TRANS_H /* for size_t */ #include <stddef.h> #include "mkl_types.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* In-place transposition routines */ #define mkl_simatcopy MKL_Simatcopy void MKL_Simatcopy( const char ordering, const char trans, size_t rows, size_t cols, const float alpha, float * AB, size_t lda, size_t ldb); #define mkl_dimatcopy MKL_Dimatcopy void MKL_Dimatcopy( const char ordering, const char trans, size_t rows, size_t cols, const double alpha, double * AB, size_t lda, size_t ldb); #define mkl_cimatcopy MKL_Cimatcopy void MKL_Cimatcopy( const char ordering, const char trans, size_t rows, size_t cols, const MKL_Complex8 alpha, MKL_Complex8 * AB, size_t lda, size_t ldb); #define mkl_zimatcopy MKL_Zimatcopy void MKL_Zimatcopy( const char ordering, const char trans, size_t rows, size_t cols, const MKL_Complex16 alpha, MKL_Complex16 * AB, size_t lda, size_t ldb); /* Out-of-place transposition routines */ #define mkl_somatcopy MKL_Somatcopy void MKL_Somatcopy( char ordering, char trans, size_t rows, size_t cols, const float alpha, const float * A, size_t lda, float * B, size_t ldb); #define mkl_domatcopy MKL_Domatcopy void MKL_Domatcopy( char ordering, char trans, size_t rows, size_t cols, const double alpha, const double * A, size_t lda, double * B, size_t ldb); #define mkl_comatcopy MKL_Comatcopy void MKL_Comatcopy( char ordering, char trans, size_t rows, size_t cols, const MKL_Complex8 alpha, const MKL_Complex8 * A, size_t lda, MKL_Complex8 * B, size_t ldb); #define mkl_zomatcopy MKL_Zomatcopy void MKL_Zomatcopy( char ordering, char trans, size_t rows, size_t cols, const MKL_Complex16 alpha, const MKL_Complex16 * A, size_t lda, MKL_Complex16 * B, size_t ldb); /* Out-of-place transposition routines (all-strided case) */ #define mkl_somatcopy2 MKL_Somatcopy2 void MKL_Somatcopy2( char ordering, char trans, size_t rows, size_t cols, const float alpha, const float * A, size_t lda, size_t stridea, float * B, size_t ldb, size_t strideb); #define mkl_domatcopy2 MKL_Domatcopy2 void MKL_Domatcopy2( char ordering, char trans, size_t rows, size_t cols, const double alpha, const double * A, size_t lda, size_t stridea, double * B, size_t ldb, size_t strideb); #define mkl_comatcopy2 MKL_Comatcopy2 void MKL_Comatcopy2( char ordering, char trans, size_t rows, size_t cols, const MKL_Complex8 alpha, const MKL_Complex8 * A, size_t lda, size_t stridea, MKL_Complex8 * B, size_t ldb, size_t strideb); #define mkl_zomatcopy2 MKL_Zomatcopy2 void MKL_Zomatcopy2( char ordering, char trans, size_t rows, size_t cols, const MKL_Complex16 alpha, const MKL_Complex16 * A, size_t lda, size_t stridea, MKL_Complex16 * B, size_t ldb, size_t strideb); /* Out-of-place memory movement routines */ #define mkl_somatadd MKL_Somatadd void MKL_Somatadd( char ordering, char transa, char transb, size_t rows, size_t cols, const float alpha, const float * A, size_t lda, const float beta, const float * B, size_t ldb, float * C, size_t ldc); #define mkl_domatadd MKL_Domatadd void MKL_Domatadd( char ordering, char transa, char transb, size_t rows, size_t cols, const double alpha, const double * A, size_t lda, const double beta, const double * B, size_t ldb, double * C, size_t ldc); #define mkl_comatadd MKL_Comatadd void MKL_Comatadd( char ordering, char transa, char transb, size_t rows, size_t cols, const MKL_Complex8 alpha, const MKL_Complex8 * A, size_t lda, const MKL_Complex8 beta, const MKL_Complex8 * B, size_t ldb, MKL_Complex8 * C, size_t ldc); #define mkl_zomatadd MKL_Zomatadd void MKL_Zomatadd( char ordering, char transa, char transb, size_t rows, size_t cols, const MKL_Complex16 alpha, const MKL_Complex16 * A, size_t lda, const MKL_Complex16 beta, const MKL_Complex16 * B, size_t ldb, MKL_Complex16 * C, size_t ldc); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _MKL_TRANS_H */
c8f1dbb325d5b2a0cef8df88775a8d7f9e59b306
0744dcc5394cebf57ebcba343747af6871b67017
/os/board/rtl8730e/src/component/usb/host_new/cdc_ecm/usbh_cdc_ecm_hal.c
cea77cac47f9f9c246f932c77e7b0060af1ee0b6
[ "GPL-1.0-or-later", "BSD-3-Clause", "ISC", "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive", "Apache-2.0" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C
false
false
13,774
c
usbh_cdc_ecm_hal.c
/** ****************************************************************************** * @file usbh_cdc_ecm_hal.c * @author Realsil WLAN5 Team * @version V1.0.0 * @date 2023-01-13 * @brief This file provides the apis for USB CDC ECM host class ****************************************************************************** * @attention * * This module is a confidential and proprietary property of RealTek and * possession or use of this module requires written permission of RealTek. * * Copyright(c) 2023, Realtek Semiconductor Corporation. All rights reserved. ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include <platform_opts.h> #include <FreeRTOS.h> #include <task.h> #include <lwip/sockets.h> #include <lwip/netdb.h> #include "usbh_cdc_ecm.h" #include "usbh_cdc_ecm_hal.h" /* Private defines -----------------------------------------------------------*/ #define CONFIG_USBH_CDC_ECM_HOT_PLUG_TEST 1 /* Hot plug test */ #define USBH_CDC_ECM_INTR_BUF_SIZE 256 /* Buffer size for INTR loopback test, which should match with device INTR loopback buffer size */ #define USBH_CDC_ECM_LOOPBACK_CNT 100 /* Loopback test round */ #define USBH_CORE_INIT_FAIL (1) #define USBH_CLASS_INIT_FAIL (2) /* Private types -------------------------------------------------------------*/ #pragma pack(push) #pragma pack(1) typedef struct { usb_report_usbdata report_data; //usb rx callback function volatile u8 send_success; //usb tx send flag volatile u8 cdc_ecm_is_ready; //ecm attached status volatile u8 ecm_hw_connect; //ecm ethernet connect status:0 disconnect,1 connect volatile u8 ecm_init_success; //usb init success } usbh_cdc_ecm_host_hal_t; #pragma pack(pop) /* Private macros ------------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static u8 cdc_ecm_cb_init(void); static u8 cdc_ecm_cb_deinit(void); static u8 cdc_ecm_cb_attach(void); static u8 cdc_ecm_cb_detach(void); static u8 cdc_ecm_cb_setup(void); static u8 cdc_ecm_cb_process(usb_host_t *host, u8 id); static u8 cdc_ecm_cb_bulk_send(usbh_urb_state_t state); static u8 cdc_ecm_cb_bulk_receive(u8 *pbuf, u32 Len); static u8 cdc_ecm_cb_intr_receive(u8 *buf, u32 length); static u8 set_usbh_cdc_ecm_bulk_send_flag(u8 flag); static u8 usbh_cdc_ecm_doinit(void); /* Private variables ---------------------------------------------------------*/ static u8 cdc_ecm_intr_rx_buf[USBH_CDC_ECM_INTR_BUF_SIZE]; static _sema cdc_ecm_detach_sema; static _sema cdc_ecm_attach_sema; static _sema cdc_ecm_intr_start_sema; static _sema cdc_ecm_bulk_start_sema; static usbh_cdc_ecm_host_hal_t usbh_cdc_ecm_host_user; static usbh_config_t usbh_ecm_cfg = { .pipes = 5U, .speed = USB_SPEED_HIGH, .dma_enable = FALSE, .main_task_priority = 3U, .isr_task_priority = 4U, .rx_fifo_size = 0x200U, .nptx_fifo_size = 0x100U, .ptx_fifo_size = 0x100U, }; static usbh_cdc_ecm_state_cb_t cdc_ecm_usb_cb = { .init = cdc_ecm_cb_init, .deinit = cdc_ecm_cb_deinit, .attach = cdc_ecm_cb_attach, .detach = cdc_ecm_cb_detach, .setup = cdc_ecm_cb_setup, .bulk_send = cdc_ecm_cb_bulk_send, .bulk_receive = cdc_ecm_cb_bulk_receive, .intr_received = cdc_ecm_cb_intr_receive, }; static usbh_user_cb_t usbh_ecm_usr_cb = { .process = cdc_ecm_cb_process }; /* Private functions ---------------------------------------------------------*/ static u8 usbh_cdc_ecm_get_usb_status(void)// { return usbh_cdc_ecm_host_user.cdc_ecm_is_ready ; } static u8 set_usbh_cdc_ecm_bulk_send_flag(u8 flag) { u8 ret = usbh_cdc_ecm_host_user.send_success; usbh_cdc_ecm_host_user.send_success = flag; return ret; } static u8 cdc_ecm_cb_init(void) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[CDC_ECM] CDC ECM INIT\n"); return HAL_OK; } static u8 cdc_ecm_cb_deinit(void) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[CDC_ECM] CDC ECM DEINIT\n"); return HAL_OK; } static u8 cdc_ecm_cb_attach(void) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[CDC_ECM] ATTACH\n"); rtw_up_sema(&cdc_ecm_attach_sema); return HAL_OK; } static u8 cdc_ecm_cb_detach(void) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[CDC_ECM] DETACH\n"); usbh_cdc_ecm_host_user.cdc_ecm_is_ready = 0; #if CONFIG_USBH_CDC_ECM_HOT_PLUG_TEST rtw_up_sema(&cdc_ecm_detach_sema); #endif return HAL_OK; } static u8 cdc_ecm_cb_setup(void) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[CDC_ECM] SETUP\n"); usbh_cdc_ecm_host_user.cdc_ecm_is_ready = 1; rtw_up_sema(&cdc_ecm_intr_start_sema); rtw_up_sema(&cdc_ecm_bulk_start_sema); return HAL_OK; } static u8 cdc_ecm_cb_bulk_receive(u8 *buf, u32 length) { //DBG_PRINTF(MODULE_USB_CLASS, LEVEL_TRACE, "[CDC_ECM] bulk receive \n"); if (usbh_cdc_ecm_host_user.report_data != NULL) { usbh_cdc_ecm_host_user.report_data(buf, length); } return HAL_OK; } static u8 cdc_ecm_cb_bulk_send(usbh_urb_state_t state) { set_usbh_cdc_ecm_bulk_send_flag(1); if (state != USBH_URB_DONE) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_ERROR, "[CDC_ECM] Transmit fail: %d\n", state); } return HAL_OK; } //todo //add parse to get the ethernet status static u8 cdc_ecm_cb_intr_receive(u8 *buf, u32 length) { //DBG_PRINTF(MODULE_USB_CLASS, LEVEL_TRACE, "[USBH] INTR RX len=%d\n", length); if (buf && length >= 8) { /*A1 00 00 00 01 00 00 00 */ if (length == 8 && buf[0] == 0xA1 && buf[1] == CDC_ECM_NOTIFY_NETWORK_CONNECTION) { usbh_cdc_ecm_host_user.ecm_hw_connect = buf[2]; } /*A1 2A 00 00 01 00 00 08 00 00 00 00 00 00 00 00 */ else if (length == 16 && buf[0] == 0xA1 && buf[1] == CDC_ECM_NOTIFY_CONNECTION_SPEED_CHANGE) { //usbh_cdc_ecm_speed_change_t } } return HAL_OK; } static u8 cdc_ecm_cb_process(usb_host_t *host, u8 id) { UNUSED(host); DBG_PRINTF(MODULE_USB_CLASS, LEVEL_TRACE, "[CDC_ECM] Process ,id=%d\n", id); switch (id) { case USBH_MSG_USER_SET_CONFIG: usbh_cdc_ecm_setconfig(host, 1); //choose config id=1 break; case USBH_MSG_DISCONNECTED: usbh_cdc_ecm_host_user.cdc_ecm_is_ready = 0; break; case USBH_MSG_CONNECTED: break; default: break; } return HAL_OK; } static void ecm_intr_rx_thread(void *param) { int i; UNUSED(param); DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[USBH] INTR test pending, wait for device ready\n"); if (rtw_down_sema(&cdc_ecm_intr_start_sema)) { rtw_msleep_os(500); DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[USBH] intr send task started \n"); do { i++; if (!usbh_cdc_ecm_get_usb_status()) { //18s if ((i % 10 == 0)) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_WARN, "[USBH] Device disconnected, intr test aborted[%d]\n", usbh_cdc_ecm_get_usb_status()); } rtw_msleep_os(1000); continue; } if (!usbh_cdc_ecm_intr_in_processing()) { usbh_cdc_ecm_intr_receive(cdc_ecm_intr_rx_buf, USBH_CDC_ECM_INTR_BUF_SIZE); } rtw_msleep_os(1 * 50); //should sleep by bInterval value } while (1); } rtw_thread_exit(); } static void ecm_bulk_rx_thread(void *param) { u32 i; UNUSED(param); DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[USBH] bulk test pending, wait for device ready\n"); if (rtw_down_sema(&cdc_ecm_bulk_start_sema)) { rtw_msleep_os(500); DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[USBH] bulk send task started \n"); do { i++; if (!usbh_cdc_ecm_get_usb_status()) { if ((i % 10 == 0)) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_WARN, "[USBH] Device disconnected, bulk test aborted[%d]\n", usbh_cdc_ecm_get_usb_status()); } rtw_msleep_os(1000); continue; } if (!usbh_cdc_ecm_bulk_in_processing()) { usbh_cdc_ecm_bulk_receive(); //rtw_msleep_os(1*1); } else { rtw_msleep_os(1 * 1); } } while (1); } rtw_thread_exit(); } #if CONFIG_USBH_CDC_ECM_HOT_PLUG_TEST static void ecm_hotplug_thread(void *param) { int ret = 0; UNUSED(param); for (;;) { rtw_down_sema(&cdc_ecm_detach_sema); rtw_msleep_os(2000); usbh_cdc_ecm_deinit(); usbh_deinit(); rtw_msleep_os(10); DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[CDC_ECM] Free heap size: 0x%lx\n", xPortGetFreeHeapSize()); ret = usbh_cdc_ecm_doinit(); if (ret != 0) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_ERROR, "[CDC_ECM] Fail to init USB host controller: %d\n", ret); break; } } rtw_thread_exit(); } #endif static u8 usbh_cdc_ecm_doinit(void) { int status; status = usbh_init(&usbh_ecm_cfg, &usbh_ecm_usr_cb); if (status != HAL_OK) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_ERROR, "[CDC_ECM] Fail to init USB host controller: %d\n", status); return USBH_CORE_INIT_FAIL; } status = usbh_cdc_ecm_init(&cdc_ecm_usb_cb); /*0 means use default transfer size, and it can not exceed 65536*/ if (status != HAL_OK) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_ERROR, "[CDC_ECM] Fail to init USB host cdc_ecm driver: %d\n", status); return USBH_CLASS_INIT_FAIL; } if (rtw_down_sema(&cdc_ecm_attach_sema)) { usbh_cdc_ecm_state_t step = CDC_ECM_STATE_ALT_SETTING; u8 loop = 1; u8 mac_str[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; do { switch (step) { case CDC_ECM_STATE_ALT_SETTING: //choose alt status = usbh_cdc_ecm_alt_setting(); if (HAL_OK != status) { rtw_msleep_os(100); } else { step = CDC_ECM_STATE_SWITCH_TO_TRANSFER; } break; case CDC_ECM_STATE_SET_ETHERNET_MULTICAST_FILTER://set the multi list status = usbh_cdc_ecm_set_ethernet_multicast_filter(mac_str, 6); if (HAL_OK != status) { rtw_msleep_os(100); } else { step = CDC_ECM_STATE_SET_ETHERNET_PACKET_FILTER; } break; case CDC_ECM_STATE_SET_ETHERNET_PACKET_FILTER://set the filter status = usbh_cdc_ecm_set_ethernet_packetfilter(CDC_ECM_ETH_PACKET_TYPE_DIRECTED); if (HAL_OK != status) { rtw_msleep_os(100); } else { step = CDC_ECM_STATE_SWITCH_TO_TRANSFER; } break; case CDC_ECM_STATE_SWITCH_TO_TRANSFER://switch to transfer default: status = usbh_cdc_ecm_set_ethernet_start_transfer(); if (HAL_OK != status) { rtw_msleep_os(100); } else { loop = 0; } break; } } while (loop); } return HAL_OK; } static void usbh_cdc_ecm_init_thread(void *param) { int status; struct task_struct intr_task; struct task_struct bulk_task; #if CONFIG_USBH_CDC_ECM_HOT_PLUG_TEST struct task_struct hotplug_task; #endif UNUSED(param); rtw_init_sema(&cdc_ecm_detach_sema, 0); rtw_init_sema(&cdc_ecm_attach_sema, 0); rtw_init_sema(&cdc_ecm_intr_start_sema, 0); rtw_init_sema(&cdc_ecm_bulk_start_sema, 0); status = usbh_cdc_ecm_doinit(); if (USBH_CORE_INIT_FAIL == status) { goto free_sema_exit; } else if (USBH_CLASS_INIT_FAIL == status) { goto usb_deinit_exit; } #if CONFIG_USBH_CDC_ECM_HOT_PLUG_TEST status = rtw_create_task(&hotplug_task, "ecm_hotplug_thread", 512, tskIDLE_PRIORITY + 2, (thread_func_t)ecm_hotplug_thread, NULL); if (status != pdPASS) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_ERROR, "[CDC_ECM] Fail to create USBH cdc_ecm hotplug check thread\n"); goto usb_ecm_deinit_exit; } #endif status = rtw_create_task(&intr_task, "ecm_intr_rx_thread", 512, tskIDLE_PRIORITY + 2, (thread_func_t)ecm_intr_rx_thread, NULL); if (status != pdPASS) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_ERROR, "[USBH] Fail to create USBH INTR intr_cdc_ecm_test_task thread\n"); goto usbh_ecm_cdc_deinit_exit; } status = rtw_create_task(&bulk_task, "ecm_bulk_rx_thread", 512, tskIDLE_PRIORITY + 2, (thread_func_t)ecm_bulk_rx_thread, NULL); if (status != pdPASS) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_ERROR, "[USBH] Fail to create USBH BULK ecm_bulk_rx_thread thread\n"); goto delete_intr_task_exit; } goto example_exit; delete_intr_task_exit: rtw_delete_task(&intr_task); usbh_ecm_cdc_deinit_exit: #if CONFIG_USBH_CDC_ECM_HOT_PLUG_TEST rtw_delete_task(&hotplug_task); #endif usb_ecm_deinit_exit: usbh_cdc_ecm_deinit(); usb_deinit_exit: usbh_deinit(); free_sema_exit: rtw_free_sema(&cdc_ecm_detach_sema); rtw_free_sema(&cdc_ecm_attach_sema); rtw_free_sema(&cdc_ecm_intr_start_sema); rtw_free_sema(&cdc_ecm_bulk_start_sema); example_exit: rtw_thread_exit(); } /* Exported functions --------------------------------------------------------*/ u8 usbh_cdc_ecm_do_deinit(void)//todo destory all usb task { return 0 ; } u8 usbh_cdc_ecm_do_init(usb_report_usbdata cb_handle) { int status; struct task_struct task; usbh_cdc_ecm_host_user.report_data = cb_handle ; #if 0 DBG_ERR_MSG_ON(MODULE_USB_OTG); DBG_WARN_MSG_ON(MODULE_USB_OTG); DBG_INFO_MSG_ON(MODULE_USB_OTG); //ConfigDebug[LEVEL_TRACE] |= BIT(MODULE_USB_OTG); DBG_ERR_MSG_ON(MODULE_USB_CLASS); DBG_WARN_MSG_ON(MODULE_USB_CLASS); DBG_INFO_MSG_ON(MODULE_USB_CLASS); //ConfigDebug[LEVEL_TRACE] |= BIT(MODULE_USB_CLASS); #endif DBG_PRINTF(MODULE_USB_CLASS, LEVEL_INFO, "[CDC_ECM] enter USB host init...\n"); if (0 == usbh_cdc_ecm_host_user.ecm_init_success) { status = rtw_create_task(&task, "ecm_init_thread", 512, tskIDLE_PRIORITY + 1, usbh_cdc_ecm_init_thread, NULL); if (status != pdPASS) { DBG_PRINTF(MODULE_USB_CLASS, LEVEL_ERROR, "[CDC_ECM] Fail to create USB host cdc_ecm init thread: %d\n", status); return 1 ; } usbh_cdc_ecm_host_user.ecm_init_success = 1; } return 0; } u16 usbh_cdc_ecm_get_receive_mps(void) { return usbh_cdc_ecm_get_usbin_mps(); } u8 usbh_cdc_ecm_get_sendflag(void) { return usbh_cdc_ecm_host_user.send_success; } u8 usbh_cdc_ecm_senddata(u8 *buf, u32 len) { set_usbh_cdc_ecm_bulk_send_flag(0); return usbh_cdc_ecm_bulk_send(buf, len); } u8 usbh_cdc_ecm_get_connect_status(void)//1 up { u8 ret = usbh_cdc_ecm_host_user.cdc_ecm_is_ready && usbh_cdc_ecm_host_user.ecm_hw_connect; return ret ; }
4fbdfac1a345792ce4af4feba257462ec06209f4
984bc4181baec6e5a4b05a657e666b0e9f89f3f3
/include/twebsocketsession.h
48a8b4548b35cfeabdfc68b3bb65f12f35425e2d
[ "BSD-3-Clause" ]
permissive
treefrogframework/treefrog-framework
0173245ff92162d2107af79861505981980d1eca
a1df97793e8cc628779378e5adae9af6987460c1
refs/heads/master
2023-08-22T03:57:58.891846
2023-05-18T14:00:42
2023-05-18T14:00:42
7,067,532
1,152
263
BSD-3-Clause
2023-08-08T20:25:03
2012-12-08T13:17:01
C++
UTF-8
C
false
false
38
h
twebsocketsession.h
#include "../src/twebsocketsession.h"
a72b7bcbdfa4457efc5545cfc5a741e854cdcfeb
0744dcc5394cebf57ebcba343747af6871b67017
/os/board/rtl8730e/src/component/soc/amebad2/atf/lib/psci/psci_private.h
e2dcfa8b1edf2eb1f1f28d15987faec69f54bc92
[ "GPL-1.0-or-later", "BSD-3-Clause", "ISC", "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive", "Apache-2.0" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C
false
false
11,439
h
psci_private.h
/* * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef PSCI_PRIVATE_H #define PSCI_PRIVATE_H #include <stdbool.h> #include <arch.h> #include <arch_helpers.h> #include <common/bl_common.h> #include <lib/bakery_lock.h> #include <lib/el3_runtime/cpu_data.h> #include <lib/psci/psci.h> #include <lib/spinlock.h> /* * The PSCI capability which are provided by the generic code but does not * depend on the platform or spd capabilities. */ #define PSCI_GENERIC_CAP \ (define_psci_cap(PSCI_VERSION) | \ define_psci_cap(PSCI_AFFINITY_INFO_AARCH64) | \ define_psci_cap(PSCI_FEATURES)) /* * The PSCI capabilities mask for 64 bit functions. */ #define PSCI_CAP_64BIT_MASK \ (define_psci_cap(PSCI_CPU_SUSPEND_AARCH64) | \ define_psci_cap(PSCI_CPU_ON_AARCH64) | \ define_psci_cap(PSCI_AFFINITY_INFO_AARCH64) | \ define_psci_cap(PSCI_MIG_AARCH64) | \ define_psci_cap(PSCI_MIG_INFO_UP_CPU_AARCH64) | \ define_psci_cap(PSCI_NODE_HW_STATE_AARCH64) | \ define_psci_cap(PSCI_SYSTEM_SUSPEND_AARCH64) | \ define_psci_cap(PSCI_STAT_RESIDENCY_AARCH64) | \ define_psci_cap(PSCI_STAT_COUNT_AARCH64) | \ define_psci_cap(PSCI_SYSTEM_RESET2_AARCH64) | \ define_psci_cap(PSCI_MEM_CHK_RANGE_AARCH64)) /* * Helper functions to get/set the fields of PSCI per-cpu data. */ static inline void psci_set_aff_info_state(aff_info_state_t aff_state) { set_cpu_data(psci_svc_cpu_data.aff_info_state, aff_state); } static inline aff_info_state_t psci_get_aff_info_state(void) { return get_cpu_data(psci_svc_cpu_data.aff_info_state); } static inline aff_info_state_t psci_get_aff_info_state_by_idx(unsigned int idx) { return get_cpu_data_by_index(idx, psci_svc_cpu_data.aff_info_state); } static inline void psci_set_aff_info_state_by_idx(unsigned int idx, aff_info_state_t aff_state) { set_cpu_data_by_index(idx, psci_svc_cpu_data.aff_info_state, aff_state); } static inline unsigned int psci_get_suspend_pwrlvl(void) { return get_cpu_data(psci_svc_cpu_data.target_pwrlvl); } static inline void psci_set_suspend_pwrlvl(unsigned int target_lvl) { set_cpu_data(psci_svc_cpu_data.target_pwrlvl, target_lvl); } static inline void psci_set_cpu_local_state(plat_local_state_t state) { set_cpu_data(psci_svc_cpu_data.local_state, state); } static inline plat_local_state_t psci_get_cpu_local_state(void) { return get_cpu_data(psci_svc_cpu_data.local_state); } static inline plat_local_state_t psci_get_cpu_local_state_by_idx( unsigned int idx) { return get_cpu_data_by_index(idx, psci_svc_cpu_data.local_state); } /* Helper function to identify a CPU standby request in PSCI Suspend call */ static inline bool is_cpu_standby_req(unsigned int is_power_down_state, unsigned int retn_lvl) { return (is_power_down_state == 0U) && (retn_lvl == 0U); } /******************************************************************************* * The following two data structures implement the power domain tree. The tree * is used to track the state of all the nodes i.e. power domain instances * described by the platform. The tree consists of nodes that describe CPU power * domains i.e. leaf nodes and all other power domains which are parents of a * CPU power domain i.e. non-leaf nodes. ******************************************************************************/ typedef struct non_cpu_pwr_domain_node { /* * Index of the first CPU power domain node level 0 which has this node * as its parent. */ unsigned int cpu_start_idx; /* * Number of CPU power domains which are siblings of the domain indexed * by 'cpu_start_idx' i.e. all the domains in the range 'cpu_start_idx * -> cpu_start_idx + ncpus' have this node as their parent. */ unsigned int ncpus; /* * Index of the parent power domain node. * TODO: Figure out whether to whether using pointer is more efficient. */ unsigned int parent_node; plat_local_state_t local_state; unsigned char level; /* For indexing the psci_lock array*/ unsigned char lock_index; } non_cpu_pd_node_t; typedef struct cpu_pwr_domain_node { u_register_t mpidr; /* * Index of the parent power domain node. * TODO: Figure out whether to whether using pointer is more efficient. */ unsigned int parent_node; /* * A CPU power domain does not require state coordination like its * parent power domains. Hence this node does not include a bakery * lock. A spinlock is required by the CPU_ON handler to prevent a race * when multiple CPUs try to turn ON the same target CPU. */ spinlock_t cpu_lock; } cpu_pd_node_t; /******************************************************************************* * The following are helpers and declarations of locks. ******************************************************************************/ #if HW_ASSISTED_COHERENCY /* * On systems where participant CPUs are cache-coherent, we can use spinlocks * instead of bakery locks. */ #define DEFINE_PSCI_LOCK(_name) spinlock_t _name #define DECLARE_PSCI_LOCK(_name) extern DEFINE_PSCI_LOCK(_name) /* One lock is required per non-CPU power domain node */ DECLARE_PSCI_LOCK(psci_locks[PSCI_NUM_NON_CPU_PWR_DOMAINS]); /* * On systems with hardware-assisted coherency, make PSCI cache operations NOP, * as PSCI participants are cache-coherent, and there's no need for explicit * cache maintenance operations or barriers to coordinate their state. */ static inline void psci_flush_dcache_range(uintptr_t __unused addr, size_t __unused size) { /* Empty */ } #define psci_flush_cpu_data(member) #define psci_inv_cpu_data(member) static inline void psci_dsbish(void) { /* Empty */ } static inline void psci_lock_get(non_cpu_pd_node_t *non_cpu_pd_node) { spin_lock(&psci_locks[non_cpu_pd_node->lock_index]); } static inline void psci_lock_release(non_cpu_pd_node_t *non_cpu_pd_node) { spin_unlock(&psci_locks[non_cpu_pd_node->lock_index]); } #else /* if HW_ASSISTED_COHERENCY == 0 */ /* * Use bakery locks for state coordination as not all PSCI participants are * cache coherent. */ #define DEFINE_PSCI_LOCK(_name) DEFINE_BAKERY_LOCK(_name) #define DECLARE_PSCI_LOCK(_name) DECLARE_BAKERY_LOCK(_name) /* One lock is required per non-CPU power domain node */ DECLARE_PSCI_LOCK(psci_locks[PSCI_NUM_NON_CPU_PWR_DOMAINS]); /* * If not all PSCI participants are cache-coherent, perform cache maintenance * and issue barriers wherever required to coordinate state. */ static inline void psci_flush_dcache_range(uintptr_t addr, size_t size) { flush_dcache_range(addr, size); } #define psci_flush_cpu_data(member) flush_cpu_data(member) #define psci_inv_cpu_data(member) inv_cpu_data(member) static inline void psci_dsbish(void) { dsbish(); } static inline void psci_lock_get(non_cpu_pd_node_t *non_cpu_pd_node) { bakery_lock_get(&psci_locks[non_cpu_pd_node->lock_index]); } static inline void psci_lock_release(non_cpu_pd_node_t *non_cpu_pd_node) { bakery_lock_release(&psci_locks[non_cpu_pd_node->lock_index]); } #endif /* HW_ASSISTED_COHERENCY */ static inline void psci_lock_init(non_cpu_pd_node_t *non_cpu_pd_node, unsigned char idx) { non_cpu_pd_node[idx].lock_index = idx; } /******************************************************************************* * Data prototypes ******************************************************************************/ extern const plat_psci_ops_t *psci_plat_pm_ops; extern non_cpu_pd_node_t psci_non_cpu_pd_nodes[PSCI_NUM_NON_CPU_PWR_DOMAINS]; extern cpu_pd_node_t psci_cpu_pd_nodes[PLATFORM_CORE_COUNT]; extern unsigned int psci_caps; extern unsigned int psci_plat_core_count; /******************************************************************************* * SPD's power management hooks registered with PSCI ******************************************************************************/ extern const spd_pm_ops_t *psci_spd_pm; /******************************************************************************* * Function prototypes ******************************************************************************/ /* Private exported functions from psci_common.c */ int psci_validate_power_state(unsigned int power_state, psci_power_state_t *state_info); void psci_query_sys_suspend_pwrstate(psci_power_state_t *state_info); int psci_validate_mpidr(u_register_t mpidr); void psci_init_req_local_pwr_states(void); void psci_get_target_local_pwr_states(unsigned int end_pwrlvl, psci_power_state_t *target_state); int psci_validate_entry_point(entry_point_info_t *ep, uintptr_t entrypoint, u_register_t context_id); void psci_get_parent_pwr_domain_nodes(unsigned int cpu_idx, unsigned int end_lvl, unsigned int *node_index); void psci_do_state_coordination(unsigned int end_pwrlvl, psci_power_state_t *state_info); void psci_acquire_pwr_domain_locks(unsigned int end_pwrlvl, const unsigned int *parent_nodes); void psci_release_pwr_domain_locks(unsigned int end_pwrlvl, const unsigned int *parent_nodes); int psci_validate_suspend_req(const psci_power_state_t *state_info, unsigned int is_power_down_state); unsigned int psci_find_max_off_lvl(const psci_power_state_t *state_info); unsigned int psci_find_target_suspend_lvl(const psci_power_state_t *state_info); void psci_set_pwr_domains_to_run(unsigned int end_pwrlvl); void psci_print_power_domain_map(void); unsigned int psci_is_last_on_cpu(void); int psci_spd_migrate_info(u_register_t *mpidr); void psci_do_pwrdown_sequence(unsigned int power_level); /* * CPU power down is directly called only when HW_ASSISTED_COHERENCY is * available. Otherwise, this needs post-call stack maintenance, which is * handled in assembly. */ void prepare_cpu_pwr_dwn(unsigned int power_level); /* Private exported functions from psci_on.c */ int psci_cpu_on_start(u_register_t target_cpu, const entry_point_info_t *ep); void psci_cpu_on_finish(unsigned int cpu_idx, const psci_power_state_t *state_info); /* Private exported functions from psci_off.c */ int psci_do_cpu_off(unsigned int end_pwrlvl); /* Private exported functions from psci_suspend.c */ void psci_cpu_suspend_start(const entry_point_info_t *ep, unsigned int end_pwrlvl, psci_power_state_t *state_info, unsigned int is_power_down_state); void psci_cpu_suspend_finish(unsigned int cpu_idx, const psci_power_state_t *state_info); /* Private exported functions from psci_helpers.S */ void psci_do_pwrdown_cache_maintenance(unsigned int pwr_level); void psci_do_pwrup_cache_maintenance(void); /* Private exported functions from psci_system_off.c */ void __dead2 psci_system_off(void); void __dead2 psci_system_reset(void); u_register_t psci_system_reset2(uint32_t reset_type, u_register_t cookie); /* Private exported functions from psci_stat.c */ void psci_stats_update_pwr_down(unsigned int end_pwrlvl, const psci_power_state_t *state_info); void psci_stats_update_pwr_up(unsigned int end_pwrlvl, const psci_power_state_t *state_info); u_register_t psci_stat_residency(u_register_t target_cpu, unsigned int power_state); u_register_t psci_stat_count(u_register_t target_cpu, unsigned int power_state); /* Private exported functions from psci_mem_protect.c */ u_register_t psci_mem_protect(unsigned int enable); u_register_t psci_mem_chk_range(uintptr_t base, u_register_t length); #endif /* PSCI_PRIVATE_H */
dc6a146a5fd866f23874384d1dae9e107557f3b5
de21f9075f55640514c29ef0f1fe3f0690845764
/regression/goto-synthesizer/loop_contracts_synthesis_03/main.c
be272d35f2cf80497eafe067716e0113476f531b
[ "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
247
c
main.c
#define SIZE 80 void main() { unsigned long len; __CPROVER_assume(len <= SIZE); __CPROVER_assume(len >= 8); char *array = malloc(len); const char *end = array + len; unsigned s = 0; while(array != end) { s += *array++; } }
92bd0f603bedfd16055b37cf73265f2579658137
bed3ac926beac0f4e0293303d7b2a6031ee476c9
/Modules/ThirdParty/VNL/src/vxl/v3p/netlib/lapack/double/dlagv2.h
2256d46fee64d4a83f20c7e269f07b5955c0e948
[ "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
362
h
dlagv2.h
extern int v3p_netlib_dlagv2_( v3p_netlib_doublereal *a, v3p_netlib_integer *lda, v3p_netlib_doublereal *b, v3p_netlib_integer *ldb, v3p_netlib_doublereal *alphar, v3p_netlib_doublereal *alphai, v3p_netlib_doublereal *beta, v3p_netlib_doublereal *csl, v3p_netlib_doublereal *snl, v3p_netlib_doublereal *csr, v3p_netlib_doublereal *snr );
cc5ddadd28e1757d1542b8e50eb569ad6b09f83e
6ccc8f09f1bd7ced44a0d423e5b166304d9e3ea3
/Sources/AGGRenderer/CAGGRenderer/include/CAGGRenderer.h
40423c303dfa978164feacb7a44ac57f42a9b793
[ "Apache-2.0" ]
permissive
KarthikRIyer/swiftplot
d9be6d68e2cd118a9c17bc0fdfba4aa724a531b4
36f46087d36de0375d6245e767b33b3efcb7dc30
refs/heads/master
2022-07-20T18:32:46.290586
2022-04-02T18:26:25
2022-04-02T18:26:25
185,946,183
416
46
Apache-2.0
2022-10-12T23:38:46
2019-05-10T08:04:45
C++
UTF-8
C
false
false
1,968
h
CAGGRenderer.h
#include<stdbool.h> #include<stddef.h> #ifdef __cplusplus extern "C" { #endif void * initializePlot(float w, float h, const char* fontPath); void delete_plot(void *object); void draw_rect(const float *x, const float *y, float thickness, float r, float g, float b, float a, const void *object); void draw_solid_rect(const float *x, const float *y, float r, float g, float b, float a, int hatch_pattern, const void *object); void draw_solid_rect_with_border(const float *x, const float *y, float thickness, float r_fill, float g_fill, float b_fill, float a_fill, float r_stroke, float g_stroke, float b_stroke, float a_stroke, const void *object); void draw_solid_circle(float cx, float cy, float radius, float r, float g, float b, float a, const void *object); void draw_solid_ellipse(float cx, float cy, float rx, float ry, float r, float g, float b, float a, const void *object); void draw_solid_triangle(float x1, float x2, float x3, float y1, float y2, float y3, float r, float g, float b, float a, const void *object); void draw_solid_polygon(const float* x, const float* y, int count, float r, float g, float b, float a, const void *object); void draw_line(const float *x, const float *y, float thickness, float r, float g, float b, float a, bool is_dashed, const void *object); void draw_plot_lines(const float *x, const float *y, int size, float thickness, float r, float g, float b, float a, bool isDashed, const void *object); void draw_text(const char *s, float x, float y, float size, float r, float g, float b, float a, float thickness, float angle, const void *object); void get_text_size(const char *s, float size, float* outW, float* outH, const void *object); unsigned save_image(const char *s, const char** errorDesc, const void *object); unsigned create_png_buffer(unsigned char** output, size_t *outputSize, const char** errorDesc, const void *object); void free_png_buffer(unsigned char** output); #ifdef __cplusplus } #endif
36c96629f08c365811098f61413621349e6e5493
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
/AKWF-c/AKWF_eorgan/AKWF_eorgan_0099.h
516583b9d4c8f0f2ae09b17b688d5026413c2088
[ "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,686
h
AKWF_eorgan_0099.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_eorgan_0099 256 samples +-----------------------------------------------------------------------------------------------------------------+ | ** ** ** ** | | ** ** ****** * ** ** | | * ** ** ** * ** **** | |** ** ** *** ** ** ** * *** | |* ** ** *** **** ** * ** | |* **** * * * | | * ** * | | ** * ** | | * * * | | * * * **** *| | * ** ** **** *** ** ** *| | *** ** ** ** * *** ** ** **| | ** ** ** * ** * ** * | | ** ** ** ***** ****** | | ** ** ** | +-----------------------------------------------------------------------------------------------------------------+ */ const uint16_t AKWF_eorgan_0099 [] = { 33651, 38403, 43233, 47514, 51285, 54341, 56782, 58493, 59653, 60208, 60377, 60113, 59593, 58761, 57737, 56446, 54971, 53314, 51611, 49805, 47974, 46117, 44333, 42697, 41331, 40331, 39808, 39834, 40444, 41642, 43371, 45551, 48036, 50607, 53015, 55150, 56894, 58208, 59058, 59483, 59518, 59260, 58777, 58163, 57425, 56601, 55709, 54743, 53690, 52602, 51537, 50471, 49416, 48386, 47427, 46606, 46009, 45719, 45839, 46423, 47505, 49071, 51075, 53419, 55976, 58511, 60792, 62702, 64143, 65073, 65484, 65406, 64903, 64070, 62995, 61769, 60449, 59085, 57689, 56273, 54817, 53385, 52022, 50713, 49451, 48255, 47158, 46175, 45396, 44899, 44764, 45040, 45748, 46867, 48344, 50067, 51911, 53632, 55004, 55903, 56236, 55964, 55082, 53635, 51696, 49374, 46775, 44008, 41166, 38317, 35501, 32744, 30051, 27503, 25162, 23029, 21118, 19452, 18084, 17071, 16498, 16446, 16998, 18194, 20053, 22535, 25572, 29032, 32777, 36506, 39934, 42927, 45355, 47154, 48286, 48775, 48661, 48030, 46965, 45548, 43839, 41889, 39720, 37347, 34772, 32070, 29313, 26500, 23660, 20833, 18089, 15525, 13242, 11352, 9959, 9138, 8925, 9315, 10269, 11686, 13440, 15290, 17011, 18473, 19574, 20259, 20510, 20350, 19834, 19039, 18045, 16941, 15737, 14470, 13158, 11794, 10368, 8928, 7534, 6165, 4827, 3538, 2346, 1311, 523, 71, 48, 512, 1498, 2993, 4949, 7268, 9823, 12378, 14704, 16683, 18215, 19263, 19809, 19894, 19578, 18952, 18110, 17139, 16097, 15034, 13963, 12895, 11810, 10773, 9828, 8955, 8156, 7446, 6859, 6409, 6183, 6260, 6727, 7620, 8976, 10760, 12928, 15360, 17942, 20412, 22566, 24262, 25423, 25989, 25978, 25413, 24391, 22995, 21353, 19557, 17709, 15880, 14097, 12405, 10781, 9343, 8108, 7133, 6359, 5901, 5698, 5939, 6560, 7809, 9578, 12125, 15219, 19109, 23372, 28378, };
7c1daf55a5e784daac1e3be3e632812777614545
bed3ac926beac0f4e0293303d7b2a6031ee476c9
/Modules/ThirdParty/libLBFGS/src/arithmetic_sse_double.h
83405eeb1f1577e83e0a94fbe7734120ce74e64d
[ "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
8,830
h
arithmetic_sse_double.h
/* * SSE2 implementation of vector oprations (64bit double). * * Copyright (c) 2007-2010 Naoaki Okazaki * All rights reserved. * * 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. */ /* $Id$ */ #include <stdlib.h> #ifndef __APPLE__ #include <malloc.h> #endif #include <memory.h> #if 1400 <= _MSC_VER #include <intrin.h> #endif/*1400 <= _MSC_VER*/ #if HAVE_EMMINTRIN_H #include <emmintrin.h> #endif/*HAVE_EMMINTRIN_H*/ inline static void* vecalloc(size_t size) { #if defined(_MSC_VER) void *memblock = _aligned_malloc(size, 16); #elif defined(__APPLE__) /* OS X always aligns on 16-byte boundaries */ void *memblock = malloc(size); #else void *memblock = NULL, *p = NULL; if (posix_memalign(&p, 16, size) == 0) { memblock = p; } #endif if (memblock != NULL) { memset(memblock, 0, size); } return memblock; } inline static void vecfree(void *memblock) { #ifdef _MSC_VER _aligned_free(memblock); #else free(memblock); #endif } #define fsigndiff(x, y) \ ((_mm_movemask_pd(_mm_set_pd(*(x), *(y))) + 1) & 0x002) #define vecset(x, c, n) \ { \ int i; \ __m128d XMM0 = _mm_set1_pd(c); \ for (i = 0;i < (n);i += 8) { \ _mm_store_pd((x)+i , XMM0); \ _mm_store_pd((x)+i+2, XMM0); \ _mm_store_pd((x)+i+4, XMM0); \ _mm_store_pd((x)+i+6, XMM0); \ } \ } #define veccpy(y, x, n) \ { \ int i; \ for (i = 0;i < (n);i += 8) { \ __m128d XMM0 = _mm_load_pd((x)+i ); \ __m128d XMM1 = _mm_load_pd((x)+i+2); \ __m128d XMM2 = _mm_load_pd((x)+i+4); \ __m128d XMM3 = _mm_load_pd((x)+i+6); \ _mm_store_pd((y)+i , XMM0); \ _mm_store_pd((y)+i+2, XMM1); \ _mm_store_pd((y)+i+4, XMM2); \ _mm_store_pd((y)+i+6, XMM3); \ } \ } #define vecncpy(y, x, n) \ { \ int i; \ for (i = 0;i < (n);i += 8) { \ __m128d XMM0 = _mm_setzero_pd(); \ __m128d XMM1 = _mm_setzero_pd(); \ __m128d XMM2 = _mm_setzero_pd(); \ __m128d XMM3 = _mm_setzero_pd(); \ __m128d XMM4 = _mm_load_pd((x)+i ); \ __m128d XMM5 = _mm_load_pd((x)+i+2); \ __m128d XMM6 = _mm_load_pd((x)+i+4); \ __m128d XMM7 = _mm_load_pd((x)+i+6); \ XMM0 = _mm_sub_pd(XMM0, XMM4); \ XMM1 = _mm_sub_pd(XMM1, XMM5); \ XMM2 = _mm_sub_pd(XMM2, XMM6); \ XMM3 = _mm_sub_pd(XMM3, XMM7); \ _mm_store_pd((y)+i , XMM0); \ _mm_store_pd((y)+i+2, XMM1); \ _mm_store_pd((y)+i+4, XMM2); \ _mm_store_pd((y)+i+6, XMM3); \ } \ } #define vecadd(y, x, c, n) \ { \ int i; \ __m128d XMM7 = _mm_set1_pd(c); \ for (i = 0;i < (n);i += 4) { \ __m128d XMM0 = _mm_load_pd((x)+i ); \ __m128d XMM1 = _mm_load_pd((x)+i+2); \ __m128d XMM2 = _mm_load_pd((y)+i ); \ __m128d XMM3 = _mm_load_pd((y)+i+2); \ XMM0 = _mm_mul_pd(XMM0, XMM7); \ XMM1 = _mm_mul_pd(XMM1, XMM7); \ XMM2 = _mm_add_pd(XMM2, XMM0); \ XMM3 = _mm_add_pd(XMM3, XMM1); \ _mm_store_pd((y)+i , XMM2); \ _mm_store_pd((y)+i+2, XMM3); \ } \ } #define vecdiff(z, x, y, n) \ { \ int i; \ for (i = 0;i < (n);i += 8) { \ __m128d XMM0 = _mm_load_pd((x)+i ); \ __m128d XMM1 = _mm_load_pd((x)+i+2); \ __m128d XMM2 = _mm_load_pd((x)+i+4); \ __m128d XMM3 = _mm_load_pd((x)+i+6); \ __m128d XMM4 = _mm_load_pd((y)+i ); \ __m128d XMM5 = _mm_load_pd((y)+i+2); \ __m128d XMM6 = _mm_load_pd((y)+i+4); \ __m128d XMM7 = _mm_load_pd((y)+i+6); \ XMM0 = _mm_sub_pd(XMM0, XMM4); \ XMM1 = _mm_sub_pd(XMM1, XMM5); \ XMM2 = _mm_sub_pd(XMM2, XMM6); \ XMM3 = _mm_sub_pd(XMM3, XMM7); \ _mm_store_pd((z)+i , XMM0); \ _mm_store_pd((z)+i+2, XMM1); \ _mm_store_pd((z)+i+4, XMM2); \ _mm_store_pd((z)+i+6, XMM3); \ } \ } #define vecscale(y, c, n) \ { \ int i; \ __m128d XMM7 = _mm_set1_pd(c); \ for (i = 0;i < (n);i += 4) { \ __m128d XMM0 = _mm_load_pd((y)+i ); \ __m128d XMM1 = _mm_load_pd((y)+i+2); \ XMM0 = _mm_mul_pd(XMM0, XMM7); \ XMM1 = _mm_mul_pd(XMM1, XMM7); \ _mm_store_pd((y)+i , XMM0); \ _mm_store_pd((y)+i+2, XMM1); \ } \ } #define vecmul(y, x, n) \ { \ int i; \ for (i = 0;i < (n);i += 8) { \ __m128d XMM0 = _mm_load_pd((x)+i ); \ __m128d XMM1 = _mm_load_pd((x)+i+2); \ __m128d XMM2 = _mm_load_pd((x)+i+4); \ __m128d XMM3 = _mm_load_pd((x)+i+6); \ __m128d XMM4 = _mm_load_pd((y)+i ); \ __m128d XMM5 = _mm_load_pd((y)+i+2); \ __m128d XMM6 = _mm_load_pd((y)+i+4); \ __m128d XMM7 = _mm_load_pd((y)+i+6); \ XMM4 = _mm_mul_pd(XMM4, XMM0); \ XMM5 = _mm_mul_pd(XMM5, XMM1); \ XMM6 = _mm_mul_pd(XMM6, XMM2); \ XMM7 = _mm_mul_pd(XMM7, XMM3); \ _mm_store_pd((y)+i , XMM4); \ _mm_store_pd((y)+i+2, XMM5); \ _mm_store_pd((y)+i+4, XMM6); \ _mm_store_pd((y)+i+6, XMM7); \ } \ } #if 3 <= __SSE__ || defined(__SSE3__) /* Horizontal add with haddps SSE3 instruction. The work register (rw) is unused. */ #define __horizontal_sum(r, rw) \ r = _mm_hadd_ps(r, r); \ r = _mm_hadd_ps(r, r); #else /* Horizontal add with SSE instruction. The work register (rw) is used. */ #define __horizontal_sum(r, rw) \ rw = r; \ r = _mm_shuffle_ps(r, rw, _MM_SHUFFLE(1, 0, 3, 2)); \ r = _mm_add_ps(r, rw); \ rw = r; \ r = _mm_shuffle_ps(r, rw, _MM_SHUFFLE(2, 3, 0, 1)); \ r = _mm_add_ps(r, rw); #endif #define vecdot(s, x, y, n) \ { \ int i; \ __m128d XMM0 = _mm_setzero_pd(); \ __m128d XMM1 = _mm_setzero_pd(); \ __m128d XMM2, XMM3, XMM4, XMM5; \ for (i = 0;i < (n);i += 4) { \ XMM2 = _mm_load_pd((x)+i ); \ XMM3 = _mm_load_pd((x)+i+2); \ XMM4 = _mm_load_pd((y)+i ); \ XMM5 = _mm_load_pd((y)+i+2); \ XMM2 = _mm_mul_pd(XMM2, XMM4); \ XMM3 = _mm_mul_pd(XMM3, XMM5); \ XMM0 = _mm_add_pd(XMM0, XMM2); \ XMM1 = _mm_add_pd(XMM1, XMM3); \ } \ XMM0 = _mm_add_pd(XMM0, XMM1); \ XMM1 = _mm_shuffle_pd(XMM0, XMM0, _MM_SHUFFLE2(1, 1)); \ XMM0 = _mm_add_pd(XMM0, XMM1); \ _mm_store_sd((s), XMM0); \ } #define vec2norm(s, x, n) \ { \ int i; \ __m128d XMM0 = _mm_setzero_pd(); \ __m128d XMM1 = _mm_setzero_pd(); \ __m128d XMM2, XMM3, XMM4, XMM5; \ for (i = 0;i < (n);i += 4) { \ XMM2 = _mm_load_pd((x)+i ); \ XMM3 = _mm_load_pd((x)+i+2); \ XMM4 = XMM2; \ XMM5 = XMM3; \ XMM2 = _mm_mul_pd(XMM2, XMM4); \ XMM3 = _mm_mul_pd(XMM3, XMM5); \ XMM0 = _mm_add_pd(XMM0, XMM2); \ XMM1 = _mm_add_pd(XMM1, XMM3); \ } \ XMM0 = _mm_add_pd(XMM0, XMM1); \ XMM1 = _mm_shuffle_pd(XMM0, XMM0, _MM_SHUFFLE2(1, 1)); \ XMM0 = _mm_add_pd(XMM0, XMM1); \ XMM0 = _mm_sqrt_pd(XMM0); \ _mm_store_sd((s), XMM0); \ } #define vec2norminv(s, x, n) \ { \ int i; \ __m128d XMM0 = _mm_setzero_pd(); \ __m128d XMM1 = _mm_setzero_pd(); \ __m128d XMM2, XMM3, XMM4, XMM5; \ for (i = 0;i < (n);i += 4) { \ XMM2 = _mm_load_pd((x)+i ); \ XMM3 = _mm_load_pd((x)+i+2); \ XMM4 = XMM2; \ XMM5 = XMM3; \ XMM2 = _mm_mul_pd(XMM2, XMM4); \ XMM3 = _mm_mul_pd(XMM3, XMM5); \ XMM0 = _mm_add_pd(XMM0, XMM2); \ XMM1 = _mm_add_pd(XMM1, XMM3); \ } \ XMM2 = _mm_set1_pd(1.0); \ XMM0 = _mm_add_pd(XMM0, XMM1); \ XMM1 = _mm_shuffle_pd(XMM0, XMM0, _MM_SHUFFLE2(1, 1)); \ XMM0 = _mm_add_pd(XMM0, XMM1); \ XMM0 = _mm_sqrt_pd(XMM0); \ XMM2 = _mm_div_pd(XMM2, XMM0); \ _mm_store_sd((s), XMM2); \ }
0a83b44619d83dceca455d3a15f0086ecf732d92
3f55217e912141e04815bc8bcb6fbd5638d0896e
/src/hd/rhd_qtree.h
279b75925631cd99721cc8461abdf3624572e9f1
[ "BSD-2-Clause" ]
permissive
NREL/Radiance
bfbb93c99d86368ad0f27052a2a5504aeced47f8
2fcca99ace2f2435f32a09525ad31f2b3be3c1bc
refs/heads/master
2021-12-26T12:42:04.586614
2021-12-18T00:43:56
2021-12-18T00:43:56
8,210,805
164
68
NOASSERTION
2019-06-06T19:57:11
2013-02-15T00:47:56
C
UTF-8
C
false
false
2,261
h
rhd_qtree.h
/* RCSid $Id: rhd_qtree.h,v 3.20 2018/10/05 19:46:26 greg Exp $ */ /* * Quadtree data structures for holodeck display drivers. */ #ifndef _RAD_RHD_QTREE_H_ #define _RAD_RHD_QTREE_H_ #include "color.h" #include "tonemap.h" #include "rhdriver.h" #ifdef __cplusplus extern "C" { #endif #define DL 0 /* down left */ #define DR 1 /* down right */ #define UL 2 /* up left */ #define UR 3 /* up right */ #define BRF(i) (0x1<<(i)) /* branch flag bit */ #define LFF(i) (0x10<<(i)) /* leaf flag bit */ #define CHF(i) (0x100<<(i)) /* change flag bit */ #define CHBRF(i) (0x101<<(i)) /* changed branch bit */ #define CHLFF(i) (0x110<<(i)) /* changed leaf bit */ #define BR_ANY 0xf /* flags for any branches */ #define LF_ANY 0xf0 /* flags for any leaves */ #define CH_ANY 0xf00 /* flags for any change */ typedef struct rtree { short flgs; /* content flags (defined above) */ union { struct rtree *b; /* if branch */ int li; /* if leaf */ } k[4]; /* children */ } RTREE; extern struct rleaves { float (*wp)[3]; /* world intersection point array */ int32 *wd; /* world direction array */ TMbright *brt; /* encoded brightness array */ uby8 (*chr)[3]; /* encoded chrominance array */ uby8 (*rgb)[3]; /* tone-mapped color array */ int nl; /* count of leaves in our pile */ int bl, tl; /* bottom and top (next) leaf index */ int tml; /* next leaf needing tone-mapping */ char *base; /* base of allocated memory */ } qtL; /* our pile of leaves */ #define is_stump(t) (!((t)->flgs & (BR_ANY|LF_ANY))) extern RTREE qtrunk; /* trunk of quadtree */ extern double qtDepthEps; /* epsilon to compare depths (z fraction) */ extern int qtMinNodesiz; /* minimum node dimension (pixels) */ extern int rayqleft; /* number of rays to queue before flush */ extern TMstruct *tmGlobal; /* global tone-mapping structure */ /* rhd_qtree.c */ extern int qtAllocLeaves(register int n); extern void qtFreeLeaves(void); extern int qtCompost(int pct); extern void qtReplant(void); extern int qtFindLeaf(int x, int y); extern int qtMapLeaves(int redo); /* rhd_qtree2c.c rhd_qtree2r.c */ extern void qtRedraw(int x0, int y0, int x1, int y1); extern void qtUpdate(void); #ifdef __cplusplus } #endif #endif /* _RAD_RHD_QTREE_H_ */
c7de8670fddc138d05a2a172f3802f33d5cc78d1
e8b04bef9aa1ac8e2c109dd315f133c8f4d28ae6
/projects/robots/nex/controllers/fire_bird_6_obstacle_avoidance/fire_bird_6_obstacle_avoidance.c
d8e17cc60374993fb1075f2e84a85adb72f12331
[ "Apache-2.0" ]
permissive
cyberbotics/webots
f075dacf4067e8dcebbfd89e8690df8525f6d745
8aba6eaae76989facf3442305c8089d3cc366bcf
refs/heads/master
2023-08-31T09:41:13.205940
2023-08-18T10:48:30
2023-08-18T10:48:30
156,228,018
2,495
1,525
Apache-2.0
2023-08-28T16:30:33
2018-11-05T14:09:10
C++
UTF-8
C
false
false
2,647
c
fire_bird_6_obstacle_avoidance.c
/* * Copyright 1996-2023 Cyberbotics Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://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. */ /* * Description: Demo code for obstacle avoidance on Firebird 6 robot * Author: Anant Malewar; Nex Robotics */ #include <webots/distance_sensor.h> #include <webots/motor.h> #include <webots/robot.h> #include <stdio.h> #define TIME_STEP 64 int main(int argc, char **argv) { wb_robot_init(); printf("Fire Bird 6 controller for obstacle avoidance\n"); int i; WbDeviceTag ps[8], left_motor, right_motor; char ps_names[8][4] = {"ps0", "ps1", "ps2", "ps3", "ps4", "ps5", "ps6", "ps7"}; for (i = 0; i < 8; ++i) { ps[i] = wb_robot_get_device(ps_names[i]); wb_distance_sensor_enable(ps[i], TIME_STEP); } left_motor = wb_robot_get_device("left wheel motor"); right_motor = wb_robot_get_device("right wheel motor"); wb_motor_set_position(left_motor, INFINITY); wb_motor_set_position(right_motor, INFINITY); wb_motor_set_velocity(left_motor, 0.0); wb_motor_set_velocity(right_motor, 0.0); while (wb_robot_step(TIME_STEP) != -1) { double ps_values[8]; for (i = 0; i < 8; ++i) { ps_values[i] = wb_distance_sensor_get_value(ps[i]); printf("%f ", ps_values[i]); } printf("\n"); double threshold = 0.25; bool left_obstacle = ps_values[1] < threshold || ps_values[0] < threshold; bool right_obstacle = ps_values[3] < threshold || ps_values[4] < threshold; bool front_obstacle = ps_values[2] < threshold; // init speeds double left_speed = 1; double right_speed = 1; // modify speeds according to obstacles if (front_obstacle) { // turn back, but slightly right to not block the robot left_speed -= 1.0; right_speed -= 2.0; } else if (left_obstacle) { // turn right left_speed += 2.0; right_speed -= 2.0; } else if (right_obstacle) { // turn left left_speed -= 2.0; right_speed += 2.0; } // write actuators inputs wb_motor_set_velocity(left_motor, left_speed); wb_motor_set_velocity(right_motor, right_speed); }; wb_robot_cleanup(); return 0; }
c90e90abe1727fb8f82c9b932df684619122d137
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/spi/spi-sh.c
3c3600a994bdfce9284b63e637fc10e7515e4548
[ "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
12,608
c
spi-sh.c
/* * SH SPI bus driver * * Copyright (C) 2011 Renesas Solutions Corp. * * Based on pxa2xx_spi.c: * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs * * 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; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/errno.h> #include <linux/timer.h> #include <linux/delay.h> #include <linux/list.h> #include <linux/workqueue.h> #include <linux/interrupt.h> #include <linux/platform_device.h> #include <linux/io.h> #include <linux/spi/spi.h> #define SPI_SH_TBR 0x00 #define SPI_SH_RBR 0x00 #define SPI_SH_CR1 0x08 #define SPI_SH_CR2 0x10 #define SPI_SH_CR3 0x18 #define SPI_SH_CR4 0x20 #define SPI_SH_CR5 0x28 /* CR1 */ #define SPI_SH_TBE 0x80 #define SPI_SH_TBF 0x40 #define SPI_SH_RBE 0x20 #define SPI_SH_RBF 0x10 #define SPI_SH_PFONRD 0x08 #define SPI_SH_SSDB 0x04 #define SPI_SH_SSD 0x02 #define SPI_SH_SSA 0x01 /* CR2 */ #define SPI_SH_RSTF 0x80 #define SPI_SH_LOOPBK 0x40 #define SPI_SH_CPOL 0x20 #define SPI_SH_CPHA 0x10 #define SPI_SH_L1M0 0x08 /* CR3 */ #define SPI_SH_MAX_BYTE 0xFF /* CR4 */ #define SPI_SH_TBEI 0x80 #define SPI_SH_TBFI 0x40 #define SPI_SH_RBEI 0x20 #define SPI_SH_RBFI 0x10 #define SPI_SH_WPABRT 0x04 #define SPI_SH_SSS 0x01 /* CR8 */ #define SPI_SH_P1L0 0x80 #define SPI_SH_PP1L0 0x40 #define SPI_SH_MUXI 0x20 #define SPI_SH_MUXIRQ 0x10 #define SPI_SH_FIFO_SIZE 32 #define SPI_SH_SEND_TIMEOUT (3 * HZ) #define SPI_SH_RECEIVE_TIMEOUT (HZ >> 3) #undef DEBUG struct spi_sh_data { void __iomem *addr; int irq; struct spi_master *master; struct list_head queue; struct workqueue_struct *workqueue; struct work_struct ws; unsigned long cr1; wait_queue_head_t wait; spinlock_t lock; int width; }; static void spi_sh_write(struct spi_sh_data *ss, unsigned long data, unsigned long offset) { if (ss->width == 8) iowrite8(data, ss->addr + (offset >> 2)); else if (ss->width == 32) iowrite32(data, ss->addr + offset); } static unsigned long spi_sh_read(struct spi_sh_data *ss, unsigned long offset) { if (ss->width == 8) return ioread8(ss->addr + (offset >> 2)); else if (ss->width == 32) return ioread32(ss->addr + offset); else return 0; } static void spi_sh_set_bit(struct spi_sh_data *ss, unsigned long val, unsigned long offset) { unsigned long tmp; tmp = spi_sh_read(ss, offset); tmp |= val; spi_sh_write(ss, tmp, offset); } static void spi_sh_clear_bit(struct spi_sh_data *ss, unsigned long val, unsigned long offset) { unsigned long tmp; tmp = spi_sh_read(ss, offset); tmp &= ~val; spi_sh_write(ss, tmp, offset); } static void clear_fifo(struct spi_sh_data *ss) { spi_sh_set_bit(ss, SPI_SH_RSTF, SPI_SH_CR2); spi_sh_clear_bit(ss, SPI_SH_RSTF, SPI_SH_CR2); } static int spi_sh_wait_receive_buffer(struct spi_sh_data *ss) { int timeout = 100000; while (spi_sh_read(ss, SPI_SH_CR1) & SPI_SH_RBE) { udelay(10); if (timeout-- < 0) return -ETIMEDOUT; } return 0; } static int spi_sh_wait_write_buffer_empty(struct spi_sh_data *ss) { int timeout = 100000; while (!(spi_sh_read(ss, SPI_SH_CR1) & SPI_SH_TBE)) { udelay(10); if (timeout-- < 0) return -ETIMEDOUT; } return 0; } static int spi_sh_send(struct spi_sh_data *ss, struct spi_message *mesg, struct spi_transfer *t) { int i, retval = 0; int remain = t->len; int cur_len; unsigned char *data; unsigned long tmp; long ret; if (t->len) spi_sh_set_bit(ss, SPI_SH_SSA, SPI_SH_CR1); data = (unsigned char *)t->tx_buf; while (remain > 0) { cur_len = min(SPI_SH_FIFO_SIZE, remain); for (i = 0; i < cur_len && !(spi_sh_read(ss, SPI_SH_CR4) & SPI_SH_WPABRT) && !(spi_sh_read(ss, SPI_SH_CR1) & SPI_SH_TBF); i++) spi_sh_write(ss, (unsigned long)data[i], SPI_SH_TBR); if (spi_sh_read(ss, SPI_SH_CR4) & SPI_SH_WPABRT) { /* Abort SPI operation */ spi_sh_set_bit(ss, SPI_SH_WPABRT, SPI_SH_CR4); retval = -EIO; break; } cur_len = i; remain -= cur_len; data += cur_len; if (remain > 0) { ss->cr1 &= ~SPI_SH_TBE; spi_sh_set_bit(ss, SPI_SH_TBE, SPI_SH_CR4); ret = wait_event_interruptible_timeout(ss->wait, ss->cr1 & SPI_SH_TBE, SPI_SH_SEND_TIMEOUT); if (ret == 0 && !(ss->cr1 & SPI_SH_TBE)) { printk(KERN_ERR "%s: timeout\n", __func__); return -ETIMEDOUT; } } } if (list_is_last(&t->transfer_list, &mesg->transfers)) { tmp = spi_sh_read(ss, SPI_SH_CR1); tmp = tmp & ~(SPI_SH_SSD | SPI_SH_SSDB); spi_sh_write(ss, tmp, SPI_SH_CR1); spi_sh_set_bit(ss, SPI_SH_SSA, SPI_SH_CR1); ss->cr1 &= ~SPI_SH_TBE; spi_sh_set_bit(ss, SPI_SH_TBE, SPI_SH_CR4); ret = wait_event_interruptible_timeout(ss->wait, ss->cr1 & SPI_SH_TBE, SPI_SH_SEND_TIMEOUT); if (ret == 0 && (ss->cr1 & SPI_SH_TBE)) { printk(KERN_ERR "%s: timeout\n", __func__); return -ETIMEDOUT; } } return retval; } static int spi_sh_receive(struct spi_sh_data *ss, struct spi_message *mesg, struct spi_transfer *t) { int i; int remain = t->len; int cur_len; unsigned char *data; unsigned long tmp; long ret; if (t->len > SPI_SH_MAX_BYTE) spi_sh_write(ss, SPI_SH_MAX_BYTE, SPI_SH_CR3); else spi_sh_write(ss, t->len, SPI_SH_CR3); tmp = spi_sh_read(ss, SPI_SH_CR1); tmp = tmp & ~(SPI_SH_SSD | SPI_SH_SSDB); spi_sh_write(ss, tmp, SPI_SH_CR1); spi_sh_set_bit(ss, SPI_SH_SSA, SPI_SH_CR1); spi_sh_wait_write_buffer_empty(ss); data = (unsigned char *)t->rx_buf; while (remain > 0) { if (remain >= SPI_SH_FIFO_SIZE) { ss->cr1 &= ~SPI_SH_RBF; spi_sh_set_bit(ss, SPI_SH_RBF, SPI_SH_CR4); ret = wait_event_interruptible_timeout(ss->wait, ss->cr1 & SPI_SH_RBF, SPI_SH_RECEIVE_TIMEOUT); if (ret == 0 && spi_sh_read(ss, SPI_SH_CR1) & SPI_SH_RBE) { printk(KERN_ERR "%s: timeout\n", __func__); return -ETIMEDOUT; } } cur_len = min(SPI_SH_FIFO_SIZE, remain); for (i = 0; i < cur_len; i++) { if (spi_sh_wait_receive_buffer(ss)) break; data[i] = (unsigned char)spi_sh_read(ss, SPI_SH_RBR); } remain -= cur_len; data += cur_len; } /* deassert CS when SPI is receiving. */ if (t->len > SPI_SH_MAX_BYTE) { clear_fifo(ss); spi_sh_write(ss, 1, SPI_SH_CR3); } else { spi_sh_write(ss, 0, SPI_SH_CR3); } return 0; } static void spi_sh_work(struct work_struct *work) { struct spi_sh_data *ss = container_of(work, struct spi_sh_data, ws); struct spi_message *mesg; struct spi_transfer *t; unsigned long flags; int ret; pr_debug("%s: enter\n", __func__); spin_lock_irqsave(&ss->lock, flags); while (!list_empty(&ss->queue)) { mesg = list_entry(ss->queue.next, struct spi_message, queue); list_del_init(&mesg->queue); spin_unlock_irqrestore(&ss->lock, flags); list_for_each_entry(t, &mesg->transfers, transfer_list) { pr_debug("tx_buf = %p, rx_buf = %p\n", t->tx_buf, t->rx_buf); pr_debug("len = %d, delay_usecs = %d\n", t->len, t->delay_usecs); if (t->tx_buf) { ret = spi_sh_send(ss, mesg, t); if (ret < 0) goto error; } if (t->rx_buf) { ret = spi_sh_receive(ss, mesg, t); if (ret < 0) goto error; } mesg->actual_length += t->len; } spin_lock_irqsave(&ss->lock, flags); mesg->status = 0; mesg->complete(mesg->context); } clear_fifo(ss); spi_sh_set_bit(ss, SPI_SH_SSD, SPI_SH_CR1); udelay(100); spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD, SPI_SH_CR1); clear_fifo(ss); spin_unlock_irqrestore(&ss->lock, flags); return; error: mesg->status = ret; mesg->complete(mesg->context); spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD, SPI_SH_CR1); clear_fifo(ss); } static int spi_sh_setup(struct spi_device *spi) { struct spi_sh_data *ss = spi_master_get_devdata(spi->master); if (!spi->bits_per_word) spi->bits_per_word = 8; pr_debug("%s: enter\n", __func__); spi_sh_write(ss, 0xfe, SPI_SH_CR1); /* SPI sycle stop */ spi_sh_write(ss, 0x00, SPI_SH_CR1); /* CR1 init */ spi_sh_write(ss, 0x00, SPI_SH_CR3); /* CR3 init */ clear_fifo(ss); /* 1/8 clock */ spi_sh_write(ss, spi_sh_read(ss, SPI_SH_CR2) | 0x07, SPI_SH_CR2); udelay(10); return 0; } static int spi_sh_transfer(struct spi_device *spi, struct spi_message *mesg) { struct spi_sh_data *ss = spi_master_get_devdata(spi->master); unsigned long flags; pr_debug("%s: enter\n", __func__); pr_debug("\tmode = %02x\n", spi->mode); spin_lock_irqsave(&ss->lock, flags); mesg->actual_length = 0; mesg->status = -EINPROGRESS; spi_sh_clear_bit(ss, SPI_SH_SSA, SPI_SH_CR1); list_add_tail(&mesg->queue, &ss->queue); queue_work(ss->workqueue, &ss->ws); spin_unlock_irqrestore(&ss->lock, flags); return 0; } static void spi_sh_cleanup(struct spi_device *spi) { struct spi_sh_data *ss = spi_master_get_devdata(spi->master); pr_debug("%s: enter\n", __func__); spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD, SPI_SH_CR1); } static irqreturn_t spi_sh_irq(int irq, void *_ss) { struct spi_sh_data *ss = (struct spi_sh_data *)_ss; unsigned long cr1; cr1 = spi_sh_read(ss, SPI_SH_CR1); if (cr1 & SPI_SH_TBE) ss->cr1 |= SPI_SH_TBE; if (cr1 & SPI_SH_TBF) ss->cr1 |= SPI_SH_TBF; if (cr1 & SPI_SH_RBE) ss->cr1 |= SPI_SH_RBE; if (cr1 & SPI_SH_RBF) ss->cr1 |= SPI_SH_RBF; if (ss->cr1) { spi_sh_clear_bit(ss, ss->cr1, SPI_SH_CR4); wake_up(&ss->wait); } return IRQ_HANDLED; } static int spi_sh_remove(struct platform_device *pdev) { struct spi_sh_data *ss = dev_get_drvdata(&pdev->dev); spi_unregister_master(ss->master); destroy_workqueue(ss->workqueue); free_irq(ss->irq, ss); iounmap(ss->addr); return 0; } static int spi_sh_probe(struct platform_device *pdev) { struct resource *res; struct spi_master *master; struct spi_sh_data *ss; int ret, irq; /* get base addr */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (unlikely(res == NULL)) { dev_err(&pdev->dev, "invalid resource\n"); return -EINVAL; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "platform_get_irq error\n"); return -ENODEV; } master = spi_alloc_master(&pdev->dev, sizeof(struct spi_sh_data)); if (master == NULL) { dev_err(&pdev->dev, "spi_alloc_master error.\n"); return -ENOMEM; } ss = spi_master_get_devdata(master); dev_set_drvdata(&pdev->dev, ss); switch (res->flags & IORESOURCE_MEM_TYPE_MASK) { case IORESOURCE_MEM_8BIT: ss->width = 8; break; case IORESOURCE_MEM_32BIT: ss->width = 32; break; default: dev_err(&pdev->dev, "No support width\n"); ret = -ENODEV; goto error1; } ss->irq = irq; ss->master = master; ss->addr = ioremap(res->start, resource_size(res)); if (ss->addr == NULL) { dev_err(&pdev->dev, "ioremap error.\n"); ret = -ENOMEM; goto error1; } INIT_LIST_HEAD(&ss->queue); spin_lock_init(&ss->lock); INIT_WORK(&ss->ws, spi_sh_work); init_waitqueue_head(&ss->wait); ss->workqueue = create_singlethread_workqueue( dev_name(master->dev.parent)); if (ss->workqueue == NULL) { dev_err(&pdev->dev, "create workqueue error\n"); ret = -EBUSY; goto error2; } ret = request_irq(irq, spi_sh_irq, 0, "spi_sh", ss); if (ret < 0) { dev_err(&pdev->dev, "request_irq error\n"); goto error3; } master->num_chipselect = 2; master->bus_num = pdev->id; master->setup = spi_sh_setup; master->transfer = spi_sh_transfer; master->cleanup = spi_sh_cleanup; ret = spi_register_master(master); if (ret < 0) { printk(KERN_ERR "spi_register_master error.\n"); goto error4; } return 0; error4: free_irq(irq, ss); error3: destroy_workqueue(ss->workqueue); error2: iounmap(ss->addr); error1: spi_master_put(master); return ret; } static struct platform_driver spi_sh_driver = { .probe = spi_sh_probe, .remove = spi_sh_remove, .driver = { .name = "sh_spi", .owner = THIS_MODULE, }, }; module_platform_driver(spi_sh_driver); MODULE_DESCRIPTION("SH SPI bus driver"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Yoshihiro Shimoda"); MODULE_ALIAS("platform:sh_spi");
ae97295998313858b13e989bacd038e7fd1a221a
3bd385b466cb035fecd2b0c11ae054d42bf44fc2
/src/annotationsketch/text_width_calculator_cairo.c
e6854b6a3e6e355e6d97ee8cd350f644221d064c
[ "LicenseRef-scancode-unknown-license-reference", "ISC", "BSD-2-Clause", "LicenseRef-scancode-mit-old-style", "Zlib", "MIT", "BSD-3-Clause", "bzip2-1.0.6" ]
permissive
genometools/genometools
c366dff04f6baa887f6b3be3ec55bce824b2bae1
df1df94b8c05a9c9bf848ffc6755c87b58573da5
refs/heads/master
2023-04-13T13:57:18.748796
2023-04-09T21:29:53
2023-04-09T21:29:53
11,177,980
237
63
NOASSERTION
2023-04-09T21:29:54
2013-07-04T13:39:38
C
UTF-8
C
false
false
5,172
c
text_width_calculator_cairo.c
/* Copyright (c) 2008-2012 Sascha Steinbiss <steinbiss@zbh.uni-hamburg.de> Copyright (c) 2008-2012 Center for Bioinformatics, University of Hamburg Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <cairo.h> #include <pango/pangocairo.h> #include "core/class_alloc_lock.h" #include "core/ensure_api.h" #include "core/ma_api.h" #include "core/mathsupport_api.h" #include "core/str_api.h" #include "core/unused_api.h" #include "annotationsketch/default_formats.h" #include "annotationsketch/style.h" #include "annotationsketch/text_width_calculator.h" #include "annotationsketch/text_width_calculator_cairo.h" #include "annotationsketch/text_width_calculator_rep.h" #define GT_TWC_FORMAT CAIRO_FORMAT_ARGB32 #define GT_TWC_WIDTH 500 #define GT_TWC_HEIGHT 60 struct GtTextWidthCalculatorCairo { const GtTextWidthCalculator parent_instance; GtStyle *style; cairo_t *context; cairo_surface_t *mysurf; PangoLayout *layout; PangoFontDescription *desc; bool own_context; }; #define gt_text_width_calculator_cairo_cast(TWC)\ gt_text_width_calculator_cast(gt_text_width_calculator_cairo_class(),\ TWC) double gt_text_width_calculator_cairo_get_text_width(GtTextWidthCalculator *twc, const char *text, GT_UNUSED GtError *err) { GtTextWidthCalculatorCairo *twcc; PangoRectangle rect; gt_assert(twc && text); twcc = gt_text_width_calculator_cairo_cast(twc); /* redo layout */ pango_layout_set_text(twcc->layout, text, -1); /* get extents */ pango_layout_get_pixel_extents(twcc->layout, &rect, NULL); if (twcc->style) cairo_restore(twcc->context); gt_assert(gt_double_smaller_double(0, rect.width)); return rect.width; } void gt_text_width_calculator_cairo_delete(GtTextWidthCalculator *twc) { GtTextWidthCalculatorCairo *twcc; if (!twc) return; twcc = gt_text_width_calculator_cairo_cast(twc); g_object_unref(twcc->layout); if (twcc->style) gt_style_delete(twcc->style); if (twcc->own_context) { cairo_destroy(twcc->context); cairo_surface_destroy(twcc->mysurf); } } const GtTextWidthCalculatorClass* gt_text_width_calculator_cairo_class(void) { static const GtTextWidthCalculatorClass *twcc = NULL; gt_class_alloc_lock_enter(); if (!twcc) { twcc = gt_text_width_calculator_class_new( sizeof (GtTextWidthCalculatorCairo), gt_text_width_calculator_cairo_get_text_width, gt_text_width_calculator_cairo_delete); } gt_class_alloc_lock_leave(); return twcc; } GtTextWidthCalculator* gt_text_width_calculator_cairo_new(cairo_t *context, GtStyle *style, GtError *err) { GtTextWidthCalculatorCairo *twcc; GtTextWidthCalculator *twc; GtStr *fontfam = NULL; double theight = TEXT_SIZE_DEFAULT; char buf[BUFSIZ]; twc = gt_text_width_calculator_create(gt_text_width_calculator_cairo_class()); twcc = gt_text_width_calculator_cairo_cast(twc); fontfam = gt_str_new_cstr("Sans"); if (style) twcc->style = gt_style_ref(style); if (!context) { twcc->mysurf = cairo_image_surface_create(GT_TWC_FORMAT, GT_TWC_WIDTH, GT_TWC_HEIGHT); twcc->context = cairo_create(twcc->mysurf); twcc->own_context = true; } else { twcc->context = context; twcc->own_context = false; } if (twcc->style) { if (gt_style_get_num(twcc->style, "format", "block_caption_font_size", &theight, NULL, err) == GT_STYLE_QUERY_ERROR) { gt_str_delete(fontfam); gt_text_width_calculator_delete(twc); return NULL; } if (gt_style_get_str(twcc->style, "format", "block_caption_font_family", fontfam, NULL, err ) == GT_STYLE_QUERY_ERROR) { gt_str_delete(fontfam); return NULL; } cairo_save(twcc->context); } twcc->layout = pango_cairo_create_layout(twcc->context); snprintf(buf, BUFSIZ, "%s %d", gt_str_get(fontfam), (int) theight); twcc->desc = pango_font_description_from_string(buf); pango_layout_set_font_description(twcc->layout, twcc->desc); pango_font_description_free(twcc->desc); gt_str_delete(fontfam); return twc; }
6b43cb58815fbb0b34e6c2527eacab6e3e503f52
9ceacf33fd96913cac7ef15492c126d96cae6911
/sys/netinet6/in6_proto.c
4e48a1e45b5f1662e2df500c381cf8bee5809e60
[]
no_license
openbsd/src
ab97ef834fd2d5a7f6729814665e9782b586c130
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
refs/heads/master
2023-09-02T18:54:56.624627
2023-09-02T15:16:12
2023-09-02T15:16:12
66,966,208
3,394
1,235
null
2023-08-08T02:42:25
2016-08-30T18:18:25
C
UTF-8
C
false
false
10,845
c
in6_proto.c
/* $OpenBSD: in6_proto.c,v 1.112 2022/11/23 14:48:28 kn Exp $ */ /* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project 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 PROJECT 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 PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)in_proto.c 8.1 (Berkeley) 6/10/93 */ #include <sys/param.h> #include <sys/socket.h> #include <sys/protosw.h> #include <sys/kernel.h> #include <sys/domain.h> #include <sys/mbuf.h> #include <net/if.h> #include <net/if_var.h> #include <net/route.h> #include <net/rtable.h> #include <netinet/in.h> #include <netinet/ip.h> #include <netinet/ip_var.h> #include <netinet/in_pcb.h> #include <netinet/ip6.h> #include <netinet6/ip6_var.h> #include <netinet/icmp6.h> #include <netinet/tcp.h> #include <netinet/tcp_timer.h> #include <netinet/tcp_var.h> #include <netinet/udp.h> #include <netinet/udp_var.h> #include <netinet/ip_ipsp.h> #include <netinet/ip_ah.h> #include <netinet/ip_esp.h> #include <netinet/ip_ipip.h> #include <netinet6/in6_var.h> #include <netinet6/nd6.h> #include "gif.h" #if NGIF > 0 #include <net/if_gif.h> #endif #include "carp.h" #if NCARP > 0 #include <netinet/ip_carp.h> #endif #include "pf.h" #if NPF > 0 #include <netinet6/ip6_divert.h> #endif #include "etherip.h" #if NETHERIP > 0 #include <net/if_etherip.h> #endif #include "gre.h" #if NGRE > 0 #include <net/if_gre.h> #endif /* * TCP/IP protocol family: IP6, ICMP6, UDP, TCP. */ u_char ip6_protox[IPPROTO_MAX]; const struct protosw inet6sw[] = { { .pr_domain = &inet6domain, .pr_protocol = IPPROTO_IPV6, .pr_init = ip6_init, .pr_slowtimo = frag6_slowtimo, .pr_sysctl = ip6_sysctl }, { .pr_type = SOCK_DGRAM, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_UDP, .pr_flags = PR_ATOMIC|PR_ADDR|PR_SPLICE, .pr_input = udp_input, .pr_ctlinput = udp6_ctlinput, .pr_ctloutput = ip6_ctloutput, .pr_usrreqs = &udp6_usrreqs, .pr_sysctl = udp_sysctl }, { .pr_type = SOCK_STREAM, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_TCP, .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS|PR_SPLICE, .pr_input = tcp_input, .pr_ctlinput = tcp6_ctlinput, .pr_ctloutput = tcp_ctloutput, .pr_usrreqs = &tcp6_usrreqs, .pr_sysctl = tcp_sysctl }, { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_RAW, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = rip6_input, .pr_ctlinput = rip6_ctlinput, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, .pr_sysctl = rip6_sysctl }, { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_ICMPV6, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = icmp6_input, .pr_ctlinput = rip6_ctlinput, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, .pr_init = icmp6_init, .pr_fasttimo = icmp6_fasttimo, .pr_sysctl = icmp6_sysctl }, { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_DSTOPTS, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = dest6_input }, { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_ROUTING, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = route6_input }, { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_FRAGMENT, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = frag6_input }, #ifdef IPSEC { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_AH, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = ah46_input, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, .pr_sysctl = ah_sysctl }, { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_ESP, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = esp46_input, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, .pr_sysctl = esp_sysctl }, { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_IPCOMP, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = ipcomp46_input, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, .pr_sysctl = ipcomp_sysctl }, #endif /* IPSEC */ { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_IPV4, .pr_flags = PR_ATOMIC|PR_ADDR, #if NGIF > 0 .pr_input = in6_gif_input, #else .pr_input = ipip_input, #endif .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, /* XXX */ }, { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_IPV6, .pr_flags = PR_ATOMIC|PR_ADDR, #if NGIF > 0 .pr_input = in6_gif_input, #else .pr_input = ipip_input, #endif .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, /* XXX */ }, #if defined(MPLS) && NGIF > 0 { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_MPLS, .pr_flags = PR_ATOMIC|PR_ADDR, #if NGIF > 0 .pr_input = in6_gif_input, #else .pr_input = ipip_input, #endif .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, /* XXX */ }, #endif /* MPLS */ #if NCARP > 0 { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_CARP, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = carp6_proto_input, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, .pr_sysctl = carp_sysctl }, #endif /* NCARP */ #if NPF > 0 { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_DIVERT, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &divert6_usrreqs, .pr_init = divert6_init, .pr_sysctl = divert6_sysctl }, #endif /* NPF > 0 */ #if NETHERIP > 0 { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_ETHERIP, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = ip6_etherip_input, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, }, #endif /* NETHERIP */ #if NGRE > 0 { .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_protocol = IPPROTO_GRE, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = gre_input6, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, }, #endif /* NGRE */ { /* raw wildcard */ .pr_type = SOCK_RAW, .pr_domain = &inet6domain, .pr_flags = PR_ATOMIC|PR_ADDR, .pr_input = rip6_input, .pr_ctloutput = rip6_ctloutput, .pr_usrreqs = &rip6_usrreqs, .pr_init = rip6_init } }; const struct domain inet6domain = { .dom_family = AF_INET6, .dom_name = "internet6", .dom_protosw = inet6sw, .dom_protoswNPROTOSW = &inet6sw[nitems(inet6sw)], .dom_sasize = sizeof(struct sockaddr_in6), .dom_rtoffset = offsetof(struct sockaddr_in6, sin6_addr), .dom_maxplen = 128, }; /* * Internet configuration info */ int ip6_forwarding = 0; /* no forwarding unless sysctl'd to enable */ int ip6_mforwarding = 0; /* no multicast forwarding unless ... */ int ip6_multipath = 0; /* no using multipath routes unless ... */ int ip6_sendredirects = 1; int ip6_defhlim = IPV6_DEFHLIM; int ip6_defmcasthlim = IPV6_DEFAULT_MULTICAST_HOPS; int ip6_maxfragpackets = 200; int ip6_maxfrags = 200; int ip6_log_interval = 5; int ip6_hdrnestlimit = 10; /* appropriate? */ int ip6_dad_count = 1; /* DupAddrDetectionTransmits */ int ip6_dad_pending; /* number of currently running DADs */ int ip6_auto_flowlabel = 1; int ip6_use_deprecated = 1; /* allow deprecated addr (RFC2462 5.5.4) */ int ip6_mcast_pmtu = 0; /* enable pMTU discovery for multicast? */ int ip6_neighborgcthresh = 2048; /* Threshold # of NDP entries for GC */ int ip6_maxdynroutes = 4096; /* Max # of routes created via redirect */ time_t ip6_log_time = (time_t)0L; /* raw IP6 parameters */ /* * Nominal space allocated to a raw ip socket. */ #define RIPV6SNDQ 8192 #define RIPV6RCVQ 8192 u_long rip6_sendspace = RIPV6SNDQ; u_long rip6_recvspace = RIPV6RCVQ; /* ICMPV6 parameters */ int icmp6_redirtimeout = 10 * 60; /* 10 minutes */ int icmp6errppslim = 100; /* 100pps */ int ip6_mtudisc_timeout = IPMTUDISCTIMEOUT;
4711d96789e350b41d23a57d1e82ed52ef4e934c
67305fcba68fdf469862aed2959ad1dd5b22a536
/examples/27_iot_cloud_ali_iotkit/packages/ali-iotkit-v2.0.3/iotkit-embedded/src/tfs/platform/pal_platform_sha256.c
5b6e2b7279c5396220508ea0130e599d9135f2b2
[ "Apache-2.0" ]
permissive
RT-Thread/IoT_Board
cdabf100a8d515fbcaa65ab0b72ec67acb0d2c9a
2d218a4e06f06dbb356ec00767904f91d00db7cc
refs/heads/master
2023-09-04T16:51:34.485240
2022-01-19T01:26:16
2022-01-19T01:26:16
161,133,933
344
238
Apache-2.0
2023-06-06T04:10:57
2018-12-10T07:21:46
C
UTF-8
C
false
false
261
c
pal_platform_sha256.c
/* * Copyright (C) 2015 YunOS Project. All rights reserved. */ #include "utils_sha256.h" int pal_sha256_sum(const uint8_t *addr, const int len, uint8_t *mac, uint32_t *mac_len) { utils_sha256(addr, (size_t)len, mac); *mac_len = 32; return 0; }
a1281af71fd1e8884a87070a391bc8e4c51b8105
ecce427678ecff2a93a47f3b1b664202c7d27617
/levels/bob/seesaw_platform/model.inc.c
0271ad4288eb36406bb718577edd40154d91168c
[]
no_license
sm64pc/sm64ex
ecf37f31b3f7426c4874254660d856030d789714
54cd27ccee45a2403b45f07a00d6043c51149969
refs/heads/nightly
2023-08-11T12:14:34.424168
2023-07-01T11:45:50
2023-07-01T11:45:50
262,091,731
795
238
null
2023-07-01T11:45:51
2020-05-07T15:43:27
C
UTF-8
C
false
false
4,430
c
model.inc.c
// 0x0700E510 - 0x0700E528 static const Lights1 bob_seg7_lights_0700E510 = gdSPDefLights1( 0x3f, 0x3f, 0x3f, 0xff, 0xff, 0xff, 0x28, 0x28, 0x28 ); // 0x0700E528 - 0x0700E628 static const Vtx bob_seg7_vertex_0700E528[] = { {{{ -180, 51, -904}, 0, { 990, 0}, {0xcd, 0x33, 0x99, 0xff}}}, {{{ -180, 0, -904}, 0, { 950, 284}, {0xac, 0xac, 0xd6, 0xff}}}, {{{ -180, 51, 905}, 0, { -3222, 0}, {0xac, 0x54, 0x2a, 0xff}}}, {{{ -180, 0, -904}, 0, { -3204, 0}, {0xac, 0xac, 0xd6, 0xff}}}, {{{ 181, 0, -904}, 0, { -3204, 2012}, {0x33, 0xcd, 0x99, 0xff}}}, {{{ 181, 0, 905}, 0, { 990, 2012}, {0x54, 0xac, 0x2a, 0xff}}}, {{{ -180, 0, 905}, 0, { 990, 0}, {0xcd, 0xcd, 0x67, 0xff}}}, {{{ 181, 51, -904}, 0, { 990, 2012}, {0x54, 0x54, 0xd6, 0xff}}}, {{{ 181, 51, 905}, 0, { -3222, 2012}, {0x33, 0x33, 0x67, 0xff}}}, {{{ 181, 0, 905}, 0, { -3244, 304}, {0x54, 0xac, 0x2a, 0xff}}}, {{{ 181, 0, -904}, 0, { 950, 284}, {0x33, 0xcd, 0x99, 0xff}}}, {{{ 181, 51, -904}, 0, { 990, 0}, {0x54, 0x54, 0xd6, 0xff}}}, {{{ 181, 51, 905}, 0, { -3222, 0}, {0x33, 0x33, 0x67, 0xff}}}, {{{ -180, 0, 905}, 0, { 0, 172}, {0xcd, 0xcd, 0x67, 0xff}}}, {{{ 181, 51, 905}, 0, { 690, 0}, {0x33, 0x33, 0x67, 0xff}}}, {{{ -180, 51, 905}, 0, { 0, 0}, {0xac, 0x54, 0x2a, 0xff}}}, }; // 0x0700E628 - 0x0700E6C8 static const Vtx bob_seg7_vertex_0700E628[] = { {{{ -180, 0, -904}, 0, { 950, 284}, {0xac, 0xac, 0xd6, 0xff}}}, {{{ -180, 0, 905}, 0, { -3244, 304}, {0xcd, 0xcd, 0x67, 0xff}}}, {{{ -180, 51, 905}, 0, { -3222, 0}, {0xac, 0x54, 0x2a, 0xff}}}, {{{ 181, 0, -904}, 0, { 268, 2012}, {0x33, 0xcd, 0x99, 0xff}}}, {{{ -180, 0, -904}, 0, { 990, 2012}, {0xac, 0xac, 0xd6, 0xff}}}, {{{ -180, 51, -904}, 0, { 990, 1808}, {0xcd, 0x33, 0x99, 0xff}}}, {{{ 181, 51, -904}, 0, { 268, 1808}, {0x54, 0x54, 0xd6, 0xff}}}, {{{ -180, 0, 905}, 0, { 0, 172}, {0xcd, 0xcd, 0x67, 0xff}}}, {{{ 181, 0, 905}, 0, { 690, 172}, {0x54, 0xac, 0x2a, 0xff}}}, {{{ 181, 51, 905}, 0, { 690, 0}, {0x33, 0x33, 0x67, 0xff}}}, }; // 0x0700E6C8 - 0x0700E768 static const Gfx bob_seg7_dl_0700E6C8[] = { gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, generic_09006000), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), gsSPLight(&bob_seg7_lights_0700E510.l, 1), gsSPLight(&bob_seg7_lights_0700E510.a, 2), gsSPVertex(bob_seg7_vertex_0700E528, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 6, 3, 5, 0x0, 7, 0, 2, 0x0), gsSP2Triangles( 8, 7, 2, 0x0, 9, 10, 11, 0x0), gsSP2Triangles(12, 9, 11, 0x0, 13, 14, 15, 0x0), gsSPVertex(bob_seg7_vertex_0700E628, 10, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 5, 6, 0x0, 7, 8, 9, 0x0), gsSPEndDisplayList(), }; // 0x0700E768 - 0x0700E810 const Gfx bob_seg7_dl_0700E768[] = { gsDPPipeSync(), gsDPSetCycleType(G_CYC_2CYCLE), gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), gsDPSetDepthSource(G_ZS_PIXEL), gsDPSetFogColor(160, 160, 160, 255), gsSPFogPosition(980, 1000), gsSPSetGeometryMode(G_FOG), gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_PASS2), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), gsDPTileSync(), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 6, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (64 - 1) << G_TEXTURE_IMAGE_FRAC), gsSPDisplayList(bob_seg7_dl_0700E6C8), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsDPPipeSync(), gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF, G_RM_NOOP2), gsSPClearGeometryMode(G_FOG), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), gsSPEndDisplayList(), };
22b29906ca9b0807d366199bb3364f0596904c6a
0ff5c3178e87a28a82165bfa908d9319cf7a2323
/30. CPP Programs/Median of two sorted array.cpp
c2e300399b70568f63883f690523114728d88a5e
[ "MIT" ]
permissive
SR-Sunny-Raj/Hacktoberfest2021-DSA
40bf8385ed976fd81d27340514579b283c339c1f
116526c093ed1ac7907483d001859df63c902cb3
refs/heads/master
2023-01-31T07:46:26.016367
2023-01-26T12:45:32
2023-01-26T12:45:32
262,236,251
261
963
MIT
2023-03-25T14:22:10
2020-05-08T05:36:07
C++
UTF-8
C
false
false
1,681
cpp
Median of two sorted array.cpp
// A divide and conquer based efficient solution to find median // of two sorted arrays of same size. #include<bits/stdc++.h> using namespace std; int median(int [], int); /* to get median of a sorted array */ /* This function returns median of ar1[] and ar2[]. Assumptions in this function: Both ar1[] and ar2[] are sorted arrays Both have n elements */ int getMedian(int ar1[], int ar2[], int n) { /* return -1 for invalid input */ if (n <= 0) return -1; if (n == 1) return (ar1[0] + ar2[0])/2; if (n == 2) return (max(ar1[0], ar2[0]) + min(ar1[1], ar2[1])) / 2; int m1 = median(ar1, n); /* get the median of the first array */ int m2 = median(ar2, n); /* get the median of the second array */ /* If medians are equal then return either m1 or m2 */ if (m1 == m2) return m1; /* if m1 < m2 then median must exist in ar1[m1....] and ar2[....m2] */ if (m1 < m2) { if (n % 2 == 0) return getMedian(ar1 + n/2 - 1, ar2, n - n/2 +1); return getMedian(ar1 + n/2, ar2, n - n/2); } /* if m1 > m2 then median must exist in ar1[....m1] and ar2[m2...] */ if (n % 2 == 0) return getMedian(ar2 + n/2 - 1, ar1, n - n/2 + 1); return getMedian(ar2 + n/2, ar1, n - n/2); } /* Function to get median of a sorted array */ int median(int arr[], int n) { if (n%2 == 0) return (arr[n/2] + arr[n/2-1])/2; else return arr[n/2]; } /* Driver program to test above function */ int main() { int ar1[] = {1, 2, 3, 6}; int ar2[] = {4, 6, 8, 10}; int n1 = sizeof(ar1)/sizeof(ar1[0]); int n2 = sizeof(ar2)/sizeof(ar2[0]); if (n1 == n2) printf("Median is %d", getMedian(ar1, ar2, n1)); else printf("Doesn't work for arrays of unequal size"); return 0; }
2a654ff9f167d79b9b9b2e97c8ed2312adec5f92
010279e2ba272d09e9d2c4e903722e5faba2cf7a
/contrib/python/numpy/py2/numpy/core/src/common/ucsnarrow.c
8e293e9f2d9ef13678e4fe76daf62661800ca785
[ "Apache-2.0" ]
permissive
catboost/catboost
854c1a1f439a96f1ae6b48e16644be20aa04dba2
f5042e35b945aded77b23470ead62d7eacefde92
refs/heads/master
2023-09-01T12:14:14.174108
2023-09-01T10:01:01
2023-09-01T10:22:12
97,556,265
8,012
1,425
Apache-2.0
2023-09-11T03:32:32
2017-07-18T05:29:04
Python
UTF-8
C
false
false
4,233
c
ucsnarrow.c
#define NPY_NO_DEPRECATED_API NPY_API_VERSION #define PY_SSIZE_T_CLEAN #include <Python.h> #include <locale.h> #include <stdio.h> #define _MULTIARRAYMODULE #include "numpy/arrayobject.h" #include "numpy/npy_math.h" #include "npy_config.h" #include "npy_pycompat.h" #include "ctors.h" /* * Functions only needed on narrow builds of Python for converting back and * forth between the NumPy Unicode data-type (always 4-bytes) and the * Python Unicode scalar (2-bytes on a narrow build). */ /* * The ucs2 buffer must be large enough to hold 2*ucs4length characters * due to the use of surrogate pairs. * * The return value is the number of ucs2 bytes used-up which * is ucs4length + number of surrogate pairs found. * * Values above 0xffff are converted to surrogate pairs. */ NPY_NO_EXPORT int PyUCS2Buffer_FromUCS4(Py_UNICODE *ucs2, npy_ucs4 *ucs4, int ucs4length) { int i; int numucs2 = 0; npy_ucs4 chr; for (i = 0; i < ucs4length; i++) { chr = *ucs4++; if (chr > 0xffff) { numucs2++; chr -= 0x10000L; *ucs2++ = 0xD800 + (Py_UNICODE) (chr >> 10); *ucs2++ = 0xDC00 + (Py_UNICODE) (chr & 0x03FF); } else { *ucs2++ = (Py_UNICODE) chr; } numucs2++; } return numucs2; } /* * This converts a UCS2 buffer of the given length to UCS4 buffer. * It converts up to ucs4len characters of UCS2 * * It returns the number of characters converted which can * be less than ucs2len if there are surrogate pairs in ucs2. * * The return value is the actual size of the used part of the ucs4 buffer. */ NPY_NO_EXPORT int PyUCS2Buffer_AsUCS4(Py_UNICODE *ucs2, npy_ucs4 *ucs4, int ucs2len, int ucs4len) { int i; npy_ucs4 chr; Py_UNICODE ch; int numchars=0; for (i = 0; (i < ucs2len) && (numchars < ucs4len); i++) { ch = *ucs2++; if (ch >= 0xd800 && ch <= 0xdfff) { /* surrogate pair */ chr = ((npy_ucs4)(ch-0xd800)) << 10; chr += *ucs2++ + 0x2400; /* -0xdc00 + 0x10000 */ i++; } else { chr = (npy_ucs4) ch; } *ucs4++ = chr; numchars++; } return numchars; } /* * Returns a PyUnicodeObject initialized from a buffer containing * UCS4 unicode. * * Parameters * ---------- * src: char * * Pointer to buffer containing UCS4 unicode. * size: Py_ssize_t * Size of buffer in bytes. * swap: int * If true, the data will be swapped. * align: int * If true, the data will be aligned. * * Returns * ------- * new_reference: PyUnicodeObject */ NPY_NO_EXPORT PyUnicodeObject * PyUnicode_FromUCS4(char *src, Py_ssize_t size, int swap, int align) { Py_ssize_t ucs4len = size / sizeof(npy_ucs4); npy_ucs4 *buf = (npy_ucs4 *)src; int alloc = 0; PyUnicodeObject *ret; /* swap and align if needed */ if (swap || align) { buf = (npy_ucs4 *)malloc(size); if (buf == NULL) { PyErr_NoMemory(); goto fail; } alloc = 1; memcpy(buf, src, size); if (swap) { byte_swap_vector(buf, ucs4len, sizeof(npy_ucs4)); } } /* trim trailing zeros */ while (ucs4len > 0 && buf[ucs4len - 1] == 0) { ucs4len--; } /* produce PyUnicode object */ #ifdef Py_UNICODE_WIDE { ret = (PyUnicodeObject *)PyUnicode_FromUnicode((Py_UNICODE*)buf, (Py_ssize_t) ucs4len); if (ret == NULL) { goto fail; } } #else { Py_ssize_t tmpsiz = 2 * sizeof(Py_UNICODE) * ucs4len; Py_ssize_t ucs2len; Py_UNICODE *tmp; if ((tmp = (Py_UNICODE *)malloc(tmpsiz)) == NULL) { PyErr_NoMemory(); goto fail; } ucs2len = PyUCS2Buffer_FromUCS4(tmp, buf, ucs4len); ret = (PyUnicodeObject *)PyUnicode_FromUnicode(tmp, (Py_ssize_t) ucs2len); free(tmp); if (ret == NULL) { goto fail; } } #endif if (alloc) { free(buf); } return ret; fail: if (alloc) { free(buf); } return NULL; }
0c0d9808da31d1e5d7b7de3f69405b9cd87a9751
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/media/tuners/mxl5005s.h
ae8db885ad87a1cfb22603910bc2bc04e360717f
[ "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,510
h
mxl5005s.h
/* MaxLinear MXL5005S VSB/QAM/DVBT tuner driver Copyright (C) 2008 MaxLinear Copyright (C) 2008 Steven Toth <stoth@linuxtv.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 __MXL5005S_H #define __MXL5005S_H #include <linux/kconfig.h> #include <linux/i2c.h> #include "dvb_frontend.h" struct mxl5005s_config { /* 7 bit i2c address */ u8 i2c_address; #define IF_FREQ_4570000HZ 4570000 #define IF_FREQ_4571429HZ 4571429 #define IF_FREQ_5380000HZ 5380000 #define IF_FREQ_36000000HZ 36000000 #define IF_FREQ_36125000HZ 36125000 #define IF_FREQ_36166667HZ 36166667 #define IF_FREQ_44000000HZ 44000000 u32 if_freq; #define CRYSTAL_FREQ_4000000HZ 4000000 #define CRYSTAL_FREQ_16000000HZ 16000000 #define CRYSTAL_FREQ_25000000HZ 25000000 #define CRYSTAL_FREQ_28800000HZ 28800000 u32 xtal_freq; #define MXL_DUAL_AGC 0 #define MXL_SINGLE_AGC 1 u8 agc_mode; #define MXL_TF_DEFAULT 0 #define MXL_TF_OFF 1 #define MXL_TF_C 2 #define MXL_TF_C_H 3 #define MXL_TF_D 4 #define MXL_TF_D_L 5 #define MXL_TF_E 6 #define MXL_TF_F 7 #define MXL_TF_E_2 8 #define MXL_TF_E_NA 9 #define MXL_TF_G 10 u8 tracking_filter; #define MXL_RSSI_DISABLE 0 #define MXL_RSSI_ENABLE 1 u8 rssi_enable; #define MXL_CAP_SEL_DISABLE 0 #define MXL_CAP_SEL_ENABLE 1 u8 cap_select; #define MXL_DIV_OUT_1 0 #define MXL_DIV_OUT_4 1 u8 div_out; #define MXL_CLOCK_OUT_DISABLE 0 #define MXL_CLOCK_OUT_ENABLE 1 u8 clock_out; #define MXL5005S_IF_OUTPUT_LOAD_200_OHM 200 #define MXL5005S_IF_OUTPUT_LOAD_300_OHM 300 u32 output_load; #define MXL5005S_TOP_5P5 55 #define MXL5005S_TOP_7P2 72 #define MXL5005S_TOP_9P2 92 #define MXL5005S_TOP_11P0 110 #define MXL5005S_TOP_12P9 129 #define MXL5005S_TOP_14P7 147 #define MXL5005S_TOP_16P8 168 #define MXL5005S_TOP_19P4 194 #define MXL5005S_TOP_21P2 212 #define MXL5005S_TOP_23P2 232 #define MXL5005S_TOP_25P2 252 #define MXL5005S_TOP_27P1 271 #define MXL5005S_TOP_29P2 292 #define MXL5005S_TOP_31P7 317 #define MXL5005S_TOP_34P9 349 u32 top; #define MXL_ANALOG_MODE 0 #define MXL_DIGITAL_MODE 1 u8 mod_mode; #define MXL_ZERO_IF 0 #define MXL_LOW_IF 1 u8 if_mode; /* Some boards need to override the built-in logic for determining the gain when in QAM mode (the HVR-1600 is one such case) */ u8 qam_gain; /* Stuff I don't know what to do with */ u8 AgcMasterByte; }; #if IS_ENABLED(CONFIG_MEDIA_TUNER_MXL5005S) extern struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mxl5005s_config *config); #else static inline struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mxl5005s_config *config) { printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); return NULL; } #endif /* CONFIG_DVB_TUNER_MXL5005S */ #endif /* __MXL5005S_H */
b560cb64ce3ab2b4d52a01d7421ba30cbae7c8f1
f8cc1dd4b1378490386def2e0571561fab10b275
/src/libstddjb/tai_unpack_little.c
b2bafbf0e5f443b159edf36995d2c6b6dcb09499
[ "ISC" ]
permissive
skarnet/skalibs
b1eb2a0e38663cbfa918ee0a7916f56227bd7c2d
1f2d5f95684e93f8523e369ef1fed7a75c444082
refs/heads/master
2023-08-23T07:33:20.996016
2023-08-08T09:39:15
2023-08-08T09:39:15
31,461,366
104
32
ISC
2021-04-11T10:10:54
2015-02-28T12:01:41
C
UTF-8
C
false
false
153
c
tai_unpack_little.c
/* ISC license. */ #include <skalibs/uint64.h> #include <skalibs/tai.h> void tai_unpack_little (char const *s, tai *t) { uint64_unpack(s, &t->x) ; }
00db31e9ebae07be848d66a9aa59d5be549c8906
909095842af0bbf2e769aff361b5af344abc7433
/engine/source/platformWin32/winMath_ScriptBinding.h
23ac19f67d978b671c94874077bd508c946f5029
[ "MIT" ]
permissive
TorqueGameEngines/Torque2D
316105e8b91cebf8660ff43871440e1c4d0b1c5e
2c555d6dd0172a05ddb6a14f014d22f335b4ccad
refs/heads/master
2023-09-01T02:22:53.663431
2023-05-02T20:45:37
2023-05-02T20:45:37
268,352,960
1,001
117
MIT
2023-05-02T20:19:19
2020-05-31T19:51:55
C
UTF-8
C
false
false
3,058
h
winMath_ScriptBinding.h
//----------------------------------------------------------------------------- // Copyright (c) 2013 GarageGames, LLC // // 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. //----------------------------------------------------------------------------- /*! @defgroup WindowsPlatform Windows Platform @ingroup TorqueScriptFunctions @{ */ /*! Use the MathInit function to install a specified math extensions, or to detect and enable all extensions. Generally speaking, the best extension choice is to used detect. This will automatically detected and enable all extensions supported by the current processor. It will also print out a list of the extension that were enabled to the console @param extension Can be any of these:detect ? Detect all supported extensions and enable.C - Enable standard C extensions.FPU - Enable floating-point-unit extensions.MMX - Enable Intel MMX extensions.3DNOW - Enable AMD 3DNOW extensions.SSE - Enable Intel SSE extensions. @return No return value. */ ConsoleFunctionWithDocs( mathInit, ConsoleVoid, 1, 10, ( extension )) { U32 properties = CPU_PROP_C; // C entensions are always used if (argc == 1) { Math::init(0); return; } for (argc--, argv++; argc; argc--, argv++) { if (dStricmp(*argv, "DETECT") == 0) { Math::init(0); return; } if (dStricmp(*argv, "C") == 0) { properties |= CPU_PROP_C; continue; } if (dStricmp(*argv, "FPU") == 0) { properties |= CPU_PROP_FPU; continue; } if (dStricmp(*argv, "MMX") == 0) { properties |= CPU_PROP_MMX; continue; } if (dStricmp(*argv, "3DNOW") == 0) { properties |= CPU_PROP_3DNOW; continue; } if (dStricmp(*argv, "SSE") == 0) { properties |= CPU_PROP_SSE; continue; } Con::printf("Error: MathInit(): ignoring unknown math extension '%s'", *argv); } Math::init(properties); } /*! @} */ // end group WindowsPlatform
5deae87e1a8c45f33e89d88b11b571fba6d7bb68
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/net/ipv6/datagram.c
0615b738e103d39806db6cd58eb11f906874f53f
[ "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
20,904
c
datagram.c
/* * common UDP/RAW code * Linux INET6 implementation * * Authors: * Pedro Roque <roque@di.fc.ul.pt> * * 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. */ #include <linux/capability.h> #include <linux/errno.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/interrupt.h> #include <linux/socket.h> #include <linux/sockios.h> #include <linux/in6.h> #include <linux/ipv6.h> #include <linux/route.h> #include <linux/slab.h> #include <linux/export.h> #include <net/ipv6.h> #include <net/ndisc.h> #include <net/addrconf.h> #include <net/transp_v6.h> #include <net/ip6_route.h> #include <net/tcp_states.h> #include <net/dsfield.h> #include <linux/errqueue.h> #include <asm/uaccess.h> static bool ipv6_mapped_addr_any(const struct in6_addr *a) { return ipv6_addr_v4mapped(a) && (a->s6_addr32[3] == 0); } static int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; struct inet_sock *inet = inet_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk); struct in6_addr *daddr, *final_p, final; struct dst_entry *dst; struct flowi6 fl6; struct ip6_flowlabel *flowlabel = NULL; struct ipv6_txoptions *opt; int addr_type; int err; if (usin->sin6_family == AF_INET) { if (__ipv6_only_sock(sk)) return -EAFNOSUPPORT; err = __ip4_datagram_connect(sk, uaddr, addr_len); goto ipv4_connected; } if (addr_len < SIN6_LEN_RFC2133) return -EINVAL; if (usin->sin6_family != AF_INET6) return -EAFNOSUPPORT; memset(&fl6, 0, sizeof(fl6)); if (np->sndflow) { fl6.flowlabel = usin->sin6_flowinfo&IPV6_FLOWINFO_MASK; if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) { flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); if (flowlabel == NULL) return -EINVAL; usin->sin6_addr = flowlabel->dst; } } addr_type = ipv6_addr_type(&usin->sin6_addr); if (addr_type == IPV6_ADDR_ANY) { /* * connect to self */ usin->sin6_addr.s6_addr[15] = 0x01; } daddr = &usin->sin6_addr; if (addr_type == IPV6_ADDR_MAPPED) { struct sockaddr_in sin; if (__ipv6_only_sock(sk)) { err = -ENETUNREACH; goto out; } sin.sin_family = AF_INET; sin.sin_addr.s_addr = daddr->s6_addr32[3]; sin.sin_port = usin->sin6_port; err = __ip4_datagram_connect(sk, (struct sockaddr *) &sin, sizeof(sin)); ipv4_connected: if (err) goto out; ipv6_addr_set_v4mapped(inet->inet_daddr, &np->daddr); if (ipv6_addr_any(&np->saddr) || ipv6_mapped_addr_any(&np->saddr)) ipv6_addr_set_v4mapped(inet->inet_saddr, &np->saddr); if (ipv6_addr_any(&np->rcv_saddr) || ipv6_mapped_addr_any(&np->rcv_saddr)) { ipv6_addr_set_v4mapped(inet->inet_rcv_saddr, &np->rcv_saddr); if (sk->sk_prot->rehash) sk->sk_prot->rehash(sk); } goto out; } if (__ipv6_addr_needs_scope_id(addr_type)) { if (addr_len >= sizeof(struct sockaddr_in6) && usin->sin6_scope_id) { if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != usin->sin6_scope_id) { err = -EINVAL; goto out; } sk->sk_bound_dev_if = usin->sin6_scope_id; } if (!sk->sk_bound_dev_if && (addr_type & IPV6_ADDR_MULTICAST)) sk->sk_bound_dev_if = np->mcast_oif; /* Connect to link-local address requires an interface */ if (!sk->sk_bound_dev_if) { err = -EINVAL; goto out; } } np->daddr = *daddr; np->flow_label = fl6.flowlabel; inet->inet_dport = usin->sin6_port; /* * Check for a route to destination an obtain the * destination cache for it. */ fl6.flowi6_proto = sk->sk_protocol; fl6.daddr = np->daddr; fl6.saddr = np->saddr; fl6.flowi6_oif = sk->sk_bound_dev_if; fl6.flowi6_mark = sk->sk_mark; fl6.fl6_dport = inet->inet_dport; fl6.fl6_sport = inet->inet_sport; fl6.flowi6_uid = sock_i_uid(sk); if (!fl6.flowi6_oif && (addr_type&IPV6_ADDR_MULTICAST)) fl6.flowi6_oif = np->mcast_oif; security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); opt = flowlabel ? flowlabel->opt : np->opt; final_p = fl6_update_dst(&fl6, opt, &final); dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true); err = 0; if (IS_ERR(dst)) { err = PTR_ERR(dst); goto out; } /* source address lookup done in ip6_dst_lookup */ if (ipv6_addr_any(&np->saddr)) np->saddr = fl6.saddr; if (ipv6_addr_any(&np->rcv_saddr)) { np->rcv_saddr = fl6.saddr; inet->inet_rcv_saddr = LOOPBACK4_IPV6; if (sk->sk_prot->rehash) sk->sk_prot->rehash(sk); } ip6_dst_store(sk, dst, ipv6_addr_equal(&fl6.daddr, &np->daddr) ? &np->daddr : NULL, #ifdef CONFIG_IPV6_SUBTREES ipv6_addr_equal(&fl6.saddr, &np->saddr) ? &np->saddr : #endif NULL); sk->sk_state = TCP_ESTABLISHED; out: fl6_sock_release(flowlabel); return err; } int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { int res; lock_sock(sk); res = __ip6_datagram_connect(sk, uaddr, addr_len); release_sock(sk); return res; } EXPORT_SYMBOL_GPL(ip6_datagram_connect); void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port, u32 info, u8 *payload) { struct ipv6_pinfo *np = inet6_sk(sk); struct icmp6hdr *icmph = icmp6_hdr(skb); struct sock_exterr_skb *serr; if (!np->recverr) return; skb = skb_clone(skb, GFP_ATOMIC); if (!skb) return; skb->protocol = htons(ETH_P_IPV6); serr = SKB_EXT_ERR(skb); serr->ee.ee_errno = err; serr->ee.ee_origin = SO_EE_ORIGIN_ICMP6; serr->ee.ee_type = icmph->icmp6_type; serr->ee.ee_code = icmph->icmp6_code; serr->ee.ee_pad = 0; serr->ee.ee_info = info; serr->ee.ee_data = 0; serr->addr_offset = (u8 *)&(((struct ipv6hdr *)(icmph + 1))->daddr) - skb_network_header(skb); serr->port = port; __skb_pull(skb, payload - skb->data); skb_reset_transport_header(skb); if (sock_queue_err_skb(sk, skb)) kfree_skb(skb); } void ipv6_local_error(struct sock *sk, int err, struct flowi6 *fl6, u32 info) { struct ipv6_pinfo *np = inet6_sk(sk); struct sock_exterr_skb *serr; struct ipv6hdr *iph; struct sk_buff *skb; if (!np->recverr) return; skb = alloc_skb(sizeof(struct ipv6hdr), GFP_ATOMIC); if (!skb) return; skb->protocol = htons(ETH_P_IPV6); skb_put(skb, sizeof(struct ipv6hdr)); skb_reset_network_header(skb); iph = ipv6_hdr(skb); iph->daddr = fl6->daddr; serr = SKB_EXT_ERR(skb); serr->ee.ee_errno = err; serr->ee.ee_origin = SO_EE_ORIGIN_LOCAL; serr->ee.ee_type = 0; serr->ee.ee_code = 0; serr->ee.ee_pad = 0; serr->ee.ee_info = info; serr->ee.ee_data = 0; serr->addr_offset = (u8 *)&iph->daddr - skb_network_header(skb); serr->port = fl6->fl6_dport; __skb_pull(skb, skb_tail_pointer(skb) - skb->data); skb_reset_transport_header(skb); if (sock_queue_err_skb(sk, skb)) kfree_skb(skb); } void ipv6_local_rxpmtu(struct sock *sk, struct flowi6 *fl6, u32 mtu) { struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6hdr *iph; struct sk_buff *skb; struct ip6_mtuinfo *mtu_info; if (!np->rxopt.bits.rxpmtu) return; skb = alloc_skb(sizeof(struct ipv6hdr), GFP_ATOMIC); if (!skb) return; skb_put(skb, sizeof(struct ipv6hdr)); skb_reset_network_header(skb); iph = ipv6_hdr(skb); iph->daddr = fl6->daddr; mtu_info = IP6CBMTU(skb); mtu_info->ip6m_mtu = mtu; mtu_info->ip6m_addr.sin6_family = AF_INET6; mtu_info->ip6m_addr.sin6_port = 0; mtu_info->ip6m_addr.sin6_flowinfo = 0; mtu_info->ip6m_addr.sin6_scope_id = fl6->flowi6_oif; mtu_info->ip6m_addr.sin6_addr = ipv6_hdr(skb)->daddr; __skb_pull(skb, skb_tail_pointer(skb) - skb->data); skb_reset_transport_header(skb); skb = xchg(&np->rxpmtu, skb); kfree_skb(skb); } /* * Handle MSG_ERRQUEUE */ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) { struct ipv6_pinfo *np = inet6_sk(sk); struct sock_exterr_skb *serr; struct sk_buff *skb, *skb2; struct sockaddr_in6 *sin; struct { struct sock_extended_err ee; struct sockaddr_in6 offender; } errhdr; int err; int copied; err = -EAGAIN; skb = skb_dequeue(&sk->sk_error_queue); if (skb == NULL) goto out; copied = skb->len; if (copied > len) { msg->msg_flags |= MSG_TRUNC; copied = len; } err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); if (err) goto out_free_skb; sock_recv_timestamp(msg, sk, skb); serr = SKB_EXT_ERR(skb); sin = (struct sockaddr_in6 *)msg->msg_name; if (sin) { const unsigned char *nh = skb_network_header(skb); sin->sin6_family = AF_INET6; sin->sin6_flowinfo = 0; sin->sin6_port = serr->port; if (skb->protocol == htons(ETH_P_IPV6)) { const struct ipv6hdr *ip6h = container_of((struct in6_addr *)(nh + serr->addr_offset), struct ipv6hdr, daddr); sin->sin6_addr = ip6h->daddr; if (np->sndflow) sin->sin6_flowinfo = ip6_flowinfo(ip6h); sin->sin6_scope_id = ipv6_iface_scope_id(&sin->sin6_addr, IP6CB(skb)->iif); } else { ipv6_addr_set_v4mapped(*(__be32 *)(nh + serr->addr_offset), &sin->sin6_addr); sin->sin6_scope_id = 0; } } memcpy(&errhdr.ee, &serr->ee, sizeof(struct sock_extended_err)); sin = &errhdr.offender; memset(sin, 0, sizeof(*sin)); if (serr->ee.ee_origin != SO_EE_ORIGIN_LOCAL) { sin->sin6_family = AF_INET6; if (skb->protocol == htons(ETH_P_IPV6)) { sin->sin6_addr = ipv6_hdr(skb)->saddr; if (np->rxopt.all) ip6_datagram_recv_ctl(sk, msg, skb); sin->sin6_scope_id = ipv6_iface_scope_id(&sin->sin6_addr, IP6CB(skb)->iif); } else { ipv6_addr_set_v4mapped(ip_hdr(skb)->saddr, &sin->sin6_addr); if (inet_sk(sk)->cmsg_flags) ip_cmsg_recv(msg, skb); } } put_cmsg(msg, SOL_IPV6, IPV6_RECVERR, sizeof(errhdr), &errhdr); /* Now we could try to dump offended packet options */ msg->msg_flags |= MSG_ERRQUEUE; err = copied; /* Reset and regenerate socket error */ spin_lock_bh(&sk->sk_error_queue.lock); sk->sk_err = 0; if ((skb2 = skb_peek(&sk->sk_error_queue)) != NULL) { sk->sk_err = SKB_EXT_ERR(skb2)->ee.ee_errno; spin_unlock_bh(&sk->sk_error_queue.lock); sk->sk_error_report(sk); } else { spin_unlock_bh(&sk->sk_error_queue.lock); } out_free_skb: kfree_skb(skb); out: return err; } EXPORT_SYMBOL_GPL(ipv6_recv_error); /* * Handle IPV6_RECVPATHMTU */ int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len, int *addr_len) { struct ipv6_pinfo *np = inet6_sk(sk); struct sk_buff *skb; struct sockaddr_in6 *sin; struct ip6_mtuinfo mtu_info; int err; int copied; err = -EAGAIN; skb = xchg(&np->rxpmtu, NULL); if (skb == NULL) goto out; copied = skb->len; if (copied > len) { msg->msg_flags |= MSG_TRUNC; copied = len; } err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); if (err) goto out_free_skb; sock_recv_timestamp(msg, sk, skb); memcpy(&mtu_info, IP6CBMTU(skb), sizeof(mtu_info)); sin = (struct sockaddr_in6 *)msg->msg_name; if (sin) { sin->sin6_family = AF_INET6; sin->sin6_flowinfo = 0; sin->sin6_port = 0; sin->sin6_scope_id = mtu_info.ip6m_addr.sin6_scope_id; sin->sin6_addr = mtu_info.ip6m_addr.sin6_addr; *addr_len = sizeof(*sin); } put_cmsg(msg, SOL_IPV6, IPV6_PATHMTU, sizeof(mtu_info), &mtu_info); err = copied; out_free_skb: kfree_skb(skb); out: return err; } int ip6_datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) { struct ipv6_pinfo *np = inet6_sk(sk); struct inet6_skb_parm *opt = IP6CB(skb); unsigned char *nh = skb_network_header(skb); if (np->rxopt.bits.rxinfo) { struct in6_pktinfo src_info; src_info.ipi6_ifindex = opt->iif; src_info.ipi6_addr = ipv6_hdr(skb)->daddr; put_cmsg(msg, SOL_IPV6, IPV6_PKTINFO, sizeof(src_info), &src_info); } if (np->rxopt.bits.rxhlim) { int hlim = ipv6_hdr(skb)->hop_limit; put_cmsg(msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); } if (np->rxopt.bits.rxtclass) { int tclass = ipv6_get_dsfield(ipv6_hdr(skb)); put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); } if (np->rxopt.bits.rxflow) { __be32 flowinfo = ip6_flowinfo((struct ipv6hdr *)nh); if (flowinfo) put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); } /* HbH is allowed only once */ if (np->rxopt.bits.hopopts && opt->hop) { u8 *ptr = nh + opt->hop; put_cmsg(msg, SOL_IPV6, IPV6_HOPOPTS, (ptr[1]+1)<<3, ptr); } if (opt->lastopt && (np->rxopt.bits.dstopts || np->rxopt.bits.srcrt)) { /* * Silly enough, but we need to reparse in order to * report extension headers (except for HbH) * in order. * * Also note that IPV6_RECVRTHDRDSTOPTS is NOT * (and WILL NOT be) defined because * IPV6_RECVDSTOPTS is more generic. --yoshfuji */ unsigned int off = sizeof(struct ipv6hdr); u8 nexthdr = ipv6_hdr(skb)->nexthdr; while (off <= opt->lastopt) { unsigned int len; u8 *ptr = nh + off; switch (nexthdr) { case IPPROTO_DSTOPTS: nexthdr = ptr[0]; len = (ptr[1] + 1) << 3; if (np->rxopt.bits.dstopts) put_cmsg(msg, SOL_IPV6, IPV6_DSTOPTS, len, ptr); break; case IPPROTO_ROUTING: nexthdr = ptr[0]; len = (ptr[1] + 1) << 3; if (np->rxopt.bits.srcrt) put_cmsg(msg, SOL_IPV6, IPV6_RTHDR, len, ptr); break; case IPPROTO_AH: nexthdr = ptr[0]; len = (ptr[1] + 2) << 2; break; default: nexthdr = ptr[0]; len = (ptr[1] + 1) << 3; break; } off += len; } } /* socket options in old style */ if (np->rxopt.bits.rxoinfo) { struct in6_pktinfo src_info; src_info.ipi6_ifindex = opt->iif; src_info.ipi6_addr = ipv6_hdr(skb)->daddr; put_cmsg(msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); } if (np->rxopt.bits.rxohlim) { int hlim = ipv6_hdr(skb)->hop_limit; put_cmsg(msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); } if (np->rxopt.bits.ohopopts && opt->hop) { u8 *ptr = nh + opt->hop; put_cmsg(msg, SOL_IPV6, IPV6_2292HOPOPTS, (ptr[1]+1)<<3, ptr); } if (np->rxopt.bits.odstopts && opt->dst0) { u8 *ptr = nh + opt->dst0; put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); } if (np->rxopt.bits.osrcrt && opt->srcrt) { struct ipv6_rt_hdr *rthdr = (struct ipv6_rt_hdr *)(nh + opt->srcrt); put_cmsg(msg, SOL_IPV6, IPV6_2292RTHDR, (rthdr->hdrlen+1) << 3, rthdr); } if (np->rxopt.bits.odstopts && opt->dst1) { u8 *ptr = nh + opt->dst1; put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); } if (np->rxopt.bits.rxorigdstaddr) { struct sockaddr_in6 sin6; __be16 *ports = (__be16 *) skb_transport_header(skb); if (skb_transport_offset(skb) + 4 <= skb->len) { /* All current transport protocols have the port numbers in the * first four bytes of the transport header and this function is * written with this assumption in mind. */ sin6.sin6_family = AF_INET6; sin6.sin6_addr = ipv6_hdr(skb)->daddr; sin6.sin6_port = ports[1]; sin6.sin6_flowinfo = 0; sin6.sin6_scope_id = ipv6_iface_scope_id(&ipv6_hdr(skb)->daddr, opt->iif); put_cmsg(msg, SOL_IPV6, IPV6_ORIGDSTADDR, sizeof(sin6), &sin6); } } return 0; } EXPORT_SYMBOL_GPL(ip6_datagram_recv_ctl); int ip6_datagram_send_ctl(struct net *net, struct sock *sk, struct msghdr *msg, struct flowi6 *fl6, struct ipv6_txoptions *opt, int *hlimit, int *tclass, int *dontfrag) { struct in6_pktinfo *src_info; struct cmsghdr *cmsg; struct ipv6_rt_hdr *rthdr; struct ipv6_opt_hdr *hdr; int len; int err = 0; for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { int addr_type; if (!CMSG_OK(msg, cmsg)) { err = -EINVAL; goto exit_f; } if (cmsg->cmsg_level != SOL_IPV6) continue; switch (cmsg->cmsg_type) { case IPV6_PKTINFO: case IPV6_2292PKTINFO: { struct net_device *dev = NULL; if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct in6_pktinfo))) { err = -EINVAL; goto exit_f; } src_info = (struct in6_pktinfo *)CMSG_DATA(cmsg); if (src_info->ipi6_ifindex) { if (fl6->flowi6_oif && src_info->ipi6_ifindex != fl6->flowi6_oif) return -EINVAL; fl6->flowi6_oif = src_info->ipi6_ifindex; } addr_type = __ipv6_addr_type(&src_info->ipi6_addr); rcu_read_lock(); if (fl6->flowi6_oif) { dev = dev_get_by_index_rcu(net, fl6->flowi6_oif); if (!dev) { rcu_read_unlock(); return -ENODEV; } } else if (addr_type & IPV6_ADDR_LINKLOCAL) { rcu_read_unlock(); return -EINVAL; } if (addr_type != IPV6_ADDR_ANY) { int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL; if (!(inet_sk(sk)->freebind || inet_sk(sk)->transparent) && !ipv6_chk_addr(net, &src_info->ipi6_addr, strict ? dev : NULL, 0)) err = -EINVAL; else fl6->saddr = src_info->ipi6_addr; } rcu_read_unlock(); if (err) goto exit_f; break; } case IPV6_FLOWINFO: if (cmsg->cmsg_len < CMSG_LEN(4)) { err = -EINVAL; goto exit_f; } if (fl6->flowlabel&IPV6_FLOWINFO_MASK) { if ((fl6->flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) { err = -EINVAL; goto exit_f; } } fl6->flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg); break; case IPV6_2292HOPOPTS: case IPV6_HOPOPTS: if (opt->hopopt || cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { err = -EINVAL; goto exit_f; } hdr = (struct ipv6_opt_hdr *)CMSG_DATA(cmsg); len = ((hdr->hdrlen + 1) << 3); if (cmsg->cmsg_len < CMSG_LEN(len)) { err = -EINVAL; goto exit_f; } if (!ns_capable(net->user_ns, CAP_NET_RAW)) { err = -EPERM; goto exit_f; } opt->opt_nflen += len; opt->hopopt = hdr; break; case IPV6_2292DSTOPTS: if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { err = -EINVAL; goto exit_f; } hdr = (struct ipv6_opt_hdr *)CMSG_DATA(cmsg); len = ((hdr->hdrlen + 1) << 3); if (cmsg->cmsg_len < CMSG_LEN(len)) { err = -EINVAL; goto exit_f; } if (!ns_capable(net->user_ns, CAP_NET_RAW)) { err = -EPERM; goto exit_f; } if (opt->dst1opt) { err = -EINVAL; goto exit_f; } opt->opt_flen += len; opt->dst1opt = hdr; break; case IPV6_DSTOPTS: case IPV6_RTHDRDSTOPTS: if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { err = -EINVAL; goto exit_f; } hdr = (struct ipv6_opt_hdr *)CMSG_DATA(cmsg); len = ((hdr->hdrlen + 1) << 3); if (cmsg->cmsg_len < CMSG_LEN(len)) { err = -EINVAL; goto exit_f; } if (!ns_capable(net->user_ns, CAP_NET_RAW)) { err = -EPERM; goto exit_f; } if (cmsg->cmsg_type == IPV6_DSTOPTS) { opt->opt_flen += len; opt->dst1opt = hdr; } else { opt->opt_nflen += len; opt->dst0opt = hdr; } break; case IPV6_2292RTHDR: case IPV6_RTHDR: if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) { err = -EINVAL; goto exit_f; } rthdr = (struct ipv6_rt_hdr *)CMSG_DATA(cmsg); switch (rthdr->type) { #if IS_ENABLED(CONFIG_IPV6_MIP6) case IPV6_SRCRT_TYPE_2: if (rthdr->hdrlen != 2 || rthdr->segments_left != 1) { err = -EINVAL; goto exit_f; } break; #endif default: err = -EINVAL; goto exit_f; } len = ((rthdr->hdrlen + 1) << 3); if (cmsg->cmsg_len < CMSG_LEN(len)) { err = -EINVAL; goto exit_f; } /* segments left must also match */ if ((rthdr->hdrlen >> 1) != rthdr->segments_left) { err = -EINVAL; goto exit_f; } opt->opt_nflen += len; opt->srcrt = rthdr; if (cmsg->cmsg_type == IPV6_2292RTHDR && opt->dst1opt) { int dsthdrlen = ((opt->dst1opt->hdrlen+1)<<3); opt->opt_nflen += dsthdrlen; opt->dst0opt = opt->dst1opt; opt->dst1opt = NULL; opt->opt_flen -= dsthdrlen; } break; case IPV6_2292HOPLIMIT: case IPV6_HOPLIMIT: if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) { err = -EINVAL; goto exit_f; } *hlimit = *(int *)CMSG_DATA(cmsg); if (*hlimit < -1 || *hlimit > 0xff) { err = -EINVAL; goto exit_f; } break; case IPV6_TCLASS: { int tc; err = -EINVAL; if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) goto exit_f; tc = *(int *)CMSG_DATA(cmsg); if (tc < -1 || tc > 0xff) goto exit_f; err = 0; *tclass = tc; break; } case IPV6_DONTFRAG: { int df; err = -EINVAL; if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) goto exit_f; df = *(int *)CMSG_DATA(cmsg); if (df < 0 || df > 1) goto exit_f; err = 0; *dontfrag = df; break; } default: LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n", cmsg->cmsg_type); err = -EINVAL; goto exit_f; } } exit_f: return err; } EXPORT_SYMBOL_GPL(ip6_datagram_send_ctl);
9421dddb9e3939c23763c7f0e1d710e072e72bd2
2c5b019dab303f7b2bbf592d7d0c8700d84331b0
/ios/ReactNativeCharts/RNChartManagerBridge.h
d5a47b871295e83f80bcc5205def99e3030748fe
[ "MIT" ]
permissive
wuxudong/react-native-charts-wrapper
8fb98faa7d79f50f8c5b42a29879f16e5791f355
11ca62ac8400d43bc77d21794b3b3eb3b2d42581
refs/heads/master
2023-08-23T00:48:19.194551
2023-04-25T01:56:55
2023-04-25T01:56:55
83,773,237
2,540
731
null
2023-08-08T10:46:56
2017-03-03T07:58:57
Java
UTF-8
C
false
false
1,297
h
RNChartManagerBridge.h
// // RNChartManagerBridge.h // reactNativeCharts // // Created by xudong wu on 25/02/2017. // Copyright wuxudong // #ifndef RNChartManagerBridge_h #define RNChartManagerBridge_h #define EXPORT_CHART_BASE_PROPERTIES \ RCT_EXPORT_VIEW_PROPERTY(data, NSDictionary) \ RCT_EXPORT_VIEW_PROPERTY(highlights, NSArray) \ RCT_EXPORT_VIEW_PROPERTY(legend, NSDictionary) \ RCT_EXPORT_VIEW_PROPERTY(chartBackgroundColor, NSInteger) \ RCT_EXPORT_VIEW_PROPERTY(chartDescription, NSDictionary) \ RCT_EXPORT_VIEW_PROPERTY(noDataText, NSString) \ RCT_EXPORT_VIEW_PROPERTY(noDataTextColor, NSInteger) \ RCT_EXPORT_VIEW_PROPERTY(touchEnabled, BOOL) \ RCT_EXPORT_VIEW_PROPERTY(highlightPerTapEnabled, BOOL) \ RCT_EXPORT_VIEW_PROPERTY(dragDecelerationEnabled, BOOL) \ RCT_EXPORT_VIEW_PROPERTY(dragDecelerationFrictionCoef, NSNumber) \ RCT_EXPORT_VIEW_PROPERTY(animation, NSDictionary) \ RCT_EXPORT_VIEW_PROPERTY(xAxis, NSDictionary) \ RCT_EXPORT_VIEW_PROPERTY(marker, NSDictionary) \ RCT_EXPORT_VIEW_PROPERTY(onSelect, RCTDirectEventBlock) \ RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock) \ RCT_EXPORT_VIEW_PROPERTY(group, NSString) \ RCT_EXPORT_VIEW_PROPERTY(identifier, NSString) \ RCT_EXPORT_VIEW_PROPERTY(syncX, BOOL) \ RCT_EXPORT_VIEW_PROPERTY(syncY, BOOL) #endif /* RNChartManagerBridge_h */
e5fe8db67ddcb40779f0d83cb8dc415ae3457dcc
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
/AKWF-c/AKWF_vgame/AKWF_vgame_0110.h
12baad426a22c026a58126b372a96b2cc5ad3a19
[ "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,684
h
AKWF_vgame_0110.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_vgame_0110 256 samples +-----------------------------------------------------------------------------------------------------------------+ |********************************************************* | | * | | * | | * | | * | | * | | * | | * * | | ************************************************ | | * | | * | | * | | * | | * | | * | +-----------------------------------------------------------------------------------------------------------------+ */ const uint16_t AKWF_vgame_0110 [] = { 43482, 47898, 46071, 47296, 46374, 47134, 46511, 47045, 46598, 46980, 46661, 46925, 46710, 46879, 46750, 46838, 46778, 46804, 46796, 46775, 46806, 46753, 46809, 46734, 46804, 46719, 46793, 46707, 46780, 46700, 46762, 46691, 46742, 46686, 46723, 46678, 46700, 46672, 46684, 46665, 46661, 46655, 46645, 46644, 46627, 46630, 46612, 46616, 46597, 46602, 46581, 46586, 46567, 46571, 46554, 46556, 46540, 46540, 46527, 46523, 46514, 46506, 46500, 46490, 46486, 46475, 46473, 46459, 46459, 46442, 46445, 46427, 46431, 46412, 46414, 46397, 46400, 46384, 46385, 46370, 46368, 46359, 46347, 46348, 46328, 46338, 46308, 46329, 46286, 46322, 46265, 46313, 46245, 46304, 46225, 46292, 46209, 46275, 46196, 46256, 46189, 46233, 46186, 46203, 46191, 46166, 46199, 46124, 46214, 46079, 46232, 46028, 46257, 45974, 46281, 45919, 46305, 45867, 46326, 45821, 46343, 45777, 46352, 45739, 46364, 45682, 46465, 44895, 24930, 21998, 23325, 22325, 23174, 22408, 23104, 22463, 23049, 22514, 23001, 22566, 22954, 22616, 22912, 22665, 22873, 22710, 22841, 22752, 22817, 22788, 22800, 22819, 22788, 22843, 22785, 22861, 22787, 22875, 22795, 22882, 22804, 22887, 22821, 22892, 22838, 22892, 22854, 22895, 22872, 22897, 22889, 22901, 22906, 22905, 22920, 22912, 22934, 22920, 22945, 22929, 22956, 22940, 22966, 22954, 22973, 22967, 22979, 22984, 22983, 22998, 22985, 23014, 22989, 23033, 22991, 23049, 22995, 23067, 23001, 23082, 23008, 23093, 23019, 23100, 23036, 23101, 23057, 23098, 23085, 23086, 23121, 23068, 23161, 23044, 23208, 23017, 23259, 22986, 23310, 22955, 23359, 22929, 23402, 22913, 23432, 22910, 23445, 22930, 23430, 22988, 23365, 23118, 23181, 23362, 3865, 1, 791, 0, 479, 0, 317, 0, 190, 46, 74, 213, 0, 381, 0, 557, 0, 764, 0, 1131, 1, 5023, };
2b5992be20f27ea0b83290180d1a12fb1fea569d
aa3befea459382dc5c01c925653d54f435b3fb0f
/sched/timer/timer_getitimer.c
43a9a86391946e356934d320ae10c73498b95ee6
[ "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
3,361
c
timer_getitimer.c
/**************************************************************************** * sched/timer/timer_getitimer.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 <errno.h> #include <time.h> #include <sys/time.h> #include "sched/sched.h" #ifndef CONFIG_DISABLE_POSIX_TIMERS /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: getitimer * * Description: * The getitimer() function will store the amount of time until the * specified timer, which, expires and the reload value of the timer * into the space pointed to by the value argument. The it_value member * of this structure will contain the amount of time before the timer * expires, or zero if the timer is disarmed. This value is returned as * the interval until timer expiration. The it_interval member of value * will contain the reload value last set by setitime(). * * Input Parameters: * which - The predefined timer id * value - The current timer value * * Returned Value: * If the getitimer() succeeds, a value of 0 (OK) will be returned. * If an error occurs, the value -1 (ERROR) will be returned, and errno * set to indicate the error. * * EINVAL - The which argument does not correspond to an predefined ID. * * Assumptions/Limitations: * Due to the asynchronous operation of this function, the time reported * by this function could be significantly more than that actual time * remaining on the timer at any time. * ****************************************************************************/ int getitimer(int which, FAR struct itimerval *value) { FAR struct tcb_s *rtcb = this_task(); struct itimerspec spec = { {0, 0}, {0, 0} }; int ret = OK; if (which != ITIMER_REAL || !value) { set_errno(EINVAL); return ERROR; } if (rtcb->group->itimer) { ret = timer_gettime(rtcb->group->itimer, &spec); } if (ret == OK) { TIMESPEC_TO_TIMEVAL(&value->it_value, &spec.it_value); TIMESPEC_TO_TIMEVAL(&value->it_interval, &spec.it_interval); } return ret; } #endif /* CONFIG_DISABLE_POSIX_TIMERS */
616443cb07ed1e7d91b63f34a4a7d3fa262ae029
15050cf4e2dfa69dd0764502831c5d6a02856c2d
/tools/lights/main.h
6358f2de0c2d4906beb8e8823f308240ac2333ba
[ "MIT" ]
permissive
aap/librw
5644223e69b5ab5ce26a643081918bc45a8c937a
05db81b92f30484a536990a6b792166102405c51
refs/heads/master
2023-08-31T00:14:50.862209
2023-02-21T00:24:42
2023-02-21T00:24:42
28,191,349
465
114
MIT
2023-08-24T01:26:56
2014-12-18T16:25:07
C++
UTF-8
C
false
false
120
h
main.h
extern rw::World *World; extern rw::Camera *Camera; extern rw::V3d Xaxis; extern rw::V3d Yaxis; extern rw::V3d Zaxis;
522363c2d5a28f811ef879b7a36bb601556fc266
fdc312adbcf72c3432fad614ffca08cb69175ed8
/src/io/pfssetlabel.c
935d5e3b6d8396e00680b163a6a1f3653acd9897
[]
no_license
n64decomp/libreultra
2231cc07e1edd8bfce1cea34036ebe15b2c9439a
1aca5c13ca041cef86f8dc194b727361dad9c09b
refs/heads/master
2022-02-12T01:57:21.614124
2020-02-01T21:07:06
2020-02-01T21:07:06
168,697,460
157
38
null
2022-01-29T11:31:37
2019-02-01T12:55:42
C
UTF-8
C
false
false
450
c
pfssetlabel.c
#include <os_internal.h> #include "controller.h" s32 osPfsSetLabel(OSPfs *pfs, u8 *label) { int i; s32 ret; PFS_CHECK_ID; if (label != NULL) { for (i = 0; i < ARRLEN(pfs->label); i++) { if (*label == 0) break; pfs->label[i] = *label++; } } SET_ACTIVEBANK_TO_ZERO; ERRCK(__osContRamWrite(pfs->queue, pfs->channel, 7, pfs->label, FALSE)); return 0; }
af6d74ba6d56957d8dcac3bcf3352aefb5dc4362
2cba91dbfb4eedab402e195b6723da73194fd33c
/ffi-cdecl/elf_decl.c
52d2e40e5924bfbc666af3912463a3303b1517aa
[ "MIT" ]
permissive
koreader/android-luajit-launcher
9bb47af8ed7277871c10e0fbb6d028d3b59498cb
ee231f2825614c8b268930f3b8ffea6be37c9df1
refs/heads/master
2023-07-26T21:57:58.264429
2023-07-22T10:50:47
2023-07-23T11:37:33
15,648,711
115
75
MIT
2023-09-10T16:24:36
2014-01-05T09:37:08
Kotlin
UTF-8
C
false
false
1,279
c
elf_decl.c
#include <elf.h> #include "ffi-cdecl.h" // Constants cdecl_const(EI_NIDENT) cdecl_const(EI_MAG0) cdecl_const(ELFMAG0) cdecl_const(EI_MAG1) cdecl_const(ELFMAG1) cdecl_const(EI_MAG2) cdecl_const(ELFMAG2) cdecl_const(EI_MAG3) cdecl_const(ELFMAG3) cdecl_const(EI_CLASS) cdecl_const(ELFCLASSNONE) cdecl_const(ELFCLASS32) cdecl_const(ELFCLASS64) cdecl_const(SHT_STRTAB) cdecl_const(SHT_DYNAMIC) cdecl_const(DT_NEEDED) // ELFCLASS32 cdecl_c99_type(Elf32_Half, uint16_t) cdecl_c99_type(Elf32_Word, uint32_t) cdecl_c99_type(Elf32_Sword, int32_t) cdecl_c99_type(Elf32_Xword, uint64_t) cdecl_c99_type(Elf32_Sxword, int64_t) cdecl_c99_type(Elf32_Addr, uint32_t) cdecl_c99_type(Elf32_Off, uint32_t) cdecl_c99_type(Elf32_Section, uint16_t) cdecl_c99_type(Elf32_Versym, Elf32_Half) cdecl_type(Elf32_Ehdr) cdecl_type(Elf32_Shdr) cdecl_type(Elf32_Dyn) // ELFCLASS64 cdecl_c99_type(Elf64_Half, uint16_t) cdecl_c99_type(Elf64_Word, uint32_t) cdecl_c99_type(Elf64_Sword, int32_t) cdecl_c99_type(Elf64_Xword, uint64_t) cdecl_c99_type(Elf64_Sxword, int64_t) cdecl_c99_type(Elf64_Addr, uint64_t) cdecl_c99_type(Elf64_Off, uint64_t) cdecl_c99_type(Elf64_Section, uint16_t) cdecl_c99_type(Elf64_Versym, Elf64_Half) cdecl_type(Elf64_Ehdr) cdecl_type(Elf64_Shdr) cdecl_type(Elf64_Dyn)
4b6b114d6562543ac85a97dd5170bb403c99edf4
c30c2a2f2b8cf648175e1ae6f37c7834a08a8c51
/examples/flow_tracker/flow_tracker.c
e9f15c6c68e505327caec37cf88a6cb4f03f1330
[ "BSD-3-Clause" ]
permissive
sdnfv/openNetVM
bb411bf10075697a5f276cb517df7b8c631b56cf
20e01501355129bfa8f46d44f39ca2a8bbb516d0
refs/heads/master
2022-09-02T15:45:00.358618
2022-02-01T02:53:19
2022-02-01T02:53:19
56,240,513
276
153
NOASSERTION
2022-08-04T19:16:59
2016-04-14T13:40:21
C
UTF-8
C
false
false
12,687
c
flow_tracker.c
/********************************************************************* * openNetVM * https://sdnfv.github.io * * BSD LICENSE * * Copyright(c) * 2015-2019 George Washington University * 2015-2019 University of California Riverside * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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. * * flow_tracker.c - an example using onvm. Stores incoming flows and prints info about them. ********************************************************************/ #include <errno.h> #include <getopt.h> #include <inttypes.h> #include <stdarg.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <rte_common.h> #include <rte_cycles.h> #include <rte_hash.h> #include <rte_ip.h> #include <rte_malloc.h> #include <rte_mbuf.h> #include "onvm_flow_table.h" #include "onvm_nflib.h" #include "onvm_pkt_helper.h" #define NF_TAG "flow_tracker" #define TBL_SIZE 100 #define EXPIRE_TIME 5 /*Struct that holds all NF state information */ struct state_info { struct onvm_ft *ft; uint16_t destination; uint16_t print_delay; uint16_t num_stored; uint64_t elapsed_cycles; uint64_t last_cycles; }; /*Struct that holds info about each flow, and is stored at each flow table entry */ struct flow_stats { int pkt_count; uint64_t last_pkt_cycles; int is_active; }; struct state_info *state_info; /* * Prints application arguments */ static void usage(const char *progname) { printf("Usage:\n"); printf("%s [EAL args] -- [NF_LIB args] --d <destination>\n", progname); printf("%s -F <CONFIG_FILE.json> [EAL args] -- [NF_LIB args] -- [NF args]\n\n", progname); printf("Flags:\n"); printf(" - `-d <destination_id>`: Service ID to send packets to`\n"); printf(" - `-p <print_delay>`: Number of seconds between each print (default is 5)\n"); } /* * Loops through inputted arguments and assigns values as necessary */ static int parse_app_args(int argc, char *argv[], const char *progname) { int c, dst_flag = 0; while ((c = getopt(argc, argv, "d:p:")) != -1) { switch (c) { case 'd': state_info->destination = strtoul(optarg, NULL, 10); dst_flag = 1; RTE_LOG(INFO, APP, "Sending packets to service ID %d\n", state_info->destination); break; case 'p': state_info->print_delay = strtoul(optarg, NULL, 10); break; case '?': usage(progname); if (optopt == 'd') RTE_LOG(INFO, APP, "Option -%c requires an argument\n", optopt); else if (optopt == 'p') RTE_LOG(INFO, APP, "Option -%c requires an argument\n", optopt); else RTE_LOG(INFO, APP, "Unknown option character\n"); return -1; default: usage(progname); return -1; } } if (!dst_flag) { RTE_LOG(INFO, APP, "Flow Tracker NF requires a destination NF service ID with the -d flag \n"); return -1; } return optind; } /* * Updates flow status to be "active" or "expired" */ static int update_status(uint64_t elapsed_cycles, struct flow_stats *data) { if (unlikely(data == NULL)) { return -1; } if ((elapsed_cycles - data->last_pkt_cycles) / rte_get_timer_hz() >= EXPIRE_TIME) { data->is_active = 0; } else { data->is_active = 1; } return 0; } /* * Clears expired entries from the flow table */ static int clear_entries(struct state_info *state_info) { if (unlikely(state_info == NULL)) { return -1; } printf("Clearing expired entries\n"); struct flow_stats *data = NULL; struct onvm_ft_ipv4_5tuple *key = NULL; uint32_t next = 0; int ret = 0; while (onvm_ft_iterate(state_info->ft, (const void **)&key, (void **)&data, &next) > -1) { if (update_status(state_info->elapsed_cycles, data) < 0) { return -1; } if (!data->is_active) { ret = onvm_ft_remove_key(state_info->ft, key); state_info->num_stored--; if (ret < 0) { printf("Key should have been removed, but was not\n"); state_info->num_stored++; } } } return 0; } /* * Prints out information about flows stored in table */ static void do_stats_display(struct state_info *state_info) { struct flow_stats *data = NULL; struct onvm_ft_ipv4_5tuple *key = NULL; uint32_t next = 0; int32_t index; printf("------------------------------\n"); printf(" Flow Table Contents\n"); printf("------------------------------\n"); printf("Current capacity: %d / %d\n\n", state_info->num_stored, TBL_SIZE); while ((index = onvm_ft_iterate(state_info->ft, (const void **)&key, (void **)&data, &next)) > -1) { update_status(state_info->elapsed_cycles, data); printf("%d. Status: ", index); if (data->is_active) { printf("Active\n"); } else { printf("Expired\n"); } printf("Key information:\n"); _onvm_ft_print_key(key); printf("Packet count: %d\n\n", data->pkt_count); } } /* * Adds an entry to the flow table. It first checks if the table is full, and * if so, it calls clear_entries() to free up space. */ static int table_add_entry(struct onvm_ft_ipv4_5tuple *key, struct state_info *state_info) { struct flow_stats *data = NULL; if (unlikely(key == NULL || state_info == NULL)) { return -1; } if (TBL_SIZE - state_info->num_stored == 0) { int ret = clear_entries(state_info); if (ret < 0) { return -1; } } int tbl_index = onvm_ft_add_key(state_info->ft, key, (char **)&data); if (tbl_index < 0) { return -1; } data->pkt_count = 0; data->last_pkt_cycles = state_info->elapsed_cycles; data->is_active = 1; state_info->num_stored += 1; return 0; } /* * Looks up a packet hash to see if there is a matching key in the table. * If it finds one, it updates the metadata associated with the key entry, * and if it doesn't, it calls table_add_entry() to add it to the table. */ static int table_lookup_entry(struct rte_mbuf *pkt, struct state_info *state_info) { struct flow_stats *data = NULL; struct onvm_ft_ipv4_5tuple key; if (unlikely(pkt == NULL || state_info == NULL)) { return -1; } int ret = onvm_ft_fill_key_symmetric(&key, pkt); if (ret < 0) return -1; int tbl_index = onvm_ft_lookup_key(state_info->ft, &key, (char **)&data); if (tbl_index == -ENOENT) { return table_add_entry(&key, state_info); } else if (tbl_index < 0) { printf("Some other error occurred with the packet hashing\n"); return -1; } else { data->pkt_count += 1; data->last_pkt_cycles = state_info->elapsed_cycles; return 0; } } static int callback_handler(__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { state_info->elapsed_cycles = rte_get_tsc_cycles(); if ((state_info->elapsed_cycles - state_info->last_cycles) / rte_get_timer_hz() > state_info->print_delay) { state_info->last_cycles = state_info->elapsed_cycles; do_stats_display(state_info); } return 0; } static int packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta, __attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) { if (!onvm_pkt_is_ipv4(pkt)) { meta->destination = state_info->destination; meta->action = ONVM_NF_ACTION_TONF; return 0; } if (table_lookup_entry(pkt, state_info) < 0) { printf("Packet could not be identified or processed\n"); } meta->destination = state_info->destination; meta->action = ONVM_NF_ACTION_TONF; return 0; } int main(int argc, char *argv[]) { int arg_offset; struct onvm_nf_local_ctx *nf_local_ctx; struct onvm_nf_function_table *nf_function_table; const char *progname = argv[0]; nf_local_ctx = onvm_nflib_init_nf_local_ctx(); onvm_nflib_start_signal_handler(nf_local_ctx, NULL); nf_function_table = onvm_nflib_init_nf_function_table(); nf_function_table->pkt_handler = &packet_handler; nf_function_table->user_actions = &callback_handler; if ((arg_offset = onvm_nflib_init(argc, argv, NF_TAG, nf_local_ctx, nf_function_table)) < 0) { onvm_nflib_stop(nf_local_ctx); if (arg_offset == ONVM_SIGNAL_TERMINATION) { printf("Exiting due to user termination\n"); return 0; } else { rte_exit(EXIT_FAILURE, "Failed ONVM init\n"); } } argc -= arg_offset; argv += arg_offset; state_info = rte_calloc("state", 1, sizeof(struct state_info), 0); if (state_info == NULL) { onvm_nflib_stop(nf_local_ctx); rte_exit(EXIT_FAILURE, "Unable to initialize NF state"); } state_info->print_delay = 5; state_info->num_stored = 0; if (parse_app_args(argc, argv, progname) < 0) { onvm_nflib_stop(nf_local_ctx); rte_exit(EXIT_FAILURE, "Invalid command-line arguments"); } state_info->ft = onvm_ft_create(TBL_SIZE, sizeof(struct flow_stats)); if (state_info->ft == NULL) { onvm_nflib_stop(nf_local_ctx); rte_exit(EXIT_FAILURE, "Unable to create flow table"); } /*Initialize NF timer */ state_info->elapsed_cycles = rte_get_tsc_cycles(); onvm_nflib_run(nf_local_ctx); onvm_nflib_stop(nf_local_ctx); onvm_ft_free(state_info->ft); rte_free(state_info); printf("If we reach here, program is ending!\n"); return 0; }
4faff9620a4a49ab0f121fb73d12c8eeffc980b7
bed3ac926beac0f4e0293303d7b2a6031ee476c9
/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5FDpublic.h
36f37f0b58e51e823534d9f356a98904c8420540
[ "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
22,470
h
H5FDpublic.h
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Programmer: Robb Matzke * Monday, July 26, 1999 */ #ifndef H5FDpublic_H #define H5FDpublic_H #include "H5public.h" #include "H5Fpublic.h" /*for H5F_close_degree_t */ #define H5_HAVE_VFL 1 /*define a convenient app feature test*/ #define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */ /* Types of allocation requests: see H5Fpublic.h */ typedef enum H5F_mem_t H5FD_mem_t; /* Map "fractal heap" header blocks to 'ohdr' type file memory, since its * a fair amount of work to add a new kind of file memory and they are similar * enough to object headers and probably too minor to deserve their own type. * * Map "fractal heap" indirect blocks to 'ohdr' type file memory, since they * are similar to fractal heap header blocks. * * Map "fractal heap" direct blocks to 'lheap' type file memory, since they * will be replacing local heaps. * * Map "fractal heap" 'huge' objects to 'draw' type file memory, since they * represent large objects that are directly stored in the file. * * -QAK */ #define H5FD_MEM_FHEAP_HDR H5FD_MEM_OHDR #define H5FD_MEM_FHEAP_IBLOCK H5FD_MEM_OHDR #define H5FD_MEM_FHEAP_DBLOCK H5FD_MEM_LHEAP #define H5FD_MEM_FHEAP_HUGE_OBJ H5FD_MEM_DRAW /* Map "free space" header blocks to 'ohdr' type file memory, since its * a fair amount of work to add a new kind of file memory and they are similar * enough to object headers and probably too minor to deserve their own type. * * Map "free space" serialized sections to 'lheap' type file memory, since they * are similar enough to local heap info. * * -QAK */ #define H5FD_MEM_FSPACE_HDR H5FD_MEM_OHDR #define H5FD_MEM_FSPACE_SINFO H5FD_MEM_LHEAP /* Map "shared object header message" master table to 'ohdr' type file memory, * since its a fair amount of work to add a new kind of file memory and they are * similar enough to object headers and probably too minor to deserve their own * type. * * Map "shared object header message" indices to 'btree' type file memory, * since they are similar enough to B-tree nodes. * * -QAK */ #define H5FD_MEM_SOHM_TABLE H5FD_MEM_OHDR #define H5FD_MEM_SOHM_INDEX H5FD_MEM_BTREE /* Map "extensible array" header blocks to 'ohdr' type file memory, since its * a fair amount of work to add a new kind of file memory and they are similar * enough to object headers and probably too minor to deserve their own type. * * Map "extensible array" index blocks to 'ohdr' type file memory, since they * are similar to extensible array header blocks. * * Map "extensible array" super blocks to 'btree' type file memory, since they * are similar enough to B-tree nodes. * * Map "extensible array" data blocks & pages to 'lheap' type file memory, since * they are similar enough to local heap info. * * -QAK */ #define H5FD_MEM_EARRAY_HDR H5FD_MEM_OHDR #define H5FD_MEM_EARRAY_IBLOCK H5FD_MEM_OHDR #define H5FD_MEM_EARRAY_SBLOCK H5FD_MEM_BTREE #define H5FD_MEM_EARRAY_DBLOCK H5FD_MEM_LHEAP #define H5FD_MEM_EARRAY_DBLK_PAGE H5FD_MEM_LHEAP /* Map "fixed array" header blocks to 'ohdr' type file memory, since its * a fair amount of work to add a new kind of file memory and they are similar * enough to object headers and probably too minor to deserve their own type. * * Map "fixed array" data blocks & pages to 'lheap' type file memory, since * they are similar enough to local heap info. * */ #define H5FD_MEM_FARRAY_HDR H5FD_MEM_OHDR #define H5FD_MEM_FARRAY_DBLOCK H5FD_MEM_LHEAP #define H5FD_MEM_FARRAY_DBLK_PAGE H5FD_MEM_LHEAP /* * A free-list map which maps all types of allocation requests to a single * free list. This is useful for drivers that don't really care about * keeping different requests segregated in the underlying file and which * want to make most efficient reuse of freed memory. The use of the * H5FD_MEM_SUPER free list is arbitrary. */ #define H5FD_FLMAP_SINGLE \ { \ H5FD_MEM_SUPER, /*default*/ \ H5FD_MEM_SUPER, /*super*/ \ H5FD_MEM_SUPER, /*btree*/ \ H5FD_MEM_SUPER, /*draw*/ \ H5FD_MEM_SUPER, /*gheap*/ \ H5FD_MEM_SUPER, /*lheap*/ \ H5FD_MEM_SUPER /*ohdr*/ \ } /* * A free-list map which segregates requests into `raw' or `meta' data * pools. */ #define H5FD_FLMAP_DICHOTOMY \ { \ H5FD_MEM_SUPER, /*default*/ \ H5FD_MEM_SUPER, /*super*/ \ H5FD_MEM_SUPER, /*btree*/ \ H5FD_MEM_DRAW, /*draw*/ \ H5FD_MEM_DRAW, /*gheap*/ \ H5FD_MEM_SUPER, /*lheap*/ \ H5FD_MEM_SUPER /*ohdr*/ \ } /* * The default free list map which causes each request type to use it's own * free-list. */ #define H5FD_FLMAP_DEFAULT \ { \ H5FD_MEM_DEFAULT, /*default*/ \ H5FD_MEM_DEFAULT, /*super*/ \ H5FD_MEM_DEFAULT, /*btree*/ \ H5FD_MEM_DEFAULT, /*draw*/ \ H5FD_MEM_DEFAULT, /*gheap*/ \ H5FD_MEM_DEFAULT, /*lheap*/ \ H5FD_MEM_DEFAULT /*ohdr*/ \ } /* Define VFL driver features that can be enabled on a per-driver basis */ /* These are returned with the 'query' function pointer in H5FD_class_t */ /* * Defining H5FD_FEAT_AGGREGATE_METADATA for a VFL driver means that * the library will attempt to allocate a larger block for metadata and * then sub-allocate each metadata request from that larger block. */ #define H5FD_FEAT_AGGREGATE_METADATA 0x00000001 /* * Defining H5FD_FEAT_ACCUMULATE_METADATA for a VFL driver means that * the library will attempt to cache metadata as it is written to the file * and build up a larger block of metadata to eventually pass to the VFL * 'write' routine. * * Distinguish between updating the metadata accumulator on writes and * reads. This is particularly (perhaps only, even) important for MPI-I/O * where we guarantee that writes are collective, but reads may not be. * If we were to allow the metadata accumulator to be written during a * read operation, the application would hang. */ #define H5FD_FEAT_ACCUMULATE_METADATA_WRITE 0x00000002 #define H5FD_FEAT_ACCUMULATE_METADATA_READ 0x00000004 #define H5FD_FEAT_ACCUMULATE_METADATA \ (H5FD_FEAT_ACCUMULATE_METADATA_WRITE | H5FD_FEAT_ACCUMULATE_METADATA_READ) /* * Defining H5FD_FEAT_DATA_SIEVE for a VFL driver means that * the library will attempt to cache raw data as it is read from/written to * a file in a "data seive" buffer. See Rajeev Thakur's papers: * http://www.mcs.anl.gov/~thakur/papers/romio-coll.ps.gz * http://www.mcs.anl.gov/~thakur/papers/mpio-high-perf.ps.gz */ #define H5FD_FEAT_DATA_SIEVE 0x00000008 /* * Defining H5FD_FEAT_AGGREGATE_SMALLDATA for a VFL driver means that * the library will attempt to allocate a larger block for "small" raw data * and then sub-allocate "small" raw data requests from that larger block. */ #define H5FD_FEAT_AGGREGATE_SMALLDATA 0x00000010 /* * Defining H5FD_FEAT_IGNORE_DRVRINFO for a VFL driver means that * the library will ignore the driver info that is encoded in the file * for the VFL driver. (This will cause the driver info to be eliminated * from the file when it is flushed/closed, if the file is opened R/W). */ #define H5FD_FEAT_IGNORE_DRVRINFO 0x00000020 /* * Defining the H5FD_FEAT_DIRTY_DRVRINFO_LOAD for a VFL driver means that * the library will mark the driver info dirty when the file is opened * R/W. This will cause the driver info to be re-encoded when the file * is flushed/closed. */ #define H5FD_FEAT_DIRTY_DRVRINFO_LOAD 0x00000040 /* * Defining H5FD_FEAT_POSIX_COMPAT_HANDLE for a VFL driver means that * the handle for the VFD (returned with the 'get_handle' callback) is * of type 'int' and is compatible with POSIX I/O calls. */ #define H5FD_FEAT_POSIX_COMPAT_HANDLE 0x00000080 /* * Defining H5FD_FEAT_HAS_MPI for a VFL driver means that * the driver makes use of MPI communication and code may retrieve * communicator/rank information from it */ #define H5FD_FEAT_HAS_MPI 0x00000100 /* * Defining the H5FD_FEAT_ALLOCATE_EARLY for a VFL driver will force * the library to use the H5D_ALLOC_TIME_EARLY on dataset create * instead of the default H5D_ALLOC_TIME_LATE */ #define H5FD_FEAT_ALLOCATE_EARLY 0x00000200 /* * Defining H5FD_FEAT_ALLOW_FILE_IMAGE for a VFL driver means that * the driver is able to use a file image in the fapl as the initial * contents of a file. */ #define H5FD_FEAT_ALLOW_FILE_IMAGE 0x00000400 /* * Defining H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS for a VFL driver * means that the driver is able to use callbacks to make a copy of the * image to store in memory. */ #define H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS 0x00000800 /* * Defining H5FD_FEAT_SUPPORTS_SWMR_IO for a VFL driver means that the * driver supports the single-writer/multiple-readers I/O pattern. */ #define H5FD_FEAT_SUPPORTS_SWMR_IO 0x00001000 /* * Defining H5FD_FEAT_USE_ALLOC_SIZE for a VFL driver * means that the library will just pass the allocation size to the * the driver's allocation callback which will eventually handle alignment. * This is specifically used for the multi/split driver. */ #define H5FD_FEAT_USE_ALLOC_SIZE 0x00002000 /* * Defining H5FD_FEAT_PAGED_AGGR for a VFL driver * means that the driver needs special file space mapping for paged aggregation. * This is specifically used for the multi/split driver. */ #define H5FD_FEAT_PAGED_AGGR 0x00004000 /* * Defining H5FD_FEAT_DEFAULT_VFD_COMPATIBLE for a VFL driver * that creates a file which is compatible with the default VFD. * Generally, this means that the VFD creates a single file that follows * the canonical HDF5 file format. * Regarding the Splitter VFD specifically, only drivers with this flag * enabled may be used as the Write-Only (W/O) channel driver. */ #define H5FD_FEAT_DEFAULT_VFD_COMPATIBLE 0x00008000 /* Forward declaration */ typedef struct H5FD_t H5FD_t; /* Class information for each file driver */ typedef struct H5FD_class_t { const char * name; haddr_t maxaddr; H5F_close_degree_t fc_degree; herr_t (*terminate)(void); hsize_t (*sb_size)(H5FD_t *file); herr_t (*sb_encode)(H5FD_t *file, char *name /*out*/, unsigned char *p /*out*/); herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p); size_t fapl_size; void *(*fapl_get)(H5FD_t *file); void *(*fapl_copy)(const void *fapl); herr_t (*fapl_free)(void *fapl); size_t dxpl_size; void *(*dxpl_copy)(const void *dxpl); herr_t (*dxpl_free)(void *dxpl); H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl, haddr_t maxaddr); herr_t (*close)(H5FD_t *file); int (*cmp)(const H5FD_t *f1, const H5FD_t *f2); herr_t (*query)(const H5FD_t *f1, unsigned long *flags); herr_t (*get_type_map)(const H5FD_t *file, H5FD_mem_t *type_map); haddr_t (*alloc)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); haddr_t (*get_eoa)(const H5FD_t *file, H5FD_mem_t type); herr_t (*set_eoa)(H5FD_t *file, H5FD_mem_t type, haddr_t addr); haddr_t (*get_eof)(const H5FD_t *file, H5FD_mem_t type); herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void **file_handle); herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, void *buffer); herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, const void *buffer); herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, hbool_t closing); herr_t (*truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing); herr_t (*lock)(H5FD_t *file, hbool_t rw); herr_t (*unlock)(H5FD_t *file); H5FD_mem_t fl_map[H5FD_MEM_NTYPES]; } H5FD_class_t; /* A free list is a singly-linked list of address/size pairs. */ typedef struct H5FD_free_t { haddr_t addr; hsize_t size; struct H5FD_free_t *next; } H5FD_free_t; /* * The main datatype for each driver. Public fields common to all drivers * are declared here and the driver appends private fields in memory. */ struct H5FD_t { hid_t driver_id; /*driver ID for this file */ const H5FD_class_t *cls; /*constant class info */ unsigned long fileno; /* File 'serial' number */ unsigned access_flags; /* File access flags (from create or open) */ unsigned long feature_flags; /* VFL Driver feature Flags */ haddr_t maxaddr; /* For this file, overrides class */ haddr_t base_addr; /* Base address for HDF5 data w/in file */ /* Space allocation management fields */ hsize_t threshold; /* Threshold for alignment */ hsize_t alignment; /* Allocation alignment */ hbool_t paged_aggr; /* Paged aggregation for file space is enabled or not */ }; /** * Define enum for the source of file image callbacks */ //! <!-- [H5FD_file_image_op_t_snip] --> typedef enum { H5FD_FILE_IMAGE_OP_NO_OP, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, /**< Passed to the \p image_malloc and \p image_memcpy callbacks when a * file image buffer is to be copied while being set in a file access * property list (FAPL)*/ H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, /**< Passed to the \p image_malloc and \p image_memcpy callbacks * when a file image buffer is to be copied when a FAPL is copied*/ H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, /**<Passed to the \p image_malloc and \p image_memcpy callbacks when * a file image buffer is to be copied while being retrieved from a FAPL*/ H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, /**<Passed to the \p image_free callback when a file image * buffer is to be released during a FAPL close operation*/ H5FD_FILE_IMAGE_OP_FILE_OPEN, /**<Passed to the \p image_malloc and * \p image_memcpy callbackswhen a * file image buffer is to be copied during a file open operation \n * While the file image being opened will typically be copied from a * FAPL, this need not always be the case. For example, the core file * driver, also known as the memory file driver, takes its initial * image from a file.*/ H5FD_FILE_IMAGE_OP_FILE_RESIZE, /**<Passed to the \p image_realloc callback when a file driver needs * to resize an image buffer*/ H5FD_FILE_IMAGE_OP_FILE_CLOSE /**<Passed to the \p image_free callback when an image buffer is to * be released during a file close operation*/ } H5FD_file_image_op_t; //! <!-- [H5FD_file_image_op_t_snip] --> /** * Define structure to hold file image callbacks */ //! <!-- [H5FD_file_image_callbacks_t_snip] --> typedef struct { /** * \param[in] size Size in bytes of the file image buffer to allocate * \param[in] file_image_op A value from H5FD_file_image_op_t indicating * the operation being performed on the file image * when this callback is invoked * \param[in] udata Value passed in in the H5Pset_file_image_callbacks * parameter \p udata */ //! <!-- [image_malloc_snip] --> void *(*image_malloc)(size_t size, H5FD_file_image_op_t file_image_op, void *udata); //! <!-- [image_malloc_snip] --> /** * \param[in] dest Address of the destination buffer * \param[in] src Address of the source buffer * \param[in] file_image_op A value from #H5FD_file_image_op_t indicating * the operation being performed on the file image * when this callback is invoked * \param[in] udata Value passed in in the H5Pset_file_image_callbacks * parameter \p udata */ //! <!-- [image_memcpy_snip] --> void *(*image_memcpy)(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *udata); //! <!-- [image_memcpy_snip] --> /** * \param[in] ptr Pointer to the buffer being reallocated * \param[in] file_image_op A value from #H5FD_file_image_op_t indicating * the operation being performed on the file image * when this callback is invoked * \param[in] udata Value passed in in the H5Pset_file_image_callbacks * parameter \p udata */ //! <!-- [image_realloc_snip] --> void *(*image_realloc)(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata); //! <!-- [image_realloc_snip] --> /** * \param[in] udata Value passed in in the H5Pset_file_image_callbacks * parameter \p udata */ //! <!-- [image_free_snip] --> herr_t (*image_free)(void *ptr, H5FD_file_image_op_t file_image_op, void *udata); //! <!-- [image_free_snip] --> /** * \param[in] udata Value passed in in the H5Pset_file_image_callbacks * parameter \p udata */ //! <!-- [udata_copy_snip] --> void *(*udata_copy)(void *udata); //! <!-- [udata_copy_snip] --> /** * \param[in] udata Value passed in in the H5Pset_file_image_callbacks * parameter \p udata */ //! <!-- [udata_free_snip] --> herr_t (*udata_free)(void *udata); //! <!-- [udata_free_snip] --> /** * \brief The final field in the #H5FD_file_image_callbacks_t struct, * provides a pointer to user-defined data. This pointer will be * passed to the image_malloc, image_memcpy, image_realloc, and * image_free callbacks. Define udata as NULL if no user-defined * data is provided. */ void *udata; } H5FD_file_image_callbacks_t; //! <!-- [H5FD_file_image_callbacks_t_snip] --> #ifdef __cplusplus extern "C" { #endif /* Function prototypes */ H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); H5_DLL herr_t H5FDunregister(hid_t driver_id); H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); H5_DLL herr_t H5FDclose(H5FD_t *file); H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags); H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type); H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); H5_DLL haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type); H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle); H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf /*out*/); H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw); H5_DLL herr_t H5FDunlock(H5FD_t *file); /* Allows querying a VFD ID for features before the file is opened */ H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/); #ifdef __cplusplus } #endif #endif
0c3940b1b115fee70908414e847e70864411cd8a
83b8b30ebb633eecd29ca0a7a20cc43a293c9333
/ports/mimxrt10xx/peripherals/mimxrt10xx/pins.c
d052711033c9b4579c772bc1169d6b11f9007e5d
[ "MIT", "GPL-1.0-or-later" ]
permissive
adafruit/circuitpython
430ec895149d1eb814b505db39b4977a35ee88a7
506dca71b0cbb7af749bb51f86b01021db5483b3
refs/heads/main
2023-08-21T16:30:46.781068
2023-08-20T00:39:44
2023-08-20T00:39:44
66,166,069
3,806
1,560
MIT
2023-09-14T19:23:51
2016-08-20T20:10:40
C
UTF-8
C
false
false
3,361
c
pins.c
#include "peripherals/mimxrt10xx/pins.h" typedef struct { gpio_change_interrupt_t *func; void *data; } pin_change_interrupt_data; /* Array of GPIO peripheral base address. */ static GPIO_Type *const s_gpioBases[] = GPIO_BASE_PTRS; static uint32_t GPIO_GetInstance(GPIO_Type *base) { uint32_t instance; /* Find the instance index from base address mappings. */ for (instance = 0U; instance < ARRAY_SIZE(s_gpioBases); instance++) { if (s_gpioBases[instance] == base) { break; } } assert(instance < ARRAY_SIZE(s_gpioBases)); return instance; } /* to find IRQ based on GPIO */ static const IRQn_Type low_irqs[] = GPIO_COMBINED_LOW_IRQS; static const IRQn_Type high_irqs[] = GPIO_COMBINED_HIGH_IRQS; static volatile pin_change_interrupt_data pcid[MP_ARRAY_SIZE(s_gpioBases)][32]; void enable_pin_change_interrupt(const mcu_pin_obj_t *pin, gpio_change_interrupt_t func, void *data) { int instance = GPIO_GetInstance(pin->gpio); volatile pin_change_interrupt_data *pci = &pcid[instance][pin->number]; common_hal_mcu_disable_interrupts(); pci->data = data; pci->func = func; IRQn_Type irq = pin->number < 16 ? low_irqs[instance] : high_irqs[instance]; if (irq != NotAvail_IRQn) { EnableIRQ(irq); } pin->gpio->IMR |= (1 << pin->number); common_hal_mcu_enable_interrupts(); } void disable_pin_change_interrupt(const mcu_pin_obj_t *pin) { volatile pin_change_interrupt_data *pci = &pcid[GPIO_GetInstance(pin->gpio)][pin->number]; common_hal_mcu_disable_interrupts(); pin->gpio->IMR &= ~(1 << pin->number); pci->data = NULL; pci->func = NULL; pin->gpio->ISR = (1 << pin->number); // acknowledge any pending interrupt common_hal_mcu_enable_interrupts(); } static void pin_change_interrupt_common(uint32_t isr, volatile pin_change_interrupt_data *pcr) { for (uint32_t i = 0; i < 32; i++) { if (isr & (1 << i)) { pin_change_interrupt_data cb = pcr[i]; if (cb.func) { cb.func(cb.data); } } } } #define GPIO_INTERRUPT_HANDLER(name, ptr, instance, offset) \ void name(void); \ __attribute__((used)) void name(void) { \ uint32_t isr = ptr->ISR; \ ptr->ISR = isr; \ pin_change_interrupt_common(isr, pcid[instance]); \ } #if defined(GPIO1) GPIO_INTERRUPT_HANDLER(GPIO1_Combined_0_15_IRQHandler, GPIO1, 1, 0); GPIO_INTERRUPT_HANDLER(GPIO1_Combined_16_31_IRQHandler, GPIO1, 1, 16); #endif #if defined(GPIO2) GPIO_INTERRUPT_HANDLER(GPIO2_Combined_0_15_IRQHandler, GPIO2, 2, 0); GPIO_INTERRUPT_HANDLER(GPIO2_Combined_16_31_IRQHandler, GPIO2, 2, 16); #endif #if defined(GPIO3) GPIO_INTERRUPT_HANDLER(GPIO3_Combined_0_15_IRQHandler, GPIO3, 3, 0); GPIO_INTERRUPT_HANDLER(GPIO3_Combined_16_31_IRQHandler, GPIO3, 3, 16); #endif #if defined(GPIO4) GPIO_INTERRUPT_HANDLER(GPIO4_Combined_0_15_IRQHandler, GPIO4, 4, 0); GPIO_INTERRUPT_HANDLER(GPIO4_Combined_16_31_IRQHandler, GPIO4, 4, 16); #endif #if defined(GPIO5) GPIO_INTERRUPT_HANDLER(GPIO5_Combined_0_15_IRQHandler, GPIO5, 5, 0); GPIO_INTERRUPT_HANDLER(GPIO5_Combined_16_31_IRQHandler, GPIO5, 5, 16); #endif #if defined(GPIO6) GPIO_INTERRUPT_HANDLER(GPIO6_Combined_0_15_IRQHandler, GPIO6, 6, 0); GPIO_INTERRUPT_HANDLER(GPIO6_Combined_16_31_IRQHandler, GPIO6, 6, 16); #endif
75c93628e1111c5903dd46121f1123494bbec03b
7664f318ed04bd0680f3d82321c18896e3ef6ad5
/src/overlays/actors/ovl_En_Fz/z_en_fz.c
957f2df07c207c28074b79fd980329de59c07436
[]
no_license
zeldaret/oot
9c80ce17f2d8fd61514b375f92ee4739b5ce9d4e
2875ab4fcf5c5f81d76353d1ee0024c9ea8d0b23
refs/heads/master
2023-08-29T05:29:31.356427
2023-08-28T22:48:52
2023-08-28T22:48:52
247,875,738
4,401
802
null
2023-09-14T13:34:38
2020-03-17T04:02:19
C
UTF-8
C
false
false
28,993
c
z_en_fz.c
#include "z_en_fz.h" #include "assets/objects/object_fz/object_fz.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_10) void EnFz_Init(Actor* thisx, PlayState* play); void EnFz_Destroy(Actor* thisx, PlayState* play); void EnFz_Update(Actor* thisx, PlayState* play); void EnFz_Draw(Actor* thisx, PlayState* play); void EnFz_UpdateTargetPos(EnFz* this, PlayState* play); // Stationary Freezard void EnFz_SetupBlowSmokeStationary(EnFz* this); void EnFz_BlowSmokeStationary(EnFz* this, PlayState* play); // Moving Freezard that can vanish and reappear void EnFz_Wait(EnFz* this, PlayState* play); void EnFz_SetupAppear(EnFz* this); void EnFz_Appear(EnFz* this, PlayState* play); void EnFz_SetupAimForMove(EnFz* this); void EnFz_AimForMove(EnFz* this, PlayState* play); void EnFz_SetupMoveTowardsPlayer(EnFz* this); void EnFz_MoveTowardsPlayer(EnFz* this, PlayState* play); void EnFz_SetupAimForFreeze(EnFz* this); void EnFz_AimForFreeze(EnFz* this, PlayState* play); void EnFz_SetupBlowSmoke(EnFz* this, PlayState* play); void EnFz_BlowSmoke(EnFz* this, PlayState* play); void EnFz_SetupDisappear(EnFz* this); void EnFz_Disappear(EnFz* this, PlayState* play); void EnFz_SetupWait(EnFz* this); // Killed with fire source void EnFz_SetupMelt(EnFz* this); void EnFz_Melt(EnFz* this, PlayState* play); // Death void EnFz_SetupDespawn(EnFz* this, PlayState* play); void EnFz_Despawn(EnFz* this, PlayState* play); // Ice Smoke Effects void EnFz_SpawnIceSmokeNoFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale); void EnFz_SpawnIceSmokeFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale, f32 xyScaleTarget, s16 primAlpha, u8 isTimerMod8); void EnFz_UpdateIceSmoke(EnFz* this, PlayState* play); void EnFz_DrawEffects(EnFz* this, PlayState* play); ActorInit En_Fz_InitVars = { ACTOR_EN_FZ, ACTORCAT_ENEMY, FLAGS, OBJECT_FZ, sizeof(EnFz), (ActorFunc)EnFz_Init, (ActorFunc)EnFz_Destroy, (ActorFunc)EnFz_Update, (ActorFunc)EnFz_Draw, }; static ColliderCylinderInitType1 sCylinderInit1 = { { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, COLSHAPE_CYLINDER, }, { ELEMTYPE_UNK0, { 0xFFCFFFFF, 0x00, 0x00 }, { 0xFFCE0FDB, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, { 30, 80, 0, { 0, 0, 0 } }, }; static ColliderCylinderInitType1 sCylinderInit2 = { { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, COLSHAPE_CYLINDER, }, { ELEMTYPE_UNK0, { 0xFFCFFFFF, 0x00, 0x00 }, { 0x0001F024, 0x00, 0x00 }, TOUCH_NONE, BUMP_ON, OCELEM_NONE, }, { 35, 80, 0, { 0, 0, 0 } }, }; static ColliderCylinderInitType1 sCylinderInit3 = { { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, COLSHAPE_CYLINDER, }, { ELEMTYPE_UNK0, { 0x20000000, 0x02, 0x08 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, { 20, 30, -15, { 0, 0, 0 } }, }; static DamageTable sDamageTable = { /* Deku nut */ DMG_ENTRY(0, 0x0), /* Deku stick */ DMG_ENTRY(0, 0xF), /* Slingshot */ DMG_ENTRY(0, 0xF), /* Explosive */ DMG_ENTRY(2, 0xF), /* Boomerang */ DMG_ENTRY(0, 0xF), /* Normal arrow */ DMG_ENTRY(0, 0xF), /* Hammer swing */ DMG_ENTRY(2, 0xF), /* Hookshot */ DMG_ENTRY(2, 0xF), /* Kokiri sword */ DMG_ENTRY(0, 0xF), /* Master sword */ DMG_ENTRY(2, 0xF), /* Giant's Knife */ DMG_ENTRY(4, 0xF), /* Fire arrow */ DMG_ENTRY(4, 0x2), /* Ice arrow */ DMG_ENTRY(0, 0xF), /* Light arrow */ DMG_ENTRY(0, 0xF), /* Unk arrow 1 */ DMG_ENTRY(0, 0xF), /* Unk arrow 2 */ DMG_ENTRY(0, 0xF), /* Unk arrow 3 */ DMG_ENTRY(0, 0xF), /* Fire magic */ DMG_ENTRY(4, 0x2), /* Ice magic */ DMG_ENTRY(0, 0x0), /* Light magic */ DMG_ENTRY(0, 0x0), /* Shield */ DMG_ENTRY(0, 0x0), /* Mirror Ray */ DMG_ENTRY(0, 0x0), /* Kokiri spin */ DMG_ENTRY(0, 0xF), /* Giant spin */ DMG_ENTRY(4, 0xF), /* Master spin */ DMG_ENTRY(2, 0xF), /* Kokiri jump */ DMG_ENTRY(0, 0xF), /* Giant jump */ DMG_ENTRY(8, 0xF), /* Master jump */ DMG_ENTRY(4, 0xF), /* Unknown 1 */ DMG_ENTRY(0, 0x0), /* Unblockable */ DMG_ENTRY(0, 0x0), /* Hammer jump */ DMG_ENTRY(0, 0x0), /* Unknown 2 */ DMG_ENTRY(0, 0x0), }; static InitChainEntry sInitChain[] = { ICHAIN_S8(naviEnemyId, NAVI_ENEMY_FREEZARD, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), }; void EnFz_Init(Actor* thisx, PlayState* play) { EnFz* this = (EnFz*)thisx; Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.colChkInfo.health = 6; Collider_InitCylinder(play, &this->collider1); Collider_SetCylinderType1(play, &this->collider1, &this->actor, &sCylinderInit1); Collider_InitCylinder(play, &this->collider2); Collider_SetCylinderType1(play, &this->collider2, &this->actor, &sCylinderInit2); Collider_InitCylinder(play, &this->collider3); Collider_SetCylinderType1(play, &this->collider3, &this->actor, &sCylinderInit3); Actor_SetScale(&this->actor, 0.008f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.flags &= ~ACTOR_FLAG_0; this->unusedTimer1 = 0; this->unusedCounter = 0; this->updateBgInfo = true; this->isMoving = false; this->isFreezing = false; this->isActive = true; this->isDespawning = false; this->actor.speed = 0.0f; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; this->posOrigin.y = this->actor.world.pos.y; this->iceSmokeFreezingSpawnHeight = this->actor.world.pos.y; this->posOrigin.x = this->actor.world.pos.x; this->posOrigin.z = this->actor.world.pos.z; this->unusedFloat = 135.0f; if (this->actor.params < 0) { this->envAlpha = 0; this->actor.scale.y = 0.0f; EnFz_SetupWait(this); } else { this->envAlpha = 255; EnFz_SetupBlowSmokeStationary(this); } EnFz_UpdateTargetPos(this, play); } void EnFz_Destroy(Actor* thisx, PlayState* play) { EnFz* this = (EnFz*)thisx; Collider_DestroyCylinder(play, &this->collider1); Collider_DestroyCylinder(play, &this->collider2); Collider_DestroyCylinder(play, &this->collider3); } void EnFz_UpdateTargetPos(EnFz* this, PlayState* play) { Vec3f pos; Vec3f hitPos; Vec3f vec1; s32 bgId; CollisionPoly* hitPoly; pos.x = this->actor.world.pos.x; pos.y = this->actor.world.pos.y + 20.0f; pos.z = this->actor.world.pos.z; Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, MTXMODE_APPLY); vec1.x = vec1.y = 0.0f; vec1.z = 220.0f; Matrix_MultVec3f(&vec1, &this->wallHitPos); if (BgCheck_EntityLineTest1(&play->colCtx, &pos, &this->wallHitPos, &hitPos, &hitPoly, true, false, false, true, &bgId)) { Math_Vec3f_Copy(&this->wallHitPos, &hitPos); } pos.x = this->actor.world.pos.x - this->wallHitPos.x; pos.z = this->actor.world.pos.z - this->wallHitPos.z; this->distToTargetSq = SQ(pos.x) + SQ(pos.z); } s32 EnFz_ReachedTarget(EnFz* this, Vec3f* vec) { if (this->distToTargetSq <= (SQ(this->actor.world.pos.x - vec->x) + SQ(this->actor.world.pos.z - vec->z))) { return true; } else { return false; } } void EnFz_Damaged(EnFz* this, PlayState* play, Vec3f* vec, s32 numEffects, f32 unkFloat) { s32 i; Vec3f pos; Vec3f vel; Vec3f accel; Color_RGBA8 primColor; Color_RGBA8 envColor; f32 scale; s32 life; primColor.r = 155; primColor.g = 255; primColor.b = 255; primColor.a = 255; envColor.r = 200; envColor.g = 200; envColor.b = 200; accel.x = accel.z = 0.0f; accel.y = -1.0f; for (i = 0; i < numEffects; i++) { scale = Rand_CenteredFloat(0.3f) + 0.6f; life = (s32)Rand_CenteredFloat(5.0f) + 12; pos.x = Rand_CenteredFloat(unkFloat) + vec->x; pos.y = Rand_ZeroFloat(unkFloat) + vec->y; pos.z = Rand_CenteredFloat(unkFloat) + vec->z; vel.x = Rand_CenteredFloat(10.0f); vel.y = Rand_ZeroFloat(10.0f) + 2.0f; vel.z = Rand_CenteredFloat(10.0f); EffectSsEnIce_Spawn(play, &pos, scale, &vel, &accel, &primColor, &envColor, life); } CollisionCheck_SpawnShieldParticles(play, vec); } void EnFz_SpawnIceSmokeHiddenState(EnFz* this) { } // Fully grown void EnFz_SpawnIceSmokeGrowingState(EnFz* this) { Vec3f pos; Vec3f velocity; Vec3f accel; if ((this->counter % 16) == 0) { pos.x = Rand_CenteredFloat(40.0f) + this->actor.world.pos.x; pos.y = Rand_CenteredFloat(40.0f) + this->actor.world.pos.y + 30.0f; pos.z = Rand_CenteredFloat(40.0f) + this->actor.world.pos.z; accel.x = accel.z = 0.0f; accel.y = 0.1f; velocity.x = velocity.y = velocity.z = 0.0f; EnFz_SpawnIceSmokeNoFreeze(this, &pos, &velocity, &accel, Rand_ZeroFloat(7.5f) + 15.0f); } } // (2) Growing or Shrinking to/from hiding or (3) melting from fire void EnFz_SpawnIceSmokeActiveState(EnFz* this) { Vec3f pos; Vec3f velocity; Vec3f accel; if ((this->counter % 4) == 0) { pos.x = Rand_CenteredFloat(40.0f) + this->actor.world.pos.x; pos.y = this->iceSmokeFreezingSpawnHeight; pos.z = Rand_CenteredFloat(40.0f) + this->actor.world.pos.z; accel.x = accel.z = 0.0f; accel.y = 0.1f; velocity.x = velocity.y = velocity.z = 0.0f; EnFz_SpawnIceSmokeNoFreeze(this, &pos, &velocity, &accel, Rand_ZeroFloat(7.5f) + 15.0f); } } void EnFz_ApplyDamage(EnFz* this, PlayState* play) { Vec3f vec; if (this->isMoving && ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (Actor_TestFloorInDirection(&this->actor, play, 60.0f, this->actor.world.rot.y) == 0))) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; this->isMoving = false; this->speedXZ = 0.0f; this->actor.speed = 0.0f; } if (this->isFreezing) { if ((this->actor.params < 0) && (this->collider1.base.atFlags & AT_HIT)) { this->isMoving = false; this->collider1.base.acFlags &= ~AC_HIT; this->actor.speed = this->speedXZ = 0.0f; this->timer = 10; EnFz_SetupDisappear(this); } else if (this->collider2.base.acFlags & AC_BOUNCED) { this->collider2.base.acFlags &= ~AC_BOUNCED; this->collider1.base.acFlags &= ~AC_HIT; } else if (this->collider1.base.acFlags & AC_HIT) { this->collider1.base.acFlags &= ~AC_HIT; switch (this->actor.colChkInfo.damageEffect) { case 0xF: Actor_ApplyDamage(&this->actor); Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_XLU, 8); if (this->actor.colChkInfo.health != 0) { Actor_PlaySfx(&this->actor, NA_SE_EN_FREEZAD_DAMAGE); vec.x = this->actor.world.pos.x; vec.y = this->actor.world.pos.y; vec.z = this->actor.world.pos.z; EnFz_Damaged(this, play, &vec, 10, 0.0f); this->unusedCounter++; } else { Actor_PlaySfx(&this->actor, NA_SE_EN_FREEZAD_DEAD); Actor_PlaySfx(&this->actor, NA_SE_EV_ICE_BROKEN); vec.x = this->actor.world.pos.x; vec.y = this->actor.world.pos.y; vec.z = this->actor.world.pos.z; EnFz_Damaged(this, play, &vec, 30, 10.0f); EnFz_SetupDespawn(this, play); } break; case 2: Actor_ApplyDamage(&this->actor); Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_XLU, 8); if (this->actor.colChkInfo.health == 0) { Actor_PlaySfx(&this->actor, NA_SE_EN_FREEZAD_DEAD); EnFz_SetupMelt(this); } else { Actor_PlaySfx(&this->actor, NA_SE_EN_FREEZAD_DAMAGE); } break; default: break; } } } } void EnFz_SetYawTowardsPlayer(EnFz* this) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 10, 2000, 0); this->actor.world.rot.y = this->actor.shape.rot.y; } void EnFz_SetupDisappear(EnFz* this) { this->state = 2; this->isFreezing = false; this->actor.flags &= ~ACTOR_FLAG_0; this->actionFunc = EnFz_Disappear; } void EnFz_Disappear(EnFz* this, PlayState* play) { this->envAlpha -= 16; if (this->envAlpha > 255) { this->envAlpha = 0; } if (Math_SmoothStepToF(&this->actor.scale.y, 0.0f, 1.0f, 0.0005f, 0) == 0.0f) { EnFz_SetupWait(this); } } void EnFz_SetupWait(EnFz* this) { this->state = 0; this->unusedNum2 = 0; this->unusedNum1 = 0; this->timer = 100; this->actionFunc = EnFz_Wait; this->actor.world.pos.x = this->posOrigin.x; this->actor.world.pos.y = this->posOrigin.y; this->actor.world.pos.z = this->posOrigin.z; } void EnFz_Wait(EnFz* this, PlayState* play) { if ((this->timer == 0) && (this->actor.xzDistToPlayer < 400.0f)) { EnFz_SetupAppear(this); } } void EnFz_SetupAppear(EnFz* this) { this->state = 2; this->timer = 20; this->unusedNum2 = 4000; this->actionFunc = EnFz_Appear; } void EnFz_Appear(EnFz* this, PlayState* play) { if (this->timer == 0) { this->envAlpha += 8; if (this->envAlpha > 255) { this->envAlpha = 255; } if (Math_SmoothStepToF(&this->actor.scale.y, 0.008f, 1.0f, 0.0005f, 0.0f) == 0.0f) { EnFz_SetupAimForMove(this); } } } void EnFz_SetupAimForMove(EnFz* this) { this->state = 1; this->timer = 40; this->updateBgInfo = true; this->isFreezing = true; this->actor.flags |= ACTOR_FLAG_0; this->actionFunc = EnFz_AimForMove; this->actor.gravity = -1.0f; } void EnFz_AimForMove(EnFz* this, PlayState* play) { EnFz_SetYawTowardsPlayer(this); if (this->timer == 0) { EnFz_SetupMoveTowardsPlayer(this); } } void EnFz_SetupMoveTowardsPlayer(EnFz* this) { this->state = 1; this->isMoving = true; this->timer = 100; this->actionFunc = EnFz_MoveTowardsPlayer; this->speedXZ = 4.0f; } void EnFz_MoveTowardsPlayer(EnFz* this, PlayState* play) { if ((this->timer == 0) || !this->isMoving) { EnFz_SetupAimForFreeze(this); } } void EnFz_SetupAimForFreeze(EnFz* this) { this->state = 1; this->timer = 40; this->actionFunc = EnFz_AimForFreeze; this->speedXZ = 0.0f; this->actor.speed = 0.0f; } void EnFz_AimForFreeze(EnFz* this, PlayState* play) { EnFz_SetYawTowardsPlayer(this); if (this->timer == 0) { EnFz_SetupBlowSmoke(this, play); } } void EnFz_SetupBlowSmoke(EnFz* this, PlayState* play) { this->state = 1; this->timer = 80; this->actionFunc = EnFz_BlowSmoke; EnFz_UpdateTargetPos(this, play); } void EnFz_BlowSmoke(EnFz* this, PlayState* play) { Vec3f vec1; Vec3f pos; Vec3f velocity; Vec3f accel; u8 isTimerMod8; s16 primAlpha; if (this->timer == 0) { EnFz_SetupDisappear(this); } else if (this->timer >= 11) { isTimerMod8 = false; primAlpha = 150; func_8002F974(&this->actor, NA_SE_EN_FREEZAD_BREATH - SFX_FLAG); if ((this->timer - 10) < 16) { // t < 26 primAlpha = (this->timer * 10) - 100; } accel.x = accel.z = 0.0f; accel.y = 0.6f; pos.x = this->actor.world.pos.x; pos.y = this->actor.world.pos.y + 20.0f; pos.z = this->actor.world.pos.z; Matrix_RotateY(BINANG_TO_RAD_ALT(this->actor.shape.rot.y), MTXMODE_NEW); vec1.x = 0.0f; vec1.y = -2.0f; vec1.z = 20.0f; // xz velocity Matrix_MultVec3f(&vec1, &velocity); if ((this->timer % 8) == 0) { isTimerMod8 = true; } EnFz_SpawnIceSmokeFreeze(this, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, isTimerMod8); pos.x += (velocity.x * 0.5f); pos.y += (velocity.y * 0.5f); pos.z += (velocity.z * 0.5f); EnFz_SpawnIceSmokeFreeze(this, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, false); } } void EnFz_SetupDespawn(EnFz* this, PlayState* play) { this->state = 0; this->updateBgInfo = true; this->isFreezing = false; this->isDespawning = true; this->actor.flags &= ~ACTOR_FLAG_0; this->isActive = false; this->timer = 60; this->speedXZ = 0.0f; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; this->actor.speed = 0.0f; Actor_ChangeCategory(play, &play->actorCtx, &this->actor, ACTORCAT_PROP); Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x60); this->actionFunc = EnFz_Despawn; } void EnFz_Despawn(EnFz* this, PlayState* play) { if (this->timer == 0) { Actor_Kill(&this->actor); } } void EnFz_SetupMelt(EnFz* this) { this->state = 3; this->isFreezing = false; this->isDespawning = true; this->actor.flags &= ~ACTOR_FLAG_0; this->actionFunc = EnFz_Melt; this->actor.speed = 0.0f; this->speedXZ = 0.0f; } void EnFz_Melt(EnFz* this, PlayState* play) { Math_StepToF(&this->actor.scale.y, 0.0006f, 0.0002f); if (this->actor.scale.y < 0.006f) { this->actor.scale.x += 0.0004f; this->actor.scale.z += 0.0004f; } if (this->actor.scale.y < 0.004f) { this->envAlpha -= 8; if (this->envAlpha > 255) { this->envAlpha = 0; } } if (this->envAlpha == 0) { EnFz_SetupDespawn(this, play); } } void EnFz_SetupBlowSmokeStationary(EnFz* this) { this->state = 1; this->timer = 40; this->updateBgInfo = true; this->isFreezing = true; this->actor.flags |= ACTOR_FLAG_0; this->actionFunc = EnFz_BlowSmokeStationary; this->actor.gravity = -1.0f; } void EnFz_BlowSmokeStationary(EnFz* this, PlayState* play) { Vec3f vec1; Vec3f pos; Vec3f velocity; Vec3f accel; u8 isTimerMod8; s16 primAlpha; if (this->counter & 0xC0) { EnFz_SetYawTowardsPlayer(this); EnFz_UpdateTargetPos(this, play); } else { isTimerMod8 = false; primAlpha = 150; func_8002F974(&this->actor, NA_SE_EN_FREEZAD_BREATH - SFX_FLAG); if ((this->counter & 0x3F) >= 48) { primAlpha = 630 - ((this->counter & 0x3F) * 10); } accel.x = accel.z = 0.0f; accel.y = 0.6f; pos.x = this->actor.world.pos.x; pos.y = this->actor.world.pos.y + 20.0f; pos.z = this->actor.world.pos.z; Matrix_RotateY(BINANG_TO_RAD_ALT(this->actor.shape.rot.y), MTXMODE_NEW); vec1.x = 0.0f; vec1.y = -2.0f; vec1.z = 20.0f; Matrix_MultVec3f(&vec1, &velocity); if ((this->counter % 8) == 0) { isTimerMod8 = true; } EnFz_SpawnIceSmokeFreeze(this, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, isTimerMod8); pos.x += (velocity.x * 0.5f); pos.y += (velocity.y * 0.5f); pos.z += (velocity.z * 0.5f); EnFz_SpawnIceSmokeFreeze(this, &pos, &velocity, &accel, 2.0f, 25.0f, primAlpha, false); } } static EnFzSpawnIceSmokeFunc iceSmokeSpawnFuncs[] = { EnFz_SpawnIceSmokeHiddenState, EnFz_SpawnIceSmokeGrowingState, EnFz_SpawnIceSmokeActiveState, EnFz_SpawnIceSmokeActiveState, }; void EnFz_Update(Actor* thisx, PlayState* play) { EnFz* this = (EnFz*)thisx; s32 pad; this->counter++; if (this->unusedTimer1 != 0) { this->unusedTimer1--; } if (this->timer != 0) { this->timer--; } if (this->unusedTimer2 != 0) { this->unusedTimer2--; } Actor_SetFocus(&this->actor, 50.0f); EnFz_ApplyDamage(this, play); this->actionFunc(this, play); if (!this->isDespawning) { Collider_UpdateCylinder(&this->actor, &this->collider1); Collider_UpdateCylinder(&this->actor, &this->collider2); if (this->isFreezing) { if (this->actor.colorFilterTimer == 0) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); } CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); } } Math_StepToF(&this->actor.speed, this->speedXZ, 0.2f); Actor_MoveXZGravity(&this->actor); if (this->updateBgInfo) { Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2); } iceSmokeSpawnFuncs[this->state](this); EnFz_UpdateIceSmoke(this, play); } void EnFz_Draw(Actor* thisx, PlayState* play) { static Gfx* displayLists[] = { gFreezardIntactDL, // Body fully intact (5 or 6 health) gFreezardTopRightHornChippedDL, // Top right horn chipped off (from Freezards perspective) (3 or 4 health) gFreezardHeadChippedDL, // Entire head chipped off (1 or 2 health) }; EnFz* this = (EnFz*)thisx; s32 pad; s32 index; index = (6 - this->actor.colChkInfo.health) >> 1; OPEN_DISPS(play->state.gfxCtx, "../z_en_fz.c", 1167); if (1) {} if (this->actor.colChkInfo.health == 0) { index = 2; } if (this->isActive) { func_8002ED80(&this->actor, play, 0); Gfx_SetupDL_25Xlu(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, play->state.frames & 0x7F, 32, 32, 1, 0, (2 * play->state.frames) & 0x7F, 32, 32)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_en_fz.c", 1183), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetCombineLERP(POLY_XLU_DISP++, TEXEL1, PRIMITIVE, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIMITIVE, TEXEL0, PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, COMBINED, 0, ENVIRONMENT, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, 155, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, this->envAlpha); gSPDisplayList(POLY_XLU_DISP++, displayLists[index]); } CLOSE_DISPS(play->state.gfxCtx, "../z_en_fz.c", 1200); EnFz_DrawEffects(this, play); } void EnFz_SpawnIceSmokeNoFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale) { EnFzEffect* effect = this->effects; s16 i; for (i = 0; i < EN_FZ_EFFECT_COUNT; i++) { if (effect->type == 0) { effect->type = 1; effect->pos = *pos; effect->velocity = *velocity; effect->accel = *accel; effect->primAlphaState = 0; effect->xyScale = xyScale / 1000.0f; effect->primAlpha = 0; effect->timer = 0; break; } effect++; } } void EnFz_SpawnIceSmokeFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 xyScale, f32 xyScaleTarget, s16 primAlpha, u8 isTimerMod8) { EnFzEffect* effect = this->effects; s16 i; for (i = 0; i < EN_FZ_EFFECT_COUNT; i++) { if (effect->type == 0) { effect->type = 2; effect->pos = *pos; effect->velocity = *velocity; effect->accel = *accel; effect->primAlphaState = 0; effect->xyScale = xyScale / 1000.0f; effect->xyScaleTarget = xyScaleTarget / 1000.0f; effect->primAlpha = primAlpha; effect->timer = 0; effect->isTimerMod8 = isTimerMod8; break; } effect++; } } void EnFz_UpdateIceSmoke(EnFz* this, PlayState* play) { EnFzEffect* effect = this->effects; s16 i; Vec3f pos; for (i = 0; i < EN_FZ_EFFECT_COUNT; i++) { if (effect->type) { effect->pos.x += effect->velocity.x; effect->pos.y += effect->velocity.y; effect->pos.z += effect->velocity.z; effect->timer++; effect->velocity.x += effect->accel.x; effect->velocity.y += effect->accel.y; effect->velocity.z += effect->accel.z; if (effect->type == 1) { if (effect->primAlphaState == 0) { // Becoming more opaque effect->primAlpha += 10; if (effect->primAlpha >= 100) { effect->primAlphaState++; } } else { // Becoming more transparent effect->primAlpha -= 3; if (effect->primAlpha <= 0) { effect->primAlpha = 0; effect->type = 0; } } } else if (effect->type == 2) { // Freezing Math_ApproachF(&effect->xyScale, effect->xyScaleTarget, 0.1f, effect->xyScaleTarget / 10.0f); if (effect->primAlphaState == 0) { // Becoming more opaque if (effect->timer >= 7) { effect->primAlphaState++; } } else { // Becoming more transparent, slows down effect->accel.y = 2.0f; effect->primAlpha -= 17; effect->velocity.x *= 0.75f; effect->velocity.z *= 0.75f; if (effect->primAlpha <= 0) { effect->primAlpha = 0; effect->type = 0; } } if ((this->unusedTimer2 == 0) && (effect->primAlpha >= 101) && effect->isTimerMod8) { this->collider3.dim.pos.x = (s16)effect->pos.x; this->collider3.dim.pos.y = (s16)effect->pos.y; this->collider3.dim.pos.z = (s16)effect->pos.z; CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider3.base); } pos.x = effect->pos.x; pos.y = effect->pos.y + 10.0f; pos.z = effect->pos.z; if ((effect->primAlphaState != 2) && EnFz_ReachedTarget(this, &pos)) { effect->primAlphaState = 2; effect->velocity.x = 0.0f; effect->velocity.z = 0.0f; } } } effect++; } } void EnFz_DrawEffects(EnFz* this, PlayState* play) { EnFzEffect* effect = this->effects; s16 i; GraphicsContext* gfxCtx = play->state.gfxCtx; u8 materialFlag = 0; OPEN_DISPS(gfxCtx, "../z_en_fz.c", 1384); Gfx_SetupDL_25Xlu(play->state.gfxCtx); for (i = 0; i < EN_FZ_EFFECT_COUNT; i++) { if (effect->type > 0) { gDPPipeSync(POLY_XLU_DISP++); if (!materialFlag) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamStartDL)); materialFlag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, effect->primAlpha); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 3 * (effect->timer + (3 * i)), 15 * (effect->timer + (3 * i)), 32, 64, 1, 0, 0, 32, 32)); Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(effect->xyScale, effect->xyScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_en_fz.c", 1424), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamDL)); } effect++; } CLOSE_DISPS(gfxCtx, "../z_en_fz.c", 1430); }
3d87ef29725a8f341235473be5484a454ec5cdcf
e61d085f74b9fc33f3211af8056932c2807a5446
/multifm/rtl_sdr_if.h
35c38b11e2fea8c0d84027a0ebe719668be07f4c
[]
no_license
pvachon/tsl-sdr
8ab592019356f749785acea2fb84795ce20acac6
b2e935f3e0a957ba55d8c522edd3b90c38f7df20
refs/heads/master
2022-09-24T21:51:55.087025
2020-08-16T23:37:32
2020-08-16T23:37:32
78,375,956
123
12
null
2022-09-20T02:23:21
2017-01-08T22:56:05
C
UTF-8
C
false
false
529
h
rtl_sdr_if.h
#pragma once #include <multifm/receiver.h> struct rtlsdr_dev; struct config; /** * State for the RTL-SDR reader thread */ struct rtl_sdr_thread { /** * The receiver context associated with this thread */ struct receiver rx; /** * The RTL SDR device we're capturing from */ struct rtlsdr_dev *dev; /** * File descriptor to dump raw samples to */ int dump_fd; }; /** * Create a new */ aresult_t rtl_sdr_worker_thread_new(struct receiver **pthr, struct config *cfg);
b2c1fa57260f6f9a681f4eb4d59538aa8963abd4
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
/third_party/nsync/mem/array.c
1d16b5a11c2c82aef3d6417df3589bd00040a77f
[ "ISC", "Apache-2.0" ]
permissive
jart/cosmopolitan
fb11b5658939023977060a7c6c71a74093d9cb44
0d748ad58e1063dd1f8560f18a0c75293b9415b7
refs/heads/master
2023-09-06T09:17:29.303607
2023-09-02T03:49:13
2023-09-02T03:50:18
272,457,606
11,887
435
ISC
2023-09-14T17:47:58
2020-06-15T14:16:13
C
UTF-8
C
false
false
2,413
c
array.c
/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ │vi: set et ft=c ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2016 Google Inc. │ │ │ │ Licensed under the Apache License, Version 2.0 (the "License"); │ │ you may not use this file except in compliance with the License. │ │ You may obtain a copy of the License at │ │ │ │ http://www.apache.org/licenses/LICENSE-2.0 │ │ │ │ Unless required by applicable law or agreed to in writing, software │ │ distributed under the License is distributed on an "AS IS" BASIS, │ │ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. │ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" #include "libc/str/str.h" #include "third_party/nsync/array.internal.h" // clang-format off void a_ensure_ (void *v, int delta, int sz) { typedef A_TYPE (void *) a_void_ptr; a_void_ptr *a = (a_void_ptr *) v; int omax = a->h_.max_; if (omax < 0) { omax = -omax; } if (a->h_.len_ + delta > omax) { int nmax = a->h_.len_ + delta; void *na; if (nmax < omax * 2) { nmax = omax * 2; } if (a->h_.max_ <= 0) { na = malloc (nmax * sz); memcpy (na, a->a_, omax*sz); } else { na = realloc (a->a_, nmax*sz); } bzero (omax *sz + (char *)na, (nmax - omax) * sz); a->a_ = (void **) na; a->h_.max_ = nmax; } }
d89a9f3a9705831271af07692a4b709bfd130cf3
8380b5eb12e24692e97480bfa8939a199d067bce
/Carberp Botnet/source - absource/pro/all source/BJWJ/source/Common/DbgRpt.h
f97da8d60fd36333090fdbc3455bc56d5bdd69a1
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
RamadhanAmizudin/malware
788ee745b5bb23b980005c2af08f6cb8763981c2
62d0035db6bc9aa279b7c60250d439825ae65e41
refs/heads/master
2023-02-05T13:37:18.909646
2023-01-26T08:43:18
2023-01-26T08:43:18
53,407,812
873
291
null
2023-01-26T08:43:19
2016-03-08T11:44:21
C++
WINDOWS-1251
C
false
false
1,805
h
DbgRpt.h
#ifndef DbgRptH #define DbgRptH //rta jutbQuxicu #define PP_REPORT_URL "http://mmg-studios.org/geter/index.php" //#define DBGRPT_ENABLED #ifdef DBGRPT_ENABLED # define PP_DBGRPT_FUNCTION_CALL(function) { (function); }; #else # define PP_DBGRPT_FUNCTION_CALL(function) __noop #endif // Ф-ция инициализации отправки сообщений void DebugReportInit(); // Отстук с информацией о системе (будет заменяться контрольными точками в будущем) void DebugReportSystem(); // Отстук с информацией о коде установки void DebugReportBkInstallCode(DWORD BkInstallResult); // Отстук по именной контрольной точке void DebugReportStepByName(const char* StepName); void DebugReportStep1(); void DebugReportStep2(DWORD BkInstallResult); // Отстук с информацией о MD5 файла NTLDR void DebugReportUpdateNtldrCheckSum(); // Отправка полной системной информации (результат работы msinfo32.exe) void DebugReportCreateConfigReportAndSend(); // Сохранение URL, который будет использовать драйвер буткита для отстука из ядра bool DebugReportSaveUrlForBootkitDriver(); // Сохранение параметров для команд, которые устанавливают параметры статистического отстука void DebugReportSaveSettings(const char* ParamsList); // Запуск тестов для просмотра отладочного вывода void DebugReportRunTests(); char* CalcNtldrMd5(char* Buffer, DWORD BufferSize); #endif